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.StringIDstatic org.slf4j.Loggerloggerstatic java.lang.StringPROP_ENABLE_SERIAL_MGMTstatic java.lang.StringPROP_ENABLE_SERIAL_NUMBER_RECOVERYstatic java.lang.StringPROP_INFINITE_REPLICA_NUMBERstatic java.lang.StringPROP_INFINITE_REQUEST_NUMBERstatic java.lang.StringPROP_INFINITE_SERIAL_NUMBERstatic java.lang.StringPROP_MAX_REPLICA_NUMBERstatic java.lang.StringPROP_MAX_REQUEST_NUMBERstatic java.lang.StringPROP_MAX_SERIAL_NUMBERstatic java.lang.StringPROP_MIN_REPLICA_NUMBERstatic java.lang.StringPROP_MIN_REQUEST_NUMBERstatic java.lang.StringPROP_MIN_SERIAL_NUMBERstatic java.lang.StringPROP_NEXT_MAX_REPLICA_NUMBERstatic java.lang.StringPROP_NEXT_MAX_REQUEST_NUMBERstatic java.lang.StringPROP_NEXT_MAX_SERIAL_NUMBERstatic java.lang.StringPROP_NEXT_MIN_REPLICA_NUMBERstatic java.lang.StringPROP_NEXT_MIN_REQUEST_NUMBERstatic java.lang.StringPROP_NEXT_MIN_SERIAL_NUMBERstatic java.lang.StringPROP_NEXT_SERIAL_NUMBERstatic java.lang.StringPROP_REPLICA_BASEDNstatic java.lang.StringPROP_REPLICA_INCREMENTstatic java.lang.StringPROP_REPLICA_LOW_WATER_MARKstatic java.lang.StringPROP_REPLICA_RANGE_DNstatic java.lang.StringPROP_REQUEST_BASEDNstatic java.lang.StringPROP_REQUEST_INCREMENTstatic java.lang.StringPROP_REQUEST_LOW_WATER_MARKstatic java.lang.StringPROP_REQUEST_RANGE_DNstatic java.lang.StringPROP_SERIAL_BASEDNstatic java.lang.StringPROP_SERIAL_INCREMENTstatic java.lang.StringPROP_SERIAL_LOW_WATER_MARKstatic java.lang.StringPROP_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 IDBSSessioncreateSession()Creates a database session.booleanenableSerialNumberRecovery()Avoids losing serial number.java.lang.StringgetBaseDN()Retrieves base DN of backend database.LDAPConfiggetConfigStore()Retrieves internal DB configuration store.DatabaseConfiggetDBConfigStore()Retrieves DB subsystem configuration store.booleangetEnableSerialMgmt()Determines if serial number management has been enabledjava.lang.StringgetEntryAttribute(java.lang.String dn, java.lang.String attrName, java.lang.String defaultValue, java.lang.String errorValue)Gets attribute value for specified entryjava.lang.StringgetId()Retrieves subsystem identifier.java.lang.StringgetIncrementConfig(int repo)Gets range increment for next range in config filestatic IDBSubsystemgetInstance()LdapAuthInfogetLdapAuthInfo()LdapConnInfogetLdapConnInfo()Retrieves LDAP connection info (host, port, secure)java.lang.StringgetLowWaterMarkConfig(int repo)Gets low water mark limit in config filejava.lang.StringgetMaxSerialConfig(int repo)Gets maximum serial number limit in config filejava.lang.StringgetMinSerialConfig(int repo)Gets minimum serial number limit in config filejava.lang.StringgetNextMaxSerialConfig(int repo)Gets maximum serial number limit in next range in config filejava.lang.StringgetNextMinSerialConfig(int repo)Gets minimum serial number limit in next range in config filejava.lang.StringgetNextRange(int repo)Gets start of next range from database.java.math.BigIntegergetNextSerialConfig()Gets the next serial number in config fileIDBRegistrygetRegistry()Retrieves the registry.booleanhasRangeConflict(int repo)Determines if a range conflict has been observed in database.voidinit(IConfigStore config)Initializes the internal registery.voidreturnConn(netscape.ldap.LDAPConnection conn)Returns LDAP connection to connection pool.voidsetEnableSerialMgmt(boolean v)Sets whether serial number management is enabled for certs and requests.voidsetId(java.lang.String id)Sets subsystem identifier.static voidsetInstance(IDBSubsystem dbSubsystem)This method is used for unit tests.voidsetMaxSerialConfig(int repo, java.lang.String serial)Sets maximum serial number limit in config filevoidsetMinSerialConfig(int repo, java.lang.String serial)Sets minimum serial number limit in config filevoidsetNextMaxSerialConfig(int repo, java.lang.String serial)Sets maximum serial number limit for next range in config filevoidsetNextMinSerialConfig(int repo, java.lang.String serial)Sets minimum serial number limit for next range in config filevoidsetNextSerialConfig(java.math.BigInteger serial)Records next serial number in config filevoidshutdown()Shutdowns this subsystem gracefully.voidstartup()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:
getIdin interfaceISubsystem- Returns:
- subsystem identifier
-
setId
public void setId(java.lang.String id) throws EBaseExceptionSets subsystem identifier.- Specified by:
setIdin interfaceISubsystem- Parameters:
id- subsystem identifier- Throws:
EBaseException- failed to set id
-
enableSerialNumberRecovery
public boolean enableSerialNumberRecovery()
Description copied from interface:IDBSubsystemAvoids losing serial number.- Specified by:
enableSerialNumberRecoveryin interfaceIDBSubsystem- Returns:
- true if serial number recovery option is enabled
-
getEnableSerialMgmt
public boolean getEnableSerialMgmt()
Description copied from interface:IDBSubsystemDetermines if serial number management has been enabled- Specified by:
getEnableSerialMgmtin interfaceIDBSubsystem- Returns:
- true if enabled, false otherwise
-
setEnableSerialMgmt
public void setEnableSerialMgmt(boolean v) throws EBaseExceptionDescription copied from interface:IDBSubsystemSets whether serial number management is enabled for certs and requests.- Specified by:
setEnableSerialMgmtin interfaceIDBSubsystem- Parameters:
v- true/false- Throws:
EBaseException- failed to set
-
getNextSerialConfig
public java.math.BigInteger getNextSerialConfig()
Description copied from interface:IDBSubsystemGets the next serial number in config file- Specified by:
getNextSerialConfigin interfaceIDBSubsystem- Returns:
- next serial number
-
setNextSerialConfig
public void setNextSerialConfig(java.math.BigInteger serial) throws EBaseExceptionDescription copied from interface:IDBSubsystemRecords next serial number in config file- Specified by:
setNextSerialConfigin 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:
getMinSerialConfigin 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:
getMaxSerialConfigin 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:
getNextMinSerialConfigin 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:
getNextMaxSerialConfigin 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:
getLowWaterMarkConfigin 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:
getIncrementConfigin interfaceIDBSubsystem- Parameters:
repo- repo identifier- Returns:
- range increment
-
setMaxSerialConfig
public void setMaxSerialConfig(int repo, java.lang.String serial) throws EBaseExceptionSets maximum serial number limit in config file- Specified by:
setMaxSerialConfigin interfaceIDBSubsystem- Parameters:
repo- repo identifierserial- max serial number- Throws:
EBaseException- failed to set
-
setMinSerialConfig
public void setMinSerialConfig(int repo, java.lang.String serial) throws EBaseExceptionSets minimum serial number limit in config file- Specified by:
setMinSerialConfigin interfaceIDBSubsystem- Parameters:
repo- repo identifierserial- min serial number- Throws:
EBaseException- failed to set
-
setNextMaxSerialConfig
public void setNextMaxSerialConfig(int repo, java.lang.String serial) throws EBaseExceptionSets maximum serial number limit for next range in config file- Specified by:
setNextMaxSerialConfigin 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 EBaseExceptionSets minimum serial number limit for next range in config file- Specified by:
setNextMinSerialConfigin 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:
getNextRangein 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:
hasRangeConflictin 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:
initin 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:IDBSubsystemGets attribute value for specified entry- Specified by:
getEntryAttributein 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 EBaseExceptionStarts up this service.- Specified by:
startupin interfaceISubsystem- Throws:
EBaseException- failed to start up
-
getConfigStore
public LDAPConfig getConfigStore()
Retrieves internal DB configuration store.- Specified by:
getConfigStorein interfaceIDBSubsystem- Specified by:
getConfigStorein interfaceISubsystem- Returns:
- internal DB configuration store
-
getDBConfigStore
public DatabaseConfig getDBConfigStore()
Retrieves DB subsystem configuration store.- Specified by:
getDBConfigStorein interfaceIDBSubsystem- Returns:
- DB subsystem configuration store
-
getBaseDN
public java.lang.String getBaseDN()
Retrieves base DN of backend database.- Specified by:
getBaseDNin 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:
shutdownin interfaceISubsystem
-
getRegistry
public IDBRegistry getRegistry()
Retrieves the registry.- Specified by:
getRegistryin interfaceIDBSubsystem- Returns:
- registry
-
createSession
public IDBSSession createSession() throws EDBException
Creates a database session.- Specified by:
createSessionin interfaceIDBSubsystem- Returns:
- database session
- Throws:
EDBException- failed to create session
-
returnConn
public void returnConn(netscape.ldap.LDAPConnection conn)
Description copied from interface:IDBSubsystemReturns LDAP connection to connection pool.- Specified by:
returnConnin interfaceIDBSubsystem- Parameters:
conn- connection to be returned
-
-