[OPNFLWPLUG-1102] Refactor OpenFlow protocol serializers/deserializers Created: 02/Sep/20 Updated: 02/May/23 |
|
| Status: | Confirmed |
| Project: | OpenFlowPlugin |
| Component/s: | openflowjava-impl |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Examination of the use of this class shows we can reduce code duplication by sharing simple action case serialize. Furthermore we can reuse objects across deserializeHeader() invocations. Similar is true for others, hence audit and refactor them from performance. |
| Comments |
| Comment by Robert Varga [ 06/Jan/21 ] |
|
A first pass has been made. We still need to deal with registries, which are quite inefficient. All of the lookups go through generalized MessageCodeKey and similar constructs, forcing callers to create these. Rather than exposing keys in this way, we should provide specialized lookup registries, where all required parameters will be supplied to the lookup method, hence instead of this:
private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) { long expId = property.augmentation(ExperimenterIdTableFeatureProperty.class).getExperimenter().getValue() .toJava(); OFSerializer<TableFeatureProperties> serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( EncodeConstants.OF13_VERSION_ID, expId)); serializer.serialize(property, output); } we would do something like:
private void writeExperimenterRelatedTableProperty(final ByteBuf output, final TableFeatureProperties property) { long expId = property.augmentation(ExperimenterIdTableFeatureProperty.class).getExperimenter().getValue() .toJava(); OFSerializer<TableFeatureProperties> serializer = registry.getSerializer( EncodeConstants.OF13_VERSION_ID, expId, TableFeatureProperties.class); serializer.serialize(property, output); } With this, we can perform a number of internal optimizations to speed up lookup:
Structuring things this way will also allow us to propagate invariants, such as:
|