本文整理汇总了Java中org.onosproject.net.flow.TableStatisticsEntry类的典型用法代码示例。如果您正苦于以下问题:Java TableStatisticsEntry类的具体用法?Java TableStatisticsEntry怎么用?Java TableStatisticsEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableStatisticsEntry类属于org.onosproject.net.flow包,在下文中一共展示了TableStatisticsEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
/**
* Gets table statistics for all tables of all devices.
*
* @onos.rsModel StatisticsFlowsTables
* @return 200 OK with JSON encoded array of table statistics
*/
@GET
@Path("flows/tables")
@Produces(MediaType.APPLICATION_JSON)
public Response getTableStatistics() {
final FlowRuleService service = get(FlowRuleService.class);
final Iterable<Device> devices = get(DeviceService.class).getDevices();
final ObjectNode root = mapper().createObjectNode();
final ArrayNode rootArrayNode = root.putArray("statistics");
for (final Device device : devices) {
final ObjectNode deviceStatsNode = mapper().createObjectNode();
deviceStatsNode.put("device", device.id().toString());
final ArrayNode statisticsNode = deviceStatsNode.putArray("table");
final Iterable<TableStatisticsEntry> tableStatsEntries = service.getFlowTableStatistics(device.id());
if (tableStatsEntries != null) {
for (final TableStatisticsEntry entry : tableStatsEntries) {
statisticsNode.add(codec(TableStatisticsEntry.class).encode(entry, this));
}
}
rootArrayNode.add(deviceStatsNode);
}
return ok(root).build();
}
示例2: getTableStatisticsByDeviceId
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
/**
* Gets table statistics for all tables of a specified device.
*
* @onos.rsModel StatisticsFlowsTables
* @param deviceId device ID
* @return 200 OK with JSON encoded array of table statistics
*/
@GET
@Path("flows/tables/{deviceId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTableStatisticsByDeviceId(@PathParam("deviceId") String deviceId) {
final FlowRuleService service = get(FlowRuleService.class);
final Iterable<TableStatisticsEntry> tableStatisticsEntries =
service.getFlowTableStatistics(DeviceId.deviceId(deviceId));
final ObjectNode root = mapper().createObjectNode();
final ArrayNode rootArrayNode = root.putArray("statistics");
final ObjectNode deviceStatsNode = mapper().createObjectNode();
deviceStatsNode.put("device", deviceId);
final ArrayNode statisticsNode = deviceStatsNode.putArray("table");
for (final TableStatisticsEntry entry : tableStatisticsEntries) {
statisticsNode.add(codec(TableStatisticsEntry.class).encode(entry, this));
}
rootArrayNode.add(deviceStatsNode);
return ok(root).build();
}
示例3: getTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
public Iterable<TableStatisticsEntry> getTableStatistics(NetworkId networkId, DeviceId deviceId) {
MastershipService mastershipService =
vnaService.get(networkId, MastershipService.class);
NodeId master = mastershipService.getMasterFor(deviceId);
if (master == null) {
log.debug("Failed to getTableStats: No master for {}", deviceId);
return Collections.emptyList();
}
if (deviceTableStats.get(networkId) == null) {
deviceTableStats.put(networkId, Maps.newConcurrentMap());
}
List<TableStatisticsEntry> tableStats = deviceTableStats.get(networkId).get(deviceId);
if (tableStats == null) {
return Collections.emptyList();
}
return ImmutableList.copyOf(tableStats);
}
示例4: pushTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
private void pushTableStatistics(Dpid dpid, OFTableStatsReply replies) {
DeviceId did = DeviceId.deviceId(Dpid.uri(dpid));
List<TableStatisticsEntry> tableStatsEntries = replies.getEntries().stream()
.map(entry -> buildTableStatistics(did, entry))
.filter(Objects::nonNull)
.collect(Collectors.toList());
providerService.pushTableStatistics(did, tableStatsEntries);
}
示例5: execute
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
protected void execute() {
FlowRuleService flowService = get(FlowRuleService.class);
DeviceService deviceService = get(DeviceService.class);
SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats =
getSortedTableStats(deviceService, flowService);
if (outputJson()) {
print("%s", json(deviceTableStats.keySet(), deviceTableStats));
} else {
deviceTableStats.forEach((device, tableStats) -> printTableStats(device, tableStats));
}
}
示例6: json
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
/**
* Produces a JSON array of table statistics grouped by the each device.
*
* @param devices collection of devices
* @param deviceTableStats collection of table statistics per each device
* @return JSON array
*/
private JsonNode json(Iterable<Device> devices,
Map<Device, List<TableStatisticsEntry>> deviceTableStats) {
ObjectMapper mapper = new ObjectMapper();
ArrayNode result = mapper.createArrayNode();
for (Device device : devices) {
result.add(json(mapper, device, deviceTableStats.get(device)));
}
return result;
}
示例7: printTableStats
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
/**
* Prints flow table statistics.
*
* @param d the device
* @param tableStats the set of flow table statistics for that device
*/
protected void printTableStats(Device d,
List<TableStatisticsEntry> tableStats) {
boolean empty = tableStats == null || tableStats.isEmpty();
print("deviceId=%s, tableCount=%d", d.id(), empty ? 0 : tableStats.size());
if (!empty) {
for (TableStatisticsEntry t : tableStats) {
print(FORMAT, t.tableId(), t.activeFlowEntries(),
t.packetsLookedup(), t.packetsMatched());
}
}
}
示例8: getSortedTableStats
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
/**
* Returns the list of table statistics sorted using the device ID URIs and table IDs.
*
* @param deviceService device service
* @param flowService flow rule service
* @return sorted table statistics list
*/
protected SortedMap<Device, List<TableStatisticsEntry>> getSortedTableStats(DeviceService deviceService,
FlowRuleService flowService) {
SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats = new TreeMap<>(Comparators.ELEMENT_COMPARATOR);
List<TableStatisticsEntry> tableStatsList;
Iterable<Device> devices = uri == null ? deviceService.getDevices() :
Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri)));
for (Device d : devices) {
tableStatsList = newArrayList(flowService.getFlowTableStatistics(d.id()));
tableStatsList.sort((p1, p2) -> Integer.valueOf(p1.tableId()).compareTo(Integer.valueOf(p2.tableId())));
deviceTableStats.put(d, tableStatsList);
}
return deviceTableStats;
}
示例9: encode
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
public ObjectNode encode(TableStatisticsEntry entry, CodecContext context) {
checkNotNull(entry, "Table Statistics entry cannot be null");
final ObjectNode result = context.mapper().createObjectNode()
.put("tableId", entry.tableId())
.put("deviceId", entry.deviceId().toString())
.put("activeEntries", entry.activeFlowEntries())
.put("packetsLookedUp", entry.packetsLookedup())
.put("packetsMatched", entry.packetsMatched());
return result;
}
示例10: getTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
public Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId) {
List<TableStatisticsEntry> tableStats = deviceTableStats.get(deviceId);
if (tableStats == null) {
return Collections.emptyList();
}
return ImmutableList.copyOf(tableStats);
}
示例11: activate
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Activate
public void activate(ComponentContext context) {
configService.registerProperties(getClass());
idGenerator = coreService.getIdGenerator(FlowRuleService.FLOW_OP_TOPIC);
local = clusterService.getLocalNode().id();
eventHandler = Executors.newSingleThreadExecutor(
groupedThreads("onos/flow", "event-handler", log));
messageHandlingExecutor = Executors.newFixedThreadPool(
msgHandlerPoolSize, groupedThreads("onos/store/flow", "message-handlers", log));
registerMessageHandlers(messageHandlingExecutor);
if (backupEnabled) {
replicaInfoManager.addListener(flowTable);
backupTask = backupSenderExecutor.scheduleWithFixedDelay(
flowTable::backup,
0,
backupPeriod,
TimeUnit.MILLISECONDS);
}
deviceTableStats = storageService.<DeviceId, List<TableStatisticsEntry>>eventuallyConsistentMapBuilder()
.withName("onos-flow-table-stats")
.withSerializer(SERIALIZER_BUILDER)
.withAntiEntropyPeriod(5, TimeUnit.SECONDS)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.withTombstonesDisabled()
.build();
deviceTableStats.addListener(tableStatsListener);
logConfig("Started");
}
示例12: getTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
public Iterable<TableStatisticsEntry> getTableStatistics(DeviceId deviceId) {
NodeId master = mastershipService.getMasterFor(deviceId);
if (master == null) {
log.debug("Failed to getTableStats: No master for {}", deviceId);
return Collections.emptyList();
}
List<TableStatisticsEntry> tableStats = deviceTableStats.get(deviceId);
if (tableStats == null) {
return Collections.emptyList();
}
return ImmutableList.copyOf(tableStats);
}
示例13: activate
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Activate
public void activate(ComponentContext context) {
configService.registerProperties(getClass());
idGenerator = coreService.getIdGenerator(FLOW_OP_TOPIC);
local = clusterService.getLocalNode().id();
eventHandler = Executors.newSingleThreadExecutor(
groupedThreads("onos/virtual-flow", "event-handler", log));
messageHandlingExecutor = Executors.newFixedThreadPool(
msgHandlerPoolSize, groupedThreads("onos/store/virtual-flow", "message-handlers", log));
registerMessageHandlers(messageHandlingExecutor);
deviceTableStats = storageService
.<NetworkId, Map<DeviceId, List<TableStatisticsEntry>>>eventuallyConsistentMapBuilder()
.withName("onos-virtual-flow-table-stats")
.withSerializer(serializerBuilder)
.withAntiEntropyPeriod(5, TimeUnit.SECONDS)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.withTombstonesDisabled()
.build();
deviceTableStats.addListener(tableStatsListener);
logConfig("Started");
}
示例14: updateTableStatistics
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
@Override
public FlowRuleEvent updateTableStatistics(NetworkId networkId,
DeviceId deviceId,
List<TableStatisticsEntry> tableStats) {
if (deviceTableStats.get(networkId) == null) {
deviceTableStats.put(networkId, Maps.newConcurrentMap());
}
deviceTableStats.get(networkId).put(deviceId, tableStats);
return null;
}
示例15: ofFlowTableStatsEntry
import org.onosproject.net.flow.TableStatisticsEntry; //导入依赖的package包/类
private OFTableStatsEntry ofFlowTableStatsEntry(TableStatisticsEntry tableStatisticsEntry) {
OFTableStatsEntry ofTableStatsEntry = FACTORY.buildTableStatsEntry()
.setTableId(TableId.of(tableStatisticsEntry.tableId()))
.setActiveCount(tableStatisticsEntry.activeFlowEntries())
.setLookupCount(U64.of(tableStatisticsEntry.packetsLookedup()))
.setMatchedCount(U64.of(tableStatisticsEntry.packetsLookedup()))
.build();
return ofTableStatsEntry;
}