private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs, final Collection<YangInstanceIdentifier> paths) { final Set<DOMRpcIdentifier> ret = new HashSet<>(); for (final YangInstanceIdentifier path : paths) { for (final SchemaPath rpc : rpcs) { ret.add(DOMRpcIdentifier.create(rpc, path)); } } return ret; }
private static ListMultimap<SchemaPath, YangInstanceIdentifier> decomposeIdentifiers(final Set<DOMRpcIdentifier> rpcs) { final ListMultimap<SchemaPath, YangInstanceIdentifier> ret = LinkedListMultimap.create(); for (DOMRpcIdentifier i : rpcs) { ret.put(i.getType(), i.getContextReference()); } return ret; }
private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) { super(rpcId.getType(), impls); this.rpcId = Preconditions.checkNotNull(rpcId); }
@Override public final String toString() { return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString(); } }
/** * This method is invoked on RPC invocation of the registered method. * rpc(localname) is used to invoke the correct requested method. */ @Override public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(DOMRpcIdentifier rpc, NormalizedNode<?, ?> input) { if (rpc.equals(CREATE_SUBSCRIPTION_RPC)) { LOG.debug("This is a create subscription RPC"); return createSubscriptionRpcHandler(input); } else if (rpc.equals(MODIFY_SUBSCRIPTION_RPC)) { LOG.info("This is a modify subscrition RPC. Not supported ..."); } else if (rpc.equals(DELETE_SUBSCRIPTION_RPC)) { deleteSubscriptionRpcHandler(input); } else { LOG.info("Unknown RPC..."); } return Futures.immediateCheckedFuture((DOMRpcResult) new DefaultDOMRpcResult()); }
private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) { super(globalRpcId.getType(), impls); this.keyId = Preconditions.checkNotNull(keyId); this.globalRpcId = Preconditions.checkNotNull(globalRpcId); }
@Override public final boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof DOMRpcIdentifier)) { return false; } DOMRpcIdentifier other = (DOMRpcIdentifier) obj; if (!type.equals(other.type)) { return false; } return Objects.equals(getContextReference(), other.getContextReference()); }
boolean contains(final DOMRpcIdentifier input) { final AbstractDOMRpcRoutingTableEntry contexts = rpcs.get(input.getType()); return contexts != null && contexts.containsContext(input.getContextReference()); }
@Override public DOMRpcIdentifier apply(final RpcDefinition input) { // TODO add support for routed rpcs ... is it necessary in this case ? return DOMRpcIdentifier.create(input.getPath()); } };
protected void onRpcsAvailable(Collection<DOMRpcIdentifier> rpcs) { for(DOMRpcIdentifier identifier: rpcs) { if(rpcSchemaPaths.contains(identifier.getType())) { LOG.debug("{}: onRpcsAvailable - found SchemaPath {}", logName(), identifier.getType()); retrieveService("RpcProviderRegistry", RpcProviderRegistry.class, service -> { rpcRegistry = (RpcProviderRegistry)service; setSatisfied(); }); break; } } }
public org.opendaylight.mdsal.dom.api.DOMRpcIdentifier toMdsal() { return org.opendaylight.mdsal.dom.api.DOMRpcIdentifier.create(type, getContextReference()); }
@Override public void onRpcAvailable(@Nonnull final Collection<DOMRpcIdentifier> rpcs) { Preconditions.checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); if (LOG.isDebugEnabled()) { LOG.debug("Adding registration for [{}]", rpcs); } final List<RpcRouter.RouteIdentifier<?,?,?>> routeIds = new ArrayList<>(); for (final DOMRpcIdentifier rpc : rpcs) { final RpcRouter.RouteIdentifier<?,?,?> routeId = new RouteIdentifierImpl(null, rpc.getType().getLastComponent(), rpc.getContextReference()); routeIds.add(routeId); } final RpcRegistry.Messages.AddOrUpdateRoutes addRpcMsg = new RpcRegistry.Messages.AddOrUpdateRoutes(routeIds); rpcRegistry.tell(addRpcMsg, ActorRef.noSender()); }
RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) { super(def.getPath(), impls); this.keyId = Preconditions.checkNotNull(keyId); this.globalRpcId = DOMRpcIdentifier.create(def.getPath()); }
@Override public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) { final SchemaPath schemaPath = rpc.getType(); final DataObject bindingInput = input != null ? deserilialize(rpc.getType(),input) : null; final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath,bindingInput); return transformResult(schemaPath,bindingResult); }
@Override public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + type.hashCode(); result = prime * result + getContextReference().hashCode(); return result; }
@Override public void onRpcUnavailable(@Nonnull final Collection<DOMRpcIdentifier> rpcs) { Preconditions.checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null."); if(LOG.isDebugEnabled()) { LOG.debug("Removing registration for [{}]", rpcs); } final List<RpcRouter.RouteIdentifier<?,?,?>> routeIds = new ArrayList<>(); for (final DOMRpcIdentifier rpc : rpcs) { final RpcRouter.RouteIdentifier<?,?,?> routeId = new RouteIdentifierImpl(null, rpc.getType().getLastComponent(), rpc.getContextReference()); routeIds.add(routeId); } final RpcRegistry.Messages.RemoveRoutes removeRpcMsg = new RpcRegistry.Messages.RemoveRoutes(routeIds); rpcRegistry.tell(removeRpcMsg, ActorRef.noSender()); } }
/** * Add all the locally registered RPCs in the clustered routing table */ private void announceSupportedRpcs(){ LOG.debug("Adding all supported rpcs to routing table"); final Set<RpcDefinition> currentlySupportedRpc = schemaContext.getOperations(); final List<DOMRpcIdentifier> rpcs = new ArrayList<>(); for (final RpcDefinition rpcDef : currentlySupportedRpc) { rpcs.add(DOMRpcIdentifier.create(rpcDef.getPath())); } if(!rpcs.isEmpty()) { rpcListener.onRpcAvailable(rpcs); } }
public static ExecuteRpc from(final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) { final Node serializedInput; if(input != null) { serializedInput = NormalizedNodeSerializer.serialize(input); } else { serializedInput = null; } return new ExecuteRpc(serializedInput, rpc.getType().getLastComponent()); }
@SuppressWarnings({"unchecked", "rawtypes"}) private Future<FindRoutersReply> findRouteAsync(final DOMRpcIdentifier rpc) { // FIXME: Refactor routeId and message to use DOMRpcIdentifier directly. final RpcRouter.RouteIdentifier<?, ?, ?> routeId = new RouteIdentifierImpl(null, rpc.getType().getLastComponent(), rpc.getContextReference()); final RpcRegistry.Messages.FindRouters findMsg = new RpcRegistry.Messages.FindRouters(routeId); return (Future) ask(rpcRegistry, findMsg, config.getAskDuration()); } }
public static DOMRpcIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier mdsal) { return create(mdsal.getType(), mdsal.getContextReference()); }