本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFFlowStatsEntry类的典型用法代码示例。如果您正苦于以下问题:Java OFFlowStatsEntry类的具体用法?Java OFFlowStatsEntry怎么用?Java OFFlowStatsEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFFlowStatsEntry类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFFlowStatsEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFlowStat
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private Map<String, Object> buildFlowStat(final OFFlowStatsEntry entry) {
Map<String, Object> data = new HashMap<>();
data.put("version", entry.getVersion());
data.put("duration-nsec", entry.getDurationNsec());
data.put("duration-sec", entry.getDurationSec());
data.put("hard-timeout", entry.getHardTimeout());
data.put("idle-timeout", entry.getIdleTimeout());
data.put("priority", entry.getPriority());
data.put("byte-count", entry.getByteCount().getValue());
data.put("packer-count", entry.getPacketCount().getValue());
data.put("flags", entry.getFlags());
data.put("cookie", Long.toHexString(entry.getCookie().getValue()));
data.put("table-id", entry.getTableId().getValue());
data.put("match", buildFlowMatch(entry.getMatch()));
data.put("instructions", buildFlowInstructions(entry.getInstructions()));
return data;
}
示例2: getPairFlowInformation
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
public double[] getPairFlowInformation(Map<OFFlowStatsEntry, FlowEntry> table,
Map<OFFlowStatsEntry, Boolean> pairFlowSet) {
double[] vals = new double[4];
//total flow
vals[0] = table.size();
//pair flow
vals[1] = pairFlowSet.size();
//single flow
vals[2] = vals[0] - vals[1];
//pairflowratio flow
if (vals[1] == 0) {
vals[3] = 0;
} else {
vals[3] = vals[1] / vals[0];
}
return vals;
}
示例3: analyzeStatsReply
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
@SuppressWarnings("unused")
private void analyzeStatsReply(OFMessage reply) {
log.info("recieved stats reply (xid = {} type: {}) from sw {} ",
reply.getXid(), reply.getType(), getStringId());
if (reply.getType() == OFType.STATS_REPLY) {
OFStatsReply sr = (OFStatsReply) reply;
if (sr.getStatsType() == OFStatsType.FLOW) {
OFFlowStatsReply fsr = (OFFlowStatsReply) sr;
log.info("received flow stats sw {} --> {}", getStringId(), fsr);
// fsr.getEntries().get(0).getMatch().getMatchFields()
for (OFFlowStatsEntry e : fsr.getEntries()) {
for (MatchField<?> mf : e.getMatch().getMatchFields()) {
log.info("mf is exact: {} for {}: {}",
e.getMatch().isExact(mf),
mf.id,
e.getMatch().get(mf));
}
}
}
}
}
示例4: getStatisticsReply
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private OFStatsReply getStatisticsReply(int transactionId,
int count, boolean moreReplies, OFVersion version) {
OFFactory factory = OFFactories.getFactory(version);
List<OFFlowStatsEntry> statistics = new ArrayList<OFFlowStatsEntry>();
for (int i = 0; i < count; ++i) {
statistics.add(factory.buildFlowStatsEntry().build());
}
assertEquals(statistics.size(), count);
org.projectfloodlight.openflow.protocol.OFStatsReply.Builder
statsReplyBuilder = factory.buildFlowStatsReply()
.setXid(transactionId)
.setEntries(statistics);
if (moreReplies) {
statsReplyBuilder.setFlags(
Collections.singleton(OFStatsReplyFlags.REPLY_MORE));
}
return statsReplyBuilder.build();
}
示例5: getInstructions
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
switch (entry.getVersion()) {
case OF_10:
return Lists.newArrayList(
OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
case OF_11:
case OF_12:
case OF_13:
case OF_14:
case OF_15:
return entry.getInstructions();
default:
log.warn("Unknown OF version {}", entry.getVersion());
}
return Lists.newLinkedList();
}
示例6: getFlows
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
@Get("json")
@SuppressWarnings("unchecked")
public Map<String, Object> getFlows() {
Map<String, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get flows for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes()
.get(ISwitchManager.class.getCanonicalName());
try {
OFFlowStatsReply replay = switchManager.dumpFlowTable(DatapathId.of(switchId));
logger.debug("OF_STATS: {}", replay);
if (replay != null) {
for (OFFlowStatsEntry entry : replay.getEntries()) {
String key = String.format("flow-0x%s",
Long.toHexString(entry.getCookie().getValue()).toUpperCase());
response.put(key, buildFlowStat(entry));
}
}
} catch (IllegalArgumentException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(),
ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
}
return response;
}
示例7: publishFlowStats
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private synchronized Collection<OFFlowStatsEntry> publishFlowStats(Dpid dpid,
OFFlowStatsReply reply) {
//TODO: Get rid of synchronized
fullFlowStats.putAll(dpid, reply.getEntries());
if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
return fullFlowStats.removeAll(dpid);
}
return null;
}
示例8: FlowEntryBuilder
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
public FlowEntryBuilder(DeviceId deviceId, OFFlowStatsEntry entry, DriverService driverService) {
this.stat = entry;
this.match = entry.getMatch();
this.instructions = getInstructions(entry);
this.deviceId = deviceId;
this.removed = null;
this.flowMod = null;
this.type = FlowType.STAT;
this.driverService = driverService;
}
示例9: getInstructions
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
switch (entry.getVersion()) {
case OF_10:
return Lists.newArrayList(
OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
case OF_11:
case OF_12:
case OF_13:
return entry.getInstructions();
default:
log.warn("Unknown OF version {}", entry.getVersion());
}
return Lists.newLinkedList();
}
示例10: getApplicationInfoFromInternalFlowTable
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
public Map<OFFlowStatsEntry, FlowEntry> getApplicationInfoFromInternalFlowTable(
Dpid dpid,
List<OFFlowStatsEntry> statsEntries) {
//private DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid));
/**
*TODO optimize mechanism for comparing between incoming and internal one.
*/
Map<OFFlowStatsEntry, FlowEntry> flowEntiresWithFlowInformation = new HashMap<>();
Iterable<FlowEntry> internalFlowEntries = flowRuleService.getFlowEntries(deviceId);
for (int i = 0; i < statsEntries.size(); i++) {
OFFlowStatsEntry entry = statsEntries.get(i);
TrafficSelector inSelector =
featureCollectorProviderUtil.buildSelector(entry.getMatch());
for (FlowEntry flowEntry : internalFlowEntries) {
if (flowEntry.selector().equals(inSelector)) {
flowEntiresWithFlowInformation.put(entry, flowEntry);
break;
}
}
}
return flowEntiresWithFlowInformation;
}
示例11: FlowEntryBuilder
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry, Type tableType) {
this.stat = entry;
this.match = entry.getMatch();
this.instructions = getInstructions(entry);
this.dpid = dpid;
this.removed = null;
this.flowMod = null;
this.type = FlowType.STAT;
this.tableType = tableType;
}
示例12: deleteflowentry
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
private void deleteflowentry(DatapathId src,OFFlowStatsEntry entry){
OFFlowMod.Builder fmb = switchService.getSwitch(src).getOFFactory().buildFlowDelete();
fmb.setMatch(entry.getMatch())
.setActions(entry.getActions())
.setIdleTimeout(entry.getIdleTimeout())
.setHardTimeout(entry.getHardTimeout());
switchService.getSwitch(src).write(fmb.build());
}
示例13: sumflows
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
/**
* ͳ�Ʒ�������������ɾ��ԭʼ���������ɾ������Ϊ֮����·����ȼ����ߵ������
* @param sw
* @param values
* @return
*/
protected long sumflows(DatapathId sw, List<OFFlowStatsReply> values){
long sum=0;
OFFlowStatsReply value=values.get(0);
List<OFFlowStatsEntry> entries = value.getEntries();
for(OFFlowStatsEntry entry: entries){
long bc = entry.getByteCount().getValue();
sum += bc;
deleteflowentry(sw,entry);
}
return sum;
}
示例14: deleteflowentry
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
/**
* ɾ��ԭʼ������
* @param src
* @param entry
*/
private void deleteflowentry(DatapathId src,OFFlowStatsEntry entry){
OFFlowMod.Builder fmb = switchService.getSwitch(src).getOFFactory().buildFlowDelete();
fmb.setMatch(entry.getMatch())
//.setActions(entry.getActions())
.setActions(((OFInstructionApplyActions)entry.getInstructions().get(0)).getActions())
.setIdleTimeout(entry.getIdleTimeout())
.setHardTimeout(entry.getHardTimeout());
switchService.getSwitch(src).write(fmb.build());
}
示例15: getActions
import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; //导入依赖的package包/类
public static List<OFAction> getActions(OFFlowStatsEntry e) {
if(e.getVersion() == OFVersion.OF_10) {
return e.getActions();
} else {
for(OFInstruction i: e.getInstructions()) {
if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
return ((OFInstructionApplyActions) i).getActions();
}
}
return ImmutableList.of();
}
}