import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.dom.api.DOMActionResult;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMOperationResult;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
import org.opendaylight.yangtools.yang.binding.Action;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcInput;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@NonNullByDefault
-final class ActionAdapter extends AbstractBindingAdapter<DOMOperationService> implements InvocationHandler {
+final class ActionAdapter extends AbstractBindingAdapter<DOMActionService> implements InvocationHandler {
private final Class<? extends Action<?, ?, ?>> type;
private final NodeIdentifier inputName;
private final SchemaPath schemaPath;
- ActionAdapter(final BindingToNormalizedNodeCodec codec, final DOMOperationService delegate,
+ ActionAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService delegate,
final Class<? extends Action<?, ?, ?>> type) {
super(codec, delegate);
this.type = requireNonNull(type);
if (args.length == 2) {
final InstanceIdentifier<?> path = (InstanceIdentifier<?>) requireNonNull(args[0]);
final RpcInput input = (RpcInput) requireNonNull(args[1]);
- final FluentFuture<DOMOperationResult> future = getDelegate().invokeAction(schemaPath,
+ final FluentFuture<? extends DOMActionResult> future = getDelegate().invokeAction(schemaPath,
new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, getCodec().toNormalized(path)),
getCodec().toLazyNormalizedNodeActionInput(type, inputName, input));
import org.opendaylight.mdsal.binding.api.ActionService;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.yang.binding.Action;
import org.opendaylight.yangtools.yang.binding.DataObject;
@Beta
@NonNullByDefault
final class ActionServiceAdapter
- extends AbstractBindingLoadingAdapter<DOMOperationService, Class<? extends Action<?, ?, ?>>, ActionAdapter>
+ extends AbstractBindingLoadingAdapter<DOMActionService, Class<? extends Action<?, ?, ?>>, ActionAdapter>
implements ActionService {
private static final class ConstrainedAction implements Delegator<Action<?, ?, ?>>,
Action<InstanceIdentifier<?>, RpcInput, RpcOutput> {
}
}
- ActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMOperationService delegate) {
+ ActionServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMActionService delegate) {
super(codec, delegate);
}
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
}
@Override
- public ActionService createActionService(final DOMOperationService domService) {
+ public ActionService createActionService(final DOMActionService domService) {
return new ActionServiceAdapter(codec, domService);
}
}
import java.util.Collection;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.mdsal.dom.api.DOMOperationResult;
+import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
- * Utility methods for converting {@link RpcResult} to/from {@link DOMOperationResult} and {@link DOMRpcResult}.
+ * Utility methods for converting {@link RpcResult} to/from {@link DOMActionResult} and {@link DOMRpcResult}.
*/
@NonNullByDefault
final class RpcResultUtil {
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.dom.adapter.spi.AdapterFactory;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMService;
factory::createRpcConsumerRegistry),
new AdaptingTracker<>(ctx, DOMRpcProviderService.class, RpcProviderService.class,
factory::createRpcProviderService),
- new AdaptingTracker<>(ctx, DOMOperationService.class, ActionService.class, factory::createActionService));
+ new AdaptingTracker<>(ctx, DOMActionService.class, ActionService.class, factory::createActionService));
LOG.debug("Starting {} DOMService trackers", trackers.size());
trackers.forEach(ServiceTracker::open);
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMService;
RpcProviderService createRpcProviderService(DOMRpcProviderService domService);
/**
- * Create a {@link ActionService} backed by a {@link DOMOperationService}.
+ * Create a {@link ActionService} backed by a {@link DOMActionService}.
*
* @param domService Backing DOMOperationService
* @return A ActionService
* @throws NullPointerException if {@code domService} is null
*/
- ActionService createActionService(DOMOperationService domService);
+ ActionService createActionService(DOMActionService domService);
}
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.binding.api.ActionService;
-import org.opendaylight.mdsal.dom.api.DOMOperationResult;
-import org.opendaylight.mdsal.dom.api.DOMOperationService;
-import org.opendaylight.mdsal.dom.spi.SimpleDOMOperationResult;
+import org.opendaylight.mdsal.dom.api.DOMActionResult;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.spi.SimpleDOMActionResult;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.Cont;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.cont.Foo;
import org.opendaylight.yang.gen.v1.urn.odl.actions.norev.cont.foo.Input;
private static final RpcOutput BINDING_FOO_OUTPUT = new OutputBuilder().build();
@Mock
- private DOMOperationService delegate;
+ private DOMActionService delegate;
private ActionService service;
- private SettableFuture<DOMOperationResult> domResult;
+ private SettableFuture<DOMActionResult> domResult;
@Override
@Before
BINDING_FOO_INPUT);
assertNotNull(future);
assertFalse(future.isDone());
- domResult.set(new SimpleDOMOperationResult(DOM_FOO_OUTPUT, ImmutableList.of()));
+ domResult.set(new SimpleDOMActionResult(DOM_FOO_OUTPUT, ImmutableList.of()));
final RpcResult<Output> bindingResult = Futures.getDone(future);
assertEquals(ImmutableList.of(), bindingResult.getErrors());
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
- * An {@link DOMOperationServiceExtension} exposed by {@link DOMOperationService}s which allow their users to listen
- * for operations becoming available.
+ * An {@link DOMActionServiceExtension} exposed by {@link DOMActionService}s which allow their users to listen
+ * for actions are becoming available.
*
* @author Robert Varga
*/
@Beta
@NonNullByDefault
-public interface DOMOperationAvailabilityExtension extends DOMOperationServiceExtension {
+public interface DOMActionAvailabilityExtension extends DOMActionServiceExtension {
/**
* Register a {@link AvailabilityListener} with this service to receive notifications about operation
* implementations becoming (un)available. The listener will be invoked with the current implementations reported
*
* <p>
* Users should note that using a listener does not necessarily mean that
- * {@link DOMOperationService#invokeRpc(QName, ContainerNode)} and
- * {@link DOMOperationService#invokeAction(SchemaPath, DOMDataTreeIdentifier, ContainerNode)} will not report
- * a failure due to {@link DOMOperationNotAvailableException} and need to be ready to handle it.
+ * {@link DOMActionService#invokeAction(SchemaPath, DOMDataTreeIdentifier, ContainerNode)} will not report
+ * a failure due to {@link DOMActionNotAvailableException} and need to be ready to handle it.
*
* <p>
* Implementations are encouraged to take reasonable precautions to prevent this scenario from occurring.
/**
* An {@link EventListener} used to track Operation implementations becoming (un)available
- * to a {@link DOMOperationService}.
+ * to a {@link DOMActionService}.
*/
interface AvailabilityListener extends EventListener {
/**
- * Method invoked whenever an operation type becomes available or unavailable. There are two sets reported,
+ * Method invoked whenever an action type becomes available or unavailable. There are two sets reported,
* removed and added. To reconstruct the state, first apply removed and then added operations, like this:
*
* <code>
- * Set<AvailableOperation<?>> operations;
+ * Set<DOMActionInstancelt;?>> operations;
* operations.removeAll(removed);
* operations.addAll(added);
* </code>
* @param removed operations which disappeared
* @param added operations which became available
*/
- void onOperationsChanged(Set<DOMOperationInstance<?>> removed, Set<DOMOperationInstance<?>> added);
+ void onActionsChanged(Set<DOMActionInstance> removed, Set<DOMActionService> added);
/**
* Implementation filtering method. This method is useful for forwarding operation implementations,
* @param impl Operation implementation being registered
* @return False if the implementation should not be reported, defaults to true.
*/
- default boolean acceptsImplementation(final DOMOperationImplementation impl) {
+ default boolean acceptsImplementation(final DOMActionImplementation impl) {
return true;
}
}
/**
* Base class for failures that can occur during operation invocation. This covers transport and protocol-level
- * failures, not implementation-reported errors, which are part of {@link DOMOperationResult}.
+ * failures, not implementation-reported errors, which are part of {@link DOMActionResult}.
*
* @author Robert Varga
*/
@Beta
@NonNullByDefault
-public abstract class DOMOperationException extends Exception {
+public abstract class DOMActionException extends Exception {
private static final long serialVersionUID = 1L;
/**
*
* @param message Exception message
*/
- protected DOMOperationException(final String message) {
+ protected DOMActionException(final String message) {
super(message);
}
* @param message Exception message
* @param cause Chained cause
*/
- protected DOMOperationException(final String message, final Throwable cause) {
+ protected DOMActionException(final String message, final Throwable cause) {
super(message, cause);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.api;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.FluentFuture;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+/**
+ * Interface implemented by an individual operation implementation. This API allows for dispatch implementations, e.g.
+ * an individual object handling a multitude of operations.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@FunctionalInterface
+@NonNullByDefault
+public interface DOMActionImplementation {
+ /**
+ * Initiate invocation of the action. Implementations of this method are expected to not block.
+ *
+ * @param type SchemaPath of the action to be invoked. This path refers to an effective action instantiated on top
+ * of the conceptual {@link StoreTreeNode}.
+ * @param path {@link DOMDataTreeIdentifier} of parent data node which action attached to.
+ * @param input Input arguments
+ * @return A FluentFuture which completes with the result of invocation
+ * @throws NullPointerException if any of the arguments is null
+ */
+ FluentFuture<? extends DOMActionResult> invokeAction(SchemaPath type, DOMDataTreeIdentifier path,
+ ContainerNode input);
+
+ /**
+ * Return the relative invocation cost of this implementation. Default implementation returns 0.
+ *
+ * @return Non-negative cost of invoking this implementation.
+ */
+ default long invocationCost() {
+ return 0;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.api;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
+import java.util.Objects;
+import java.util.Set;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+/**
+ * An action which is subject to availability.
+ */
+public final class DOMActionInstance implements Immutable {
+ private final Set<DOMDataTreeIdentifier> dataTrees;
+ private final SchemaPath type;
+
+ DOMActionInstance(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
+ this.type = requireNonNull(type);
+ this.dataTrees = ImmutableSet.copyOf(dataTrees);
+ checkArgument(!dataTrees.isEmpty());
+ }
+
+ public static DOMActionInstance of(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
+ return new DOMActionInstance(type, dataTrees);
+ }
+
+ public static DOMActionInstance of(final SchemaPath type, final DOMDataTreeIdentifier... dataTrees) {
+ return of(type, ImmutableSet.copyOf(dataTrees));
+ }
+
+ public static DOMActionInstance of(final SchemaPath type, final LogicalDatastoreType datastore,
+ final YangInstanceIdentifier path) {
+ return of(type, ImmutableSet.of(new DOMDataTreeIdentifier(datastore, path)));
+ }
+
+ /**
+ * Return the set of data trees on which this action is available. These identifiers are required to point
+ * to concrete items, i.e. they may not be wildcards.
+ *
+ * @return Set of trees on which this action is available.
+ */
+ public Set<DOMDataTreeIdentifier> getDataTrees() {
+ return dataTrees;
+ }
+
+ /**
+ * Return the operation type.
+ *
+ * @return operation type.
+ */
+ public SchemaPath getType() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getType(), dataTrees);
+ }
+
+ @Override
+ public boolean equals(final @Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DOMActionInstance)) {
+ return false;
+ }
+ final DOMActionInstance other = (DOMActionInstance) obj;
+ return getType().equals(other.type) && dataTrees.equals(other.dataTrees);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("type", type).add("dataTrees", dataTrees).toString();
+ }
+}
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
- * Exception indicating that no implementation of the requested operation is available.
+ * Exception indicating that no implementation of the requested action is available.
*/
@Beta
@NonNullByDefault
-public final class DOMOperationNotAvailableException extends DOMOperationException {
+public final class DOMActionNotAvailableException extends DOMActionException {
private static final long serialVersionUID = 1L;
- public DOMOperationNotAvailableException(final String format, final Object... args) {
+ public DOMActionNotAvailableException(final String format, final Object... args) {
super(String.format(format, args));
}
- public DOMOperationNotAvailableException(final Throwable cause, final String format, final Object... args) {
+ public DOMActionNotAvailableException(final Throwable cause, final String format, final Object... args) {
super(String.format(format, args), requireNonNull(cause));
}
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.api;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+
+/**
+ * A {@link DOMService} which allows registration of action implementations with a conceptual router. The client
+ * counterpart of this service is {@link DOMActionService}.
+ */
+@Beta
+@NonNullByDefault
+public interface DOMActionProviderService
+ extends DOMExtensibleService<DOMActionProviderService, DOMActionProviderServiceExtension> {
+ /**
+ * Register an {@link DOMActionImplementation} object with this service.
+ *
+ * @param implementation action implementation, must not be null
+ * @param instances Set of supported operation identifiers. Must not be null, empty, or contain a null element.
+ * @return A {@link ObjectRegistration} object, guaranteed to be non-null.
+ * @throws NullPointerException if implementation or types is null
+ * @throws IllegalArgumentException if {@code instances} is empty
+ */
+ <T extends DOMActionImplementation> ObjectRegistration<T> registerActionImplementation(T implementation,
+ Set<DOMActionInstance> instances);
+
+ default <T extends DOMActionImplementation> ObjectRegistration<T> registerActionImplementation(
+ final T implementation, final DOMActionInstance... instances) {
+ return registerActionImplementation(implementation, ImmutableSet.copyOf(instances));
+ }
+}
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
- * Marker interface for extensions of {@link DOMOperationProviderService}.
+ * Marker interface for extensions of {@link DOMActionProviderService}.
*
* @author Robert Varga
*/
@Beta
@NonNullByDefault
-public interface DOMOperationProviderServiceExtension
- extends DOMServiceExtension<DOMOperationProviderService, DOMOperationProviderServiceExtension> {
+public interface DOMActionProviderServiceExtension
+ extends DOMServiceExtension<DOMActionProviderService, DOMActionProviderServiceExtension> {
}
*/
@Beta
@NonNullByDefault
-public interface DOMOperationResult {
+public interface DOMActionResult {
/**
* Returns a set of errors and warnings which occurred during processing the call.
*
import com.google.common.annotations.Beta;
import com.google.common.util.concurrent.FluentFuture;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
- * A {@link DOMService} which allows clients to invoke Actions and RPCs. The conceptual model of this service is that
- * of a dynamic router, where the set of available Operation services can change dynamically. The service allows users
- * to add a listener to track the process of Actions and RPCs becoming available.
+ * A {@link DOMService} which allows clients to invoke Actions. The conceptual model of this service is that
+ * of a dynamic router, where the set of available Action services can change dynamically.
*
* @author Robert Varga
*/
@Beta
@NonNullByDefault
-public interface DOMOperationService extends DOMExtensibleService<DOMOperationService, DOMOperationServiceExtension> {
- /**
- * Initiate invocation of an RPC. This method is guaranteed to not block on any external resources.
- *
- * @param type QName of the RPC to be invoked
- * @param input Input arguments
- * @return A FluentFuture which completes with the result of invocation
- * @throws NullPointerException if any of the arguments is null
- */
- FluentFuture<DOMOperationResult> invokeRpc(QName type, ContainerNode input);
-
+public interface DOMActionService extends DOMExtensibleService<DOMActionService, DOMActionServiceExtension> {
/**
* Initiate invocation of an Action. This method is guaranteed to not block on any external resources.
*
* @return A FluentFuture which completes with the result of invocation
* @throws NullPointerException if any of the arguments is null
*/
- FluentFuture<DOMOperationResult> invokeAction(SchemaPath type, DOMDataTreeIdentifier path, ContainerNode input);
+ FluentFuture<? extends DOMActionResult> invokeAction(SchemaPath type, DOMDataTreeIdentifier path,
+ ContainerNode input);
}
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
- * Marker interface for extensions of {@link DOMOperationService}.
+ * Marker interface for extensions of {@link DOMActionService}.
*
* @author Robert Varga
*/
@Beta
@NonNullByDefault
-public interface DOMOperationServiceExtension
- extends DOMServiceExtension<DOMOperationService, DOMOperationServiceExtension> {
+public interface DOMActionServiceExtension
+ extends DOMServiceExtension<DOMActionService, DOMActionServiceExtension> {
}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.api;
-
-import com.google.common.annotations.Beta;
-import com.google.common.util.concurrent.FluentFuture;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Interface implemented by an individual operation implementation. This API allows for dispatch implementations, e.g.
- * an individual object handling a multitude of operations.
- *
- * @author Robert Varga
- */
-@Beta
-@NonNullByDefault
-public interface DOMOperationImplementation {
- /**
- * An implementation of an {@code action}.
- */
- @FunctionalInterface
- interface Action extends DOMOperationImplementation {
- /**
- * Initiate invocation of the action. Implementations of this method are expected to not block.
- *
- * @param type SchemaPath of the action to be invoked. This path refers to an effective action instantiated on
- * top of the conceptual {@link StoreTreeNode}.
- * @param path {@link DOMDataTreeIdentifier} of parent data node which action attached to.
- * @param input Input arguments
- * @return A FluentFuture which completes with the result of invocation
- * @throws NullPointerException if any of the arguments is null
- */
- FluentFuture<? extends DOMOperationResult> invokeAction(SchemaPath type, DOMDataTreeIdentifier path,
- ContainerNode input);
- }
-
- /**
- * An implementation of an {@code rpc}.
- */
- @FunctionalInterface
- interface Rpc extends DOMOperationImplementation {
- /**
- * Initiate invocation of the RPC. Implementations of this method are expected to not block.
- *
- * @param type QName of the RPC to be invoked
- * @param input Input arguments
- * @return A FluentFuture which completes with the result of invocation
- * @throws NullPointerException if any of the arguments is null
- */
- FluentFuture<? extends DOMOperationResult> invokeRpc(QName type, ContainerNode input);
- }
-
- /**
- * Return the relative invocation cost of this implementation. Default implementation returns 0.
- *
- * @return Non-negative cost of invoking this implementation.
- */
- default long invocationCost() {
- return 0;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.api;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.collect.ImmutableSet;
-import java.util.Objects;
-import java.util.Set;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * An operation (RPC or action) which is subject to availability. This is a common superclass for {@link Action} and
- * {@link Rpc}.
- *
- * @param <T> type of operation type
- */
-public abstract class DOMOperationInstance<T> implements Immutable {
- public static final class Action extends DOMOperationInstance<SchemaPath> {
- private final Set<DOMDataTreeIdentifier> dataTrees;
-
- Action(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
- super(type);
- this.dataTrees = ImmutableSet.copyOf(dataTrees);
- checkArgument(!dataTrees.isEmpty());
- }
-
- /**
- * Return the set of data trees on which this action is available. These identifiers are required to point
- * to concrete items, i.e. they may not be wildcards.
- *
- * @return Set of trees on which this action is available.
- */
- public Set<DOMDataTreeIdentifier> getDataTrees() {
- return dataTrees;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(getType(), dataTrees);
- }
-
- @Override
- public boolean equals(final @Nullable Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Action)) {
- return false;
- }
- final Action other = (Action) obj;
- return getType().equals(other.getType()) && dataTrees.equals(other.dataTrees);
- }
-
- @Override
- ToStringHelper addToStringAttributes(final ToStringHelper helper) {
- return helper.add("dataTrees", dataTrees);
- }
- }
-
- public static final class Rpc extends DOMOperationInstance<QName> {
- Rpc(final QName type) {
- super(type);
- }
-
- @Override
- public int hashCode() {
- return getType().hashCode();
- }
-
- @Override
- public boolean equals(final @Nullable Object obj) {
- return this == obj || obj instanceof Rpc && getType().equals(((Rpc) obj).getType());
- }
- }
-
- private final T type;
-
- DOMOperationInstance(final T type) {
- this.type = requireNonNull(type);
- }
-
- public static Action actionOf(final SchemaPath type, final Set<DOMDataTreeIdentifier> dataTrees) {
- return new Action(type, dataTrees);
- }
-
- public static Action actionOf(final SchemaPath type, final DOMDataTreeIdentifier... dataTrees) {
- return actionOf(type, ImmutableSet.copyOf(dataTrees));
- }
-
- public static Action actionOf(final SchemaPath type, final LogicalDatastoreType datastore,
- final YangInstanceIdentifier path) {
- return actionOf(type, ImmutableSet.of(new DOMDataTreeIdentifier(datastore, path)));
- }
-
- public static Rpc rpcOf(final QName type) {
- return new Rpc(type);
- }
-
- /**
- * Return the operation type.
- *
- * @return operation type.
- */
- public final T getType() {
- return type;
- }
-
- @Override
- public abstract int hashCode();
-
- @Override
- public abstract boolean equals(@Nullable Object obj);
-
- @Override
- public final String toString() {
- return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
- }
-
- ToStringHelper addToStringAttributes(final ToStringHelper helper) {
- return helper.add("type", type);
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.mdsal.dom.api;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * A {@link DOMService} which allows registration of operation implementations with a conceptual
- * router. The client counterpart of this service is {@link DOMOperationService}.
- */
-@Beta
-@NonNullByDefault
-public interface DOMOperationProviderService
- extends DOMExtensibleService<DOMOperationProviderService, DOMOperationProviderServiceExtension> {
- /**
- * Register an {@link DOMOperationImplementation.Action} object with this service.
- *
- * @param implementation action implementation, must not be null
- * @param instances Set of supported operation identifiers. Must not be null, empty, or contain a null element.
- * @return A {@link ObjectRegistration} object, guaranteed to be non-null.
- * @throws NullPointerException if implementation or types is null
- * @throws IllegalArgumentException if {@code instances} is empty
- */
- <T extends DOMOperationImplementation.Action> ObjectRegistration<T> registerActionImplementation(T implementation,
- Set<DOMOperationInstance.Action> instances);
-
- default <T extends DOMOperationImplementation.Action> ObjectRegistration<T> registerActionImplementation(
- final T implementation, final DOMOperationInstance.Action... instances) {
- return registerActionImplementation(implementation, ImmutableSet.copyOf(instances));
- }
-
- /**
- * Register an {@link DOMOperationImplementation.Rpc} object with this service.
- *
- * @param implementation RPC implementation, must not be null
- * @param instances Set of supported operation identifiers. Must not be null, empty, or contain a null element.
- * @return A {@link ObjectRegistration} object, guaranteed to be non-null.
- * @throws NullPointerException if implementation or types is null
- * @throws IllegalArgumentException if {@code instances} is empty
- */
- <T extends DOMOperationImplementation.Rpc> ObjectRegistration<T> registerRpcImplementation(T implementation,
- Set<DOMOperationInstance.Rpc> instances);
-
- default <T extends DOMOperationImplementation.Rpc> ObjectRegistration<T> registerRpcImplementation(
- final T implementation, final DOMOperationInstance.Rpc... instances) {
- return registerRpcImplementation(implementation, ImmutableSet.copyOf(instances));
- }
-}
import javax.annotation.concurrent.ThreadSafe;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.mdsal.dom.api.DOMOperationResult;
+import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@Beta
@NonNullByDefault
@ThreadSafe
-public final class SimpleDOMOperationResult implements DOMOperationResult, Immutable {
+public final class SimpleDOMActionResult implements DOMActionResult, Immutable {
private final Collection<RpcError> errors;
private final @Nullable ContainerNode output;
- private SimpleDOMOperationResult(final Collection<RpcError> errors, final @Nullable ContainerNode output) {
+ private SimpleDOMActionResult(final Collection<RpcError> errors, final @Nullable ContainerNode output) {
this.errors = ImmutableList.copyOf(errors);
this.output = output;
}
- public SimpleDOMOperationResult(final Collection<RpcError> errors) {
+ public SimpleDOMActionResult(final Collection<RpcError> errors) {
this(errors, null);
}
- public SimpleDOMOperationResult(final ContainerNode output, final Collection<RpcError> errors) {
+ public SimpleDOMActionResult(final ContainerNode output, final Collection<RpcError> errors) {
this(errors, requireNonNull(output));
}