Package com.netscape.cmscore.dbs
Class DBSubsystem
- java.lang.Object
-
- com.netscape.cmscore.dbs.DBSubsystem
-
public class DBSubsystem extends java.lang.Object
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 Summary
Fields Modifier and Type Field Description static int
CERTS
static java.lang.String
ID
static org.slf4j.Logger
logger
static int
NUM_REPOS
static java.lang.String
PROP_ENABLE_SERIAL_MGMT
static java.lang.String
PROP_ENABLE_SERIAL_NUMBER_RECOVERY
static java.lang.String
PROP_INFINITE_REPLICA_NUMBER
static java.lang.String
PROP_INFINITE_REQUEST_NUMBER
static java.lang.String
PROP_INFINITE_SERIAL_NUMBER
static java.lang.String
PROP_MAX_REPLICA_NUMBER
static java.lang.String
PROP_MAX_REQUEST_NUMBER
static java.lang.String
PROP_MAX_SERIAL_NUMBER
static java.lang.String
PROP_MIN_REPLICA_NUMBER
static java.lang.String
PROP_MIN_REQUEST_NUMBER
static java.lang.String
PROP_MIN_SERIAL_NUMBER
static java.lang.String
PROP_NEXT_MAX_REPLICA_NUMBER
static java.lang.String
PROP_NEXT_MAX_REQUEST_NUMBER
static java.lang.String
PROP_NEXT_MAX_SERIAL_NUMBER
static java.lang.String
PROP_NEXT_MIN_REPLICA_NUMBER
static java.lang.String
PROP_NEXT_MIN_REQUEST_NUMBER
static java.lang.String
PROP_NEXT_MIN_SERIAL_NUMBER
static java.lang.String
PROP_NEXT_SERIAL_NUMBER
static java.lang.String
PROP_REPLICA_BASEDN
static java.lang.String
PROP_REPLICA_INCREMENT
static java.lang.String
PROP_REPLICA_LOW_WATER_MARK
static java.lang.String
PROP_REPLICA_RANGE_DN
static java.lang.String
PROP_REQUEST_BASEDN
static java.lang.String
PROP_REQUEST_INCREMENT
static java.lang.String
PROP_REQUEST_LOW_WATER_MARK
static java.lang.String
PROP_REQUEST_RANGE_DN
static java.lang.String
PROP_SERIAL_BASEDN
static java.lang.String
PROP_SERIAL_INCREMENT
static java.lang.String
PROP_SERIAL_LOW_WATER_MARK
static java.lang.String
PROP_SERIAL_RANGE_DN
static int
REPLICA_ID
static int
REQUESTS
-
Constructor Summary
Constructors Constructor Description DBSubsystem()
Constructs database subsystem.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IDBSSession
createSession()
Creates a database session.boolean
enableSerialNumberRecovery()
java.lang.String
getBaseDN()
Retrieves base DN of backend database.LDAPConfig
getConfigStore()
Retrieves internal DB configuration store.DatabaseConfig
getDBConfigStore()
Retrieves DB subsystem configuration store.boolean
getEnableSerialMgmt()
java.lang.String
getEntryAttribute(java.lang.String dn, java.lang.String attrName, java.lang.String defaultValue, java.lang.String errorValue)
java.lang.String
getId()
Retrieves subsystem identifier.java.lang.String
getIncrementConfig(int repo)
Gets range increment for next range in config filestatic DBSubsystem
getInstance()
LdapAuthInfo
getLdapAuthInfo()
LdapConnInfo
getLdapConnInfo()
Retrieves LDAP connection info (host, port, secure)java.lang.String
getLowWaterMarkConfig(int repo)
Gets low water mark limit in config filejava.lang.String
getMaxSerialConfig(int repo)
Gets maximum serial number limit in config filejava.lang.String
getMinSerialConfig(int repo)
Gets minimum serial number limit in config filejava.lang.String
getNextMaxSerialConfig(int repo)
Gets maximum serial number limit in next range in config filejava.lang.String
getNextMinSerialConfig(int repo)
Gets minimum serial number limit in next range in config filejava.lang.String
getNextRange(int repo)
Gets start of next range from database.java.math.BigInteger
getNextSerialConfig()
IDBRegistry
getRegistry()
Retrieves the registry.boolean
hasRangeConflict(int repo)
Determines if a range conflict has been observed in database.void
init(DatabaseConfig config, PKISocketConfig socketConfig, IPasswordStore passwordStore)
Initializes the internal registry.void
returnConn(netscape.ldap.LDAPConnection conn)
void
setEnableSerialMgmt(boolean v)
void
setId(java.lang.String id)
Sets subsystem identifier.static void
setInstance(DBSubsystem dbSubsystem)
This method is used for unit tests.void
setMaxSerialConfig(int repo, java.lang.String serial)
Sets maximum serial number limit in config filevoid
setMinSerialConfig(int repo, java.lang.String serial)
Sets minimum serial number limit in config filevoid
setNextMaxSerialConfig(int repo, java.lang.String serial)
Sets maximum serial number limit for next range in config filevoid
setNextMinSerialConfig(int repo, java.lang.String serial)
Sets minimum serial number limit for next range in config filevoid
setNextSerialConfig(java.math.BigInteger serial)
void
shutdown()
Shutdowns this subsystem gracefully.
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
CERTS
public static final int CERTS
- See Also:
- Constant Field Values
-
REQUESTS
public static final int REQUESTS
- See Also:
- Constant Field Values
-
REPLICA_ID
public static final int REPLICA_ID
- See Also:
- Constant Field Values
-
NUM_REPOS
public static final int NUM_REPOS
- See Also:
- Constant Field Values
-
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
-
-
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.
-
setId
public void setId(java.lang.String id) throws EBaseException
Sets subsystem identifier.- Throws:
EBaseException
-
enableSerialNumberRecovery
public boolean enableSerialNumberRecovery()
-
getEnableSerialMgmt
public boolean getEnableSerialMgmt()
-
setEnableSerialMgmt
public void setEnableSerialMgmt(boolean v) throws EBaseException
- Throws:
EBaseException
-
getNextSerialConfig
public java.math.BigInteger getNextSerialConfig()
-
setNextSerialConfig
public void setNextSerialConfig(java.math.BigInteger serial) throws EBaseException
- Throws:
EBaseException
-
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 identifierserial
- 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 identifierserial
- 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 identifierserial
- 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 identifierserial
- 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(DatabaseConfig config, PKISocketConfig socketConfig, IPasswordStore passwordStore) throws EBaseException
Initializes the internal registry. Connects to the data source, and create a pool of connection of which applications can use. Optionally, check the integrity of the database.- Throws:
EBaseException
-
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.
-
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)
-
getLdapAuthInfo
public LdapAuthInfo getLdapAuthInfo()
-
shutdown
public void shutdown()
Shutdowns this subsystem gracefully.
-
getRegistry
public IDBRegistry getRegistry()
Retrieves the registry.
-
createSession
public IDBSSession createSession() throws EDBException
Creates a database session.- Throws:
EDBException
-
returnConn
public void returnConn(netscape.ldap.LDAPConnection conn)
-
-