Package com.netscape.cmscore.dbs
Class DBSubsystem
- java.lang.Object
-
- com.netscape.cmscore.dbs.DBSubsystem
-
- All Implemented Interfaces:
ISubsystem
,IDBSubsystem
public class DBSubsystem extends java.lang.Object implements IDBSubsystem
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 java.lang.String
ID
static org.slf4j.Logger
logger
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
-
Fields inherited from interface com.netscape.cmscore.dbs.IDBSubsystem
CERTS, NUM_REPOS, REPLICA_ID, REQUESTS, SUB_ID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IDBSSession
createSession()
Creates a database session.boolean
enableSerialNumberRecovery()
Avoids losing serial number.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()
Determines if serial number management has been enabledjava.lang.String
getEntryAttribute(java.lang.String dn, java.lang.String attrName, java.lang.String defaultValue, java.lang.String errorValue)
Gets attribute value for specified entryjava.lang.String
getId()
Retrieves subsystem identifier.java.lang.String
getIncrementConfig(int repo)
Gets range increment for next range in config filestatic IDBSubsystem
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()
Gets the next serial number in config fileIDBRegistry
getRegistry()
Retrieves the registry.boolean
hasRangeConflict(int repo)
Determines if a range conflict has been observed in database.void
init(IConfigStore config)
Initializes the internal registery.void
returnConn(netscape.ldap.LDAPConnection conn)
Returns LDAP connection to connection pool.void
setEnableSerialMgmt(boolean v)
Sets whether serial number management is enabled for certs and requests.void
setId(java.lang.String id)
Sets subsystem identifier.static void
setInstance(IDBSubsystem 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)
Records next serial number in config filevoid
shutdown()
Shutdowns this subsystem gracefully.void
startup()
Starts up this service.
-
-
-
Field Detail
-
logger
public static org.slf4j.Logger logger
-
ID
public static java.lang.String ID
-
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 IDBSubsystem getInstance()
-
setInstance
public static void setInstance(IDBSubsystem 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 interfaceISubsystem
- Returns:
- subsystem identifier
-
setId
public void setId(java.lang.String id) throws EBaseException
Sets subsystem identifier.- Specified by:
setId
in interfaceISubsystem
- Parameters:
id
- subsystem identifier- Throws:
EBaseException
- failed to set id
-
enableSerialNumberRecovery
public boolean enableSerialNumberRecovery()
Description copied from interface:IDBSubsystem
Avoids losing serial number.- Specified by:
enableSerialNumberRecovery
in interfaceIDBSubsystem
- Returns:
- true if serial number recovery option is enabled
-
getEnableSerialMgmt
public boolean getEnableSerialMgmt()
Description copied from interface:IDBSubsystem
Determines if serial number management has been enabled- Specified by:
getEnableSerialMgmt
in interfaceIDBSubsystem
- Returns:
- true if enabled, false otherwise
-
setEnableSerialMgmt
public void setEnableSerialMgmt(boolean v) throws EBaseException
Description copied from interface:IDBSubsystem
Sets whether serial number management is enabled for certs and requests.- Specified by:
setEnableSerialMgmt
in interfaceIDBSubsystem
- Parameters:
v
- true/false- Throws:
EBaseException
- failed to set
-
getNextSerialConfig
public java.math.BigInteger getNextSerialConfig()
Description copied from interface:IDBSubsystem
Gets the next serial number in config file- Specified by:
getNextSerialConfig
in interfaceIDBSubsystem
- Returns:
- next serial number
-
setNextSerialConfig
public void setNextSerialConfig(java.math.BigInteger serial) throws EBaseException
Description copied from interface:IDBSubsystem
Records next serial number in config file- Specified by:
setNextSerialConfig
in interfaceIDBSubsystem
- Parameters:
serial
- next serial number- Throws:
EBaseException
- failed to set
-
getMinSerialConfig
public java.lang.String getMinSerialConfig(int repo)
Gets minimum serial number limit in config file- Specified by:
getMinSerialConfig
in interfaceIDBSubsystem
- Parameters:
repo
- repo identifier- Returns:
- min serial number
-
getMaxSerialConfig
public java.lang.String getMaxSerialConfig(int repo)
Gets maximum serial number limit in config file- Specified by:
getMaxSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
getNextMinSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
getNextMaxSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
getLowWaterMarkConfig
in interfaceIDBSubsystem
- 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- Specified by:
getIncrementConfig
in interfaceIDBSubsystem
- 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- Specified by:
setMaxSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
setMinSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
setNextMaxSerialConfig
in interfaceIDBSubsystem
- 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- Specified by:
setNextMinSerialConfig
in interfaceIDBSubsystem
- 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.- Specified by:
getNextRange
in interfaceIDBSubsystem
- 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.- Specified by:
hasRangeConflict
in interfaceIDBSubsystem
- 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 interfaceISubsystem
- 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)
Description copied from interface:IDBSubsystem
Gets attribute value for specified entry- Specified by:
getEntryAttribute
in interfaceIDBSubsystem
- Parameters:
dn
- entry's distinguished nameattrName
- attribute's namedefaultValue
- attribute's default valueerrorValue
- attribute's error value- Returns:
- attribute value
-
startup
public void startup() throws EBaseException
Starts up this service.- Specified by:
startup
in interfaceISubsystem
- Throws:
EBaseException
- failed to start up
-
getConfigStore
public LDAPConfig getConfigStore()
Retrieves internal DB configuration store.- Specified by:
getConfigStore
in interfaceIDBSubsystem
- Specified by:
getConfigStore
in interfaceISubsystem
- Returns:
- internal DB configuration store
-
getDBConfigStore
public DatabaseConfig getDBConfigStore()
Retrieves DB subsystem configuration store.- Specified by:
getDBConfigStore
in interfaceIDBSubsystem
- Returns:
- DB subsystem configuration store
-
getBaseDN
public java.lang.String getBaseDN()
Retrieves base DN of backend database.- Specified by:
getBaseDN
in interfaceIDBSubsystem
- Returns:
- base DN of the subsystem
-
getLdapConnInfo
public LdapConnInfo getLdapConnInfo()
Retrieves LDAP connection info (host, port, secure)
-
getLdapAuthInfo
public LdapAuthInfo getLdapAuthInfo()
-
shutdown
public void shutdown()
Shutdowns this subsystem gracefully.- Specified by:
shutdown
in interfaceISubsystem
-
getRegistry
public IDBRegistry getRegistry()
Retrieves the registry.- Specified by:
getRegistry
in interfaceIDBSubsystem
- Returns:
- registry
-
createSession
public IDBSSession createSession() throws EDBException
Creates a database session.- Specified by:
createSession
in interfaceIDBSubsystem
- Returns:
- database session
- Throws:
EDBException
- failed to create session
-
returnConn
public void returnConn(netscape.ldap.LDAPConnection conn)
Description copied from interface:IDBSubsystem
Returns LDAP connection to connection pool.- Specified by:
returnConn
in interfaceIDBSubsystem
- Parameters:
conn
- connection to be returned
-
-