@Test public void testHasAnotherMaster() { URI cokeUri = URIUtil.createURI("1.2.3.4", 6653); InetSocketAddress address = (InetSocketAddress) sw.getConnection(OFAuxId.MAIN).getLocalInetAddress(); URI pepsiUri = URIUtil.createURI(address.getHostName(), address.getPort()); updateControllerConnections(sw, OFControllerRole.ROLE_SLAVE, OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED, cokeUri.toString(), OFControllerRole.ROLE_MASTER, OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED, pepsiUri.toString()); assertFalse(sw.hasAnotherMaster()); updateControllerConnections(sw, OFControllerRole.ROLE_MASTER, OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED, cokeUri.toString(), OFControllerRole.ROLE_SLAVE, OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED, pepsiUri.toString()); assertTrue(sw.hasAnotherMaster()); }
@Override public boolean hasAnotherMaster() { IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { URI uri = entry.getKey(); if(!localURI.equals(uri)){ Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED && controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){ return true; } } else { log.warn("Unable to find controller connection with aux id " + "MAIN for switch {} on controller with URI {}.", this, uri); } } } } return false; }
OFSwitch implements IOFSwitchBackend { @Override public boolean hasAnotherMaster() { IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { URI uri = entry.getKey(); if(!localURI.equals(uri)){ Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED && controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){ return true; } } else { log.warn("Unable to find controller connection with aux id " + "MAIN for switch {} on controller with URI {}.", this, uri); } } } } return false; } }
OFSwitch implements IOFSwitchBackend { @Override public boolean hasAnotherMaster() { IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { URI uri = entry.getKey(); if(!localURI.equals(uri)){ Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED && controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){ return true; } } else { log.warn("Unable to find controller connection with aux id " + "MAIN for switch {} on controller with URI {}.", this, uri); } } } } return false; } OFSwitch(IOFConnectionBackend connection, @Nonnull OFFactory factory, @Nonnull IOFSwitchManager switchManager,
			@Nonnull DatapathId datapathId); }
OFSwitch implements IOFSwitchBackend { @Override public boolean hasAnotherMaster() { IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { URI uri = entry.getKey(); if(!localURI.equals(uri)){ Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED && controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){ return true; } } else { log.warn("Unable to find controller connection with aux id " + "MAIN for switch {} on controller with URI {}.", this, uri); } } } } return false; } OFSwitch(IOFConnectionBackend connection, @Nonnull OFFactory factory, @Nonnull IOFSwitchManager switchManager,
			@Nonnull DatapathId datapathId); @Override OFFactory getOFFactory(); @Override boolean attributeEquals(String name, Object other); @Override Object getAttribute(String name); @Override void setAttribute(String name, Object value); @Override Object removeAttribute(String name); @Override boolean hasAttribute(String name); @Override void registerConnection(IOFConnectionBackend connection); @Override ImmutableList<IOFConnection> getConnections(); @Override void removeConnections(); @Override void removeConnection(IOFConnectionBackend connection); IOFConnection getConnection(OFAuxId auxId); IOFConnection getConnection(LogicalOFMessageCategory category); @Override boolean write(OFMessage m); @Override Collection<OFMessage> write(Iterable<OFMessage> msglist); @Override boolean write(OFMessage m, LogicalOFMessageCategory category); @Override Collection<OFMessage> write(Iterable<OFMessage> msgList, LogicalOFMessageCategory category); @Override OFConnection getConnectionByCategory(LogicalOFMessageCategory category); @Override ListenableFuture<R> writeRequest(OFRequest<R> request, LogicalOFMessageCategory category); @Override ListenableFuture<R> writeRequest(OFRequest<R> request); @Override void disconnect(); @Override void setFeaturesReply(OFFeaturesReply featuresReply); @Override void setPortDescStats(OFPortDescStatsReply reply); @Override Collection<OFPortDesc> getEnabledPorts(); @Override Collection<OFPort> getEnabledPortNumbers(); @Override OFPortDesc getPort(OFPort portNumber); @Override OFPortDesc getPort(String portName); @Override OrderedCollection<PortChangeEvent> processOFPortStatus(OFPortStatus ps); @Override void processOFTableFeatures(List<OFTableFeaturesStatsReply> replies); @Override Collection<OFPortDesc> getSortedPorts(); @Override Collection<OFPortDesc> getPorts(); @Override OrderedCollection<PortChangeEvent> comparePorts(Collection<OFPortDesc> ports); @Override OrderedCollection<PortChangeEvent> setPorts(Collection<OFPortDesc> ports); @Override boolean portEnabled(OFPort portNumber); @Override boolean portEnabled(String portName); @Override DatapathId getId(); @Override String toString(); @Override ConcurrentMap<Object, Object> getAttributes(); @Override Date getConnectedSince(); @Override ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request); @Override ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request, LogicalOFMessageCategory category); @Override void cancelAllPendingRequests(); @Override boolean isConnected(); @Override boolean isActive(); @Override OFControllerRole getControllerRole(); @Override void setControllerRole(OFControllerRole role); @Override SocketAddress getInetAddress(); @Override long getBuffers(); @Override Set<OFActionType> getActions(); @Override Set<OFCapabilities> getCapabilities(); @Override Collection<TableId> getTables(); @Override short getNumTables(); @Override SwitchDescription getSwitchDescription(); @Override void setTableFull(boolean isFull); @Override void startDriverHandshake(); @Override boolean isDriverHandshakeComplete(); @Override void processDriverHandshakeMessage(OFMessage m); @Override void setSwitchProperties(SwitchDescription description); @Override SwitchStatus getStatus(); @Override void setStatus(SwitchStatus switchStatus); @Override void updateControllerConnections(OFBsnControllerConnectionsReply controllerCxnsReply); @Override boolean hasAnotherMaster(); @Override TableFeatures getTableFeatures(TableId table); @Override TableId getMaxTableForTableMissFlow(); @Override TableId setMaxTableForTableMissFlow(TableId max); @Override U64 getLatency(); }
OFSwitch implements IOFSwitchBackend { @Override public boolean hasAnotherMaster() { IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { URI uri = entry.getKey(); if(!localURI.equals(uri)){ Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED && controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){ return true; } } else { log.warn("Unable to find controller connection with aux id " + "MAIN for switch {} on controller with URI {}.", this, uri); } } } } return false; } OFSwitch(IOFConnectionBackend connection, @Nonnull OFFactory factory, @Nonnull IOFSwitchManager switchManager,
			@Nonnull DatapathId datapathId); @Override OFFactory getOFFactory(); @Override boolean attributeEquals(String name, Object other); @Override Object getAttribute(String name); @Override void setAttribute(String name, Object value); @Override Object removeAttribute(String name); @Override boolean hasAttribute(String name); @Override void registerConnection(IOFConnectionBackend connection); @Override ImmutableList<IOFConnection> getConnections(); @Override void removeConnections(); @Override void removeConnection(IOFConnectionBackend connection); IOFConnection getConnection(OFAuxId auxId); IOFConnection getConnection(LogicalOFMessageCategory category); @Override boolean write(OFMessage m); @Override Collection<OFMessage> write(Iterable<OFMessage> msglist); @Override boolean write(OFMessage m, LogicalOFMessageCategory category); @Override Collection<OFMessage> write(Iterable<OFMessage> msgList, LogicalOFMessageCategory category); @Override OFConnection getConnectionByCategory(LogicalOFMessageCategory category); @Override ListenableFuture<R> writeRequest(OFRequest<R> request, LogicalOFMessageCategory category); @Override ListenableFuture<R> writeRequest(OFRequest<R> request); @Override void disconnect(); @Override void setFeaturesReply(OFFeaturesReply featuresReply); @Override void setPortDescStats(OFPortDescStatsReply reply); @Override Collection<OFPortDesc> getEnabledPorts(); @Override Collection<OFPort> getEnabledPortNumbers(); @Override OFPortDesc getPort(OFPort portNumber); @Override OFPortDesc getPort(String portName); @Override OrderedCollection<PortChangeEvent> processOFPortStatus(OFPortStatus ps); @Override void processOFTableFeatures(List<OFTableFeaturesStatsReply> replies); @Override Collection<OFPortDesc> getSortedPorts(); @Override Collection<OFPortDesc> getPorts(); @Override OrderedCollection<PortChangeEvent> comparePorts(Collection<OFPortDesc> ports); @Override OrderedCollection<PortChangeEvent> setPorts(Collection<OFPortDesc> ports); @Override boolean portEnabled(OFPort portNumber); @Override boolean portEnabled(String portName); @Override DatapathId getId(); @Override String toString(); @Override ConcurrentMap<Object, Object> getAttributes(); @Override Date getConnectedSince(); @Override ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request); @Override ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request, LogicalOFMessageCategory category); @Override void cancelAllPendingRequests(); @Override boolean isConnected(); @Override boolean isActive(); @Override OFControllerRole getControllerRole(); @Override void setControllerRole(OFControllerRole role); @Override SocketAddress getInetAddress(); @Override long getBuffers(); @Override Set<OFActionType> getActions(); @Override Set<OFCapabilities> getCapabilities(); @Override Collection<TableId> getTables(); @Override short getNumTables(); @Override SwitchDescription getSwitchDescription(); @Override void setTableFull(boolean isFull); @Override void startDriverHandshake(); @Override boolean isDriverHandshakeComplete(); @Override void processDriverHandshakeMessage(OFMessage m); @Override void setSwitchProperties(SwitchDescription description); @Override SwitchStatus getStatus(); @Override void setStatus(SwitchStatus switchStatus); @Override void updateControllerConnections(OFBsnControllerConnectionsReply controllerCxnsReply); @Override boolean hasAnotherMaster(); @Override TableFeatures getTableFeatures(TableId table); @Override TableId getMaxTableForTableMissFlow(); @Override TableId setMaxTableForTableMissFlow(TableId max); @Override U64 getLatency(); static final int OFSWITCH_APP_ID; }