if (!Objects.equals(_key, other.getKey())) { return false; if (!Objects.equals(_nodeId, other.getNodeId())) { return false; if (!Objects.equals(_nodeType, other.getNodeType())) { return false; if (!e.getValue().equals(other.getAugmentation(e.getKey()))) { return false;
public NodeBuilder(Node base) { if (base.getKey() == null) { this._key = new NodeKey( base.getNodeId() ); this._nodeId = base.getNodeId(); } else { this._key = base.getKey(); this._nodeId = _key.getNodeId(); } this._nodeType = base.getNodeType(); if (base instanceof NodeImpl) { NodeImpl impl = (NodeImpl) 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.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.usc.channel.rev150101.topology.attributes.Node>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
/** * check the node has same id with the specified id * * @param id * a node id * @param node * a node * @return if the node has same id with the specified id then return * true,other wise return false */ public synchronized boolean sameNodeId(String id, Node node) { return id.equals(node.getNodeId().getValue()); }
/** * add a node to local topology, when the node exists in node list of * topology, then only update the refer number of the node * * @param node * the adding node */ public synchronized void addNode(Node node) { if (node != null) { String nodeId = node.getKey().getNodeId().getValue(); Integer num = nodeReferList.get(nodeId); // filter same node using nodeId // Note: here only has the nodes related with current controller, // but all of nodes including nodes related with other controllers // should have unique nodeId if (num == null) { // not exsits, add node and one refer number localNodeList.add(node); nodeReferList.put(nodeId, 1); } else { // exsits,only add refer number nodeReferList.put(nodeId, num + 1); } } }
ChannelKey channelKey = new ChannelKey(channelId); SourceBuilder sourceBuilder = new SourceBuilder(); sourceBuilder.setSourceNode(source.getNodeId()); DestinationBuilder destinationBuilder = new DestinationBuilder(); destinationBuilder.setDestNode(destination.getNodeId()); ChannelBuilder channelBuilder = new ChannelBuilder(); channelBuilder.setChannelId(channelId);
@Override public void handle(UscEvent event) { if (topoService == null) { topoService = UscServiceUtils.getService(UscTopologyService.class); if (topoService == null) { LOG.error("Failed to get UscTopologyService!"); return; } } if (event instanceof UscChannelCreateEvent) { UscChannelCreateEvent evt = (UscChannelCreateEvent) event; Node deviceNode = UscTopologyFactory.createNode(evt.getDeviceId(), UscTopologyService.NODE_TYPE_NETWORK_DEVICE); String key = UscTopologyService.NODE_TYPE_CONTROLLER + ":" + topoService.getLocalController().getNodeId().getValue() + "-" + UscTopologyService.NODE_TYPE_NETWORK_DEVICE + ":" + evt.getDeviceId() + '-' + UscTopologyService.Channel_TYPE + ":" + evt.getType(); Channel channel = UscTopologyFactory.createChannel(topoService.getLocalController(), deviceNode, key, evt.getType(), evt.isCallHome()); topoService.addChannel(channel); } else if (event instanceof UscChannelCloseEvent) { UscChannelCloseEvent evt = (UscChannelCloseEvent) event; topoService.removeChannel(evt.getDeviceId(), evt.getType()); } else if (event instanceof UscChannelErrorEvent) { UscChannelErrorEvent evt = (UscChannelErrorEvent) event; ChannelAlarm alarm = UscTopologyFactory.createChannelAlram(evt.getErrorId(), evt.getErrorCode() + "", evt.getMessage()); topoService.addChannelError(evt.getDeviceId(), evt.getType(), alarm); } }