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


Java OFFlowMod类代码示例

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


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

示例1: addPolicyToNetwork

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Add a policy-flowMod to all switches in network
 * @param policy
 */
@Override
public void addPolicyToNetwork(QoSPolicy policy) {
	OFFlowMod flow = policyToFlowMod(policy);
	logger.info("adding policy-flow {} to all switches",flow.toString());
	//add to all switches
	Map<Long, IOFSwitch> switches = floodlightProvider.getAllSwitchMap();
	//simple check
	if(!(switches.isEmpty())){
		for(IOFSwitch sw : switches.values()){
			if(!(sw.isConnected())){
				break;// cannot add
			}
			logger.info("Add flow Name: {} Flow: {} Switch "+ sw.getStringId(), 
			policy.name, flow.toString());
			//add unique flow names based on dpid hasCode :)
			flowPusher.addFlow(policy.name+Integer
					.toString(sw.getStringId()
							.hashCode()), flow, sw.getStringId());	
		}
	}
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:26,代码来源:QoS.java

示例2: clearFlowMods

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * @param sw
 *            The switch we wish to remove flows from
 * @param outPort
 *            The specific Output Action OutPort of specific flows we wish
 *            to delete
 */
public void clearFlowMods(IOFSwitch sw, Short outPort) {
    // Delete all pre-existing flows with the same output action port or
    // outPort
    OFMatch match = new OFMatch().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,代码行数:25,代码来源:PortDownReconciliation.java

示例3: ListStaticFlowEntries

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Get
public Map<String, Map<String, OFFlowMod>> ListStaticFlowEntries() {
    IStaticFlowEntryPusherService sfpService =
            (IStaticFlowEntryPusherService)getContext().getAttributes().
                get(IStaticFlowEntryPusherService.class.getCanonicalName());
    
    String param = (String) getRequestAttributes().get("switch");
    if (log.isDebugEnabled())
        log.debug("Listing all static flow entires for switch: " + param);
    
    if (param.toLowerCase().equals("all")) {
        return sfpService.getFlows();
    } else {
        try {
            Map<String, Map<String, OFFlowMod>> retMap = 
                    new HashMap<String, Map<String, OFFlowMod>>();
            retMap.put(param, sfpService.getFlows(param));
            return retMap;
            
        } catch (NumberFormatException e){
            setStatus(Status.CLIENT_ERROR_BAD_REQUEST, 
                      ControllerSwitchesResource.DPID_ERROR);
        }
    }
    return null;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:27,代码来源:ListStaticFlowEntriesResource.java

示例4: sendEntriesToSwitch

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Reads from our entriesFromStorage for the specified switch and
 * sends the FlowMods down to the controller in <b>sorted</b> order.
 *
 * Sorted is important to maintain correctness of the switch:
 * if a packet would match both a lower and a higher priority
 * rule, then we want it to match the higher priority or nothing,
 * but never just the lower priority one.  Inserting from high to
 * low priority fixes this.
 *
 * TODO consider adding a "block all" flow mod and then removing it
 * while starting up.
 *
 * @param sw The switch to send entries to
 */
protected void sendEntriesToSwitch(long switchId) {
    IOFSwitch sw = floodlightProvider.getSwitch(switchId);
    if (sw == null)
        return;
    String stringId = sw.getStringId();

    if ((entriesFromStorage != null) && (entriesFromStorage.containsKey(stringId))) {
        Map<String, OFFlowMod> entries = entriesFromStorage.get(stringId);
        List<String> sortedList = new ArrayList<String>(entries.keySet());
        // weird that Collections.sort() returns void
        Collections.sort( sortedList, new FlowModSorter(stringId));
        for (String entryName : sortedList) {
            OFFlowMod flowMod = entries.get(entryName);
            if (flowMod != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Pushing static entry {} for {}", stringId, entryName);
                }
                writeFlowModToSwitch(sw, flowMod);
            }
        }
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:38,代码来源:StaticFlowEntryPusher.java

示例5: readEntriesFromStorage

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Read entries from storageSource, and store them in a hash
 *
 * @return
 */
@LogMessageDoc(level="ERROR",
        message="failed to access storage: {reason}",
        explanation="Could not retrieve static flows from the system " +
        		"database",
        recommendation=LogMessageDoc.CHECK_CONTROLLER)
private Map<String, Map<String, OFFlowMod>> readEntriesFromStorage() {
    Map<String, Map<String, OFFlowMod>> entries = new ConcurrentHashMap<String, Map<String, OFFlowMod>>();
    try {
        Map<String, Object> row;
        // null1=no predicate, null2=no ordering
        IResultSet resultSet = storageSource.executeQuery(TABLE_NAME,
                ColumnNames, null, null);
        for (Iterator<IResultSet> it = resultSet.iterator(); it.hasNext();) {
            row = it.next().getRow();
            parseRow(row, entries);
        }
    } catch (StorageException e) {
        log.error("failed to access storage: {}", e.getMessage());
        // if the table doesn't exist, then wait to populate later via
        // setStorageSource()
    }
    return entries;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:29,代码来源:StaticFlowEntryPusher.java

示例6: clearAllFlowMods

import org.openflow.protocol.OFFlowMod; //导入依赖的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

示例7: testSingleSwitchPortDownReconciliation

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * This tests the port down reconciliation in the event that the base switch
 * is the only switch involved in the PORT_DOWN event. It simply deletes
 * flows concerning the downed port.
 * 
 * @verify checks to see that a general clearFlowMods(Short outPort) is
 *         called
 * @throws Exception
 */
@Test
public void testSingleSwitchPortDownReconciliation() throws Exception {
    log.debug("Starting single switch port down reconciliation test");
    // Load the switch map
    switches = new HashMap<Long, IOFSwitch>();
    switches.put(1L, sw1);
    mockFloodlightProvider.setSwitches(switches);

    // Reconcile flows with specified OFMatchReconcile
    pdr.reconcileFlows(lofmr);
    // Validate results
    verify(sw1);
    
    assertTrue(wc1.hasCaptured());

    List<OFMessage> msglist = wc1.getValues().get(0);

    // Make sure the messages we captures correct
    for (OFMessage m : msglist) {
        if (m instanceof OFFlowMod) assertEquals(fm, m);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:32,代码来源:PortDownReconciliationTest.java

示例8: sendEntriesToSwitch

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Reads from our entriesFromStorage for the specified switch and
 * sends the FlowMods down to the controller in <b>sorted</b> order.
 *
 * Sorted is important to maintain correctness of the switch:
 * if a packet would match both a lower and a higher priority
 * rule, then we want it to match the higher priority or nothing,
 * but never just the lower priority one.  Inserting from high to
 * low priority fixes this.
 *
 * TODO consider adding a "block all" flow mod and then removing it
 * while starting up.
 *
 * @param sw The switch to send entries to
 */
protected void sendEntriesToSwitch(IOFSwitch sw) {
    String dpid = sw.getStringId();

    if ((entriesFromStorage != null) && (entriesFromStorage.containsKey(dpid))) {
        Map<String, OFFlowMod> entries = entriesFromStorage.get(dpid);
        List<String> sortedList = new ArrayList<String>(entries.keySet());
        // weird that Collections.sort() returns void
        Collections.sort( sortedList, new FlowModSorter(dpid));
        for (String entryName : sortedList) {
            OFFlowMod flowMod = entries.get(entryName);
            if (flowMod != null) {
                if (log.isDebugEnabled()) {
                    log.debug("Pushing static entry {} for {}", dpid, entryName);
                }
                writeFlowModToSwitch(sw, flowMod);
            }
        }
    }
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:35,代码来源:StaticFlowEntryPusher.java

示例9: readEntriesFromStorage

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * Read entries from storageSource, and store them in a hash
 * 
 * @return
 */
@LogMessageDoc(level="ERROR",
        message="failed to access storage: {reason}",
        explanation="Could not retrieve static flows from the system " +
        		"database",
        recommendation=LogMessageDoc.CHECK_CONTROLLER)
private Map<String, Map<String, OFFlowMod>> readEntriesFromStorage() {
    Map<String, Map<String, OFFlowMod>> entries = new ConcurrentHashMap<String, Map<String, OFFlowMod>>();
    try {
        Map<String, Object> row;
        // null1=no predicate, null2=no ordering
        IResultSet resultSet = storageSource.executeQuery(TABLE_NAME,
                ColumnNames, null, null);
        for (Iterator<IResultSet> it = resultSet.iterator(); it.hasNext();) {
            row = it.next().getRow();
            parseRow(row, entries);
        }
    } catch (StorageException e) {
        log.error("failed to access storage: {}", e.getMessage());
        // if the table doesn't exist, then wait to populate later via
        // setStorageSource()
    }
    return entries;
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:29,代码来源:StaticFlowEntryPusher.java

示例10: clearAllFlowMods

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
@Override
@LogMessageDoc(level="ERROR",
               message="Failed to clear all flows on switch {switch}",
               explanation="An I/O error occured while trying to clear " +
               		"flows on the switch.",
               recommendation=LogMessageDoc.CHECK_SWITCH)
public void clearAllFlowMods() {
    // Delete all pre-existing flows
    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));
    try {
        List<OFMessage> msglist = new ArrayList<OFMessage>(1);
        msglist.add(fm);
        channel.write(msglist);
    } catch (Exception e) {
        log.error("Failed to clear all flows on switch " + this, e);
    }
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:24,代码来源:OFSwitchImpl.java

示例11: findSliceForFlow

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * findSliceForFlow - finds a slice based on the flow rule passed in
 * @param switchId
 * @param flowMod
 * @return Slicer
 */
private Slicer findSliceForFlow(long switchId, OFFlowMod flowMod){
	List<HashMap<Long, Slicer>> slices = parent.getSlices();
	for(HashMap<Long,Slicer> tmpSlices : slices){
		if(!tmpSlices.containsKey(switchId)){
			//switch not part of this slice
			log.debug("Switch is not part of this slice!");
			continue;
		}

		Slicer slice = tmpSlices.get(switchId);
		log.debug("Looking at slice: " + slice.getSliceName());
		List<OFFlowMod> flows = slice.allowedFlows(flowMod);
		if(flows.size() > 0){
			return slice;
		}
	}
	return null;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:25,代码来源:FlowStatCache.java

示例12: buildFlowStatFromFlowMod

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * builds a flowStat from an OFFlowMOd
 * @param flow
 * @return FSFWOFFlowStatisticsReply
 */
private FSFWOFFlowStatisticsReply buildFlowStatFromFlowMod(OFFlowMod flow){
	FSFWOFFlowStatisticsReply flowStat = new FSFWOFFlowStatisticsReply();
	flowStat.setMatch(flow.getMatch());
	flowStat.setActions(flow.getActions());
	flowStat.setPacketCount(0);
	flowStat.setByteCount(0);
	flowStat.setPriority(flow.getPriority());
	flowStat.setCookie(flow.getCookie());
	flowStat.setHardTimeout(flow.getHardTimeout());
	flowStat.setIdleTimeout(flow.getIdleTimeout());
	short length = 0;
	for(OFAction act : flowStat.getActions()){
		length += act.getLengthU();
	}
	flowStat.setLength((short)(OFFlowStatisticsReply.MINIMUM_LENGTH + length));
	return flowStat;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:23,代码来源:FlowStatCache.java

示例13: setupMinorParameters

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
protected void setupMinorParameters(TestConfig c, int idx) {
    switch (idx % 4) {
        case 0:
            c.doFlush = true;
            c.requestFlowRemovedNotifn = true;
            c.flowModCmd = OFFlowMod.OFPFC_ADD;
            break;
        case 1:
            c.doFlush = true;
            c.requestFlowRemovedNotifn = true;
            c.flowModCmd = OFFlowMod.OFPFC_MODIFY;
            break;
        case 2:
            c.doFlush = true;
            c.requestFlowRemovedNotifn = false;
            c.flowModCmd = OFFlowMod.OFPFC_MODIFY;
        case 3:
            c.doFlush = false;
            c.requestFlowRemovedNotifn = true;
            c.flowModCmd = OFFlowMod.OFPFC_ADD;
            break;
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:24,代码来源:PushRewriteRouteTest.java

示例14: deleteFlow

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
private void deleteFlow(Long switchId, OFFlowStatisticsReply flowStat){
	List<IOFSwitch> switches = this.getSwitches();
	for(IOFSwitch sw : switches){
		if(sw.getId() == switchId){
			OFFlowMod flowMod = new OFFlowMod();
			flowMod.setMatch(flowStat.getMatch().clone());
			flowMod.setIdleTimeout(flowStat.getIdleTimeout());
			flowMod.setHardTimeout(flowStat.getHardTimeout());
			flowMod.setCookie(flowStat.getCookie());
			flowMod.setPriority(flowStat.getPriority());
			flowMod.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
			flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH);
			flowMod.setXid(sw.getNextTransactionId());

			List<OFMessage> msgs = new ArrayList<OFMessage>();
			msgs.add((OFMessage)flowMod);
			
			try {
				sw.write(msgs, null);
			} catch (IOException e) {
				log.error("Error attempting to send flow delete for flow that fits in NO flowspace");
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:27,代码来源:FlowStatCache.java

示例15: clearFlowMods

import org.openflow.protocol.OFFlowMod; //导入依赖的package包/类
/**
 * @param sw
 *            The switch we wish to remove flows from
 * @param outPort
 *            The specific Output Action OutPort of specific flows we wish
 *            to delete
 */
public void clearFlowMods(IOFSwitch sw, Short outPort) {
    // Delete all pre-existing flows with the same output action port or
    // outPort
    OFMatch match = new OFMatch().setWildcards(OFMatch.OFPFW_ALL);
    OFMessage fm = ((OFFlowMod) controllerProvider.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:opendaylight,项目名称:archived-net-virt-platform,代码行数:25,代码来源:PortDownReconciliation.java


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