public abstract class DatabaseBackendImpl extends Object implements DatabaseBackend
DatabaseBackend.BUILTIN_PROP_SPARSITY, BUILTIN_PROP_SYMBOL, BUILTIN_PROP_TIME_DOMAIN, BUILTIN_PROP_TYPE, DB_PARAM_Boolean_STRICT_NAME_SPACE, DB_PARAM_Boolean_STRICT_NAME_SPACE_DEFAULT, DB_PARAM_Class_ChronicleUpdatePolicyExtension, DB_PARAM_Class_PermissionChecker, DB_PARAM_Float_CACHE_LOAD_FACTOR, DB_PARAM_Float_CACHE_LOAD_FACTOR_DEFAULT, DB_PARAM_Int_CACHE_SIZE, DB_PARAM_Int_CACHE_SIZE_DEFAULT, MAGIC_NAME_NR, MAGIC_SPARSITY_NR, MAGIC_TIMEDOMAIN_NR, MAGIC_TYPE_NR, MAX_MAGIC_NR| Constructor and Description |
|---|
DatabaseBackendImpl(String name,
ch.agent.t2.time.TimeDomainCatalog timeDomainCatalog)
Construct a
DatabaseBackend. |
| Modifier and Type | Method and Description |
|---|---|
void |
check(Permission permission,
DBObject dBObject)
Check if a permission is available on a database object.
|
boolean |
check(Permission permission,
DBObject dBObject,
boolean permissionRequired)
Check if a permission is available on a database object.
|
void |
check(Permission permission,
Surrogate surrogate)
Check if a permission is available on a database object.
|
boolean |
check(Permission permission,
Surrogate surrogate,
boolean permissionRequired)
Check if a permission is available on a database object.
|
protected void |
checkSurrogate(Surrogate surrogate,
DBObjectType required)
Check the validity of a surrogate for this database and a given database object type.
|
void |
clear()
Clear the internal state of the database.
|
void |
close()
Close the database.
|
void |
configure(DatabaseConfiguration configuration)
Configure the database.
|
<T> UpdatableProperty<T> |
createProperty(String name,
ValueType<T> valueType,
boolean indexed)
Create a property with the parameters specified.
|
UpdatableSchema |
createSchema(String name,
String nameOfBase)
Create a schema with the parameters specified.
|
<T> UpdatableValueType<T> |
createValueType(String name,
boolean restricted,
String scannerClassOrKeyword)
Create a value type with the parameters specified.
|
<T> boolean |
deleteValue(UpdatableSeries<T> series,
ch.agent.t2.time.TimeIndex t)
Delete a value from a series in the database.
|
boolean |
equals(Object obj) |
<T> ValueAccessMethods<T> |
getAccessMethods(ValueType<T> valueType)
Return the series access methods object for the given value type.
|
DatabaseCache |
getCache()
Return the database cache.
|
Chronicle |
getChronicle(String name,
boolean mustExist)
Return the chronicle with the given full name.
|
Chronicle |
getChronicle(Surrogate surrogate)
Return the chronicle identified by a surrogate.
|
ChronicleUpdatePolicy |
getChronicleUpdatePolicy()
Return the chronicle update policy object.
|
<T> ch.agent.t2.timeseries.Observation<T> |
getFirstObservation(Series<T> series,
ch.agent.t2.time.TimeIndex time)
Return the observation at a given time index or the first following
observation.
|
<T> ch.agent.t2.timeseries.Observation<T> |
getLastObservation(Series<T> series,
ch.agent.t2.time.TimeIndex time)
Return the observation at a given time index or the last preceding
observation.
|
MessageListener |
getMessageListener()
Return the message listener.
|
NamingPolicy |
getNamingPolicy()
Return the naming policy of the database.
|
protected PermissionChecker |
getPermissionChecker()
Return the permission checker.
|
Property<?> |
getProperty(String name,
boolean mustExist)
Return the property with the given name.
|
<T> ch.agent.t2.time.Range |
getRange(Series<T> series)
Return the range of the series.
|
Schema |
getSchema(Surrogate surrogate)
Return the schema identified by a surrogate.
|
Collection<Schema> |
getSchemas(String pattern)
Return schemas with names matching a pattern.
|
SchemaUpdatePolicy |
getSchemaUpdatePolicy()
Return the schema update policy.
|
<T> Series<T> |
getSeries(String name,
boolean mustExist)
Return the series with the given full name.
|
Property<?> |
getSparsityBuiltInProperty()
Return the built-in property for sparsity.
|
Property<?> |
getSymbolBuiltInProperty()
Return the built-in property for symbols.
|
Property<?> |
getTimeDomainBuiltInProperty()
Return the built-in property for time domains.
|
ch.agent.t2.time.TimeDomainCatalog |
getTimeDomainCatalog()
Return the time domain catalog.
|
Chronicle |
getTopChronicle()
Return the top chronicle.
|
Property<?> |
getTypeBuiltInProperty()
Return the built-in property for value types.
|
UpdatableSchema |
getUpdatableSchema(Schema schema)
Return the updatable schema corresponding to a schema.
|
Collection<UpdatableSchema> |
getUpdatableSchemas(String pattern)
Return updatable schemas with names matching a pattern.
|
<T> UpdatableSeries<T> |
getUpdatableSeries(String name,
boolean mustExist)
Return an updatable series.
|
UpdateEventPublisher |
getUpdateEventPublisher()
Return the event publisher for this database.
|
<T> long |
getValues(Series<T> series,
ch.agent.t2.time.Range range,
ch.agent.t2.timeseries.TimeAddressable<T> ts)
Load values into the time series in the range specified.
|
int |
hashCode() |
boolean |
isBuiltIn(AttributeDefinition<?> def)
Test whether an attribute definition is built-in.
|
protected boolean |
isChronicleUpdatePolicyExtensionAllowed() |
protected boolean |
isChronicleUpdatePolicyExtensionMandatory() |
boolean |
isStrictNameSpaceMode()
Test if strict name space mode has been configured.
|
Surrogate |
makeSurrogate(String string)
Return a
Surrogate corresponding to the input. |
void |
open()
Open the database.
|
protected void |
publish(UpdateEvent event)
Short cut method to publish a deferred event.
|
<T> void |
setAccessMethods(String valueTypeExternalRepresentation,
ValueAccessMethods<T> accessMethods)
Set the series access methods object for the given value type.
|
void |
setMessageListener(MessageListener listener)
Set the message listener used for logging messages.
|
void |
setStrictNameSpaceMode(boolean strictNameSpaceMode)
Set strict name space mode.
|
String |
toString() |
<T> boolean |
update(UpdatableSeries<T> series,
ch.agent.t2.time.Range range)
Reduce the range of a series in the database.
|
<T> long |
update(UpdatableSeries<T> series,
ch.agent.t2.timeseries.TimeAddressable<T> values)
Update a series in the database with values from a time series.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcreate, create, create, create, create, deleteAttributeValue, deleteChronicle, deleteProperty, deleteSchema, deleteSeries, deleteValueType, findChronicle, findChronicle, findChronicle, getAttributeValue, getChronicle, getChronicleOrNull, getChroniclesByAttributeValue, getChroniclesByParent, getProperty, getSchemaSurrogates, getSeries, getUpdatableSchema, makeDBObjectId, update, update, update, update, updatecommit, getProperties, getProperty, getSeries, getValueType, getValueType, getValueTypes, rollbackpublic DatabaseBackendImpl(String name, ch.agent.t2.time.TimeDomainCatalog timeDomainCatalog)
DatabaseBackend.name - the name of the databasetimeDomainCatalog - the catalog to use for scanning time domainspublic ch.agent.t2.time.TimeDomainCatalog getTimeDomainCatalog()
DatabasegetTimeDomainCatalog in interface Databasepublic void open()
throws T2DBException
DatabaseDatabase.configure(ch.agent.crnickl.api.DatabaseConfiguration). What the method does depends on the implementation.
On some implementations it is not necessary to invoke the method before
using the database. Depending on the implementation it is possible to
continue using the database after a fatal error by invoking
Database.close() then Database.open().open in interface DatabaseT2DBExceptionpublic void close()
throws T2DBException
DatabaseDatabase.close() then
Database.open().close in interface DatabaseT2DBExceptionpublic void clear()
throws T2DBException
Databaseclear in interface DatabaseT2DBExceptionpublic <T> ValueAccessMethods<T> getAccessMethods(ValueType<T> valueType)
DatabaseBackendgetAccessMethods in interface DatabaseBackendvalueType - a value typepublic <T> void setAccessMethods(String valueTypeExternalRepresentation, ValueAccessMethods<T> accessMethods)
DatabaseBackend
Value types are identified using ValueType.getExternalRepresentation().
setAccessMethods in interface DatabaseBackendvalueTypeExternalRepresentation - a string used as external representation of value typeaccessMethods - an access methods objectpublic boolean isStrictNameSpaceMode()
DatabaseBackendisStrictNameSpaceMode in interface DatabaseBackendpublic void setStrictNameSpaceMode(boolean strictNameSpaceMode)
DatabaseBackendsetStrictNameSpaceMode in interface DatabaseBackendstrictNameSpaceMode - if true set strict name space modepublic Surrogate makeSurrogate(String string) throws T2DBException
DatabaseSurrogate corresponding to the input. The input is
typically a string returned by Surrogate.toString(). An exception
is thrown if there is a syntax error or if the database of the surrogate
is unknown.makeSurrogate in interface Databasestring - a string representation of a surrogateT2DBExceptionprotected void checkSurrogate(Surrogate surrogate, DBObjectType required) throws T2DBException
surrogate - a surrogaterequired - a database object typeT2DBExceptionprotected boolean isChronicleUpdatePolicyExtensionMandatory()
protected boolean isChronicleUpdatePolicyExtensionAllowed()
public void configure(DatabaseConfiguration configuration) throws T2DBException
Databaseconfigure in interface Databaseconfiguration - a database configurationT2DBExceptionpublic boolean isBuiltIn(AttributeDefinition<?> def)
DatabaseBackendisBuiltIn in interface DatabaseBackenddef - an attribute definitionpublic DatabaseCache getCache()
DatabaseBackendgetCache in interface DatabaseBackendpublic NamingPolicy getNamingPolicy()
DatabasegetNamingPolicy in interface Databasepublic ChronicleUpdatePolicy getChronicleUpdatePolicy()
DatabaseBackendgetChronicleUpdatePolicy in interface DatabaseBackendpublic SchemaUpdatePolicy getSchemaUpdatePolicy()
DatabaseBackendgetSchemaUpdatePolicy in interface DatabaseBackendpublic UpdateEventPublisher getUpdateEventPublisher()
DatabasegetUpdateEventPublisher in interface Databaseprotected void publish(UpdateEvent event)
event - an update eventpublic void setMessageListener(MessageListener listener)
DatabasesetMessageListener in interface Databaselistener - a message listener or nullpublic MessageListener getMessageListener()
DatabaseLevel.OFF.getMessageListener in interface Databaseprotected PermissionChecker getPermissionChecker()
public boolean check(Permission permission, DBObject dBObject, boolean permissionRequired) throws T2DBException
PermissionCheckerpermissionRequired throw an exception or return false on
failure.check in interface PermissionCheckerpermission - a permissiondBObject - a database objectpermissionRequired - if true throw an exception on failure else return falseT2DBExceptionpublic void check(Permission permission, DBObject dBObject) throws T2DBException
PermissionCheckercheck in interface PermissionCheckerpermission - a permissiondBObject - a database objectT2DBExceptionpublic boolean check(Permission permission, Surrogate surrogate, boolean permissionRequired) throws T2DBException
PermissionCheckerpermissionRequired throw an exception or return false on
failure.check in interface PermissionCheckerpermission - a permissionsurrogate - a surrogate identifying a database objectpermissionRequired - if true throw an exception on failure else return falseT2DBExceptionpublic void check(Permission permission, Surrogate surrogate) throws T2DBException
PermissionCheckercheck in interface PermissionCheckerpermission - a permissionsurrogate - if true throw an exception on failure else return falseT2DBExceptionpublic Chronicle getTopChronicle()
DatabasegetTopChronicle in interface Databasepublic Chronicle getChronicle(String name, boolean mustExist) throws T2DBException
mustExist parameter determines behavior when nothing is
found: exception or null result.
When an chronicle exists for the name, throw an exception if reading it is not permitted.
getChronicle in interface Databasename - a full namemustExist - if true throw an exception instead of returning nullT2DBExceptionpublic <T> UpdatableSeries<T> getUpdatableSeries(String name, boolean mustExist) throws T2DBException
DatabasemustExist parameter. If set, the series is created on the
fly, unless something is wrong, in which case an exception is thrown. If
not set the method returns null (unless something is wrong). Something is
wrong when the chronicle does not exist or is not accessible, or when the
series is not defined in the schema.
After a new series has been created, the client must execute
Updatable.applyUpdates() on the series's chronicle or
on the series itself.
getUpdatableSeries in interface DatabaseT - the data type of the underlying time seriesname - a full namemustExist - if true throw an exception instead of returning nullT2DBExceptionpublic <T> Series<T> getSeries(String name, boolean mustExist) throws T2DBException
DatabasemustExist parameter.getSeries in interface DatabaseT - the data type of the underlying time seriesname - a full namemustExist - if true throw an exception instead of returning nullT2DBExceptionpublic Chronicle getChronicle(Surrogate surrogate) throws T2DBException
DatabasegetChronicle in interface Databasesurrogate - a surrogateT2DBExceptionpublic <T> ch.agent.t2.time.Range getRange(Series<T> series) throws T2DBException
DatabaseBackendgetRange in interface DatabaseBackendseries - a seriesT2DBExceptionpublic <T> long getValues(Series<T> series, ch.agent.t2.time.Range range, ch.agent.t2.timeseries.TimeAddressable<T> ts) throws T2DBException
DatabaseBackendgetValues in interface DatabaseBackendseries - a seriesrange - a range or nullts - a time seriesT2DBExceptionpublic <T> ch.agent.t2.timeseries.Observation<T> getFirstObservation(Series<T> series, ch.agent.t2.time.TimeIndex time) throws T2DBException
DatabaseBackendgetFirstObservation in interface DatabaseBackendtime - a time indexT2DBExceptionpublic <T> ch.agent.t2.timeseries.Observation<T> getLastObservation(Series<T> series, ch.agent.t2.time.TimeIndex time) throws T2DBException
DatabaseBackendgetLastObservation in interface DatabaseBackendtime - a time indexT2DBExceptionpublic <T> boolean update(UpdatableSeries<T> series, ch.agent.t2.time.Range range) throws T2DBException
DatabaseBackendupdate in interface DatabaseBackendseries - a seriesrange - a rangeT2DBExceptionpublic <T> boolean deleteValue(UpdatableSeries<T> series, ch.agent.t2.time.TimeIndex t) throws T2DBException
DatabaseBackenddeleteValue in interface DatabaseBackendseries - a seriest - a time indexT2DBExceptionpublic <T> long update(UpdatableSeries<T> series, ch.agent.t2.timeseries.TimeAddressable<T> values) throws T2DBException
DatabaseBackendupdate in interface DatabaseBackendseries - a seriesvalues - a time series of valuesT2DBExceptionpublic Schema getSchema(Surrogate surrogate) throws T2DBException
This method consolidates the chain of schemas by following links to the parent schema until there is no parent. The result is also known as "runtime schema".
Historical note. In a previous version of this system, chronicle level attributes were merged into series attributes. This is not done any more.
getSchema in interface Databasesurrogate - a surrogateT2DBExceptionpublic Property<?> getProperty(String name, boolean mustExist) throws T2DBException
DatabasemustExist.getProperty in interface Databasename - the name of the propertymustExist - if true throw an exception instead of returning nullT2DBExceptionpublic Property<?> getSymbolBuiltInProperty() throws T2DBException
DatabasegetSymbolBuiltInProperty in interface DatabaseT2DBExceptionpublic Property<?> getTimeDomainBuiltInProperty() throws T2DBException
DatabasegetTimeDomainBuiltInProperty in interface DatabaseT2DBExceptionpublic Property<?> getTypeBuiltInProperty() throws T2DBException
DatabasegetTypeBuiltInProperty in interface DatabaseT2DBExceptionpublic Property<?> getSparsityBuiltInProperty() throws T2DBException
DatabasegetSparsityBuiltInProperty in interface DatabaseT2DBExceptionpublic Collection<Schema> getSchemas(String pattern) throws T2DBException
DatabasegetSchemas in interface Databasepattern - a name patternT2DBExceptionpublic Collection<UpdatableSchema> getUpdatableSchemas(String pattern) throws T2DBException
DatabasegetUpdatableSchemas in interface Databasepattern - a name patternT2DBExceptionpublic UpdatableSchema getUpdatableSchema(Schema schema) throws T2DBException
DatabaseBackendgetUpdatableSchema in interface DatabaseBackendschema - a schemaT2DBExceptionpublic <T> UpdatableValueType<T> createValueType(String name, boolean restricted, String scannerClassOrKeyword) throws T2DBException
DatabaseValueType.StandardValueType or the name of a class implementing
ValueScanner. The client must execute
Updatable.applyUpdates() on the result.createValueType in interface Databasename - the name of the value typerestricted - true if the value type has a list of allowed valuesscannerClassOrKeyword - a keyword or the name of a scanner classT2DBExceptionpublic <T> UpdatableProperty<T> createProperty(String name, ValueType<T> valueType, boolean indexed) throws T2DBException
DatabaseUpdatable.applyUpdates() on the result.createProperty in interface Databasename - the name of the propertyvalueType - the value type of the attribute valuesindexed - true if the property is suitable as a search criterionT2DBExceptionpublic UpdatableSchema createSchema(String name, String nameOfBase) throws T2DBException
DatabaseUpdatable.applyUpdates() on the result.createSchema in interface Databasename - the name of the schemanameOfBase - the name of the base schema or null if there is no base schemaT2DBExceptionCopyright © 2017. All rights reserved.