Package com.illumon.iris.db.schema
Interface SchemaService
- All Superinterfaces:
AutoCloseable
,NamedImplementation
- All Known Subinterfaces:
SchemaServiceAuthenticatedMutator
,SchemaServiceUtilLayer
- All Known Implementing Classes:
SchemaService.Delegating
,SchemaServiceEtcdImpl
,SchemaServiceKvImpl
,SchemaServiceLegacyTransientImpl
,StaticSchemaServiceImpl
public interface SchemaService extends NamedImplementation, AutoCloseable
Provides methods for interacting with the system Schema store.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SchemaService.Delegating
Delegate all method calls to an implementation object. -
Method Summary
Modifier and Type Method Description String
about()
Information about a SchemaService instance.Schema
addSchema(Schema newSchema)
Add the specified schema to the service.Schema
addSchema(Schema newSchema, String code, String comment)
Add the specified schema to the service.Schema
addSchema(TableDefinitionSchema newSchema)
Add the specified schema to the service.Schema
addSchema(TableDefinitionSchema newSchema, String code, String comment)
Add the specified schema to the service.org.jdom2.Element
asElement(Schema schema)
SchemaXml
asSchemaXml(Schema schema)
boolean
authenticate()
Authenticate using default authentication.default boolean
authenticate(String user, String password)
Authenticate using the given user and password.boolean
authenticate(String user, String password, String operateAs)
Authenticate using the given user and password, operating as the operateAs user.default void
close()
default boolean
containsNamespace(String namespace)
Find out whether the given namespace is known to the schema service.boolean
containsNamespace(String namespace, boolean includeDeleted)
Find out whether the given namespace is known to the schema service.boolean
containsSchema(String namespace, String tableName)
Find out if the given schema exists.boolean
createNamespace(NamespaceSet namespaceSet, String namespaceName)
Add a namespace with the given name to the schema service, in the requested namespace set.boolean
createNamespace(NamespaceSet namespaceSet, String namespaceName, String code, String comment)
Add a namespace with the given name to the schema service, in the requested namespace set.default boolean
createNamespace(String namespaceSet, String namespaceName)
Convenience method translates the namespace set from string toNamespaceSet
and delegate tocreateNamespace(NamespaceSet, String)
default void
deleteSchema(TableDefinitionSchema schema)
Delete the specified schema.default void
deleteSchema(TableDefinitionSchema schema, String code, String comment)
Delete the specified schema.void
deleteSchema(String namespace, String tableName)
Delete the specified schema.void
deleteSchema(String namespace, String tableName, String code, String comment)
Delete the specified schema.default MutableSchema
fromDefinition(TableDefinition definition, NamespaceSet namespaceSet)
Create aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the given namespace set and taking namespace, table name, and storage type from the given TableDefinition.default MutableSchema
fromDefinition(TableDefinition definition, String namespaceSet)
Convenience method translates the namespace set from string toNamespaceSet
and delegate tofromDefinition(TableDefinition, NamespaceSet)
default MutableSchema
fromDefinition(TableDefinition definition, String namespace, String tableName, int storageType, NamespaceSet set)
Create aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the specified namespace, table name, storage type andNamespaceSet
.MutableSchema
fromDefinition(TableDefinition definition, String namespace, String tableName, int storageType, NamespaceSet set, boolean useNanosecondTimePrecision)
Create aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the specified namespace, table name, storage type andNamespaceSet
.default MutableSchema
fromDefinition(TableDefinition definition, String namespace, String tableName, int storageType, String set)
Convenience method translates the namespace set from string toNamespaceSet
and delegate tofromDefinition(TableDefinition, String, String, int, NamespaceSet)
SchemaXml
fromElement(org.jdom2.Element elem)
Collection<Schema>
getAllSchemas()
Get a collection of all known schemas in the system.Schema
getLatestSchema(String namespace, String tableName)
Get the latest version of theSchema
defined by namespace and table nameSchemaXml
getLatestSchemaXml(String namespace, String tableName)
default TableDefinition
getLatestTableDefinition(String namespace, String tableName)
Get the latest version of theSchema
for the namespace and table name, and return itsTableDefinition
.default TableDefinition
getLatestTableDefinitionRequired(String namespace, String tableName)
Get the latest version of theSchema
for the namespace and table name, and return itsTableDefinition
.TableDefinitionSchema
getLatestTableDefinitionSchema(String namespace, String tableName)
Get the latest version of theTableDefinitionSchema
defined by namespace and table nameNamespaceSet
getNamespaceSet(String namespace)
Get theNamespaceSet
for a particular namespace.default Schema
getSchema(String namespace, String tableName)
Convenience method forgetLatestSchema(String, String)
.Schema
getSchema(String namespace, String tableName, SchemaVersion version)
Get the specified version of theSchema
defined by namespace and table nameCollection<Schema>
getSchemas(NamespaceSet namespaceSet)
Get a collection of all known schemas in the system, with the given namespace set.Collection<Schema>
getSchemas(String namespace)
Get a collection of all known schemas in the given namespace.default Collection<Schema>
getSchemasForNamespaceSet(String namespaceSet)
Convenience method translates the namespace set from string toNamespaceSet
and delegate togetSchemas(NamespaceSet)
default Future<Void>
initializationStage()
Get a future representing a possibly asynchronous initialization stage.Map<NamespaceSet,Map<String,Collection<String>>>
listAllTables()
Get a map of all known tables in all known namespaces for all namespace sets.default Collection<String>
listNamespaces()
Get a collection of the namespaces available.Collection<String>
listNamespaces(boolean includeDeleted)
Get a collection of the namespaces available.default Collection<String>
listNamespaces(NamespaceSet namespaceSet)
Get a collection of the namespaces available in the given namespace set.Collection<String>
listNamespaces(NamespaceSet namespaceSet, boolean includeDeleted)
Get a collection of the namespaces available in the given namespace set.default Collection<String>
listNamespaces(String namespaceSet)
Convenience method translates the namespace set from string toNamespaceSet
and delegate tolistNamespaces(NamespaceSet)
default Collection<String>
listTableNames(String namespace)
Get a collection of all table names in the specified namespace.Collection<String>
listTableNames(String namespace, boolean includeDeleted)
Get a collection of all table names in the specified namespace.void
removeNamespace(String namespaceName)
Remove the given namespace.void
removeNamespace(String namespaceName, String code, String comment)
Remove the given namespace.default void
shutdown()
Shut down the schema service.Schema
updateSchema(Schema newSchema)
Update the schema with the same namespace and table name with the specified new schema.Schema
updateSchema(Schema newSchema, String code, String comment)
Update the schema with the same namespace and table name with the specified new schema.Schema
updateSchema(TableDefinitionSchema newSchema)
Update the schema with the same namespace and table name with the specified new schema.Schema
updateSchema(TableDefinitionSchema newSchema, String code, String comment)
Update the schema with the same namespace and table name with the specified new schema.
-
Method Details
-
about
String about()Information about a SchemaService instance. Useful for debugging.- Returns:
- a string containing information about the instance
-
authenticate
Authenticate using the given user and password. Implementations are not required to allow re-authentication.- Parameters:
user
- the user to authenticatepassword
- the password for the user- Returns:
- true only if the authentication succeeded
-
authenticate
Authenticate using the given user and password, operating as the operateAs user. Implementations are not required to allow re-authentication.- Parameters:
user
- the user to authenticatepassword
- the password for the useroperateAs
- attempt to operate as this effective user- Returns:
- true only if the authentication succeeded
-
authenticate
boolean authenticate()Authenticate using default authentication. This will be using the default private key or howeverWAuthenticationClientManager.DEFAULT
has been authenticated.- Returns:
- true only if the authentication succeeded
-
fromDefinition
@NotNull default MutableSchema fromDefinition(@NotNull TableDefinition definition, @NotNull String namespace, @NotNull String tableName, int storageType, @NotNull NamespaceSet set) throws SchemaValidationExceptionCreate aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the specified namespace, table name, storage type andNamespaceSet
. Values of namespace, table name, storage type and Namespace set from the input definition are not used.- Parameters:
definition
- create a schema based on this table definitionnamespace
- the namespace of the new schematableName
- the table name of the new schemastorageType
- the storage type of the tableset
- the namespace set for the schema- Returns:
- a new
MutableSchema
. - Throws:
SchemaValidationException
- if there was a problem creating the new schema.
-
fromDefinition
@NotNull MutableSchema fromDefinition(@NotNull TableDefinition definition, @NotNull String namespace, @NotNull String tableName, int storageType, @NotNull NamespaceSet set, boolean useNanosecondTimePrecision) throws SchemaValidationExceptionCreate aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the specified namespace, table name, storage type andNamespaceSet
. Values of namespace, table name, storage type and Namespace set from the input definition are not used.- Parameters:
definition
- create a schema based on this table definitionnamespace
- the namespace of the new schematableName
- the table name of the new schemastorageType
- the storage type of the tableset
- the namespace set for the schemauseNanosecondTimePrecision
- whether to set nanosecond time precision for DateTime columns- Returns:
- a new
MutableSchema
. - Throws:
SchemaValidationException
- if there was a problem creating the new schema.
-
fromDefinition
@NotNull default MutableSchema fromDefinition(@NotNull TableDefinition definition, @NotNull String namespace, @NotNull String tableName, int storageType, @NotNull String set) throws SchemaValidationExceptionConvenience method translates the namespace set from string toNamespaceSet
and delegate tofromDefinition(TableDefinition, String, String, int, NamespaceSet)
- Throws:
SchemaValidationException
-
fromDefinition
@NotNull default MutableSchema fromDefinition(@NotNull TableDefinition definition, @NotNull NamespaceSet namespaceSet) throws SchemaValidationExceptionCreate aMutableSchema
that supportsSchemaXml
from aTableDefinition
, using the given namespace set and taking namespace, table name, and storage type from the given TableDefinition.- Parameters:
definition
- create a schema based on this table definitionnamespaceSet
- the namespace set for the schema- Returns:
- a new
MutableSchema
. - Throws:
SchemaValidationException
- if there was a problem creating the new schema
-
fromDefinition
@NotNull default MutableSchema fromDefinition(@NotNull TableDefinition definition, @NotNull String namespaceSet) throws SchemaValidationExceptionConvenience method translates the namespace set from string toNamespaceSet
and delegate tofromDefinition(TableDefinition, NamespaceSet)
- Throws:
SchemaValidationException
-
fromElement
- Parameters:
elem
- the element to create the schema from- Returns:
- a new
Schema
- Throws:
SchemaValidationException
- if the input element is not a properly structured Schema element
-
asElement
-
asSchemaXml
-
getLatestSchema
Get the latest version of theSchema
defined by namespace and table name- Parameters:
namespace
- the namespace of the tabletableName
- the table name- Returns:
- the latest version of namespace.tablename or null if none was found
-
getSchema
Convenience method forgetLatestSchema(String, String)
. -
getLatestSchemaXml
Get the latest version of theSchema
defined by namespace and table name, as an implementation supportingSchemaXml
.- Parameters:
namespace
- the namespace of the tabletableName
- the table name- Returns:
- the latest version of namespace.tablename or null if none was found
-
getSchema
@Nullable Schema getSchema(@NotNull String namespace, @NotNull String tableName, @NotNull SchemaVersion version)Get the specified version of theSchema
defined by namespace and table name- Parameters:
namespace
- the namespace of the tabletableName
- the table nameversion
- the version of this schema to retrieve- Returns:
- the requested version of the schema for namespace.tableName or null if none was found
-
getAllSchemas
Get a collection of all known schemas in the system. The latest version of each will be returned. // TODO: subject to ACL visibility?- Returns:
- a collection of all known schemas
-
getSchemas
Get a collection of all known schemas in the system, with the given namespace set. The latest version of each will be returned.- Returns:
- a collection of all known schemas in the given namespace set
-
getSchemasForNamespaceSet
Convenience method translates the namespace set from string toNamespaceSet
and delegate togetSchemas(NamespaceSet)
-
getSchemas
Get a collection of all known schemas in the given namespace. The latest version of each will be returned.- Returns:
- a collection of all known schemas in the given namespace
-
getLatestTableDefinitionSchema
@Nullable TableDefinitionSchema getLatestTableDefinitionSchema(@NotNull String namespace, @NotNull String tableName)Get the latest version of theTableDefinitionSchema
defined by namespace and table name- Parameters:
namespace
- the namespace of the tabletableName
- the table name- Returns:
- the latest version of namespace.tableName or null if none was found
-
getLatestTableDefinition
@Nullable default TableDefinition getLatestTableDefinition(@NotNull String namespace, @NotNull String tableName)Get the latest version of theSchema
for the namespace and table name, and return itsTableDefinition
.- Parameters:
namespace
- The namespace of the tabletableName
- The table name- Returns:
- The
TableDefinition
for the latest version of namespace.tableName or null if none was found
-
getLatestTableDefinitionRequired
default TableDefinition getLatestTableDefinitionRequired(@NotNull String namespace, @NotNull String tableName)Get the latest version of theSchema
for the namespace and table name, and return itsTableDefinition
.- Parameters:
namespace
- The namespace of the tabletableName
- The table name- Returns:
- The
TableDefinition
for the latest version of namespace.tableName - Throws:
SchemaException
- if theSchema
was not found
-
getNamespaceSet
Get theNamespaceSet
for a particular namespace.- Parameters:
namespace
- The namespace name- Returns:
- the namespace set of the namespace
- Throws:
IllegalArgumentException
- if the namespace does not exist
-
containsNamespace
Find out whether the given namespace is known to the schema service.- Parameters:
namespace
- the namespace in questionincludeDeleted
- true if deleted namespaces should be considered- Returns:
- true if the namespace is found
-
containsNamespace
Find out whether the given namespace is known to the schema service.- Parameters:
namespace
- the namespace in question- Returns:
- true if the namespace is found
-
containsSchema
Find out if the given schema exists. Does not check for deleted schemas.- Parameters:
namespace
- the namespace of the tabletableName
- the table name- Returns:
- true if a schema is found for namespace.tableName
-
listNamespaces
Get a collection of the namespaces available.- Returns:
- a collection of namespace names
-
listNamespaces
Get a collection of the namespaces available.- Parameters:
includeDeleted
- true if deleted namespaces should be included- Returns:
- a collection of namespace names
-
listNamespaces
Get a collection of the namespaces available in the given namespace set.- Parameters:
namespaceSet
- list namespaces in this namespace set (User, System)- Returns:
- a collection of namespace names
-
listNamespaces
Convenience method translates the namespace set from string toNamespaceSet
and delegate tolistNamespaces(NamespaceSet)
-
listNamespaces
@NotNull Collection<String> listNamespaces(@NotNull NamespaceSet namespaceSet, boolean includeDeleted)Get a collection of the namespaces available in the given namespace set.- Parameters:
namespaceSet
- list namespaces in this set (User, System)includeDeleted
- true if deleted namespaces should be included- Returns:
- a collection of namespace names
-
listTableNames
Get a collection of all table names in the specified namespace.- Parameters:
namespace
- the name of the namespace- Returns:
- a collection of all available schemas in namespace
-
listTableNames
Get a collection of all table names in the specified namespace.- Parameters:
namespace
- the name of the namespaceincludeDeleted
- tf deleted schemas should be included- Returns:
- a collection of all available schemas in namespace, empty list if namespace does not exit
-
listAllTables
Get a map of all known tables in all known namespaces for all namespace sets.- Returns:
- all the table names, mapped by namespace set and namespace
-
createNamespace
boolean createNamespace(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName) throws SchemaExceptionAdd a namespace with the given name to the schema service, in the requested namespace set. Returns true if the namespace was added, false if it already exists. Throws a SchemaException if the namespace could not be added.- Parameters:
namespaceSet
- add namespaceName to this namespace setnamespaceName
- name of the new namespace- Returns:
- true if the namespace was added, false if it already exists.
- Throws:
SchemaException
- if the namespace could not be added to the given namespace set
-
createNamespace
default boolean createNamespace(@NotNull String namespaceSet, @NotNull String namespaceName) throws SchemaExceptionConvenience method translates the namespace set from string toNamespaceSet
and delegate tocreateNamespace(NamespaceSet, String)
- Throws:
SchemaException
-
createNamespace
boolean createNamespace(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName, @NotNull String code, @NotNull String comment) throws SchemaExceptionAdd a namespace with the given name to the schema service, in the requested namespace set. Returns true if the namespace was added, false if it already exists. Throws a SchemaException if the namespace could not be added.- Parameters:
namespaceSet
- add namespaceName to this namespace setnamespaceName
- name of the new namespacecode
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update- Returns:
- true if the namespace was added, false if it already exists.
- Throws:
SchemaException
- if the namespace could not be added to the given namespace set
-
removeNamespace
void removeNamespace(@NotNull String namespaceName, @NotNull String code, @NotNull String comment) throws SchemaExceptionRemove the given namespace. The namespace must be empty (contain no schemas).- Parameters:
namespaceName
- the namespace to removecode
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update- Throws:
SchemaException
- if the namespace cannot be removed
-
removeNamespace
Remove the given namespace. The namespace must be empty (contain no schemas).- Parameters:
namespaceName
- the namespace to remove- Throws:
SchemaException
- if the namespace cannot be removed
-
addSchema
Add the specified schema to the service.- Parameters:
newSchema
- the schema to add- Returns:
- the schema actually stored in the SchemaService
- Throws:
SchemaException
- if the schema could not be added
-
addSchema
@NotNull Schema addSchema(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws SchemaExceptionAdd the specified schema to the service.- Parameters:
newSchema
- the schema to addcode
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update * @return the schema actually stored in the SchemaService- Throws:
SchemaException
- if the schema could not be added
-
addSchema
Add the specified schema to the service.- Parameters:
newSchema
- the schema to add- Returns:
- the schema actually stored in the SchemaService
- Throws:
SchemaException
- if the schema could not be added or already exists
-
addSchema
@NotNull Schema addSchema(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws SchemaExceptionAdd the specified schema to the service.- Parameters:
newSchema
- the schema to addcode
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update- Returns:
- the schema actually stored in the SchemaService
- Throws:
SchemaException
- if the schema could not be added or already exists
-
updateSchema
@NotNull Schema updateSchema(@NotNull Schema newSchema) throws IllegalArgumentException, SchemaExceptionUpdate the schema with the same namespace and table name with the specified new schema.- Parameters:
newSchema
- the schema to update with- Throws:
IllegalArgumentException
- if the namespace or table does not existSchemaException
- if the schema could not be updated
-
updateSchema
@NotNull Schema updateSchema(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionUpdate the schema with the same namespace and table name with the specified new schema.- Parameters:
newSchema
- the schema to update withcode
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update- Returns:
- the schema actually stored in the SchemaService
- Throws:
IllegalArgumentException
- if the namespace or table does not existSchemaException
- if the schema could not be updated
-
updateSchema
@NotNull Schema updateSchema(@NotNull TableDefinitionSchema newSchema) throws IllegalArgumentException, SchemaExceptionUpdate the schema with the same namespace and table name with the specified new schema.- Parameters:
newSchema
- the schema to update with.- Returns:
- the schema actually stored in the SchemaService
- Throws:
IllegalArgumentException
- if the namespace or table does not existSchemaException
- if the schema could not be updated
-
updateSchema
@NotNull Schema updateSchema(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionUpdate the schema with the same namespace and table name with the specified new schema.- Parameters:
newSchema
- the schema to update with.code
- pass-thru to kv persistence, indicates the code source of this updatecomment
- pass-thru to kv persistence - a comment for this update- Returns:
- the schema actually stored in the SchemaService
- Throws:
IllegalArgumentException
- if the namespace or table does not existSchemaException
- if the schema could not be updated
-
deleteSchema
void deleteSchema(@NotNull String namespace, @NotNull String tableName) throws IllegalArgumentException, SchemaExceptionDelete the specified schema.- Parameters:
namespace
- the namespace of the schema to deletetableName
- the name of the schema to delete- Throws:
IllegalArgumentException
- if the namespace or table could not be foundSchemaException
- if the schema could not be deleted
-
deleteSchema
void deleteSchema(@NotNull String namespace, @NotNull String tableName, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDelete the specified schema.- Parameters:
namespace
- the namespace of the schema to deletetableName
- the name of the schema to deletecode
- pass-thru to kv persistence, indicates the code source of this deletecomment
- pass-thru to kv persistence - a comment for this delete- Throws:
IllegalArgumentException
- if the namespace or table could not be foundSchemaException
- if the schema could not be deleted
-
deleteSchema
default void deleteSchema(@NotNull TableDefinitionSchema schema) throws IllegalArgumentException, SchemaExceptionDelete the specified schema.- Parameters:
schema
- the schema to delete- Throws:
IllegalArgumentException
- if the namespace or table could not be foundSchemaException
- if the schema could not be deleted
-
deleteSchema
default void deleteSchema(@NotNull TableDefinitionSchema schema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDelete the specified schema.- Parameters:
schema
- the schema to deletecode
- pass-thru to kv persistence, indicates the code source of this deletecomment
- pass-thru to kv persistence - a comment for this delete- Throws:
IllegalArgumentException
- if the namespace or table could not be foundSchemaException
- if the schema could not be deleted
-
shutdown
default void shutdown()Shut down the schema service. This may involve cleaning up threads and releasing resources. -
close
default void close()- Specified by:
close
in interfaceAutoCloseable
-
initializationStage
Get a future representing a possibly asynchronous initialization stage. The initialization stage is finished when the future is done, and does not throw an exception.- Returns:
- a Future representing successful completion of initialization.
-