本文整理汇总了Java中org.openflow.protocol.statistics.OFFlowStatisticsReply.setMatch方法的典型用法代码示例。如果您正苦于以下问题:Java OFFlowStatisticsReply.setMatch方法的具体用法?Java OFFlowStatisticsReply.setMatch怎么用?Java OFFlowStatisticsReply.setMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.statistics.OFFlowStatisticsReply
的用法示例。
在下文中一共展示了OFFlowStatisticsReply.setMatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flowReplyBuilder
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入方法依赖的package包/类
/**
* FlowStatisticsReply Builder for incoming OFFlowStatisticsRequest
*
* @param flowReq incoming OFFlowStatisticsRequest
* @return List of OFFlowStatisticsReplies
*/
private List<OFFlowStatisticsReply> flowReplyBuilder(OFFlowStatisticsRequest flowReq) {
List<OFFlowStatisticsReply> flowReplyList = new ArrayList<OFFlowStatisticsReply>();
short port = flowReq.getOutPort();
Map<OFMatch, OFFlowTableEntry> matchedFlows = this.flow_table.getMatchingFlows(flowReq.getMatch(), false);
if (!matchedFlows.isEmpty()) {
Iterator<Map.Entry<OFMatch, OFFlowTableEntry>> matchIter = matchedFlows.entrySet().iterator();
while (matchIter.hasNext()) {
Map.Entry<OFMatch, OFFlowTableEntry> entry = matchIter.next();
OFFlowTableEntry tableEntry = entry.getValue();
OFFlowStatisticsReply flowReply = new OFFlowStatisticsReply();
flowReply.setActions(tableEntry.getActions());
flowReply.setCookie(tableEntry.getCookie());
flowReply.setDurationNanoseconds(tableEntry.getNanoDuration());
flowReply.setDurationSeconds(tableEntry.getSecondDuration());
flowReply.setHardTimeout(tableEntry.getHardTimeOut());
flowReply.setIdleTimeout(tableEntry.getIdleTimeOut());
flowReply.setMatch(entry.getKey());
flowReply.setPriority(tableEntry.getPriority());
if (this.randomizeFlag) {
long newByteCount = randomLong();
flowReply.setByteCount(newByteCount);
flowReply.setPacketCount(newByteCount / 1024);
} else {
flowReply.setByteCount(tableEntry.getByteCounter());
flowReply.setPacketCount(tableEntry.getPacketCounter());
}
flowReply.setTableId((byte) 42);
if (port != OFPort.OFPP_NONE.getValue()) {
if (entry.getValue().actionsContainOutport(port)) {
flowReplyList.add(flowReply);
}
} else {
flowReplyList.add(flowReply);
}
}
}
return flowReplyList;
}
示例2: parseStatsReply
import org.openflow.protocol.statistics.OFFlowStatisticsReply; //导入方法依赖的package包/类
/**
* Parses message into relevant properties
* @param statsType the specific Stats Type (0:DESC, 1:FLOW, 2:AGGREGATE, 3:TABLE, 4:PORT, 5:QUEUE, 6:VENDOR)
* @param rawMessage Assumes the following format and parses into properties:
* "["flow_stats_reply", 3, [{"packet_count": 0, "hard_timeout": 0, "byte_count": 0, "idle_timeout": 0, "actions": "[{'output': 65533}]",
* "duration_nsec": 27000000, "priority": 0, "duration_sec": 0, "table_id": 0, "cookie": 0, "match": "{}"}]]"
*/
public OFStatisticsReply parseStatsReply(OFStatisticsType statsType, String rawMessage) {
//EXTRACT THE JSON
String tmp = rawMessage.substring(rawMessage.indexOf(",")+2, rawMessage.length()-2);
String switchStr = tmp.substring(0, 1);
this.switchId = Long.parseLong(switchStr);
String jsonStr = tmp.substring(tmp.indexOf(",")+3);
JSONObject json = new JSONObject(jsonStr);
//ADD PROPS TO STATS_REPLY OBJECT
OFStatisticsReply statsReply = new OFStatisticsReply();
//statsReply.setFlags(Short.parseShort(flagStr));
statsReply.setStatisticType(statsType);
statsReply.setStatisticsFactory(new BasicFactory());
List<OFStatistics> statistics = new ArrayList<OFStatistics>();
switch (statsType) {
case DESC:
OFDescriptionStatistics description = new OFDescriptionStatistics();
description.setDatapathDescription("A");
description.setHardwareDescription("B");
description.setManufacturerDescription("C");
description.setSerialNumber("D");
description.setSoftwareDescription("E");
statistics.add(description);
break;
case FLOW:
OFFlowStatisticsReply flowStats = new OFFlowStatisticsReply();
flowStats.setByteCount(json.getLong("byte_count"));
flowStats.setActionFactory(new BasicFactory());
//FORMATTING SEEMS OFF (why is it in " "), NEED TO CONVERT STRING TO JSON ARRAY
String tmpArrayStr = json.getString("actions");
JSONArray jsonArray = new JSONArray(tmpArrayStr);
flowStats.setActions(parseActionsArray(jsonArray));
//
flowStats.setCookie(json.getLong("cookie"));
flowStats.setDurationNanoseconds(json.getInt("duration_nsec"));
flowStats.setDurationSeconds(json.getInt("duration_sec"));
flowStats.setHardTimeout((short)json.getInt("hard_timeout"));
flowStats.setIdleTimeout((short)json.getInt("idle_timeout"));
flowStats.setPacketCount(json.getLong("packet_count"));
flowStats.setPriority((short)json.getInt("priority"));
flowStats.setTableId((byte)json.getInt("table_id"));
OFMatch match = new OFMatch();
flowStats.setMatch(match);
statistics.add(flowStats);
break;
case TABLE:
OFTableStatistics tables = new OFTableStatistics();
tables.setTableId(Byte.parseByte(json.getString("table_id")));
//tables.setActiveCount();
//tables.setLookupCount(lookupCount);
//tables.setMatchedCount(matchedCount);
//tables.setMaximumEntries(maximumEntries);
//tables.setWildcards(wildcards);
statistics.add(tables);
break;
case PORT:
OFPortStatisticsReply portStatReply = new OFPortStatisticsReply();
portStatReply.setreceivePackets(json.getLong("packet_count"));
portStatReply.setPortNumber(Short.parseShort(json.getString("port")));
portStatReply.setReceiveBytes(json.getLong("received_bytes"));
statistics.add(portStatReply);
break;
case AGGREGATE:
case VENDOR:
case QUEUE:
}
statsReply.setStatistics(statistics);
return statsReply;
}