/** * Gets a connection specified by aux Id. * @param auxId the specified aux id for the connection desired. * @return the aux connection specified by the auxId */ public IOFConnection getConnection(OFAuxId auxId) { IOFConnection connection = this.connections.get(auxId); if (connection == null) { throw new IllegalArgumentException("OF Connection for " + this + " with " + auxId + " does not exist."); } return connection; }
public IOFConnection getConnection(LogicalOFMessageCategory category) { if (switchManager.isCategoryRegistered(category)) { return getConnection(category.getAuxId()); } else{ throw new IllegalArgumentException(category + " is not registered with the floodlight provider service."); } }
@Override public boolean hasAnotherMaster() { //TODO: refactor get connection to not throw illegal arg exceptions IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN); if(mainCxn != null) { // Determine the local URI InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress(); URI localURI = URIUtil.createURI(address.getHostName(), address.getPort()); for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) { // Don't check our own controller connections URI uri = entry.getKey(); if(!localURI.equals(uri)){ // We only care for the MAIN connection Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri); OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN); if(controllerCxn != null) { // If the controller id disconnected or not master we know it is not connected 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; }
/** * Gets the current connections that this switch handshake handler is * responsible for. Used primarily by the REST API. * @return an immutable list of IOFConnections */ public ImmutableList<IOFConnection> getConnections() { ImmutableList.Builder<IOFConnection> builder = ImmutableList.builder(); builder.add(mainConnection); builder.addAll(auxConnections.values()); return builder.build(); }
@Override public Collection<OFMessage> write(Iterable<OFMessage> msgList, LogicalOFMessageCategory category) { IOFConnection conn = this.getConnection(category); /* do first to check for supported category */ Collection<OFMessage> validMsgs = new ArrayList<OFMessage>(); Collection<OFMessage> invalidMsgs = SwitchRoleMessageValidator.pruneInvalidMessages( msgList, validMsgs, this.getOFFactory().getVersion(), this.isActive()); if (log.isDebugEnabled()) { log.debug("MESSAGES: {}, VALID: {}, INVALID: {}", new Object[] { msgList, validMsgs, invalidMsgs}); } /* Try to write all valid messages */ Collection<OFMessage> unsent = conn.write(validMsgs); for (OFMessage m : validMsgs) { if (!unsent.contains(m)) { switchManager.handleOutgoingMessage(this, m); } } /* Collect invalid and unsent messages */ Collection<OFMessage> ret = null; if (!unsent.isEmpty()) { log.warn("Could not send messages {} due to channel disconnection on switch {}", unsent, this.getId()); ret = IterableUtils.toCollection(unsent); } if (!invalidMsgs.isEmpty()) { log.warn("Could not send messages {} while in SLAVE role on switch {}", invalidMsgs, this.getId()); if (ret == null) { ret = IterableUtils.toCollection(invalidMsgs); } else { ret.addAll(IterableUtils.toCollection(invalidMsgs)); } } if (ret == null) { return Collections.emptyList(); } else { return ret; } }
public Collection<IOFConnection> getConnections() { return this.connections; }
@Override public ImmutableList<IOFConnection> getConnections() { return ImmutableList.<IOFConnection> copyOf(this.connections.values()); }
@Override public ImmutableList<IOFConnection> getConnections() { // TODO Auto-generated method stub return null; }