use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project controller by opendaylight.
the class OpsInvoker method execute.
@SuppressWarnings("checkstyle:IllegalCatch")
private void execute(final ExecuteAction msg) {
LOG.debug("Executing Action {}", msg.getType());
final ActorRef sender = getSender();
final ListenableFuture<? extends DOMActionResult> future;
try {
future = actionService.invokeAction(msg.getType(), msg.getPath(), msg.getInput());
} catch (final RuntimeException e) {
LOG.debug("Failed to invoke action {}", msg.getType(), e);
sender.tell(new Failure(e), self());
return;
}
Futures.addCallback(future, new AbstractCallback<Absolute, DOMActionResult>(getSender(), msg.getType()) {
@Override
Object nullResponse(final Absolute type) {
throw new IllegalStateException("Null invocation result of action " + type);
}
@Override
Object response(final Absolute type, final DOMActionResult result) {
final Collection<? extends RpcError> errors = result.getErrors();
return errors.isEmpty() ? new ActionResponse(result.getOutput(), result.getErrors()) : // discarding any output
new Failure(new RpcErrorsException(String.format("Execution of action %s failed", type), errors));
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project mdsal by opendaylight.
the class DOMNotificationRouter method registerNotificationListener.
@Override
public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener, final Collection<Absolute> types) {
final AbstractListenerRegistration<T> reg = new AbstractListenerRegistration<>(listener) {
@Override
protected void removeRegistration() {
synchronized (DOMNotificationRouter.this) {
replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, input -> input != this)));
}
}
};
if (!types.isEmpty()) {
final Builder<Absolute, AbstractListenerRegistration<? extends DOMNotificationListener>> b = ImmutableMultimap.builder();
b.putAll(listeners);
for (final Absolute t : types) {
b.put(t, reg);
}
replaceListeners(b.build());
}
return reg;
}
use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project mdsal by opendaylight.
the class ActionProviderServiceAdapter method registerImplementation.
@Override
public <P extends DataObject, A extends Action<? extends InstanceIdentifier<P>, ?, ?>, S extends A> ObjectRegistration<S> registerImplementation(final ActionSpec<A, P> spec, final S implementation, final LogicalDatastoreType datastore, final Set<? extends InstanceIdentifier<P>> validNodes) {
final CurrentAdapterSerializer serializer = currentSerializer();
final Absolute actionPath = serializer.getActionPath(spec);
final Impl impl = new Impl(adapterContext(), actionPath, spec.type(), implementation);
final DOMActionInstance instance = validNodes.isEmpty() ? // Register on the entire datastore
DOMActionInstance.of(actionPath, new DOMDataTreeIdentifier(datastore, YangInstanceIdentifier.empty())) : // Register on specific instances
DOMActionInstance.of(actionPath, validNodes.stream().map(node -> serializer.toDOMDataTreeIdentifier(DataTreeIdentifier.create(datastore, node))).collect(Collectors.toUnmodifiableSet()));
final ObjectRegistration<?> reg = getDelegate().registerActionImplementation(impl, instance);
return new AbstractObjectRegistration<>(implementation) {
@Override
protected void removeRegistration() {
reg.close();
}
};
}
use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project mdsal by opendaylight.
the class BindingDOMNotificationListenerAdapter method getNotificationTypes.
private static Set<Absolute> getNotificationTypes(final Class<? extends NotificationListener> type) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<Absolute> ret = new HashSet<>();
for (final Method method : type.getMethods()) {
if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
ret.add(Absolute.of(BindingReflections.findQName(notification)));
}
}
return ret;
}
use of org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute in project yangtools by opendaylight.
the class LeafRefContextTreeBuilderTest method leafRefContextUtilsTest2.
@Test
public void leafRefContextUtilsTest2() {
final QName q1 = QName.create(tst, "odl-project");
final QName q2 = QName.create(tst, "project");
final QName q3 = QName.create(tst, "name");
final Absolute node = Absolute.of(q1, q2, q3);
LeafRefContext found = rootLeafRefContext.getLeafRefReferencingContext(node);
assertNull(found);
found = rootLeafRefContext.getLeafRefReferencedByContext(node);
assertNotNull(found);
assertTrue(found.isReferenced());
assertFalse(found.getAllReferencedByLeafRefCtxs().isEmpty());
assertEquals(6, found.getAllReferencedByLeafRefCtxs().size());
assertEquals(rootLeafRefContext.getReferencedChildByName(q1).getReferencedChildByName(q2).getReferencedChildByName(q3), found);
}
Aggregations