Interface ProxyService


  • public interface ProxyService
    Manages remote proxy services and instances.

    This service can be used to make arbitrary method calls on remote objects in ONOS. The objects on which the methods are called are referred to as services and are made available to the proxy service by registering a service instance. Services must implement an interface which can be used to construct a Java proxy. Proxy interfaces may define either synchronous or asynchronous methods. Synchronous proxy methods will be blocked, and asynchronous proxy methods (which must return CompletableFuture) will be proxied using asynchronous intra-cluster communication. To make a remote call on a proxy service, get an instance of the ProxyFactory for the service type using getProxyFactory(Class, Serializer). The proxy factory is responsible for constructing proxy instances for each node in the cluster. Once a proxy instance is constructed, calls on the proxy instance will be transparently serialized and sent to the associated peer and be executed on the proxy service registered by that peer.

    • Method Detail

      • getProxyFactory

        <T> ProxyFactory<T> getProxyFactory​(Class<T> type,
                                            Serializer serializer)
        Returns a new proxy factory for the given type.

        The proxy type passed to this method must be an interface. The proxy factory can be used to construct proxy instances for different nodes in the cluster.

        Type Parameters:
        T - the proxy type
        Parameters:
        type - the proxy type
        serializer - the proxy serializer
        Returns:
        the proxy factory
        Throws:
        IllegalArgumentException - if the type is not an interface
      • registerProxyService

        <T> void registerProxyService​(Class<? super T> type,
                                      T proxy,
                                      Serializer serializer)
        Registers a proxy service.

        The proxy type passed to this method must be an interface. The proxy should be an implementation of that interface on which methods will be called when proxy calls from other nodes are received.

        Type Parameters:
        T - the proxy type
        Parameters:
        type - the proxy type
        proxy - the proxy service
        serializer - the proxy serializer
        Throws:
        IllegalArgumentException - if the type is not an interface
      • unregisterProxyService

        void unregisterProxyService​(Class<?> type)
        Unregisters the proxy service of the given type.

        Once the proxy service has been unregistered, calls to the proxy instance on this node will fail.

        Parameters:
        type - the proxy service type to unregister