当前位置: 首页>>代码示例>>Java>>正文


Java OFType类代码示例

本文整理汇总了Java中org.openflow.protocol.OFType的典型用法代码示例。如果您正苦于以下问题:Java OFType类的具体用法?Java OFType怎么用?Java OFType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OFType类属于org.openflow.protocol包,在下文中一共展示了OFType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearFlowMods

import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
 * @param sw
 *            The switch we wish to remove flows from
 * @param match
 *            The specific OFMatch object of specific flows we wish to
 *            delete
 * @param outPort
 *            The specific Output Action OutPort of specific flows we wish
 *            to delete
 */
public void clearFlowMods(IOFSwitch sw, OFMatch match, Short outPort) {
    // Delete pre-existing flows with the same match, and output action port
    // or outPort
    match.setWildcards(OFMatch.OFPFW_ALL);
    OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
                                                  .getMessage(OFType.FLOW_MOD)).setMatch(match)
                                                                               .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                               .setOutPort(outPort)
                                                                               .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
    try {
        List<OFMessage> msglist = new ArrayList<OFMessage>(1);
        msglist.add(fm);
        sw.write(msglist, cntx);
    } catch (Exception e) {
        log.error("Failed to clear flows on switch {} - {}", this, e);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:28,代码来源:PortDownReconciliation.java

示例2: addFlowReconcileListener

import org.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());
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:17,代码来源:FlowReconcileManager.java

示例3: init

import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
        throws FloodlightModuleException {
    threadPool = context.getServiceImpl(IThreadPoolService.class);
    counterStore = context.getServiceImpl(ICounterStoreService.class);
    debugCounters = 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);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:24,代码来源:FlowReconcileManager.java

示例4: init

import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
                                             throws FloodlightModuleException {
    floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
    restApi = context.getServiceImpl(IRestApiService.class);
    counterStore = context.getServiceImpl(ICounterStoreService.class);
    deviceManager = context.getServiceImpl(IDeviceService.class);
    routingEngine = context.getServiceImpl(IRoutingService.class);
    topology = context.getServiceImpl(ITopologyService.class);
    sfp = context.getServiceImpl(IStaticFlowEntryPusherService.class);
    
    messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY, 
                                        EnumSet.of(OFType.FLOW_MOD),
                                        OFMESSAGE_DAMPER_TIMEOUT);
    
    vips = new HashMap<String, LBVip>();
    pools = new HashMap<String, LBPool>();
    members = new HashMap<String, LBMember>();
    vipIpToId = new HashMap<Integer, String>();
    vipIpToMac = new HashMap<Integer, MACAddress>();
    memberIpToId = new HashMap<Integer, String>();
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:23,代码来源:LoadBalancer.java

示例5: startUp

import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void startUp(FloodlightModuleContext context) {
    clearCurrentTopology();
    // Initialize role to floodlight provider role.
    this.role = floodlightProvider.getRole();

    ScheduledExecutorService ses = threadPool.getScheduledExecutor();
    newInstanceTask = new SingletonTask(ses, new UpdateTopologyWorker());

    if (role != Role.SLAVE)
        newInstanceTask.reschedule(TOPOLOGY_COMPUTE_INTERVAL_MS,
                               TimeUnit.MILLISECONDS);

    linkDiscovery.addListener(this);
    floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
    floodlightProvider.addHAListener(this.haListener);
    addRestletRoutable();
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:TopologyManager.java

示例6: moveToWaitHello

import org.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());
    assertEquals(OFChannelHandler.ChannelState.WAIT_HELLO,
                 handler.getStateForTesting());
    verifyUniqueXids(msgs);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:OFChannelHandlerTest.java

示例7: write

import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
public void write(OFMessage m, FloodlightContext bc) {
    if (channel == null || !isConnected())
        return;
        //throws IOException {
    Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
    List<OFMessage> msg_buffer = msg_buffer_map.get(this);
    if (msg_buffer == null) {
        msg_buffer = new ArrayList<OFMessage>();
        msg_buffer_map.put(this, msg_buffer);
    }

    this.floodlightProvider.handleOutgoingMessage(this, m, bc);
    msg_buffer.add(m);

    if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) ||
        ((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
        this.write(msg_buffer);
        msg_buffer.clear();
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:22,代码来源:OFSwitchBase.java

示例8: clearAllFlowMods

import org.openflow.protocol.OFType; //导入依赖的package包/类
@LogMessageDoc(level="INFO",
        message="Switch {switch} flow cleared",
        explanation="The switch flow table has been cleared, " +
                "this normally happens on switch connection")
@Override
public void clearAllFlowMods() {
    if (channel == null || !isConnected())
        return;
    // Delete all pre-existing flows
    log.info("Clearing all flows on switch {}", this);
    OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
    OFMessage fm = ((OFFlowMod) floodlightProvider.getOFMessageFactory()
        .getMessage(OFType.FLOW_MOD))
            .setMatch(match)
        .setCommand(OFFlowMod.OFPFC_DELETE)
        .setOutPort(OFPort.OFPP_NONE)
        .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));
    fm.setXid(getNextTransactionId());
    OFMessage barrierMsg = floodlightProvider.getOFMessageFactory().getMessage(
            OFType.BARRIER_REQUEST);
    barrierMsg.setXid(getNextTransactionId());
    List<OFMessage> msglist = new ArrayList<OFMessage>(2);
    msglist.add(fm);
    msglist.add(barrierMsg);
    channel.write(msglist);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:OFSwitchBase.java

示例9: testMessageDispatchMaster

import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = (OFPacketIn)
            BasicFactory.getInstance().getMessage(OFType.PACKET_IN);
    reset(controller);
    controller.handleMessage(sw, pi, null);
    expectLastCall().once();
    sendMessageToHandlerNoControllerReset(
           Collections.<OFMessage>singletonList(pi));
    verify(controller);
    // TODO: many more to go
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:19,代码来源:OFChannelHandlerTest.java

示例10: OFMessageFuture

import org.openflow.protocol.OFType; //导入依赖的package包/类
public OFMessageFuture(IThreadPoolService tp,
        IOFSwitch sw, OFType responseType, int transactionId, long timeout, TimeUnit unit) {
    this.threadPool = tp;
    this.canceled = false;
    this.latch = new CountDownLatch(1);
    this.responseType = responseType;
    this.sw = sw;
    this.transactionId = transactionId;

    final OFMessageFuture<V> future = this;
    timeoutTimer = new Runnable() {
        @Override
        public void run() {
            if (timeoutTimer == this)
                future.cancel(true);
        }
    };
    threadPool.getScheduledExecutor().schedule(timeoutTimer, timeout, unit);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:20,代码来源:OFMessageFuture.java

示例11: sendNxRoleRequest

import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
 * Send NX role request message to the switch requesting the specified
 * role.
 *
 * @param sw switch to send the role request message to
 * @param role role to request
 */
private int sendNxRoleRequest(Role role)
        throws IOException {

    int xid = sw.getNextTransactionId();
    // Convert the role enum to the appropriate integer constant used
    // in the NX role request message
    int nxRole = role.toNxRole();

    // Construct the role request message
    OFVendor roleRequest = (OFVendor)BasicFactory.getInstance()
            .getMessage(OFType.VENDOR);
    roleRequest.setXid(xid);
    roleRequest.setVendor(OFNiciraVendorData.NX_VENDOR_ID);
    OFRoleRequestVendorData roleRequestData = new OFRoleRequestVendorData();
    roleRequestData.setRole(nxRole);
    roleRequest.setVendorData(roleRequestData);
    roleRequest.setLengthU(OFVendor.MINIMUM_LENGTH +
            roleRequestData.getLength());

    // Send it to the switch
    sw.write(Collections.<OFMessage>singletonList(roleRequest),
             new FloodlightContext());

    return xid;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:33,代码来源:OFChannelHandler.java

示例12: testReassertMaster

import org.openflow.protocol.OFType; //导入依赖的package包/类
/**
 * Test re-assert MASTER
 *
 */
@Test
public void testReassertMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    OFError err = (OFError)
            BasicFactory.getInstance().getMessage(OFType.ERROR);
    err.setXid(42);
    err.setErrorType(OFErrorType.OFPET_BAD_REQUEST);
    err.setErrorCode(OFBadRequestCode.OFPBRC_EPERM);

    reset(controller);
    controller.reassertRole(handler, Role.MASTER);
    expectLastCall().once();
    controller.handleMessage(sw, err, null);
    expectLastCall().once();

    sendMessageToHandlerNoControllerReset(
            Collections.<OFMessage>singletonList(err));

    verify(sw);
    verify(controller);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:OFChannelHandlerTest.java

示例13: setPacketIn

import org.openflow.protocol.OFType; //导入依赖的package包/类
protected void setPacketIn(IPacket packet) {
    byte[] serializedPacket = packet.serialize();
    // Build the PacketIn
    this.packetIn = ((OFPacketIn) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_IN))
            .setBufferId(-1)
            .setInPort((short) 1)
            .setPacketData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH)
            .setTotalLength((short) serializedPacket.length);

    // Add the packet to the context store
    IFloodlightProviderService.bcStore.
    put(cntx,
            IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
            (Ethernet)packet);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:17,代码来源:FirewallTest.java

示例14: moveToWaitDescriptionStatReply

import org.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();
    resetChannel();
    channel.write(capture(writeCapture));
    expectLastCall().andReturn(null).atLeastOnce();
    replay(channel);

    OFGetConfigReply cr = (OFGetConfigReply)BasicFactory.getInstance()
            .getMessage(OFType.GET_CONFIG_REPLY);
    cr.setMissSendLength((short)0xffff);

    sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(cr));

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(1, msgs.size());
    assertEquals(OFType.STATS_REQUEST, msgs.get(0).getType());
    OFStatisticsRequest sr = (OFStatisticsRequest)msgs.get(0);
    assertEquals(OFStatisticsType.DESC, sr.getStatisticType());
    // no idea why an  OFStatisticsRequest even /has/ a getStatistics()
    // methods. It really shouldn't
    assertNull(sr.getStatistics());
    verifyUniqueXids(msgs);
    assertEquals(OFChannelHandler.ChannelState.WAIT_DESCRIPTION_STAT_REPLY,
                 handler.getStateForTesting());
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:31,代码来源:OFChannelHandlerTest.java

示例15: isCallbackOrderingPrereq

import org.openflow.protocol.OFType; //导入依赖的package包/类
@Override
/*
 * ????????ģ?????˳??
 */
public boolean isCallbackOrderingPrereq(OFType type, String name) {
	// TODO Auto-generated method stub
	return (name.equals("linkdiscovery"));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:9,代码来源:FlowDispatcher.java


注:本文中的org.openflow.protocol.OFType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。