Class AbstractLifecycleComponent

java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
All Implemented Interfaces:
Closeable, AutoCloseable, LifecycleComponent, Releasable
Direct Known Subclasses:
AbstractFileWatchingService, AbstractHttpServerTransport, BlobStoreRepository, CircuitBreakerService, ClusterApplierService, ClusterService, Coordinator, DelayedAllocationService, FsHealthService, GatewayService, HealthPeriodicLogger, IndicesClusterStateService, IndicesService, InvalidRepository, JvmGcMonitorService, MasterService, MonitorService, NodeConnectionsService, NodeMetrics, PeerRecoverySourceService, ReadinessService, RepositoriesService, SearchService, SeedHostsResolver, SnapshotShardsService, SnapshotsService, TcpTransport, TimestampFieldMapperService, TransportService, UnknownTypeRepository

public abstract class AbstractLifecycleComponent extends Object implements LifecycleComponent
A component with a Lifecycle which is used to link its start and stop activities to those of the Elasticsearch node which contains it.
  • Field Details

    • lifecycle

      protected final Lifecycle lifecycle
  • Constructor Details

    • AbstractLifecycleComponent

      protected AbstractLifecycleComponent()
      Initialize this component. Other components may not yet exist when this constructor is called.
  • Method Details

    • lifecycleState

      public Lifecycle.State lifecycleState()
      Specified by:
      lifecycleState in interface LifecycleComponent
    • addLifecycleListener

      public void addLifecycleListener(LifecycleListener listener)
      Specified by:
      addLifecycleListener in interface LifecycleComponent
    • start

      public final void start()
      Specified by:
      start in interface LifecycleComponent
    • doStart

      protected abstract void doStart()
      Start this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.

      If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.

      This method is called while synchronized on lifecycle. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.

    • stop

      public final void stop()
      Specified by:
      stop in interface LifecycleComponent
    • doStop

      protected abstract void doStop()
      Stop this component. Typically that means doing the reverse of whatever doStart() does.

      This method is called while synchronized on lifecycle. It is only called once in the lifetime of a component, after calling doStart(), although it will not be called at all if this component did not successfully start.

    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Releasable
    • doClose

      protected abstract void doClose() throws IOException
      Close this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.

      This method is called while synchronized on lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.

      Throws:
      IOException