本文整理汇总了Java中org.openflow.protocol.statistics.OFStatisticsType类的典型用法代码示例。如果您正苦于以下问题:Java OFStatisticsType类的具体用法?Java OFStatisticsType怎么用?Java OFStatisticsType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFStatisticsType类属于org.openflow.protocol.statistics包,在下文中一共展示了OFStatisticsType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOFFlowStatisticsRequest
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
public void testOFFlowStatisticsRequest() throws Exception {
byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00,
0x16, 0x00, 0x01, 0x00, 0x00, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff };
OFMessageFactory factory = BasicFactory.getInstance();
ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
List<OFMessage> msg = factory.parseMessage(packetBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
TestCase.assertEquals(1, sr.getStatistics().size());
TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFFlowStatisticsRequest);
}
示例2: testOFStatisticsRequestVendor
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
public void testOFStatisticsRequestVendor() throws Exception {
byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
0x63, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20,
(byte) 0xe0, 0x00, 0x11, 0x00, 0x0c, 0x29, (byte) 0xc5,
(byte) 0x95, 0x57, 0x02, 0x25, 0x5c, (byte) 0xca, 0x00, 0x02,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x50, 0x04,
0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x00, 0x00, 0x00,
(byte) 0xff, (byte) 0xff, 0x4e, 0x20 };
OFMessageFactory factory = BasicFactory.getInstance();
ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
List<OFMessage> msg = factory.parseMessage(packetBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
TestCase.assertEquals(OFStatisticsType.VENDOR, sr.getStatisticType());
TestCase.assertEquals(1, sr.getStatistics().size());
TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFVendorStatistics);
TestCase.assertEquals(68, ((OFVendorStatistics)sr.getStatistics().get(0)).getLength());
}
示例3: sendFeatureReplyConfiguration
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的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:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:26,代码来源:Controller.java
示例4: testOFFlowStatisticsRequest
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
public void testOFFlowStatisticsRequest() throws Exception {
byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00,
0x16, 0x00, 0x01, 0x00, 0x00, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
(byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff };
OFMessageFactory factory = new BasicFactory();
ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
List<OFMessage> msg = factory.parseMessage(packetBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
TestCase.assertEquals(1, sr.getStatistics().size());
TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFFlowStatisticsRequest);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:21,代码来源:OFStatisticsRequestTest.java
示例5: testOFStatisticsRequestVendor
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
public void testOFStatisticsRequestVendor() throws Exception {
byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
0x63, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20,
(byte) 0xe0, 0x00, 0x11, 0x00, 0x0c, 0x29, (byte) 0xc5,
(byte) 0x95, 0x57, 0x02, 0x25, 0x5c, (byte) 0xca, 0x00, 0x02,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x50, 0x04,
0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x00, 0x00, 0x00,
(byte) 0xff, (byte) 0xff, 0x4e, 0x20 };
OFMessageFactory factory = new BasicFactory();
ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
List<OFMessage> msg = factory.parseMessage(packetBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
TestCase.assertEquals(OFStatisticsType.VENDOR, sr.getStatisticType());
TestCase.assertEquals(1, sr.getStatistics().size());
TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFVendorStatistics);
TestCase.assertEquals(68, ((OFVendorStatistics)sr.getStatistics().get(0)).getLength());
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:25,代码来源:OFStatisticsRequestTest.java
示例6: sendFlowStatistics
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
private void sendFlowStatistics(int tid, short port) {
OVXStatisticsRequest req = new OVXStatisticsRequest();
// TODO: stuff like below should be wrapped into an XIDUtil class
int xid = (tid << 16) | port;
req.setXid(xid);
req.setStatisticType(OFStatisticsType.FLOW);
OVXFlowStatisticsRequest freq = new OVXFlowStatisticsRequest();
OVXMatch match = new OVXMatch();
match.setWildcards(Wildcards.FULL);
freq.setMatch(match);
freq.setOutPort(OFPort.OFPP_NONE.getValue());
freq.setTableId((byte) 0xFF);
req.setStatistics(Collections.singletonList(freq));
req.setLengthU(req.getLengthU() + freq.getLength());
sendMsg(req, this);
}
示例7: getStatistics
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
// big hack; need to fix
@Override
public OFStatistics getStatistics(final OFType t, final OFStatisticsType st) {
Class<? extends OFStatistics> c;
if (t == OFType.STATS_REPLY) {
if (st.getTypeValue() == -1) {
c = OVXVendorStatistics.class;
} else {
c = OVXMessageFactory.CONVERT_STATS_REPLY_MAP[st.getTypeValue()];
}
} else if (t == OFType.STATS_REQUEST) {
if (st.getTypeValue() == -1) {
c = OVXVendorStatistics.class;
} else {
c = OVXMessageFactory.CONVERT_STATS_REQUEST_MAP[st.getTypeValue()];
}
} else {
throw new RuntimeException("non-stats type in stats factory: " + t);
}
try {
return c.getConstructor(new Class[] {}).newInstance();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例8: devirtualizeStatistic
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
@Override
public void devirtualizeStatistic(final OVXSwitch sw,
final OVXStatisticsRequest msg) {
this.activeCount = sw.getFlowTable().getFlowTable().size();
this.tableId = 1;
/*
* FIXME Currently preventing controllers from wildcarding the IP field.
* That is if they actually look at this field.
*/
this.wildcards = OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_NW_DST_ALL
& ~OFMatch.OFPFW_NW_DST_ALL;
this.name = "OVX vFlowTable (incomplete)";
this.maximumEntries = 100000;
OVXStatisticsReply reply = new OVXStatisticsReply();
reply.setXid(msg.getXid());
reply.setStatisticType(OFStatisticsType.TABLE);
reply.setStatistics(Collections.singletonList(this));
reply.setLengthU(OVXStatisticsReply.MINIMUM_LENGTH + this.getLength());
sw.sendMsg(reply, sw);
}
示例9: devirtualizeStatistic
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
/**
* Creates a reply object populated with the virtual switch params and
* sends it back to the controller.
* This is in response to receiving a Description stats request from the controller.
*
* @param sw the virtual switch
* @param msg the statistics request message
*/
@Override
public void devirtualizeStatistic(final OVXSwitch sw,
final OVXStatisticsRequest msg) {
final OVXStatisticsReply reply = new OVXStatisticsReply();
final OVXDescriptionStatistics desc = new OVXDescriptionStatistics();
desc.setDatapathDescription(OVXSwitch.DPDESCSTRING);
desc.setHardwareDescription("virtual hardware");
desc.setManufacturerDescription("Open Networking Lab");
desc.setSerialNumber(sw.getSwitchName());
desc.setSoftwareDescription(OpenVirteX.VERSION);
reply.setXid(msg.getXid());
reply.setLengthU(reply.getLength() + desc.getLength());
reply.setStatisticType(OFStatisticsType.DESC);
reply.setStatistics(Collections.singletonList(desc));
sw.sendMsg(reply, sw);
}
示例10: handleDescrStatsRequest
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
private void handleDescrStatsRequest(OFMessage msg){
OFDescriptionStatistics descrStats = mySwitch.getDescriptionStatistics();
OFStatisticsReply reply = new OFStatisticsReply();
reply.setStatisticType(OFStatisticsType.DESC);
List<OFStatistics> stats = new ArrayList<OFStatistics>();
descrStats.setHardwareDescription("FSFW: " + descrStats.getHardwareDescription());
descrStats.setManufacturerDescription("FSFW: " + descrStats.getManufacturerDescription());
descrStats.setSoftwareDescription("FSFW: " + descrStats.getSoftwareDescription());
stats.add(descrStats);
reply.setStatistics(stats);
reply.setXid(msg.getXid());
reply.setFlags((short)0x0000);
reply.setLengthU(descrStats.getLength() + reply.getLength());
try {
ofcch.sendMessage(reply);
} catch (IOException e1) {
e1.printStackTrace();
}
return;
}
示例11: readFrom
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
this.statisticType = OFStatisticsType.valueOf(data.readShort(), this
.getType());
this.flags = data.readShort();
if (this.statisticsFactory == null)
throw new RuntimeException("OFStatisticsFactory not set");
this.statistics = statisticsFactory.parseStatistics(this.getType(),
this.statisticType, data, super.getLengthU() - MINIMUM_LENGTH);
}
示例12: getFlows
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的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;
}
示例13: retrieve
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
@Get("json")
public Map<String, Object> retrieve() {
HashMap<String,Object> result = new HashMap<String,Object>();
Object values = null;
String switchId = (String) getRequestAttributes().get("switchId");
String statType = (String) getRequestAttributes().get("statType");
if (statType.equals("port")) {
values = getSwitchStatistics(switchId, OFStatisticsType.PORT);
} else if (statType.equals("queue")) {
values = getSwitchStatistics(switchId, OFStatisticsType.QUEUE);
} else if (statType.equals("flow")) {
values = getSwitchStatistics(switchId, OFStatisticsType.FLOW);
} else if (statType.equals("aggregate")) {
values = getSwitchStatistics(switchId, OFStatisticsType.AGGREGATE);
} else if (statType.equals("desc")) {
values = getSwitchStatistics(switchId, OFStatisticsType.DESC);
} else if (statType.equals("table")) {
values = getSwitchStatistics(switchId, OFStatisticsType.TABLE);
} else if (statType.equals("features")) {
values = getSwitchFeaturesReply(switchId);
}
result.put(switchId, values);
return result;
}
示例14: GetConcurrentStatsThread
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
public GetConcurrentStatsThread(long switchId, REQUESTTYPE requestType, OFStatisticsType statType) {
this.switchId = switchId;
this.requestType = requestType;
this.statType = statType;
this.switchReply = null;
this.featuresReply = null;
}
示例15: checkForTableStats
import org.openflow.protocol.statistics.OFStatisticsType; //导入依赖的package包/类
@LogMessageDocs({
@LogMessageDoc(level="INFO",
message="Switch {switch} flow table is full",
explanation="The switch flow table at least 98% full, " +
"this requires attention if using reactive flow setup"),
@LogMessageDoc(level="INFO",
message="Switch {switch} flow table capacity back to normal",
explanation="The switch flow table is less than 90% full")
})
private void checkForTableStats(OFStatisticsReply statReply) {
if (statReply.getStatisticType() != OFStatisticsType.TABLE) {
return;
}
List<? extends OFStatistics> stats = statReply.getStatistics();
// Assume a single table only
OFStatistics stat = stats.get(0);
if (stat instanceof OFTableStatistics) {
OFTableStatistics tableStat = (OFTableStatistics) stat;
int activeCount = tableStat.getActiveCount();
int maxEntry = tableStat.getMaximumEntries();
log.debug("Switch {} active entries {} max entries {}",
new Object[] { this.stringId, activeCount, maxEntry});
int percentFull = activeCount * 100 / maxEntry;
if (flowTableFull && percentFull < 90) {
log.info("Switch {} flow table capacity is back to normal",
toString());
floodlightProvider.addSwitchEvent(this.datapathId,
"SWITCH_FLOW_TABLE_NORMAL < 90% full", false);
} else if (percentFull >= 98) {
log.info("Switch {} flow table is almost full", toString());
floodlightProvider.addSwitchEvent(this.datapathId,
"SWITCH_FLOW_TABLE_ALMOST_FULL >= 98% full", false);
}
}
}