org.exist.storage
Class BrokerPool

java.lang.Object
  extended byorg.exist.storage.BrokerPool

public class BrokerPool
extends java.lang.Object

This class controls all available instances of the database. Use it to configure, start and stop database instances. You may have multiple instances defined, each using its own configuration, database directory etc.. To define multiple instances, pass an identification string to the static method configure() and use getInstance(id) to retrieve an instance.

Author:
Wolfgang Meier

Nested Class Summary
protected  class BrokerPool.ShutdownThread
           
 
Field Summary
protected  Configuration conf
           
static java.lang.String DEFAULT_INSTANCE
           
 
Constructor Summary
BrokerPool(java.lang.String id, int minBrokers, int maxBrokers, Configuration config)
          Constructor for the BrokerPool object
 
Method Summary
 int active()
          Number of active Brokers in this pool.
 int available()
          Number of available Brokers in this pool.
static void configure(int minBrokers, int maxBrokers, Configuration config)
           
static void configure(java.lang.String id, int minBrokers, int maxBrokers, Configuration config)
          Configure a new BrokerPool instance.
protected  DBBroker createBroker()
          Description of the Method
 DBBroker get()
          Get a DBBroker instance from the pool.
 Configuration getConfiguration()
           
 java.lang.String getId()
           
static BrokerPool getInstance()
           
static BrokerPool getInstance(java.lang.String id)
          Singleton method.
static java.util.Iterator getInstances()
           
 int getMax()
          Returns maximum of concurrent Brokers.
 SecurityManager getSecurityManager()
          Returns the security manager responsible for this pool
protected  void initialize()
          Initialize the current instance.
static boolean isConfigured()
           
static boolean isConfigured(java.lang.String id)
           
 boolean isInstanceConfigured()
          Has this BrokerPool been configured?
 void registerShutdownListener(ShutdownListener listener)
           
 void release(DBBroker broker)
          Release a DBBroker instance into the pool.
 void reloadSecurityManager(DBBroker broker)
          Reload the security manager.
 void shutdown()
          Shutdown all brokers.
static void stop()
           
static void stop(java.lang.String id)
          Shutdown running brokers.
static void stopAll()
           
 void sync(DBBroker broker)
          Write buffers to disk.
 void triggerSync()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INSTANCE

public static final java.lang.String DEFAULT_INSTANCE
See Also:
Constant Field Values

conf

protected Configuration conf
Constructor Detail

BrokerPool

public BrokerPool(java.lang.String id,
                  int minBrokers,
                  int maxBrokers,
                  Configuration config)
           throws EXistException
Constructor for the BrokerPool object

Throws:
EXistException - Description of the Exception
Method Detail

configure

public static final void configure(int minBrokers,
                                   int maxBrokers,
                                   Configuration config)
                            throws EXistException
Throws:
EXistException

configure

public static final void configure(java.lang.String id,
                                   int minBrokers,
                                   int maxBrokers,
                                   Configuration config)
                            throws EXistException
Configure a new BrokerPool instance. Call this before calling getInstance().

Parameters:
id - The name to identify this database instance. You may have more than one instance with different configurations.
minBrokers - Minimum number of database brokers to start during initialization.
maxBrokers - Maximum number of database brokers available to handle requests.
config - The configuration object used by this instance.
Throws:
EXistException - thrown if initialization fails.

isConfigured

public static final boolean isConfigured(java.lang.String id)

isConfigured

public static final boolean isConfigured()

getInstance

public static final BrokerPool getInstance(java.lang.String id)
                                    throws EXistException
Singleton method. Get the BrokerPool for a specified database instance.

Returns:
The instance.
Throws:
EXistException - thrown if the instance has not been configured.

getInstance

public static final BrokerPool getInstance()
                                    throws EXistException
Throws:
EXistException

getInstances

public static final java.util.Iterator getInstances()

stop

public static final void stop(java.lang.String id)
                       throws EXistException
Shutdown running brokers. After calling this method, the BrokerPool is no longer configured. You have to configure it again by calling configure().

Throws:
EXistException

stop

public static final void stop()
                       throws EXistException
Throws:
EXistException

stopAll

public static final void stopAll()

active

public int active()
Number of active Brokers in this pool.

Returns:
Description of the Return Value

available

public int available()
Number of available Brokers in this pool.

Returns:
Description of the Return Value

getConfiguration

public Configuration getConfiguration()

createBroker

protected DBBroker createBroker()
                         throws EXistException
Description of the Method

Returns:
Description of the Return Value
Throws:
EXistException - Description of the Exception

get

public DBBroker get()
             throws EXistException
Get a DBBroker instance from the pool.

Returns:
Description of the Return Value
Throws:
EXistException - Description of the Exception

getSecurityManager

public SecurityManager getSecurityManager()
Returns the security manager responsible for this pool

Returns:
The securityManager value

reloadSecurityManager

public void reloadSecurityManager(DBBroker broker)
Reload the security manager. This method is called whenever the users.xml file has been changed.

Parameters:
broker -

initialize

protected void initialize()
                   throws EXistException
Initialize the current instance.

Throws:
EXistException - Description of the Exception

release

public void release(DBBroker broker)
Release a DBBroker instance into the pool. If all active instances are in the pool (i.e. the database is currently not used), release will call sync() to flush unwritten buffers to the disk.

Parameters:
broker - Description of the Parameter

sync

public void sync(DBBroker broker)
Write buffers to disk. release() calls this method after a specified period of time to flush buffers.

Parameters:
broker -

shutdown

public void shutdown()
Shutdown all brokers.


getMax

public int getMax()
Returns maximum of concurrent Brokers.

Returns:
The max value

getId

public java.lang.String getId()

isInstanceConfigured

public final boolean isInstanceConfigured()
Has this BrokerPool been configured?

Returns:
The configured value

triggerSync

public void triggerSync()

registerShutdownListener

public void registerShutdownListener(ShutdownListener listener)


Copyright (C) Wolfgang Meier. All rights reserved.