Class DatabaseEnvironment
The settings (the database section of "service.yaml" on the
classpath) and the database key are loaded once into static final fields the first time
this class is loaded; that needs no database. The database itself is reached by
ensureDatabase(), which every pool of ODatabasePoolManager calls before it
opens a connection: it connects to OrientDB and, if the configured database does not exist yet,
creates it, enables Record-Level Security (setRecordLevelSecurity(OMetadata)), sets up
the administrative user and password, creates the AdminEnvironment,
QueryTemplateEnvironment, TypeEnvironment and the Context partition tree
(ContextEnvironment parent, then its LiveContextEnvironment and
CemeteryContextEnvironment children: the parent must exist first so hierarchical role
propagation applies at child creation), and finally runs IsModelBootstrap.bootstrap(boolean)
to register every information-system-model type. When OrientDB does not answer,
ensureDatabase() fails and the next call tries again, so a service started before its
database works as soon as the database answers.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGYThe connection strategy parameter to use.protected static final StringINI variable name for key algorithm.protected static final StringINI variable name for key file.static final StringThe database server URI.static final StringThe default administrative role name.static final Map<Environment.PermissionMode,String> Default passwords for the read/write database accounts.static final booleanWhether bootstrap Discovery scans packages contributed by externalRegistrationProviderSPI implementations (e.g.static final StringOrientDB standard Edge class name.static final StringOperator-declared name of the runtime model, the one holding the types created through REST (seeModelIdentityResolver).static final StringOrientDB standard Vertex class name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidchangeDefaultAdminPassword(com.orientechnologies.orient.core.metadata.security.OSecurity oSecurity) Deprecated.This code must be removed for OrientDB versions higher than 3.2.Xstatic voidMakes sure the database answers and, the first time, that it is prepared: creates it with its partitions and types when it does not exist yet.static KeyReturns the initialized database cryptographic symmetric key.protected static KeyInitializes the database key.protected static voidsetDateTimeFormat(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Sets the datetime format attribute for the given database connection.protected static voidsetRecordLevelSecurity(com.orientechnologies.orient.core.metadata.OMetadata oMetadata) Deprecated.This code must be removed for OrientDB versions higher than 3.2.X
-
Field Details
-
DISCOVER_ALL_REGISTRATION_PROVIDERS
public static final boolean DISCOVER_ALL_REGISTRATION_PROVIDERSWhether bootstrap Discovery scans packages contributed by externalRegistrationProviderSPI implementations (e.g.gcube-model's), in addition toinformation-system-model's own intrinsic packages (always scanned regardless). Defaults tofalsewhen absent from "service.yaml" — harmless in production, where no such SPI-contributed provider is ever present on the classpath; test environments that rely on an external provider's types (e.g.gcube-model) must set this explicitly totrue. It also decides whether the domain provider identifies the model (ModelIdentityResolver) and whether a migration realigns its types. -
RUNTIME_MODEL_NAME
Operator-declared name of the runtime model, the one holding the types created through REST (seeModelIdentityResolver).nullwhen absent from "service.yaml": the resolver's default applies. -
DEFAULT_ADMIN_ROLE
The default administrative role name.- See Also:
-
DEFAULT_PASSWORDS
Default passwords for the read/write database accounts. -
DB_URI
The database server URI. -
CONNECTION_STRATEGY_PARAMETER
public static final com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGY CONNECTION_STRATEGY_PARAMETERThe connection strategy parameter to use. -
DB_KEY_FILENAME_VARNAME
INI variable name for key file.- See Also:
-
DB_KEY_ALGORITHM_VARNAME
INI variable name for key algorithm.- See Also:
-
VERTEX_CLASS_NAME
OrientDB standard Vertex class name.- See Also:
-
EDGE_CLASS_NAME
OrientDB standard Edge class name.- See Also:
-
-
Constructor Details
-
DatabaseEnvironment
public DatabaseEnvironment()
-
-
Method Details
-
ensureDatabase
public static void ensureDatabase()Makes sure the database answers and, the first time, that it is prepared: creates it with its partitions and types when it does not exist yet. A failure is not remembered: the next call tries again.- Throws:
RuntimeException- when OrientDB does not answer or the database cannot be prepared
-
initDbKey
Initializes the database key.- Parameters:
dbSection- the database section of the configuration profile- Returns:
- the initialized key
-
setDateTimeFormat
protected static void setDateTimeFormat(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Sets the datetime format attribute for the given database connection.- Parameters:
oDatabaseDocument- the OrientDB database connection
-
setRecordLevelSecurity
@Deprecated protected static void setRecordLevelSecurity(com.orientechnologies.orient.core.metadata.OMetadata oMetadata) Deprecated.This code must be removed for OrientDB versions higher than 3.2.XConfigures Record-Level Security (RLS) on Vertex and Edge classes.- Parameters:
oMetadata- the OrientDB schema metadata
-
getDatabaseKey
Returns the initialized database cryptographic symmetric key.- Returns:
- the symmetric database key
-
changeDefaultAdminPassword
@Deprecated public static void changeDefaultAdminPassword(com.orientechnologies.orient.core.metadata.security.OSecurity oSecurity) Deprecated.This code must be removed for OrientDB versions higher than 3.2.XChanges the default passwords for database administrative accounts.- Parameters:
oSecurity- the OrientDB security context
-