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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations