use of org.onosproject.store.service.WorkQueueStats in project onos by opennetworkinglab.
the class WorkQueueTestCommand method doExecute.
@Override
protected void doExecute() {
StorageService storageService = get(StorageService.class);
Serializer serializer = Serializer.using(KryoNamespaces.BASIC);
queue = storageService.getWorkQueue(name, serializer);
if ("add".equals(operation)) {
if (value1 == null) {
print("Usage: add <value1>");
} else {
get(queue.addOne(value1));
print("Done");
}
} else if ("addMultiple".equals(operation)) {
if (value1 == null || value2 == null) {
print("Usage: addMultiple <value1> <value2>");
} else {
get(queue.addMultiple(Arrays.asList(value1, value2)));
print("Done");
}
} else if ("takeAndComplete".equals(operation)) {
int maxItems = value1 != null ? Integer.parseInt(value1) : 1;
Collection<Task<String>> tasks = get(queue.take(maxItems));
tasks.forEach(task -> get(queue.complete(task.taskId())));
print("Done");
} else if ("totalPending".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalPending());
} else if ("totalInProgress".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalInProgress());
} else if ("totalCompleted".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalCompleted());
} else if ("destroy".equals(operation)) {
get(queue.destroy());
} else {
print("Invalid operation name. Valid operations names are:" + " [add, addMultiple takeAndComplete, totalPending, totalInProgress, totalCompleted, destroy]");
}
}
use of org.onosproject.store.service.WorkQueueStats in project onos by opennetworkinglab.
the class QueuesListCommand method doExecute.
@Override
protected void doExecute() {
StorageAdminService storageAdminService = get(StorageAdminService.class);
Map<String, WorkQueueStats> queueStats = storageAdminService.getQueueStats();
if (outputJson()) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode jsonQueues = mapper.createObjectNode();
queueStats.forEach((k, v) -> {
ObjectNode jsonStats = jsonQueues.putObject(k);
jsonStats.put("pending", v.totalPending());
jsonStats.put("inProgress", v.totalInProgress());
jsonStats.put("completed", v.totalCompleted());
});
print("%s", jsonQueues);
} else {
queueStats.forEach((name, stats) -> print(FMT, name, stats.totalPending(), stats.totalInProgress(), stats.totalCompleted()));
}
}
Aggregations