本文整理汇总了Java中org.openflow.protocol.statistics.OFFlowStatisticsReply类的典型用法代码示例。如果您正苦于以下问题:Java OFFlowStatisticsReply类的具体用法?Java OFFlowStatisticsReply怎么用?Java OFFlowStatisticsReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFFlowStatisticsReply类属于org.openflow.protocol.statistics包,在下文中一共展示了OFFlowStatisticsReply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFlowStatFromFlowMod
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的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;
}
示例2: deleteFlow
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的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();
}
}
}
}
示例3: clone
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
public static FSFWOFFlowStatisticsReply clone(OFFlowStatisticsReply stat) throws CloneNotSupportedException{
FSFWOFFlowStatisticsReply newStat = new FSFWOFFlowStatisticsReply();
newStat.setByteCount(stat.getByteCount());
newStat.setPacketCount(stat.getPacketCount());
newStat.setCookie(stat.getCookie());
//need to copy the action list
List<OFAction> acts = new ArrayList<OFAction>();
for(OFAction act : stat.getActions()){
acts.add(act.clone());
}
newStat.setActions(acts);
newStat.setMatch(stat.getMatch().clone());
newStat.setDurationNanoseconds(stat.getDurationNanoseconds());
newStat.setDurationSeconds(stat.getDurationSeconds());
newStat.setHardTimeout(stat.getHardTimeout());
newStat.setIdleTimeout(stat.getIdleTimeout());
newStat.setPriority(stat.getPriority());
newStat.setTableId(stat.getTableId());
newStat.setLength((short)stat.getLength());
return newStat;
}
示例4: updateExpire
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
public void updateExpire(List<FlowTimeout> timeouts, Long switchId){
for(FlowTimeout timeout : timeouts){
if(!timeout.isHard()){
for(OFStatistics stat : statsCache.getSwitchFlowStats(switchId)){
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) stat;
if(flowStat.getMatch().equals(timeout.getFlow().getMatch())){
if(timeout.getPacketCount() == flowStat.getPacketCount()){
//hasn't changed... so it has been idle
}else{
timeout.setPacketCount(flowStat.getPacketCount());
timeout.updateLastUsed();
}
}
}
}
}
}
示例5: getFlows
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的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;
}
示例6: getStatisticsReply
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
private OFStatisticsReply getStatisticsReply(int transactionId,
int count, boolean moreReplies) {
OFStatisticsReply sr = new OFStatisticsReply();
sr.setXid(transactionId);
sr.setStatisticType(OFStatisticsType.FLOW);
List<OFStatistics> statistics = new ArrayList<OFStatistics>();
for (int i = 0; i < count; ++i) {
statistics.add(new OFFlowStatisticsReply());
}
sr.setStatistics(statistics);
if (moreReplies)
sr.setFlags((short) 1);
return sr;
}
示例7: getStatisticsReply
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
protected OFStatisticsReply getStatisticsReply(int transactionId,
int count, boolean moreReplies) {
OFStatisticsReply sr = new OFStatisticsReply();
sr.setXid(transactionId);
sr.setStatisticType(OFStatisticsType.FLOW);
List<OFStatistics> statistics = new ArrayList<OFStatistics>();
for (int i = 0; i < count; ++i) {
statistics.add(new OFFlowStatisticsReply());
}
sr.setStatistics(statistics);
if (moreReplies)
sr.setFlags((short) 1);
return sr;
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:15,代码来源:ControllerTest.java
示例8: getFlows
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的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;
}
示例9: testStatsFlow
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
@Test
public void testStatsFlow() {
String message = "[\"flow_stats_reply\", 3, [{\"packet_count\": 1, \"hard_timeout\": 0, \"byte_count\": 4, \"idle_timeout\": 5, \"actions\": \"[{'output': 65533}]\", " +
"\"duration_nsec\": 27000000, \"priority\": 6, \"duration_sec\": 0, \"table_id\": 25, \"cookie\": 2, \"match\": \"{}\"}]]";
MessageParser mp = new MessageParser();
OFStatisticsReply reply = mp.parseStatsReply(OFStatisticsType.FLOW, message);
//TESTS
assertEquals("Statistics type not set correctly", OFStatisticsType.FLOW, reply.getStatisticType());
OFStatistics stat = reply.getStatistics().get(0);
assertTrue("Returned stat is not a FlowStat class", (stat instanceof OFFlowStatisticsReply));
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) stat;
//TEST FLOWS STATS REPY
assertEquals("'byte_count' not set correctly", 4, flowStat.getByteCount());
assertEquals("'cookie' not set correctly", 2, flowStat.getCookie());
assertEquals("'duration_nsec' not set correctly", 27000000, flowStat.getDurationNanoseconds());
assertEquals("'idle_timeout' not set correctly", 5, flowStat.getIdleTimeout());
assertEquals("'packet_count' not set correctly", 1, flowStat.getPacketCount());
assertEquals("'table_id' not set correctly", (byte)25, flowStat.getTableId());
assertEquals("'priority' not set correctly", 6, flowStat.getPriority());
OFAction action = flowStat.getActions().get(0);
assertEquals("Output type not set properly not set correctly", OFActionType.OUTPUT, action.getType());
assertTrue("Output class type not set properly", (action instanceof OFActionOutput));
OFActionOutput actionOut = (OFActionOutput)action;
//PORT IS A SHORT, SO MUST BE CONVERTED FROM INT
assertEquals("Port not set properly in ActionOut", 65533, (0x0FFFF&(actionOut.getPort())));
}
示例10: removeFlows
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
public void removeFlows(){
List<OFStatistics> results = this.parent.getSlicedFlowStats(mySwitch.getId(), this.mySlicer.getSliceName());
if(results == null){
log.debug("Slicing failed!");
return;
}
List<OFMessage> deletes = new ArrayList<OFMessage>();
for(OFStatistics stat : results){
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) stat;
OFFlowMod flow = new OFFlowMod();
flow.setMatch(flowStat.getMatch());
flow.setActions(flowStat.getActions());
int length = 0;
for(OFAction act: flow.getActions()){
length += act.getLength();
}
flow.setLengthU(OFFlowMod.MINIMUM_LENGTH + length);
flow.setCommand(OFFlowMod.OFPFC_DELETE);
deletes.add(flow);
this.flowCount = this.flowCount - 1;
}
try {
this.mySwitch.write(deletes, null);
} catch (IOException e) {
e.printStackTrace();
}
}
示例11: updateFlowStatData
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
/**
* just updates the data in the flowstat
* @param cachedStat
* @param newStat
*/
private boolean updateFlowStatData(OFStatistics cachedStat, OFFlowStatisticsReply newStat, HashMap<String, Integer> flowCount){
FSFWOFFlowStatisticsReply cachedFlowStat = (FSFWOFFlowStatisticsReply) cachedStat;
if(cachedFlowStat.toBeDeleted()){
//its going to be deleted don't update
return false;
}
//update the data
cachedFlowStat.setByteCount(cachedFlowStat.getByteCount() + newStat.getByteCount());
cachedFlowStat.setPacketCount(cachedFlowStat.getPacketCount() + newStat.getPacketCount());
cachedFlowStat.setDurationNanoseconds(newStat.getDurationNanoseconds());
cachedFlowStat.setDurationSeconds(newStat.getDurationSeconds());
cachedFlowStat.setLastSeen(System.currentTimeMillis());
cachedFlowStat.setVerified(true);
String sliceName = ((FSFWOFFlowStatisticsReply) cachedStat).getSliceName();
if(cachedFlowStat.hasParent()){
if(flowCount.containsKey(sliceName)){
flowCount.put(sliceName, (flowCount.get(sliceName) + 1));
}else{
flowCount.put(sliceName,1);
}
//update the parent cache
FSFWOFFlowStatisticsReply parentStat = cachedFlowStat.getParentStat();
updateFlowStatData(parentStat,newStat,flowCount);
}
return true;
}
示例12: buildFlowMod
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
/**
* buildFlowMod - builds a FlowMod based on a flowStat
* @param flowStat
* @return OFFlowMod
*/
private OFFlowMod buildFlowMod(OFFlowStatisticsReply flowStat){
OFFlowMod flowMod = new OFFlowMod();
flowMod.setMatch(flowStat.getMatch().clone());
flowMod.setActions(flowStat.getActions());
flowMod.setPriority(flowStat.getPriority());
flowMod.setCookie(flowStat.getCookie());
flowMod.setIdleTimeout(flowStat.getIdleTimeout());
flowMod.setHardTimeout(flowStat.getHardTimeout());
return flowMod;
}
示例13: testExpandedFlowStats
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
@Test
public void testExpandedFlowStats(){
cache = new FlowStatCache(fsfw);
OFFlowMod mod = new OFFlowMod();
OFMatch match = new OFMatch();
match.setDataLayerVirtualLan((short)300);
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_VLAN));
mod.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setPort((short)65533);
actions.add(output);
mod.setActions(actions);
List<OFFlowMod> mods = slicerExpanded.allowedFlows(mod);
cache.addFlowMod(sw.getId(), slicerExpanded.getSliceName(), mod, mods);
log.error("Sending: " + expandedStats.size() + " flow stats!");
cache.setFlowCache(sw.getId(), expandedStats);
List<OFStatistics> slicedStats = cache.getSlicedFlowStats(sw.getId(), slicerExpanded.getSliceName());
assertNotNull("Sliced Stats with no allowed stats returend ok", slicedStats);
assertEquals("Sliced stats", 6, slicedStats.size());
log.error(slicedStats.get(0).toString());
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) slicedStats.get(0);
assertEquals("flowStat byte count is correct", 4L,flowStat.getByteCount());
assertEquals("flowStat packet count is correct", 4L,flowStat.getPacketCount());
}
示例14: testExpandedFlowStatsManaged
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
@Test
public void testExpandedFlowStatsManaged(){
cache = new FlowStatCache(fsfw);
OFFlowMod mod = new OFFlowMod();
OFMatch match = new OFMatch();
match.setWildcards(match.getWildcardObj().matchOn(Flag.DL_DST));
match.setDataLayerDestination("78:2B:CB:48:FF:73");
mod.setMatch(match);
List<OFAction> actions = new ArrayList<OFAction>();
OFActionOutput output = new OFActionOutput();
output.setPort((short)1);
actions.add(output);
mod.setActions(actions);
mod.setLength((short)(OFFlowMod.MINIMUM_LENGTH + output.getLength()));
List<OFFlowMod> mods = managedExpandedSlicer.managedFlows(mod);
assertEquals("Proper number of total flow mods", 4,mods.size());
cache.addFlowMod(sw.getId(), managedExpandedSlicer.getSliceName(), mod, mods);
cache.setFlowCache(sw.getId(), expandedManagedStats);
List<OFStatistics> slicedStats = cache.getSlicedFlowStats(sw.getId(), managedExpandedSlicer.getSliceName());
assertNotNull("Sliced Stats with no allowed stats returend ok", slicedStats);
for(OFStatistics stat : slicedStats){
log.error(stat.toString());
}
assertEquals("Sliced stats", 6, slicedStats.size());
log.error(slicedStats.get(0).toString());
OFFlowStatisticsReply flowStat = (OFFlowStatisticsReply) slicedStats.get(0);
assertEquals("flowStat byte count is correct", 4L,flowStat.getByteCount());
assertEquals("flowStat packet count is correct", 4L,flowStat.getPacketCount());
}
示例15: readFlow
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入依赖的package包/类
@Override
public FlowOnNode readFlow(String container, Node node, Flow flow, boolean cached) {
if (controller == null) {
// Avoid to provide cached statistics if controller went down.
// They are not valid anymore anyway
logger.error("Internal plugin error");
return null;
}
long sid = (Long) node.getID();
OFMatch ofMatch = new FlowConverter(flow).getOFMatch();
List<OFStatistics> ofList;
if (cached == true){
ofList = statsMgr.getOFFlowStatistics(sid, ofMatch, flow.getPriority());
} else {
ofList = statsMgr.queryStatistics(sid, OFStatisticsType.FLOW, ofMatch);
for (OFStatistics ofStat : ofList) {
if (((OFFlowStatisticsReply)ofStat).getPriority() == flow.getPriority()){
ofList = new ArrayList<OFStatistics>(1);
ofList.add(ofStat);
break;
}
}
}
// Convert and filter the statistics per container
List<FlowOnNode> flowOnNodeList = new FlowStatisticsConverter(ofList).getFlowOnNodeList(node);
List<FlowOnNode> filteredList = filterFlowListPerContainer(container, node, flowOnNodeList);
return (filteredList == null || filteredList.isEmpty()) ? null : filteredList.get(0);
}