Class DBSubsystem

  • All Implemented Interfaces:
    ISubsystem

    public class DBSubsystem
    extends java.lang.Object
    implements ISubsystem
    A class represents the database subsystem that manages the backend data storage. This subsystem maintains multiple sessions that allows operations to be performed, and provide a registry where all the schema information is stored.
    Version:
    $Revision$, $Date$
    Author:
    thomask
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
      • PROP_ENABLE_SERIAL_NUMBER_RECOVERY

        public static final java.lang.String PROP_ENABLE_SERIAL_NUMBER_RECOVERY
        See Also:
        Constant Field Values
      • PROP_NEXT_SERIAL_NUMBER

        public static final java.lang.String PROP_NEXT_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_MIN_SERIAL_NUMBER

        public static final java.lang.String PROP_MIN_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_MAX_SERIAL_NUMBER

        public static final java.lang.String PROP_MAX_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MIN_SERIAL_NUMBER

        public static final java.lang.String PROP_NEXT_MIN_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MAX_SERIAL_NUMBER

        public static final java.lang.String PROP_NEXT_MAX_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_SERIAL_LOW_WATER_MARK

        public static final java.lang.String PROP_SERIAL_LOW_WATER_MARK
        See Also:
        Constant Field Values
      • PROP_SERIAL_INCREMENT

        public static final java.lang.String PROP_SERIAL_INCREMENT
        See Also:
        Constant Field Values
      • PROP_SERIAL_BASEDN

        public static final java.lang.String PROP_SERIAL_BASEDN
        See Also:
        Constant Field Values
      • PROP_SERIAL_RANGE_DN

        public static final java.lang.String PROP_SERIAL_RANGE_DN
        See Also:
        Constant Field Values
      • PROP_MIN_REQUEST_NUMBER

        public static final java.lang.String PROP_MIN_REQUEST_NUMBER
        See Also:
        Constant Field Values
      • PROP_MAX_REQUEST_NUMBER

        public static final java.lang.String PROP_MAX_REQUEST_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MIN_REQUEST_NUMBER

        public static final java.lang.String PROP_NEXT_MIN_REQUEST_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MAX_REQUEST_NUMBER

        public static final java.lang.String PROP_NEXT_MAX_REQUEST_NUMBER
        See Also:
        Constant Field Values
      • PROP_REQUEST_LOW_WATER_MARK

        public static final java.lang.String PROP_REQUEST_LOW_WATER_MARK
        See Also:
        Constant Field Values
      • PROP_REQUEST_INCREMENT

        public static final java.lang.String PROP_REQUEST_INCREMENT
        See Also:
        Constant Field Values
      • PROP_REQUEST_BASEDN

        public static final java.lang.String PROP_REQUEST_BASEDN
        See Also:
        Constant Field Values
      • PROP_REQUEST_RANGE_DN

        public static final java.lang.String PROP_REQUEST_RANGE_DN
        See Also:
        Constant Field Values
      • PROP_MIN_REPLICA_NUMBER

        public static final java.lang.String PROP_MIN_REPLICA_NUMBER
        See Also:
        Constant Field Values
      • PROP_MAX_REPLICA_NUMBER

        public static final java.lang.String PROP_MAX_REPLICA_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MIN_REPLICA_NUMBER

        public static final java.lang.String PROP_NEXT_MIN_REPLICA_NUMBER
        See Also:
        Constant Field Values
      • PROP_NEXT_MAX_REPLICA_NUMBER

        public static final java.lang.String PROP_NEXT_MAX_REPLICA_NUMBER
        See Also:
        Constant Field Values
      • PROP_REPLICA_LOW_WATER_MARK

        public static final java.lang.String PROP_REPLICA_LOW_WATER_MARK
        See Also:
        Constant Field Values
      • PROP_REPLICA_INCREMENT

        public static final java.lang.String PROP_REPLICA_INCREMENT
        See Also:
        Constant Field Values
      • PROP_REPLICA_BASEDN

        public static final java.lang.String PROP_REPLICA_BASEDN
        See Also:
        Constant Field Values
      • PROP_REPLICA_RANGE_DN

        public static final java.lang.String PROP_REPLICA_RANGE_DN
        See Also:
        Constant Field Values
      • PROP_INFINITE_SERIAL_NUMBER

        public static final java.lang.String PROP_INFINITE_SERIAL_NUMBER
        See Also:
        Constant Field Values
      • PROP_INFINITE_REQUEST_NUMBER

        public static final java.lang.String PROP_INFINITE_REQUEST_NUMBER
        See Also:
        Constant Field Values
      • PROP_INFINITE_REPLICA_NUMBER

        public static final java.lang.String PROP_INFINITE_REPLICA_NUMBER
        See Also:
        Constant Field Values
      • PROP_ENABLE_SERIAL_MGMT

        public static final java.lang.String PROP_ENABLE_SERIAL_MGMT
        See Also:
        Constant Field Values
    • Constructor Detail

      • DBSubsystem

        public DBSubsystem()
        Constructs database subsystem.
    • Method Detail

      • getInstance

        public static DBSubsystem getInstance()
      • setInstance

        public static void setInstance​(DBSubsystem dbSubsystem)
        This method is used for unit tests. It allows the underlying instance to be stubbed out.
        Parameters:
        dbSubsystem - The stubbed out subsystem to override with.
      • getId

        public java.lang.String getId()
        Retrieves subsystem identifier.
        Specified by:
        getId in interface ISubsystem
        Returns:
        subsystem identifier
      • setId

        public void setId​(java.lang.String id)
                   throws EBaseException
        Sets subsystem identifier.
        Specified by:
        setId in interface ISubsystem
        Parameters:
        id - subsystem identifier
        Throws:
        EBaseException - failed to set id
      • enableSerialNumberRecovery

        public boolean enableSerialNumberRecovery()
      • getEnableSerialMgmt

        public boolean getEnableSerialMgmt()
      • getNextSerialConfig

        public java.math.BigInteger getNextSerialConfig()
      • getMinSerialConfig

        public java.lang.String getMinSerialConfig​(int repo)
        Gets minimum serial number limit in config file
        Parameters:
        repo - repo identifier
        Returns:
        min serial number
      • getMaxSerialConfig

        public java.lang.String getMaxSerialConfig​(int repo)
        Gets maximum serial number limit in config file
        Parameters:
        repo - repo identifier
        Returns:
        max serial number
      • getNextMinSerialConfig

        public java.lang.String getNextMinSerialConfig​(int repo)
        Gets minimum serial number limit in next range in config file
        Parameters:
        repo - repo identifier
        Returns:
        min serial number in next range
      • getNextMaxSerialConfig

        public java.lang.String getNextMaxSerialConfig​(int repo)
        Gets maximum serial number limit in next range in config file
        Parameters:
        repo - repo identifier
        Returns:
        max serial number in next range
      • getLowWaterMarkConfig

        public java.lang.String getLowWaterMarkConfig​(int repo)
        Gets low water mark limit in config file
        Parameters:
        repo - repo identifier
        Returns:
        low water mark
      • getIncrementConfig

        public java.lang.String getIncrementConfig​(int repo)
        Gets range increment for next range in config file
        Parameters:
        repo - repo identifier
        Returns:
        range increment
      • setMaxSerialConfig

        public void setMaxSerialConfig​(int repo,
                                       java.lang.String serial)
                                throws EBaseException
        Sets maximum serial number limit in config file
        Parameters:
        repo - repo identifier
        serial - max serial number
        Throws:
        EBaseException - failed to set
      • setMinSerialConfig

        public void setMinSerialConfig​(int repo,
                                       java.lang.String serial)
                                throws EBaseException
        Sets minimum serial number limit in config file
        Parameters:
        repo - repo identifier
        serial - min serial number
        Throws:
        EBaseException - failed to set
      • setNextMaxSerialConfig

        public void setNextMaxSerialConfig​(int repo,
                                           java.lang.String serial)
                                    throws EBaseException
        Sets maximum serial number limit for next range in config file
        Parameters:
        repo - repo identifier
        serial - max serial number for next range
        Throws:
        EBaseException - failed to set
      • setNextMinSerialConfig

        public void setNextMinSerialConfig​(int repo,
                                           java.lang.String serial)
                                    throws EBaseException
        Sets minimum serial number limit for next range in config file
        Parameters:
        repo - repo identifier
        serial - min serial number for next range
        Throws:
        EBaseException - failed to set
      • getNextRange

        public java.lang.String getNextRange​(int repo)
        Gets start of next range from database. Increments the nextRange attribute and allocates this range to the current instance by creating a pkiRange object.
        Parameters:
        repo - repo identifier
        Returns:
        start of next range
      • hasRangeConflict

        public boolean hasRangeConflict​(int repo)
        Determines if a range conflict has been observed in database. If so, delete the conflict entry and remove the next range. When the next number is requested, if the number of certs is still below the low water mark, then a new range will be requested.
        Parameters:
        repo - repo identifier
        Returns:
        true if range conflict, false otherwise
      • init

        public void init​(IConfigStore config)
                  throws EBaseException
        Initializes the internal registery. Connects to the data source, and create a pool of connection of which applications can use. Optionally, check the integrity of the database.
        Specified by:
        init in interface ISubsystem
        Parameters:
        config - configuration store
        Throws:
        EBaseException - failed to initialize
      • getEntryAttribute

        public java.lang.String getEntryAttribute​(java.lang.String dn,
                                                  java.lang.String attrName,
                                                  java.lang.String defaultValue,
                                                  java.lang.String errorValue)
      • getConfigStore

        public LDAPConfig getConfigStore()
        Retrieves internal DB configuration store.
        Specified by:
        getConfigStore in interface ISubsystem
        Returns:
        configuration store of this subsystem
      • getDBConfigStore

        public DatabaseConfig getDBConfigStore()
        Retrieves DB subsystem configuration store.
      • getBaseDN

        public java.lang.String getBaseDN()
        Retrieves base DN of backend database.
      • getLdapConnInfo

        public LdapConnInfo getLdapConnInfo()
        Retrieves LDAP connection info (host, port, secure)
      • shutdown

        public void shutdown()
        Shutdowns this subsystem gracefully.
        Specified by:
        shutdown in interface ISubsystem
      • getRegistry

        public IDBRegistry getRegistry()
        Retrieves the registry.
      • returnConn

        public void returnConn​(netscape.ldap.LDAPConnection conn)