本文整理汇总了Java中net.floodlightcontroller.counter.ICounter类的典型用法代码示例。如果您正苦于以下问题:Java ICounter类的具体用法?Java ICounter怎么用?Java ICounter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ICounter类属于net.floodlightcontroller.counter包,在下文中一共展示了ICounter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieve
import net.floodlightcontroller.counter.ICounter; //导入依赖的package包/类
@Get("json")
public Map<String, Object> retrieve(){
Map<String, Object> model = new HashMap<String,Object>();
CounterValue v;
Map<String, ICounter> counters = this.counterStore.getAll();
if (counters != null) {
Iterator<Map.Entry<String, ICounter>> it =
counters.entrySet().iterator();
while (it.hasNext()) {
Entry<String, ICounter> entry = it.next();
String counterName = entry.getKey();
v = entry.getValue().getCounterValue();
if (CounterValue.CounterType.LONG == v.getType()) {
model.put(counterName, v.getLong());
} else if (v.getType() == CounterValue.CounterType.DOUBLE) {
model.put(counterName, v.getDouble());
}
}
}
return model;
}
示例2: updateCounters
import net.floodlightcontroller.counter.ICounter; //导入依赖的package包/类
protected void updateCounters(String baseName, String tableName) {
if (counterStore != null) {
String counterName;
if (tableName != null) {
updateCounters(baseName, null);
counterName = baseName + CounterStore.TitleDelimitor + tableName;
} else {
counterName = baseName;
}
ICounter counter = counterStore.getCounter(counterName);
if (counter == null) {
counter = counterStore.createCounter(counterName, CounterType.LONG);
}
counter.increment();
}
}
示例3: getOneSwitchCounterJson
import net.floodlightcontroller.counter.ICounter; //导入依赖的package包/类
protected void getOneSwitchCounterJson(Map<String, Object> model,
String switchID, String counterName) {
String fullCounterName = "";
try {
counterName = URLDecoder.decode(counterName, "UTF-8");
fullCounterName =
switchID + ICounterStoreService.TitleDelimitor + counterName;
} catch (UnsupportedEncodingException e) {
//Just leave counterTitle undecoded if there is an issue - fail silently
}
ICounter counter = this.counterStore.getCounter(fullCounterName);
Map<String, Long> sample = new HashMap<String, Long> ();
if (counter != null) {
sample.put(counter.getCounterDate().toString(),
counter.getCounterValue().getLong());
model.put(switchID, sample);
}
}
示例4: getOneSwitchCounterJson
import net.floodlightcontroller.counter.ICounter; //导入依赖的package包/类
protected void getOneSwitchCounterJson(Map<String, Object> model,
String switchID, String counterName) {
String fullCounterName = "";
try {
counterName = URLDecoder.decode(counterName, "UTF-8");
fullCounterName =
switchID + ICounterStoreService.TitleDelimitor + counterName;
} catch (UnsupportedEncodingException e) {
//Just leave counterTitle undecoded if there is an issue - fail silently
}
ICounter counter = this.counterStore.getCounter(fullCounterName);
Map<String, Long> sample = new HashMap<String, Long> ();
if (counter != null) {
sample.put(counter.getCounterDate().toString(),
counter.getCounterValue().getLong());
model.put(switchID, sample);
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:21,代码来源:SwitchCounterResource.java
示例5: getPktInRate
import net.floodlightcontroller.counter.ICounter; //导入依赖的package包/类
protected int getPktInRate(ICounter newCnt, Date currentTime) {
if (newCnt == null ||
newCnt.getCounterDate() == null ||
newCnt.getCounterValue() == null) {
return 0;
}
// Somehow the system time is messed up. return max packetIn rate
// to reduce the system load.
if (newCnt.getCounterDate().before(
lastPacketInCounter.getCounterDate())) {
logger.debug("Time is going backward. new {}, old {}",
newCnt.getCounterDate(),
lastPacketInCounter.getCounterDate());
return MAX_SYSTEM_LOAD_PER_SECOND;
}
long elapsedTimeInSecond = (currentTime.getTime() -
lastPacketInCounter.getCounterDate().getTime()) / 1000;
if (elapsedTimeInSecond == 0) {
// This should never happen. Check to avoid division by zero.
return 0;
}
long diff = 0;
switch (newCnt.getCounterValue().getType()) {
case LONG:
long newLong = newCnt.getCounterValue().getLong();
long oldLong = lastPacketInCounter.getCounterValue().getLong();
if (newLong < oldLong) {
// Roll over event
diff = Long.MAX_VALUE - oldLong + newLong;
} else {
diff = newLong - oldLong;
}
break;
case DOUBLE:
double newDouble = newCnt.getCounterValue().getDouble();
double oldDouble = lastPacketInCounter.getCounterValue().getDouble();
if (newDouble < oldDouble) {
// Roll over event
diff = (long)(Double.MAX_VALUE - oldDouble + newDouble);
} else {
diff = (long)(newDouble - oldDouble);
}
break;
}
return (int)(diff/elapsedTimeInSecond);
}