Search in sources :

Example 1 with AtomicCounter

use of org.onosproject.store.service.AtomicCounter in project onos by opennetworkinglab.

the class CounterCommand method doExecute.

@Override
protected void doExecute() {
    StorageService storageService = get(StorageService.class);
    AtomicCounter counter = storageService.getAtomicCounter(name);
    if (outputJson()) {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode counterJsonNode = mapper.createObjectNode();
        counterJsonNode.put("value", counter.get());
        print("%s", counterJsonNode);
    } else {
        print("%d", counter.get());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) AtomicCounter(org.onosproject.store.service.AtomicCounter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StorageService(org.onosproject.store.service.StorageService)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AtomicCounter (org.onosproject.store.service.AtomicCounter)1 StorageService (org.onosproject.store.service.StorageService)1