@Test public void testNodeAdded() { GetFeaturesOutputBuilder featuresBuilder = new GetFeaturesOutputBuilder(); GetFeaturesOutput features = featuresBuilder.build(); Mockito.stub(registry.getDatapathID(connectionAdapter)).toReturn(new BigInteger("1")); Mockito.stub(registry.getFeaturesOutput(connectionAdapter)).toReturn(features); Mockito.stub(connectionAdapter.getRemoteAddress()).toReturn(new InetSocketAddress(1)); NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); String current = String.valueOf(new BigInteger("1")); builder.setId(new NodeId("openflow:" + current)); InstanceIdentifier<Node> identifier = connectionHandler.identifierFromDatapathId(new BigInteger("1")); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(resolveIpAddress(new InetSocketAddress(1).getAddress())); } catch (Exception e) { e.printStackTrace(); } SwitchFeatures swFeatures = new SwitchFeatures() { @Override public <E extends Augmentation<SwitchFeatures>> E getAugmentation(Class<E> arg0) { return null; } @Override public Class<? extends DataContainer> getImplementedInterface() { return null; } @Override public Short getMaxTables() { return null; } @Override public Long getMaxBuffers() { return null; } @Override public List<Class<? extends FeatureCapability>> getCapabilities() { return null; } }; SwitchFeaturesUtil swFeaturesUtil = SwitchFeaturesUtil.getInstance(); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); Assert.assertEquals(builder.build(), connectionHandler.nodeAdded(connectionAdapter)); }
public NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); BigInteger datapathId = this.connectionRegistry.getDatapathID(connectionAdapter); builder.setId(nodeIdFromDatapathId(datapathId)); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(getIpAddressOf(connectionAdapter)); } catch (Exception e) { LOG.warn("IP address of the node cannot be obtained."); } GetFeaturesOutput features = this.connectionRegistry.getFeaturesOutput(connectionAdapter); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { public NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); BigInteger datapathId = this.connectionRegistry.getDatapathID(connectionAdapter); builder.setId(nodeIdFromDatapathId(datapathId)); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(getIpAddressOf(connectionAdapter)); } catch (Exception e) { LOG.warn("IP address of the node cannot be obtained."); } GetFeaturesOutput features = this.connectionRegistry.getFeaturesOutput(connectionAdapter); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); } }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { public NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); BigInteger datapathId = this.connectionRegistry.getDatapathID(connectionAdapter); builder.setId(nodeIdFromDatapathId(datapathId)); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(getIpAddressOf(connectionAdapter)); } catch (Exception e) { LOG.warn("IP address of the node cannot be obtained."); } GetFeaturesOutput features = this.connectionRegistry.getFeaturesOutput(connectionAdapter); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { public NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); BigInteger datapathId = this.connectionRegistry.getDatapathID(connectionAdapter); builder.setId(nodeIdFromDatapathId(datapathId)); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(getIpAddressOf(connectionAdapter)); } catch (Exception e) { LOG.warn("IP address of the node cannot be obtained."); } GetFeaturesOutput features = this.connectionRegistry.getFeaturesOutput(connectionAdapter); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); void setSwitchFeaturesUtil(SwitchFeaturesUtil featureUtil); void init(); ShimRelay createShimRelay(); ConnectionAdaptersRegistry createConnectionAdaptersRegistry(); @Override boolean accept(InetAddress arg0); @Override void onSwitchConnected(ConnectionAdapter connectionAdapter); void handshake(ConnectionAdapter connectionAdapter); @Override void onSwitchHelloMessage(long xid, Short version, ConnectionAdapter connectionAdapter); NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter); static InstanceIdentifier<Node> identifierFromDatapathId(final BigInteger datapathId); static NodeKey nodeKeyFromDatapathId(final BigInteger datapathId); static NodeId nodeIdFromDatapathId(final BigInteger datapathId); byte getMaxOFSupportedProtocol(); List<Byte> getSupportedOFProtocols(); int getNumberOfSwitches(); Pair<Protocol, ProtocolVersions> getSupportedProtocol(); void setSupportedProtocol(byte version); @Override void onOpenFlowCoreMessage(Long datapathId, ByteBuf msg, int moduleId); @Override void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId); void collectGetFeaturesOuput(Future<RpcResult<GetFeaturesOutput>> switchReply,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesOuputToCore(final Short proposedVersion, final int moduleId,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesToSwitch(final Short proposedVersion, final Long xid,
            final ConnectionAdapter connectionAdapter); @Override void onSwitchDisconnected(ConnectionAdapter connectionAdapter); GetFeaturesOutput getFeaturesFromRegistry(ConnectionAdapter conn); }
ShimSwitchConnectionHandlerImpl implements SwitchConnectionHandler, ICoreListener, IHandshakeListener { public NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter) { NodeUpdatedBuilder builder = new NodeUpdatedBuilder(); BigInteger datapathId = this.connectionRegistry.getDatapathID(connectionAdapter); builder.setId(nodeIdFromDatapathId(datapathId)); InstanceIdentifier<Node> identifier = identifierFromDatapathId(datapathId); builder.setNodeRef(new NodeRef(identifier)); FlowCapableNodeUpdatedBuilder builder2 = new FlowCapableNodeUpdatedBuilder(); try { builder2.setIpAddress(getIpAddressOf(connectionAdapter)); } catch (Exception e) { LOG.warn("IP address of the node cannot be obtained."); } GetFeaturesOutput features = this.connectionRegistry.getFeaturesOutput(connectionAdapter); builder2.setSwitchFeatures(swFeaturesUtil.buildSwitchFeatures(features)); builder.addAugmentation(FlowCapableNodeUpdated.class, builder2.build()); return builder.build(); } ShimSwitchConnectionHandlerImpl(ZeroMQBaseConnector connector,
            NotificationPublishService _notificationProviderService); void setSwitchFeaturesUtil(SwitchFeaturesUtil featureUtil); void init(); ShimRelay createShimRelay(); ConnectionAdaptersRegistry createConnectionAdaptersRegistry(); @Override boolean accept(InetAddress arg0); @Override void onSwitchConnected(ConnectionAdapter connectionAdapter); void handshake(ConnectionAdapter connectionAdapter); @Override void onSwitchHelloMessage(long xid, Short version, ConnectionAdapter connectionAdapter); NodeUpdated nodeAdded(ConnectionAdapter connectionAdapter); static InstanceIdentifier<Node> identifierFromDatapathId(final BigInteger datapathId); static NodeKey nodeKeyFromDatapathId(final BigInteger datapathId); static NodeId nodeIdFromDatapathId(final BigInteger datapathId); byte getMaxOFSupportedProtocol(); List<Byte> getSupportedOFProtocols(); int getNumberOfSwitches(); Pair<Protocol, ProtocolVersions> getSupportedProtocol(); void setSupportedProtocol(byte version); @Override void onOpenFlowCoreMessage(Long datapathId, ByteBuf msg, int moduleId); @Override void onHelloCoreMessage(List<Pair<Protocol, ProtocolVersions>> requestedProtocols, int moduleId); void collectGetFeaturesOuput(Future<RpcResult<GetFeaturesOutput>> switchReply,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesOuputToCore(final Short proposedVersion, final int moduleId,
            final ConnectionAdapter connectionAdapter); void sendGetFeaturesToSwitch(final Short proposedVersion, final Long xid,
            final ConnectionAdapter connectionAdapter); @Override void onSwitchDisconnected(ConnectionAdapter connectionAdapter); GetFeaturesOutput getFeaturesFromRegistry(ConnectionAdapter conn); static final Long DEFAULT_XID; }