## org.apache.cassandra.service
Class AbstractCassandraDaemon

    java.lang.Object
      org.apache.cassandra.service.AbstractCassandraDaemon

All Implemented Interfaces:
  CassandraDaemon

Direct Known Subclasses:
  CassandraDaemon

    public abstract class AbstractCassandraDaemon

extends java.lang.Object
implements CassandraDaemon

The `CassandraDaemon` is an abstraction for a Cassandra daemon service, which defines not only a way to activate and deactivate it, but also hooks into its lifecycle methods (see `setup()`, `start()`, `stop()` and `setup()`).

Nested Class Summary
`static class` `AbstractCassandraDaemon.CleaningThreadPool` A subclass of Java's ThreadPoolExecutor which implements Jetty's ThreadPool interface (for integration with Avro), and performs ClientState cleanup.

Field Summary
`protected boolean` `isRunning`
`protected java.net.InetAddress` `listenAddr`
`protected int` `listenPort`

Constructor Summary
`AbstractCassandraDaemon()`

Method Summary
`void` `activate()` A convenience method to initialize and start the daemon in one shot.
`void` `deactivate()` A convenience method to stop and destroy the daemon in one shot.
`void` `destroy()` Clean up all resources obtained during the lifetime of the daemon.
`void` `init(java.lang.String[] arguments)` Initialize the Cassandra Daemon based on the given Commons Daemon-specific arguments.
`static void` `initLog4j()` Initialize logging in such a way that it checks for config changes every 10 seconds.
`boolean` `isRPCServerRunning()` Returns whether the underlying RPC server is running or not.
`protected void` `setup()` This is a hook for concrete daemons to initialize themselves suitably.
`void` `start()` Start the Cassandra Daemon, assuming that it has already been initialized via `init(String[])` Hook for JSVC
`void` `startRPCServer()` Start the underlying RPC server in idempotent manner.
`protected abstract void` `startServer()` Start the underlying RPC server.
`void` `stop()` Stop the daemon, ideally in an idempotent manner.
`void` `stopRPCServer()` Stop the underlying RPC server in idempotent manner.
`protected abstract void` `stopServer()` Stop the underlying RPC server.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### listenAddr

    protected java.net.InetAddress listenAddr

### listenPort

    protected int listenPort

### isRunning

    protected volatile boolean isRunning

Constructor Detail

### AbstractCassandraDaemon

    public AbstractCassandraDaemon()

Method Detail

### initLog4j

    public static void initLog4j()

  Initialize logging in such a way that it checks for config changes every 10 seconds.

### setup

    protected void setup()
                  throws java.io.IOException

  This is a hook for concrete daemons to initialize themselves suitably. Subclasses should override this to finish the job (listening on ports, etc.)

  Throws:
    `java.io.IOException`

### init

    public void init(java.lang.String[] arguments)
              throws java.io.IOException

  Initialize the Cassandra Daemon based on the given Commons Daemon-specific arguments. To clarify, this is a hook for JSVC.

  Specified by:
    `init` in interface `CassandraDaemon`
  Parameters:
    `arguments` - the arguments passed in from JSVC
  Throws:
    `java.io.IOException`

### start

    public void start()

  Start the Cassandra Daemon, assuming that it has already been initialized via `init(String[])` Hook for JSVC

  Specified by:
    `start` in interface `CassandraDaemon`
  Throws:
    `java.io.IOException`

### stop

    public void stop()

  Stop the daemon, ideally in an idempotent manner. Hook for JSVC

  Specified by:
    `stop` in interface `CassandraDaemon`

### startRPCServer

    public void startRPCServer()

  Start the underlying RPC server in idempotent manner.

  Specified by:
    `startRPCServer` in interface `CassandraDaemon`

### stopRPCServer

    public void stopRPCServer()

  Stop the underlying RPC server in idempotent manner.

  Specified by:
    `stopRPCServer` in interface `CassandraDaemon`

### isRPCServerRunning

    public boolean isRPCServerRunning()

  Returns whether the underlying RPC server is running or not.

  Specified by:
    `isRPCServerRunning` in interface `CassandraDaemon`

### startServer

    protected abstract void startServer()

  Start the underlying RPC server. This method shoud be able to restart a server stopped through stopServer(). Should throw a RuntimeException if the server cannot be started

### stopServer

    protected abstract void stopServer()

  Stop the underlying RPC server. This method should be able to stop server started through startServer(). Should throw a RuntimeException if the server cannot be stopped

### destroy

    public void destroy()

  Clean up all resources obtained during the lifetime of the daemon. This is a hook for JSVC.

  Specified by:
    `destroy` in interface `CassandraDaemon`

### activate

    public void activate()

  A convenience method to initialize and start the daemon in one shot.

  Specified by:
    `activate` in interface `CassandraDaemon`

### deactivate

    public void deactivate()

  A convenience method to stop and destroy the daemon in one shot.

  Specified by:
    `deactivate` in interface `CassandraDaemon`

Copyright © 2012 The Apache Software Foundation