Class ZooDiscoveryContainer

All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IContainer, IIdentifiable, IDiscoveryAdvertiser, IDiscoveryLocator

public class ZooDiscoveryContainer extends AbstractDiscoveryContainerAdapter
  • Field Details

    • CACHED_THREAD_POOL

      public static ExecutorService CACHED_THREAD_POOL
    • advertiser

      protected org.eclipse.ecf.provider.zookeeper.core.internal.Advertiser advertiser
    • localizer

      protected org.eclipse.ecf.provider.zookeeper.core.internal.Localizer localizer
    • isQuorumPeerReady

      protected boolean isQuorumPeerReady
  • Method Details

    • autoStart

      public static boolean autoStart()
      Returns:
      true if the service is in autoStart mode.
    • getSingleton

      public static ZooDiscoveryContainer getSingleton()
    • init

      public void init(ServiceReference reference)
    • setDiscoveryProperties

      public void setDiscoveryProperties(Properties discoveryProperties)
    • getDiscoveryProperties

      public Properties getDiscoveryProperties()
    • shutdown

      public void shutdown()
    • getLocalServer

      public org.apache.zookeeper.server.ZooKeeperServer getLocalServer()
    • connect

      public void connect(ID id, IConnectContext connectContext) throws ContainerConnectException
      Description copied from interface: IContainer
      Connect to a target remote process or process group. The target identified by the first parameter (targetID) is connected the implementation class. If authentication information is required, the required information is given via via the second parameter (connectContext). Callers note that depending upon the provider implementation this method may block. It is suggested that callers use a separate thread to call this method. This method provides an implementation independent way for container implementations to connect, authenticate, and communicate with a remote service or group of services. Providers are responsible for implementing this operation in a way appropriate to the given remote service (or group) via expected protocol.
      Parameters:
      id - the ID of the remote server or group to connect to. See IContainer.getConnectNamespace() for a explanation of the constraints upon this parameter.
      connectContext - any required context to allow this container to authenticate. May be null if underlying provider does not have any authentication requirements for connection.
      Throws:
      ContainerConnectException - thrown if communication cannot be established with remote service. Causes can include network connection failure, authentication failure, server error, or if container is already connected.
    • disconnect

      public void disconnect()
      Description copied from interface: IContainer
      Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return null.
    • getConnectNamespace

      public Namespace getConnectNamespace()
      Description copied from interface: IContainer
      Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls to IContainer.connect(ID, IConnectContext). If this method returns null, then it means that null is expected as a valid parameter in subsequent calls to IContainer.connect(ID, IConnectContext). If this method returns a non-null Namespace, then the targetID parameter in IContainer.connect(ID, IConnectContext) must be non-null instance created of the returned Namespace.
      Specified by:
      getConnectNamespace in interface IContainer
      Overrides:
      getConnectNamespace in class AbstractDiscoveryContainerAdapter
      Returns:
      Namespace the namespace associated with subsequent calls to IContainer.connect(ID, IConnectContext). If null, then the targetID instances passed to IContainer.connect(ID, IConnectContext) may be null. If not null, then targetID instances passed to IContainer.connect(ID, IConnectContext) must be instances of the returned Namespace.
    • getConnectedID

      public ID getConnectedID()
      Description copied from interface: IContainer
      Get the target ID that this container instance has connected to. Returns null if not connected.
      Returns:
      ID of the target we are connected to. Returns null if container not connected.
    • getServiceInfo

      public IServiceInfo getServiceInfo(IServiceID serviceID)
      Description copied from interface: IDiscoveryLocator
      Synchronously retrieve info about the service
      Parameters:
      serviceID - IServiceID of the service to get info about. Must not be null.
      Returns:
      IServiceInfo the service info retrieved. null if no information retrievable.
    • getServiceTypes

      public IServiceTypeID[] getServiceTypes()
      Description copied from interface: IDiscoveryLocator
      Synchronously get service info about all known services of given service type
      Returns:
      IServiceTypeID[] the resulting array of service type IDs. Will not be null. May be of length 0.
    • getServices

      public IServiceInfo[] getServices()
      Description copied from interface: IDiscoveryLocator
      Synchronously get service info about all known services
      Returns:
      IServiceInfo[] the resulting array of service info instances. Will not be null. May be of length 0.
    • getServices

      public IServiceInfo[] getServices(IServiceTypeID type)
      Description copied from interface: IDiscoveryLocator
      Synchronously get service info about all known services of given service type
      Parameters:
      type - IServiceTypeID defining the type of service we are interested in getting service info about. Must not be null
      Returns:
      IServiceInfo[] the resulting array of service info instances. Will not be null. May be of length 0.
    • getServicesNamespace

      public Namespace getServicesNamespace()
      Description copied from interface: IDiscoveryLocator
      Get a Namespace for services associated with this discovery container adapter. The given Namespace may be used via IServiceIDFactory to create IServiceIDs rather than simple IDs. For example:
       IServiceID serviceID = ServiceIDFactory.getDefault().createServiceID(container.getServicesNamespace(),
                      serviceType, serviceName);
       
      Specified by:
      getServicesNamespace in interface IDiscoveryAdvertiser
      Specified by:
      getServicesNamespace in interface IDiscoveryLocator
      Overrides:
      getServicesNamespace in class AbstractDiscoveryContainerAdapter
      Returns:
      Namespace for creating service IDs. Will not be null .
    • registerService

      public void registerService(IServiceInfo serviceInfo)
      Description copied from interface: IDiscoveryAdvertiser
      Register the given service. This publishes the service defined by the serviceInfo to the underlying publishing mechanism
      Parameters:
      serviceInfo - IServiceInfo of the service to be published. Must not be null.
    • unregisterAllServices

      public void unregisterAllServices()
      Description copied from interface: IDiscoveryAdvertiser
      Unregister all previously registered service.
      Specified by:
      unregisterAllServices in interface IDiscoveryAdvertiser
      Overrides:
      unregisterAllServices in class AbstractDiscoveryContainerAdapter
      See Also:
    • unregisterService

      public void unregisterService(IServiceInfo serviceInfo)
      Description copied from interface: IDiscoveryAdvertiser
      Unregister a previously registered service defined by serviceInfo.
      Parameters:
      serviceInfo - IServiceInfo defining the service to unregister. Must not be null.
    • getAllServiceListeners

      public Collection<IServiceListener> getAllServiceListeners()
    • getServiceListenersForType

      public Collection<IServiceListener> getServiceListenersForType(IServiceTypeID type)
    • getServiceTypeListeners

      public Collection<IServiceTypeListener> getServiceTypeListeners()
    • dispose

      public void dispose()
      Description copied from interface: IContainer
      Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.
      Specified by:
      dispose in interface IContainer
      Overrides:
      dispose in class AbstractDiscoveryContainerAdapter
    • getID

      public ID getID()
      Description copied from interface: IIdentifiable
      Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May return null.
      Specified by:
      getID in interface IIdentifiable
      Overrides:
      getID in class AbstractDiscoveryContainerAdapter
      Returns:
      the ID for this identifiable object. May return null.
    • isDisposed

      public boolean isDisposed()
    • getContainerName

      public String getContainerName()
      Specified by:
      getContainerName in class AbstractDiscoveryContainerAdapter
      Returns:
      The name of this discovery container