Class ServiceActor<T extends ServiceActor>

java.lang.Object
org.nustaq.kontraktor.Actors
org.nustaq.kontraktor.Actor<T>
org.nustaq.kontraktor.services.ServiceActor<T>
All Implemented Interfaces:
Serializable, Executor, org.nustaq.kontraktor.monitoring.Monitorable
Direct Known Subclasses:
DataShard, DynDataShard, PlainService, RLJsonServerService

public abstract class ServiceActor<T extends ServiceActor> extends org.nustaq.kontraktor.Actor<T>
Created by ruedi on 12.08.2015.
See Also:
  • Field Details

    • REGISTRY_DISCONNECTED

      public static final String REGISTRY_DISCONNECTED
      See Also:
    • REGISTRY_RECONNECTED

      public static final String REGISTRY_RECONNECTED
      See Also:
    • DEFAULT_START_TIMEOUT

      public static int DEFAULT_START_TIMEOUT
    • UNCONNECTED

      public static final String UNCONNECTED
      See Also:
    • serviceRegistry

      protected org.nustaq.kontraktor.remoting.base.ReconnectableRemoteRef<ServiceRegistry> serviceRegistry
    • requiredServices

      protected Map<String,Object> requiredServices
    • config

      protected ClusterCfg config
    • serviceDescription

      protected org.nustaq.kontraktor.remoting.base.ServiceDescription serviceDescription
    • cmdline

      protected ServiceArgs cmdline
    • dclient

      protected DataClient dclient
    • currentDistribution

      protected org.nustaq.reallive.server.dynamic.DynClusterDistribution currentDistribution
  • Constructor Details

    • ServiceActor

      public ServiceActor()
  • Method Details

    • RunTCP

      public static ServiceActor RunTCP(String[] args, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz)
    • RunTCP

      public static ServiceActor RunTCP(String[] args, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz, Class<? extends ServiceRegistry> serviceRegistryClass)
    • RunTCP

      public static ServiceActor RunTCP(String[] args, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz, long timeout)
    • RunTCP

      public static ServiceActor RunTCP(String[] args, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceArgs> argsClazz, Class<? extends ServiceRegistry> serviceRegistryClass, long timeout)
      run & connect a service with given cmdline args and classes
      Parameters:
      args -
      serviceClazz -
      argsClazz -
      Returns:
      Throws:
      IllegalAccessException
      InstantiationException
    • RunTCP

      public static ServiceActor RunTCP(ServiceArgs options, Class<? extends ServiceActor> serviceClazz, long timeout)
    • RunTCP

      public static ServiceActor RunTCP(ServiceArgs options, Class<? extends ServiceActor> serviceClazz, Class<? extends ServiceRegistry> serviceRegistryClass, long timeout)
    • init

      public org.nustaq.kontraktor.IPromise<Void> init(org.nustaq.kontraktor.remoting.base.ConnectableActor registryConnectable, ServiceArgs options, boolean autoRegister)
    • addServiceEventListener

      public void addServiceEventListener(BiConsumer<String,Object> l)
      runs on client side, receives forwarded service event received from service actor
      Parameters:
      l -
    • removeServiceEventListener

      public void removeServiceEventListener(BiConsumer<String,Object> l)
    • getServiceRegistry

      public ServiceRegistry getServiceRegistry()
    • fireServiceEvent

      protected void fireServiceEvent(String ev, Object arg)
    • onRegistryDisconnected

      protected void onRegistryDisconnected()
    • onRegistryConnected

      protected void onRegistryConnected(boolean autoRegister)
    • onServiceRegistryReconnected

      protected void onServiceRegistryReconnected()
    • awaitRequiredServices

      protected org.nustaq.kontraktor.IPromise<Void> awaitRequiredServices()
    • awaitRequiredServicesInternal

      protected void awaitRequiredServicesInternal(org.nustaq.kontraktor.IPromise<Void> p)
    • initRealLiveDynamic

      protected void initRealLiveDynamic()
    • old_initRealLiveDynamic

      protected void old_initRealLiveDynamic()
    • InitRealLiveDynamic

      public static DynDataClient InitRealLiveDynamic(org.nustaq.reallive.server.dynamic.DynClusterDistribution currentDistribution, ServiceRegistry serviceRegistry, Function<String,DynDataShard> serviceMapper, ServiceActor hostingService, DataCfg schema)
    • initRealLiveFixed

      protected void initRealLiveFixed()
    • getConfig

      public org.nustaq.kontraktor.IPromise<ClusterCfg> getConfig()
    • getDataClient

      public org.nustaq.kontraktor.IPromise<DataClient> getDataClient()
    • registerSelf

      protected void registerSelf()
      register at service registry
    • publishSelf

      protected void publishSelf()
    • getPort

      protected int getPort()
      Returns:
      port this service wants to expose (with default tcp exposure)
    • getHost

      protected String getHost()
      Returns:
      host this service wants to expose on (with default tcp exposure)
    • getCmdline

      protected ServiceArgs getCmdline()
    • getAllServiceNames

      protected String[] getAllServiceNames()
    • isFixedDataCluster

      protected boolean isFixedDataCluster()
    • isDynamicDataCluster

      protected boolean isDynamicDataCluster()
    • getRequiredServiceNames

      protected abstract String[] getRequiredServiceNames()
    • serviceEvent

      protected void serviceEvent(String eventId, Object cdr, Object err)
    • notifyConfigChanged

      protected void notifyConfigChanged()
      override, config contains updated ClusterCfg
    • requiredSerivceWentDown

      protected void requiredSerivceWentDown(org.nustaq.kontraktor.remoting.base.ServiceDescription cdr)
    • getService

      protected <T extends org.nustaq.kontraktor.Actor> T getService(String name)
    • connectRequiredServices

      public org.nustaq.kontraktor.IPromise connectRequiredServices()
      try to connect required (unconnected) services, in case of failur UNCONNECTED is put into service hashmap instead
      Returns:
    • connectService

      protected org.nustaq.kontraktor.IPromise<org.nustaq.kontraktor.Actor> connectService(org.nustaq.kontraktor.remoting.base.ServiceDescription serviceDescription)
    • serviceDisconnected

      protected void serviceDisconnected(org.nustaq.kontraktor.Actor act)
    • heartBeat

      public void heartBeat()
    • getStatus

      protected Serializable getStatus()
    • gravityDisconnected

      protected void gravityDisconnected()
    • createServiceDescription

      protected abstract org.nustaq.kontraktor.remoting.base.ServiceDescription createServiceDescription()
    • getServiceDescription

      protected org.nustaq.kontraktor.remoting.base.ServiceDescription getServiceDescription()
    • createDefaultConnectable

      protected org.nustaq.kontraktor.remoting.base.ConnectableActor createDefaultConnectable()