public FlowHashIdMap build() { return new FlowHashIdMapImpl(this); }
public FlowHashIdMapBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
public FlowHashIdMapBuilder(FlowHashIdMap base) { if (base.getKey() == null) { this._key = new FlowHashIdMapKey( base.getHash() ); this._hash = base.getHash(); } else { this._key = base.getKey(); this._hash = _key.getHash(); } this._flowId = base.getFlowId(); if (base instanceof FlowHashIdMapImpl) { FlowHashIdMapImpl impl = (FlowHashIdMapImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
private void updateHashCache(final ReadWriteTransaction trans, final FlowKey flowKey, final FlowHashIdMapKey hashingKey) { final FlowHashIdMapBuilder flHashIdMap = new FlowHashIdMapBuilder(); flHashIdMap.setFlowId(flowKey.getId()); flHashIdMap.setKey(hashingKey); final KeyedInstanceIdentifier<FlowHashIdMap, FlowHashIdMapKey> flHashIdent = tableRef .augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, hashingKey); /* Add new FlowHashIdMap */ trans.put(LogicalDatastoreType.OPERATIONAL, flHashIdent, flHashIdMap.build()); }
if (!Objects.equals(_flowId, other.getFlowId())) { return false; if (!Objects.equals(_hash, other.getHash())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
public TableFlowUpdateState(final KeyedInstanceIdentifier<Table, TableKey> tablePath, final Table table) { tableRef = tablePath; tableKey = tablePath.getKey(); flowIdByHash = HashBiMap.create(); if(table != null) { final FlowHashIdMapping flowHashMapping = table.getAugmentation(FlowHashIdMapping.class); if (flowHashMapping != null) { final List<FlowHashIdMap> flowHashMap = flowHashMapping.getFlowHashIdMap() != null ? flowHashMapping.getFlowHashIdMap() : Collections.<FlowHashIdMap> emptyList(); for (final FlowHashIdMap flowHashId : flowHashMap) { try { flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId()); } catch (final Exception e) { LOG.warn("flow hashing hit a duplicate for {} -> {}", flowHashId.getKey(), flowHashId.getFlowId()); } } } } }
private FlowHashIdMapImpl(FlowHashIdMapBuilder base) { if (base.getKey() == null) { this._key = new FlowHashIdMapKey( base.getHash() ); this._hash = base.getHash(); } else { this._key = base.getKey(); this._hash = _key.getHash(); } this._flowId = base.getFlowId(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.nodes.node.table.FlowHashIdMap>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) { ensureTableFowHashIdMapping(trans); final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat)); FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey); if (flowKey == null) { flowKey = searchInConfiguration(flowStat, trans); if ( flowKey == null) { flowKey = makeAlienFlowKey(); } updateHashCache(trans,flowKey,hashingKey); } final FlowBuilder flowBuilder = new FlowBuilder(flowStat); flowBuilder.setKey(flowKey); addStatistics(flowBuilder, flowStat); final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey); trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); /* check life for Alien flows */ if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION); } }
private void updateHashCache(final ReadWriteTransaction trans, final FlowKey flowKey, final FlowHashIdMapKey hashingKey) { final FlowHashIdMapBuilder flHashIdMap = new FlowHashIdMapBuilder(); flHashIdMap.setFlowId(flowKey.getId()); flHashIdMap.setKey(hashingKey); final KeyedInstanceIdentifier<FlowHashIdMap, FlowHashIdMapKey> flHashIdent = tableRef .augmentation(FlowHashIdMapping.class).child(FlowHashIdMap.class, hashingKey); /* Add new FlowHashIdMap */ trans.put(LogicalDatastoreType.OPERATIONAL, flHashIdent, flHashIdMap.build()); }
public TableFlowUpdateState(final KeyedInstanceIdentifier<Table, TableKey> tablePath, final Table table) { tableRef = tablePath; tableKey = tablePath.getKey(); flowIdByHash = HashBiMap.create(); if(table != null) { final FlowHashIdMapping flowHashMapping = table.getAugmentation(FlowHashIdMapping.class); if (flowHashMapping != null) { final List<FlowHashIdMap> flowHashMap = flowHashMapping.getFlowHashIdMap() != null ? flowHashMapping.getFlowHashIdMap() : Collections.<FlowHashIdMap> emptyList(); for (final FlowHashIdMap flowHashId : flowHashMap) { try { flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId()); } catch (final Exception e) { //flowHashId.getKey() too verbose for standard log. if(LOG.isDebugEnabled()) { final FlowId currData = flowIdByHash.get(flowHashId.getKey()); LOG.debug("flow hashing hit a duplicate for {} -> {}. Curr value: {} Equals:{}. Exception was raised:", flowHashId.getKey(), flowHashId.getFlowId(), currData, flowHashId.getFlowId().equals(currData), e); } else { LOG.warn("flow hashing hit a duplicate {}. Exception was raised: {}. Enable DEBUG for more detail.", flowHashId.getFlowId().toString().substring(0, Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,flowHashId.getFlowId().toString().length())), e.getMessage().substring(0,Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,e.getMessage().length()))); } } } } } }
void reportFlow(final FlowAndStatisticsMapList flowStat, final ReadWriteTransaction trans) { ensureTableFowHashIdMapping(trans); final FlowHashIdMapKey hashingKey = new FlowHashIdMapKey(buildFlowIdOperKey(flowStat)); FlowKey flowKey = getFlowKeyAndRemoveHash(hashingKey); if (flowKey == null) { flowKey = searchInConfiguration(flowStat, trans); if ( flowKey == null) { flowKey = makeAlienFlowKey(); } updateHashCache(trans,flowKey,hashingKey); } final FlowBuilder flowBuilder = new FlowBuilder(flowStat); flowBuilder.setKey(flowKey); addStatistics(flowBuilder, flowStat); final InstanceIdentifier<Flow> flowIdent = tableRef.child(Flow.class, flowKey); trans.put(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build()); /* check life for Alien flows */ if (flowKey.getId().getValue().startsWith(ALIEN_SYSTEM_FLOW_ID)) { removeData(flowIdent, REMOVE_AFTER_MISSING_COLLECTION); } }