Interface MastershipProxyService


  • public interface MastershipProxyService
    Manages remote mastership-based 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 MastershipProxyFactory 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 master node for the associated device and will be executed on the proxy service registered by that node.

    • Method Detail

      • getProxyFactory

        <T> MastershipProxyFactory<T> getProxyFactory​(java.lang.Class<T> type,
                                                      Serializer serializer)
        Returns a 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 mastership-based proxy instances for different devices.

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

        <T> void registerProxyService​(java.lang.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:
        java.lang.IllegalArgumentException - if the type is not an interface
      • unregisterProxyService

        void unregisterProxyService​(java.lang.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