本文整理汇总了Java中net.floodlightcontroller.core.IOFConnection类的典型用法代码示例。如果您正苦于以下问题:Java IOFConnection类的具体用法?Java IOFConnection怎么用?Java IOFConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOFConnection类属于net.floodlightcontroller.core包,在下文中一共展示了IOFConnection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnection
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
/**
* 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;
}
示例2: hasAnotherMaster
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
@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;
}
示例3: getConnections
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
/**
* 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();
}
示例4: write
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
@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;
}
}
示例5: write
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
@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;
}
}
示例6: getConnections
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
public Collection<IOFConnection> getConnections() {
return this.connections;
}
示例7: getConnections
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
@Override
public ImmutableList<IOFConnection> getConnections() {
return ImmutableList.<IOFConnection> copyOf(this.connections.values());
}
示例8: getConnections
import net.floodlightcontroller.core.IOFConnection; //导入依赖的package包/类
@Override
public ImmutableList<IOFConnection> getConnections() {
// TODO Auto-generated method stub
return null;
}