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


Java OFStatisticsRequest.setStatisticType方法代码示例

本文整理汇总了Java中org.openflow.protocol.OFStatisticsRequest.setStatisticType方法的典型用法代码示例。如果您正苦于以下问题:Java OFStatisticsRequest.setStatisticType方法的具体用法?Java OFStatisticsRequest.setStatisticType怎么用?Java OFStatisticsRequest.setStatisticType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openflow.protocol.OFStatisticsRequest的用法示例。


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

示例1: sendFeatureReplyConfiguration

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * Send the configuration requests we can only do after we have
 * the features reply
 * @throws IOException
 */
void sendFeatureReplyConfiguration() throws IOException {
    // Ensure we receive the full packet via PacketIn
    OFSetConfig config = (OFSetConfig) factory
            .getMessage(OFType.SET_CONFIG);
    config.setMissSendLength((short) 0xffff)
    .setLengthU(OFSwitchConfig.MINIMUM_LENGTH);
    sw.write(config, null);
    sw.write(factory.getMessage(OFType.GET_CONFIG_REQUEST),
            null);

    // Get Description to set switch-specific flags
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.DESC);
    req.setLengthU(req.getLengthU());
    Future<List<OFStatistics>> dfuture = 
            sw.getStatistics(req);
    sw.setAttribute(IOFSwitch.SWITCH_DESCRIPTION_FUTURE,
            dfuture);

}
 
开发者ID:smartenit-eu,项目名称:smartenit,代码行数:26,代码来源:Controller.java

示例2: getFlows

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatisticsReply> getFlows(IOFSwitch sw, Short outPort) {

    statsReply = new ArrayList<OFFlowStatisticsReply>();
    List<OFStatistics> values = null;
    Future<List<OFStatistics>> future;

    // Statistics request object for getting flows
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.FLOW);
    int requestLength = req.getLengthU();
    OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
    specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
    specificReq.setOutPort(outPort);
    specificReq.setTableId((byte) 0xff);
    req.setStatistics(Collections.singletonList((OFStatistics) specificReq));
    requestLength += specificReq.getLength();
    req.setLengthU(requestLength);

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.queryStatistics(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFStatistics stat : values) {
                statsReply.add((OFFlowStatisticsReply) stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

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

示例3: sendHandshakeDescriptionStatsRequest

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * send a description state request
 * @throws IOException
 */
private void sendHandshakeDescriptionStatsRequest() throws IOException {
    // Get Description to set switch-specific flags
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.DESC);
    req.setXid(handshakeTransactionIds--);

    channel.write(Collections.singletonList(req));
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:13,代码来源:OFChannelHandler.java

示例4: sendHandshakeDescriptionStatsRequest

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
protected void sendHandshakeDescriptionStatsRequest() {
    final OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.DESC);
    req.setXid(this.handshakeTransactionIds--);

    this.channel.write(Collections.singletonList(req));

}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:9,代码来源:SwitchChannelHandler.java

示例5: getFlows

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatisticsReply> getFlows(IOFSwitch sw, Short outPort) {

    statsReply = new ArrayList<OFFlowStatisticsReply>();
    List<OFStatistics> values = null;
    Future<List<OFStatistics>> future;

    // Statistics request object for getting flows
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.FLOW);
    int requestLength = req.getLengthU();
    OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
    specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
    specificReq.setOutPort(outPort);
    specificReq.setTableId((byte) 0xff);
    req.setStatistics(Collections.singletonList((OFStatistics) specificReq));
    requestLength += specificReq.getLength();
    req.setLengthU(requestLength);

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.getStatistics(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFStatistics stat : values) {
                statsReply.add((OFFlowStatisticsReply) stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:41,代码来源:PortDownReconciliation.java

示例6: sendFeatureReplyConfiguration

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * Send the configuration requests we can only do after we have
 * the features reply
 * @throws IOException
 */
private void sendFeatureReplyConfiguration() throws IOException {
    List<OFMessage> msglist = new ArrayList<OFMessage>(3);

    // Ensure we receive the full packet via PacketIn
    OFSetConfig configSet = (OFSetConfig) factory
            .getMessage(OFType.SET_CONFIG);
    configSet.setMissSendLength((short) 0xffff)
        .setLengthU(OFSwitchConfig.MINIMUM_LENGTH);
    configSet.setXid(-4);
    msglist.add(configSet);

    // Verify (need barrier?)
    OFGetConfigRequest configReq = (OFGetConfigRequest)
            factory.getMessage(OFType.GET_CONFIG_REQUEST);
    configReq.setXid(-3);
    msglist.add(configReq);

    // Get Description to set switch-specific flags
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.DESC);
    req.setXid(-2);  // something "large"
    req.setLengthU(req.getLengthU());
    msglist.add(req);

    channel.write(msglist);
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:32,代码来源:Controller.java

示例7: getFlowStatsForSwitch

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * Retrieves FlowStats for everything on the switch
 * and returns them.
 * @param sw
 * @return List of OFStatistics objects
 */
private List<OFStatistics> getFlowStatsForSwitch(IOFSwitch sw){
	List <OFStatistics> statsReply = new ArrayList<OFStatistics>();
	List <OFStatistics> values = null;
	Future<List<OFStatistics>> future;
	// Statistics request object for getting flows
       OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.FLOW);
    int requestLength = req.getLengthU();
   	OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
       specificReq.setMatch(new OFMatch().setWildcards(0xffffffff));
       specificReq.setTableId((byte) 0xff);
       specificReq.setOutPort((short)-1);
       req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
       requestLength += specificReq.getLength();
       req.setLengthU(requestLength);
       
       try {
       	future = sw.queryStatistics(req);
       	log.debug(future.toString());
       	values = future.get(10, TimeUnit.SECONDS);
       	log.debug(values.toString());
       	if(values != null){
           	for(OFStatistics stat : values){
           		log.debug("Adding Stat");
           		statsReply.add(stat);
           	}
           }
       } catch (Exception e) {
           log.error("Failure retrieving statistics from switch " + sw, e);
       }
       log.debug("Stats cached for switch: " + sw.getId() + ". Total flows cached: " + statsReply.size());
       return statsReply;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:40,代码来源:FlowStatCacher.java

示例8: getPortStatsForSwitch

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
private HashMap<Short, OFStatistics> getPortStatsForSwitch(IOFSwitch sw){
	List <OFStatistics> values = null;
	Future<List<OFStatistics>> future;
	// Statistics request object for getting flows
       OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.PORT);
    int requestLength = req.getLengthU();
   	OFPortStatisticsRequest specificReq = new OFPortStatisticsRequest();
       specificReq.setPortNumber(OFPort.OFPP_NONE.getValue());
       req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
       requestLength += specificReq.getLength();
       req.setLengthU(requestLength);
       HashMap<Short, OFStatistics> statsReply = new HashMap<Short, OFStatistics>();
       
       try {
       	future = sw.queryStatistics(req);
       	log.debug(future.toString());
       	values = future.get(10, TimeUnit.SECONDS);
       	log.debug(values.toString());
       	if(values != null){
           	for(OFStatistics stat : values){
           		OFPortStatisticsReply portStat = (OFPortStatisticsReply) stat;
           		log.debug("Adding Stat");
           		statsReply.put(portStat.getPortNumber(), stat);
           	}
           }
       } catch (Exception e) {
           log.error("Failure retrieving statistics from switch " + sw, e);
       }
       log.debug("Stats cached for switch: " + sw.getId() + ". Total ports stats cached: " + statsReply.size());
       return statsReply;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:33,代码来源:FlowStatCacher.java

示例9: query

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
public ConcurrentMap<Long, List<OFStatistics>> query() {
	Map<Long, Set<Link>> linkMap = linkDiscoveryService.getSwitchLinks();
	for (Long switchId : linkMap.keySet()) {
	//	IOFSwitch sw = floodlightProvider.getSwitches().get(switchId);
		IOFSwitch sw = floodlightProvider.getSwitch(switchId);
		// System.out.println("sw = &&&&&&&&&&&&&&&&&&&" + switchId);
		Future<List<OFStatistics>> future;
		List<OFStatistics> values = null;
		if (sw != null) {
			OFStatisticsRequest req = new OFStatisticsRequest();
			req.setStatisticType(OFStatisticsType.PORT);
			OFPortStatisticsRequest specificReq = new OFPortStatisticsRequest();
			specificReq.setPortNumber((short) OFPort.OFPP_NONE.getValue());
			req.setStatistics(Collections
					.singletonList((OFStatistics) specificReq));
			int requestLength = req.getLengthU();
			requestLength += specificReq.getLength();
			req.setLengthU(requestLength);
			try {
				future = sw.queryStatistics(req);
				values = future.get(10, TimeUnit.SECONDS);
				// System.out
				// .println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<get port statics info="
				// + values);
				if (ofstaticsMap.get(switchId) != null) {
					preofstaticsMap.put(switchId,
							ofstaticsMap.get(switchId));
				}
				ofstaticsMap.put(switchId, values);
				// System.out
				// .println("------------->>>>>>switchid<<<<<<--------------"
				// + switchId + ofstaticsMap.get(switchId));
				// System.out
				// .println("------------->>>>>>switchid<<<<<<--------------"
				// + switchId + values);
			} catch (Exception e) {
				log.error(
						"Failure retrieving statistics from switch " + sw,
						e);
			}
		}
	}
	return ofstaticsMap;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:45,代码来源:FlowDispatcher.java

示例10: querySwitchStats

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
@LogMessageDoc(level="ERROR",
        message="Failure to send stats request to switch {sw}, {exception}",
        explanation="Controller is not able to send request to switch",
        recommendation=LogMessageDoc.CHECK_SWITCH)
public void querySwitchStats(long swId,
                             IOFMessageListener callbackHandler) {
    IOFSwitch sw = controllerProvider.getSwitches().get(swId);
    if ((sw == null) || (!sw.isConnected())) {
        if (logger.isDebugEnabled()) {
            logger.debug("Failed to send flow-stats request to switch Id {}",
                    swId);
        }
        return;
    } else {
        if (logger.isTraceEnabled()) {
            logger.trace(
                "Sending flow scan request to switch {} Id={}", 
                sw, swId);
        }
    }
    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.FLOW);
    int requestLength = req.getLengthU();

    OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(FlowCacheObj.WILD_ALL);
    specificReq.setMatch(match);
    specificReq.setOutPort(OFPort.OFPP_NONE.getValue());
    specificReq.setTableId((byte) 0xff);
    req.setStatistics(Collections.singletonList(
                                        (OFStatistics)specificReq));
    requestLength += specificReq.getLength();

    req.setLengthU(requestLength);
    try {
        sw.sendStatsQuery(req, sw.getNextTransactionId(), callbackHandler);
    } catch (Exception e) {
        logger.error("Failure to send stats request to switch {}, {}",
                                                                sw, e);
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:43,代码来源:BetterFlowCache.java

示例11: getSwitchFlowsMatchOutputPort

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
/**
 * Gets the flows from a switch that matches a given output port. This 
 * method is used to handle link down event.
 * TODO - Refactor to use async response from switch
 *
 * @param sw the switch object
 * @param outPort the output port of the switch to match
 * @return the flows in the switch that match the output port
 */
@LogMessageDoc(level="ERROR",
        message="Failure retrieving flows from switch {switch}, {exception}",
        explanation="Controller is not able to retrieve flows from switch",
        recommendation=LogMessageDoc.CHECK_SWITCH)
public void getSwitchFlowsMatchOutputPort(IOFSwitch sw, short outPort,
                                                PendingSwitchResp pendQ) {
    if (sw != null) {
        OFStatisticsRequest req = new OFStatisticsRequest();
        req.setStatisticType(OFStatisticsType.FLOW);
        int requestLength = req.getLengthU();

        OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
        OFMatch match = new OFMatch();
        match.setWildcards(0xffffffff);
        specificReq.setMatch(match);
        specificReq.setOutPort(outPort);
        specificReq.setTableId((byte) 0xff);
        req.setStatistics(Collections.singletonList(
                                            (OFStatistics)specificReq));
        requestLength += specificReq.getLength();

        req.setLengthU(requestLength);
        try {
            if (sw.isConnected()) {
                int transId = sw.getNextTransactionId();
                /* Need to add the pending resp. to the map before the
                 * request is sent to the switch; otherwise the response
                 * from the switch may come before it is added to map
                 * resulting in "unexpected" response.
                 */
                PendingSwRespKey pendSwRespKey =
                        new PendingSwRespKey(sw.getId(), transId);
                pendSwRespMap.put(pendSwRespKey, pendQ);
                if (logger.isTraceEnabled()) {
                    logger.trace("Added key {} to pending map",
                                                pendSwRespKey.toString());
                }
                sw.sendStatsQuery(req, transId, this);
                return;
            }
        } catch (Exception e) {
            logger.error("Failure retrieving flows from switch {}, {}",
                         sw, e);
        }
    }
    return;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:57,代码来源:BetterFlowReconcileManager.java

示例12: testFlowCachePeriodicSwitchFlowTableScan

import org.openflow.protocol.OFStatisticsRequest; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testFlowCachePeriodicSwitchFlowTableScan() throws Exception {
    betterFlowCacheMgr.fqTask.setEnableFlowQueryTask(true);
    /* Periodic scan interval has already been set to low value 
     * in the setup() */

    /* Add a flow to flow cache */
    OFMatch ofm = new OFMatch();
    ofm.setDataLayerSource(Ethernet.toByteArray(device1.getMACAddress()));
    ofm.setDataLayerDestination(Ethernet.
                                toByteArray(device2.getMACAddress()));
    ofm.setDataLayerVirtualLan((short)-1);
    OFMatchWithSwDpid ofmWithSwDpid = new OFMatchWithSwDpid(ofm, 1L);
    betterFlowCacheMgr.addFlow("testNetVirt1", ofmWithSwDpid, 2L, 1L, (short)1,
            (short)0, FlowCacheObj.FCActionPERMIT);
    /* Check that its scan count is zero */
    FlowCacheObj fco = 
    betterFlowCacheMgr.getAllFlowsByApplInstVlanSrcDestDevicesInternal(
            "testNetVirt1", (short)-1, device1.getMACAddress(), 
            device2.getMACAddress());
    assertTrue(fco != null);
    assertEquals(0, fco.fce.scanCnt);

    Capture<OFStatisticsRequest> request =
            new Capture<OFStatisticsRequest>(CaptureType.ALL);
    Capture<Integer> xid = new Capture<Integer>(CaptureType.ALL);
    Capture<IOFMessageListener> iofml =
            new Capture<IOFMessageListener>(CaptureType.ALL);

    OFStatisticsRequest req = new OFStatisticsRequest();
    req.setStatisticType(OFStatisticsType.FLOW);
    int requestLength = req.getLengthU();
    OFFlowStatisticsRequest specificReq = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(FlowCacheObj.WILD_ALL);
    specificReq.setMatch(match);
    specificReq.setOutPort(OFPort.OFPP_NONE.getValue());
    specificReq.setTableId((byte) 0xff);
    req.setStatistics(Collections.singletonList((OFStatistics)specificReq));
    requestLength += specificReq.getLength();
    req.setLengthU(requestLength);

    sw1.sendStatsQuery(capture(request),  capture(xid), capture(iofml));
    expectLastCall().atLeastOnce();
    sw2.sendStatsQuery(capture(request),  capture(xid), capture(iofml));
    expectLastCall().atLeastOnce();
    sw3.sendStatsQuery(capture(request),  capture(xid), capture(iofml));
    expectLastCall().atLeastOnce();
    replay(sw1, sw2, sw3);
    /* Sleep for to allow for the switch flow table scans to kick in */
    Thread.sleep((long)(betterFlowCacheMgr.periodicSwScanIntervalMsec*2.5)); 
    verify(sw1, sw2, sw3);
    assertTrue(iofml.getValues().size() >= 3);
    assertEquals(betterFlowCacheMgr, iofml.getValues().get(1));
    assertEquals(betterFlowCacheMgr, iofml.getValues().get(2));
    assertEquals(betterFlowCacheMgr, iofml.getValues().get(3));
    assertTrue(request.getValues().size() >= 3);
    assertEquals(req, request.getValues().get(1));
    assertEquals(req, request.getValues().get(2));
    assertEquals(req, request.getValues().get(3));
    /* Confirm that the scan count of the entry in flow cache was
     * incremented as we didn't inject any response from the switches.
     */
    assertTrue(2 <= fco.fce.scanCnt);
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:67,代码来源:BetterFlowCacheTest.java


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