Search in sources :

Example 1 with DocumentPath

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

the class DistributedDynamicConfigStore method addKey.

private Boolean addKey(String path, DataNode.Type type) {
    log.trace("addKey({}, {})", path, type);
    DocumentPath dpath = DocumentPath.from(path);
    log.trace("dpath={}", dpath);
    // FIXME Not atomic, should probably use create or replace
    if (completeVersioned(keystore.get(dpath)) != null) {
        log.trace(" keystore.set({}, {})", dpath, type);
        completeVersioned(keystore.set(dpath, type));
        return true;
    }
    log.trace(" keystore.create({}, {})", dpath, type);
    Boolean result = complete(keystore.create(dpath, type));
    return result;
}
Also used : DocumentPath(org.onosproject.store.service.DocumentPath)

Example 2 with DocumentPath

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

the class DistributedContextEventMapTreeStore method asJsonTree.

@Override
public ObjectNode asJsonTree() throws WorkflowException {
    DocumentPath rootPath = DocumentPath.from(Lists.newArrayList("root"));
    Map<String, Versioned<String>> eventmap = complete(eventMapTree.getChildren(rootPath));
    ObjectNode rootNode = JsonNodeFactory.instance.objectNode();
    for (Map.Entry<String, Versioned<String>> eventTypeEntry : eventmap.entrySet()) {
        String eventType = eventTypeEntry.getKey();
        ObjectNode eventTypeNode = JsonNodeFactory.instance.objectNode();
        rootNode.put(eventType, eventTypeNode);
        DocumentPath eventTypePath = DocumentPath.from(Lists.newArrayList("root", eventType));
        Map<String, Versioned<String>> hintmap = complete(eventMapTree.getChildren(eventTypePath));
        for (Map.Entry<String, Versioned<String>> hintEntry : hintmap.entrySet()) {
            String hint = hintEntry.getKey();
            ObjectNode hintNode = JsonNodeFactory.instance.objectNode();
            eventTypeNode.put(hint, hintNode);
            DocumentPath hintPath = DocumentPath.from(Lists.newArrayList("root", eventType, hint));
            Map<String, Versioned<String>> contextmap = complete(eventMapTree.getChildren(hintPath));
            for (Map.Entry<String, Versioned<String>> ctxtEntry : contextmap.entrySet()) {
                hintNode.put(ctxtEntry.getKey(), ctxtEntry.getValue().value());
            }
        }
    }
    return rootNode;
}
Also used : Versioned(org.onosproject.store.service.Versioned) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DocumentPath(org.onosproject.store.service.DocumentPath) Map(java.util.Map) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap)

Example 3 with DocumentPath

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

the class DistributedContextEventMapTreeStore method getChildren.

@Override
public Map<String, Versioned<String>> getChildren(String path) throws WorkflowException {
    DocumentPath dpath = DocumentPath.from(path);
    Map<String, Versioned<String>> entries = complete(eventMapTree.getChildren(dpath));
    return entries;
}
Also used : Versioned(org.onosproject.store.service.Versioned) DocumentPath(org.onosproject.store.service.DocumentPath)

Example 4 with DocumentPath

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

the class DistributedContextEventMapTreeStore method registerEventMap.

@Override
public void registerEventMap(String eventType, Set<String> eventHintSet, String contextName, String programCounterString) throws WorkflowException {
    for (String eventHint : eventHintSet) {
        // Insert in eventCxtPerHintMap
        DocumentPath dpathForCxt = DocumentPath.from(Lists.newArrayList("root", eventType, eventHint, contextName));
        String currentWorkletType = completeVersioned(eventMapTree.get(dpathForCxt));
        if (currentWorkletType == null) {
            complete(eventMapTree.createRecursive(dpathForCxt, programCounterString));
        } else {
            complete(eventMapTree.replace(dpathForCxt, programCounterString, currentWorkletType));
        }
        log.trace("RegisterEventMap for eventType:{}, eventSet:{}, contextName:{}, pc:{}", eventType, eventHintSet, contextName, programCounterString);
    }
    hintSetPerCxtMap.put(contextName, eventHintSet);
    log.trace("RegisterEventMap in hintSetPerCxt for " + "eventType:{}, eventSet:{}, contextName:{}, pc:{}", eventType, eventHintSet, contextName, programCounterString);
}
Also used : DocumentPath(org.onosproject.store.service.DocumentPath)

Example 5 with DocumentPath

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

the class DistributedContextEventMapTreeStore method getEventMapByHint.

@Override
public Map<String, String> getEventMapByHint(String eventType, String eventHint) throws WorkflowException {
    DocumentPath path = DocumentPath.from(Lists.newArrayList("root", eventType, eventHint));
    Map<String, Versioned<String>> contexts = complete(eventMapTree.getChildren(path));
    Map<String, String> eventMap = Maps.newHashMap();
    if (Objects.isNull(contexts)) {
        return eventMap;
    }
    for (Map.Entry<String, Versioned<String>> entry : contexts.entrySet()) {
        eventMap.put(entry.getKey(), entry.getValue().value());
    }
    log.trace("getEventMapByHint returns eventMap {} ", eventMap);
    return eventMap;
}
Also used : Versioned(org.onosproject.store.service.Versioned) DocumentPath(org.onosproject.store.service.DocumentPath) Map(java.util.Map) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap)

Aggregations

DocumentPath (org.onosproject.store.service.DocumentPath)7 Versioned (org.onosproject.store.service.Versioned)5 Map (java.util.Map)2 FailedException (org.onosproject.config.FailedException)2 EventuallyConsistentMap (org.onosproject.store.service.EventuallyConsistentMap)2 DataNode (org.onosproject.yang.model.DataNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 KeyLeaf (org.onosproject.yang.model.KeyLeaf)1 NodeKey (org.onosproject.yang.model.NodeKey)1