KeyedInstanceIdentifierV2(final KeyedInstanceIdentifier<T, K> source) { super(source); key = source.getKey(); }
/** * Return the key associated with the last component of the specified identifier. * * @param id instance identifier * @return key associated with the last component * @throws IllegalArgumentException if the supplied identifier type cannot have a key. * @throws NullPointerException if id is null. */ public static <N extends Identifiable<K> & DataObject, K extends Identifier<N>> K keyOf(final InstanceIdentifier<N> id) { Preconditions.checkNotNull(id); Preconditions.checkArgument(id instanceof KeyedInstanceIdentifier, "%s does not have a key", id); @SuppressWarnings("unchecked") final K ret = ((KeyedInstanceIdentifier<N, K>)id).getKey(); return ret; }
/** * Return the key associated with the last component of the specified identifier. * * @param id instance identifier * @return key associated with the last component * @throws IllegalArgumentException if the supplied identifier type cannot have a key. * @throws NullPointerException if id is null. */ public static <N extends Identifiable<K> & DataObject, K extends Identifier<N>> K keyOf( final InstanceIdentifier<N> id) { requireNonNull(id); checkArgument(id instanceof KeyedInstanceIdentifier, "%s does not have a key", id); @SuppressWarnings("unchecked") final K ret = ((KeyedInstanceIdentifier<N, K>)id).getKey(); return ret; }
@Override public void readCurrentAttributes(final InstanceIdentifier<C> id, final B builder, final ReadContext context) throws ReadFailedException { final Optional<Method> method = ReflectionUtils.findMethodReflex(builder.getClass(), "withKey", Collections.singletonList(keyType), builder.getClass()); checkArgument(method.isPresent(), "Unable to build withKey for %s", builder); try { method.get().invoke(builder, ((KeyedInstanceIdentifier)id).getKey()); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalArgumentException("Unable to build withKey for " + builder, e); } }
public static org.opendaylight.controller.sal.core.Node toAdNode(final InstanceIdentifier<Node> identifier) { @SuppressWarnings("unchecked") final NodeKey tpKey = ((KeyedInstanceIdentifier<Node,NodeKey>)identifier).getKey(); return InventoryMapping.nodeFromNodeId(tpKey.getId().getValue()); }
public static org.opendaylight.controller.sal.core.NodeConnector toAdNodeConnector(final InstanceIdentifier<NodeConnector> identifier) { @SuppressWarnings("unchecked") final NodeConnectorKey tpKey = ((KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey>) identifier).getKey(); return InventoryMapping.nodeConnectorFromId(tpKey.getId().getValue()); }
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()); } } } } }
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()))); } } } } } }
/** * Method builds OVS NodeId which is based on: * 1. OVS Node InstanceIdentifier which manages the OVS Bridge * 2. OVS Bridge name * <p> * If the two aforementioned fields are missing, NullPointerException is raised. * <p> * * @param ovsdbBridge OvsdbBridgeAugmentation * @return NodeId */ private static NodeId getManagedByNodeId(OvsdbBridgeAugmentation ovsdbBridge) { Preconditions.checkNotNull(ovsdbBridge, "Cannot getManagedByNodeId, OvsdbBridgeAugmentation is null."); Preconditions.checkNotNull(ovsdbBridge.getBridgeName(), "Cannot build getManagedByNodeId, BridgeName is null."); Preconditions.checkNotNull(ovsdbBridge.getManagedBy(), "Cannot build getManagedByNodeId, ManagedBy is null."); String bridgeName = (ovsdbBridge.getBridgeName().getValue()); InstanceIdentifier<Node> nodeIID = (InstanceIdentifier<Node>) ovsdbBridge.getManagedBy().getValue(); KeyedInstanceIdentifier keyedInstanceIdentifier = (KeyedInstanceIdentifier) nodeIID.firstIdentifierOf(Node.class); Preconditions.checkNotNull(keyedInstanceIdentifier, "Cannot build getManagedByNodeId, parent OVS Node is null."); NodeKey nodeKey = (NodeKey) keyedInstanceIdentifier.getKey(); String nodeId = nodeKey.getNodeId().getValue(); nodeId = nodeId.concat(OVSDB_BRIDGE_PREFIX + bridgeName); return new NodeId(nodeId); }
(KeyedInstanceIdentifier) instanceIdentifier.firstIdentifierOf(ServiceFunctionForwarder.class); if (keyedInstanceIdentifier != null) { ServiceFunctionForwarderKey sffKey = (ServiceFunctionForwarderKey) keyedInstanceIdentifier.getKey(); SffName sffName = sffKey.getName(); (KeyedInstanceIdentifier) instanceIdentifier.firstIdentifierOf(ServiceFunctionForwarder.class); if (keyedInstanceIdentifier != null) { ServiceFunctionForwarderKey sffKey = (ServiceFunctionForwarderKey) keyedInstanceIdentifier.getKey(); String sffNameAsString = sffKey.getName().getValue(); String sffDataPlaneLocatorNameAsString = sffDataPlaneLocator.getName().getValue();
private void insert(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) { final NodeKey nodeKey = sourcePath.getKey(); final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class); final Node1 nodeAgument = new Node1Builder().setEventSourceNode( new NodeId(nodeKey.getNodeId().getValue())).build(); putData(OPERATIONAL, augmentPath, nodeAgument); }
private void insert(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) { final NodeKey nodeKey = sourcePath.getKey(); final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class); final Node1 nodeAgument = new Node1Builder().setEventSourceNode(new NodeId(nodeKey.getNodeId().getValue())).build(); putData(OPERATIONAL, augmentPath, nodeAgument); }
private InstanceIdentifier<IgpNodeAttributes> ensureNodePresent(final ReadWriteTransaction trans, final NodeId ni) { final NodeUsage present = this.nodes.get(ni); if (present != null) { return present.attrId; } final KeyedInstanceIdentifier<Node, NodeKey> nii = nodeInstanceId(ni); final InstanceIdentifier<IgpNodeAttributes> ret = nii.builder().augmentation(Node1.class).child(IgpNodeAttributes.class).build(); trans.merge(LogicalDatastoreType.OPERATIONAL, nii, new NodeBuilder().setKey(nii.getKey()).setNodeId(ni) .addAugmentation(Node1.class, new Node1Builder().setIgpNodeAttributes( new IgpNodeAttributesBuilder().setPrefix(Collections.<Prefix>emptyList()).build()).build()).build()); this.nodes.put(ni, new NodeUsage(ret)); return ret; }
public static TopologyReferenceSingletonService createBackwardsCssInstance(final TopologyTypes topologyTypes, final TopologyId topologyId, final DataBroker dataBroker, final BundleContext bundleContext, final KeyedInstanceIdentifier<Rib, RibKey> ribIId) { final Topology topology = createConfiguration(topologyTypes, topologyId, ribIId.getKey().getId());
@Override public java.lang.AutoCloseable createInstance() { final RIB rib = getTargetRibDependency(); final WaitingServiceTracker<BgpDeployer> bgpDeployerTracker = WaitingServiceTracker.create(BgpDeployer.class, this.bundleContext); final BgpDeployer bgpDeployer = bgpDeployerTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES); //map configuration to OpenConfig BGP final Neighbor neighbor = bgpDeployer.getMappingService().fromApplicationPeer(getApplicationRibId(), getBgpPeerId()); //write to configuration DS final KeyedInstanceIdentifier<Protocol, ProtocolKey> protocolIId = bgpDeployer.getInstanceIdentifier().child(Protocols.class) .child(Protocol.class, new ProtocolKey(BGP.class, rib.getInstanceIdentifier().getKey().getId().getValue())); final InstanceIdentifier<Bgp> bgpIID = protocolIId.augmentation(Protocol1.class).child(Bgp.class); final KeyedInstanceIdentifier<Neighbor, NeighborKey> neighborIId = protocolIId.augmentation(Protocol1.class).child(Bgp.class) .child(Neighbors.class).child(Neighbor.class, neighbor.getKey()); bgpDeployer.onNeighborModified(bgpIID, neighbor, () -> bgpDeployer.writeConfiguration(neighbor, neighborIId)); return () -> { bgpDeployer.onNeighborRemoved(bgpIID, neighbor); bgpDeployerTracker.close(); }; }
.child(Protocol.class, new ProtocolKey(BGP.class, rib.getInstanceIdentifier().getKey().getId().getValue())); final InstanceIdentifier<Bgp> bgpIID = protocolIId.augmentation(Protocol1.class).child(Bgp.class); final KeyedInstanceIdentifier<Neighbor, NeighborKey> neighborIId = protocolIId.augmentation(Protocol1.class).child(Bgp.class)