本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFType类的典型用法代码示例。如果您正苦于以下问题:Java OFType类的具体用法?Java OFType怎么用?Java OFType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFType类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchMessage
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
if (theListeners != null) {
Command result = Command.CONTINUE;
Iterator<IOFMessageListener> it = theListeners.iterator();
if (OFType.PACKET_IN.equals(msg.getType())) {
OFPacketIn pi = (OFPacketIn)msg;
Ethernet eth = new Ethernet();
eth.deserialize(pi.getData(), 0, pi.getData().length);
IFloodlightProviderService.bcStore.put(bc,
IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
eth);
}
while (it.hasNext() && !Command.STOP.equals(result)) {
result = it.next().receive(sw, msg, bc);
}
}
// paag
for (IControllerCompletionListener listener:completionListeners)
listener.onMessageConsumed(sw, msg, bc);
}
示例2: logListeners
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
private void logListeners() {
for (Map.Entry<OFType,
ListenerDispatcher<OFType,
IOFMessageListener>> entry
: listeners.entrySet()) {
OFType type = entry.getKey();
ListenerDispatcher<OFType, IOFMessageListener> ldd =
entry.getValue();
StringBuffer sb = new StringBuffer();
sb.append("OFListeners for ");
sb.append(type);
sb.append(": ");
for (IOFMessageListener l : ldd.getOrderedListeners()) {
sb.append(l.getName());
sb.append(",");
}
log.debug(sb.toString());
}
}
示例3: init
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
threadPoolService = context.getServiceImpl(IThreadPoolService.class);
debugCounterService = context.getServiceImpl(IDebugCounterService.class);
flowQueue = new PriorityPendingQueue<OFMatchReconcile>();
flowReconcileListeners = new ListenerDispatcher<OFType, IFlowReconcileListener>();
Map<String, String> configParam = context.getConfigParams(this);
String enableValue = configParam.get(EnableConfigKey);
registerFlowReconcileManagerDebugCounters();
// Set flowReconcile default to true
flowReconcileEnabled = true;
if (enableValue != null &&
enableValue.equalsIgnoreCase("false")) {
flowReconcileEnabled = false;
}
flowReconcileThreadRunCount = new AtomicInteger(0);
lastReconcileTime = new Date(0);
logger.debug("FlowReconcile is {}", flowReconcileEnabled);
}
示例4: write
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void write(OFMessage m) {
if (!isConnected()) {
if (logger.isDebugEnabled())
logger.debug("{}: not connected - dropping message {}", this, m);
return;
}
if (logger.isDebugEnabled())
logger.debug("{}: send {}", this, m);
List<OFMessage> msgBuffer = localMsgBuffer.get();
if (msgBuffer == null) {
msgBuffer = new ArrayList<OFMessage>();
localMsgBuffer.set(msgBuffer);
}
counters.updateWriteStats(m);
msgBuffer.add(m);
if ((msgBuffer.size() >= Controller.BATCH_MAX_SIZE) || ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
this.write(msgBuffer);
localMsgBuffer.set(null);
}
}
示例5: moveToWaitDescriptionStatReply
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
* Builds on moveToWaitConfigReply()
* adds testing for WAIT_CONFIG_REPLY state
*/
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
moveToWaitConfigReply();
connection.clearMessages();
OFGetConfigReply cr = factory.buildGetConfigReply()
.setMissSendLen(0xFFFF)
.build();
switchHandler.processOFMessage(cr);
OFMessage msg = connection.retrieveMessage();
assertEquals(OFType.STATS_REQUEST, msg.getType());
OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
assertEquals(OFStatsType.DESC, sr.getStatsType());
verifyUniqueXids(msg);
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
示例6: init
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context) throws FloodlightModuleException
{
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
deviceService = context.getServiceImpl(IDeviceService.class);
routingService = context.getServiceImpl(IRoutingService.class);
switchService = context.getServiceImpl(IOFSwitchService.class);
linkService = context.getServiceImpl(ILinkDiscoveryService.class);
messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
EnumSet.of(OFType.FLOW_MOD),
OFMESSAGE_DAMPER_TIMEOUT);
library = new FP_LibFloodlight( LoggerFactory.getLogger( getClass() ));
}
示例7: moveToWaitConfigReply
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_CONFIG_REPLY state
* adds testing for beginHandshake() which moves the state from
* InitState to WaitConfigReply.
*/
@Test
public void moveToWaitConfigReply() throws Exception {
moveToPreConfigReply();
List<OFMessage> msgs = connection.getMessages();
assertEquals(3, msgs.size());
assertEquals(OFType.SET_CONFIG, msgs.get(0).getType());
OFSetConfig sc = (OFSetConfig)msgs.get(0);
assertEquals(0xffff, sc.getMissSendLen());
assertEquals(OFType.BARRIER_REQUEST, msgs.get(1).getType());
assertEquals(OFType.GET_CONFIG_REQUEST, msgs.get(2).getType());
verifyUniqueXids(msgs);
msgs.clear();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitConfigReplyState.class));
verifyAll();
}
示例8: startUp
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
clearCurrentTopology();
// Initialize role to floodlight provider role.
this.role = floodlightProviderService.getRole();
ScheduledExecutorService ses = threadPoolService.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());
if (role != HARole.STANDBY) {
newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS, TimeUnit.MILLISECONDS);
}
linkDiscoveryService.addListener(this);
floodlightProviderService.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProviderService.addHAListener(this.haListener);
addRestletRoutable();
}
示例9: moveToWaitHello
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Test
public void moveToWaitHello() throws Exception {
resetChannel();
channel.write(capture(writeCapture));
expectLastCall().andReturn(null).once();
replay(channel);
// replay unused mocks
replay(messageEvent);
handler.channelConnected(ctx, channelStateEvent);
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.HELLO, msgs.get(0).getType());
assertThat(handler.getStateForTesting(), CoreMatchers.instanceOf(OFChannelHandler.WaitHelloState.class));
verifyUniqueXids(msgs);
}
示例10: moveToWaitFeaturesReply
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_FEATURES_REPLY state
* Builds on moveToWaitHello()
* adds testing for WAIT_HELLO state
*/
@Test
public void moveToWaitFeaturesReply() throws Exception {
moveToWaitHello();
resetChannel();
expect(channel.writeAndFlush(capture(writeCapture))).andReturn(null).once();
replay(channel);
OFMessage hello = factory.buildHello().build();
sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(hello));
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.FEATURES_REQUEST, msgs.get(0).getType());
verifyUniqueXids(msgs);
assertThat(handler.getStateForTesting(), CoreMatchers.instanceOf(OFChannelHandler.WaitFeaturesReplyState.class));
}
示例11: pruneInvalidMessages
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Sorts any invalid messages by moving them from the msgList. The net result
* is a new list returned containing the invalid messages and a pruned msgList
* containing only those messages that are valid for the given role of the controller
* and OpenFlow version of the switch.
*
* @param msgList the list of messages to sort
* @param valid the list of valid messages (caller must allocate)
* @param swVersion the OFVersion of the switch
* @param isSlave true if controller is slave; false otherwise
* @return list of messages that are not valid, removed from input parameter msgList
*/
protected static Collection<OFMessage> pruneInvalidMessages(Iterable<OFMessage> msgList, Collection<OFMessage> valid, OFVersion swVersion, boolean isActive) {
if (isActive) { /* master or equal/other support all */
valid.addAll(IterableUtils.toCollection(msgList));
return Collections.emptyList();
} else { /* slave */
Set<OFType> invalidSlaveMsgs = invalidSlaveMsgsByOFVersion.get(swVersion);
List<OFMessage> invalid = new ArrayList<OFMessage>();
Iterator<OFMessage> itr = msgList.iterator();
while (itr.hasNext()) {
OFMessage m = itr.next();
if (invalidSlaveMsgs.contains(m.getType())) {
invalid.add(m);
} else {
valid.add(m);
}
}
return invalid;
}
}
示例12: moveToWaitFeaturesReply
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_FEATURES_REPLY state
* Builds on moveToWaitHello()
* adds testing for WAIT_HELLO state
*/
@Test
public void moveToWaitFeaturesReply() throws Exception {
moveToWaitHello();
resetChannel();
channel.write(capture(writeCapture));
expectLastCall().andReturn(null).atLeastOnce();
replay(channel);
OFMessage hello = factory.buildHello().build();
sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(hello));
List<OFMessage> msgs = getMessagesFromCapture();
assertEquals(1, msgs.size());
assertEquals(OFType.FEATURES_REQUEST, msgs.get(0).getType());
verifyUniqueXids(msgs);
assertThat(handler.getStateForTesting(), CoreMatchers.instanceOf(OFChannelHandler.WaitFeaturesReplyState.class));
}
示例13: init
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/**
* Initialize internal data structures
*/
public void init(Map<String, String> configParams) throws FloodlightModuleException {
this.moduleLoaderState = ModuleLoaderState.INIT;
// These data structures are initialized here because other
// module's startUp() might be called before ours
this.messageListeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, IOFMessageListener>>();
this.haListeners = new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
this.controllerNodeIPsCache = new HashMap<String, String>();
this.updates = new LinkedBlockingQueue<IUpdate>();
this.providerMap = new HashMap<String, List<IInfoProvider>>();
setConfigParams(configParams);
HARole initialRole = getInitialRole(configParams);
this.notifiedRole = initialRole;
this.shutdownService = new ShutdownServiceImpl();
this.roleManager = new RoleManager(this, this.shutdownService,
this.notifiedRole,
INITIAL_ROLE_CHANGE_DESCRIPTION);
this.timer = new HashedWheelTimer();
// Switch Service Startup
this.switchService.registerLogicalOFMessageCategory(LogicalOFMessageCategory.MAIN);
this.switchService.addOFSwitchListener(new NotificationSwitchListener());
this.counters = new ControllerCounters(debugCounterService);
}
示例14: addFlowReconcileListener
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public synchronized void addFlowReconcileListener(
IFlowReconcileListener listener) {
flowReconcileListeners.addListener(OFType.FLOW_MOD, listener);
if (logger.isTraceEnabled()) {
StringBuffer sb = new StringBuffer();
sb.append("FlowMod listeners: ");
for (IFlowReconcileListener l :
flowReconcileListeners.getOrderedListeners()) {
sb.append(l.getName());
sb.append(",");
}
logger.trace(sb.toString());
}
}
示例15: moveToWaitConfigReply
import org.projectfloodlight.openflow.protocol.OFType; //导入依赖的package包/类
/** Move the channel from scratch to WAIT_CONFIG_REPLY state
* adds testing for beginHandshake() which moves the state from
* InitState to WaitConfigReply.
*/
@Test
public void moveToWaitConfigReply() throws Exception {
moveToPreConfigReply();
List<OFMessage> msgs = connection.getMessages();
assertEquals(3, msgs.size());
assertEquals(OFType.SET_CONFIG, msgs.get(0).getType());
OFSetConfig sc = (OFSetConfig)msgs.get(0);
assertEquals(0xffff, sc.getMissSendLen());
assertEquals(OFType.BARRIER_REQUEST, msgs.get(1).getType());
assertEquals(OFType.GET_CONFIG_REQUEST, msgs.get(2).getType());
verifyUniqueXids(msgs);
msgs.clear();
assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitConfigReplyState.class));
verifyAll();
}