Package com.illumon.iris.db.schema
Class SchemaServiceKvImpl
java.lang.Object
com.illumon.iris.db.schema.SchemaServiceKvImpl
- All Implemented Interfaces:
SchemaService
,SchemaServiceAuthenticatedMutator
,SchemaServiceUtilLayer
,NamedImplementation
,AutoCloseable
- Direct Known Subclasses:
SchemaServiceEtcdImpl
public abstract class SchemaServiceKvImpl extends Object implements SchemaServiceUtilLayer, SchemaServiceAuthenticatedMutator
SchemaService implementation that serves data from a cached collection of data
from etcd.
All single calls are internally consistent, but could be slightly out of date
with respect to etcd.
Abstract: implementations must provide getPersistenceProvider.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.schema.SchemaService
SchemaService.Delegating
-
Field Summary
Fields Modifier and Type Field Description protected boolean
closed
protected CachingSchemasKvAccessorInterface
kvPersistence
-
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, com.fishlib.auth.UserContext userContext, String code, String comment)
Adds a UserContext parameter toSchemaService.addSchema(Schema, String, String)
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.boolean
authenticate()
Authenticate using default authentication.boolean
authenticate(String user, String password, String operateAs)
Authenticate using the given user and password, operating as the operateAs user.void
close()
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, com.fishlib.auth.UserContext userContext, String code, String comment)
Adds a UserContext parameter toSchemaService.createNamespace(NamespaceSet, String, String, String)
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.void
deleteSchema(String namespace, String tableName)
Delete the specified schema.void
deleteSchema(String namespace, String tableName, com.fishlib.auth.UserContext userContext, String code, String comment)
Adds a UserContext parameter toSchemaService.deleteSchema(String, String, String, String)
void
deleteSchema(String namespace, String tableName, String code, String comment)
Delete the specified schema.Collection<Schema>
getAllSchemas()
Get a collection of all known schemas in the system.Collection<Schema>
getAllSchemas(Predicate<? super io.deephaven.kv.schema.SchemaStateAdapter.Namespace> filter)
Schema
getLatestSchema(String namespaceName, String tableName)
Get the latest version of theSchema
defined by namespace and table nameSchemaXml
getLatestSchemaXml(String namespace, String tableName)
TableDefinition
getLatestTableDefinition(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.Schema
getSchema(String namespaceName, 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.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.List<String>
listNamespaces(boolean includeDeleted)
Get a collection of the namespaces available.List<String>
listNamespaces(NamespaceSet namespaceSet)
Get a collection of the namespaces available in the given namespace set.List<String>
listNamespaces(NamespaceSet namespaceSet, boolean includeDeleted)
Get a collection of the namespaces available in the given namespace set.List<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, com.fishlib.auth.UserContext userContext, String code, String comment)
Adds a UserContext parameter toSchemaService.removeNamespace(String, String, String)
void
removeNamespace(String namespaceName, String code, String comment)
Remove the given namespace.Schema
updateSchema(Schema newSchema)
Update the schema with the same namespace and table name with the specified new schema.Schema
updateSchema(Schema newSchema, com.fishlib.auth.UserContext userContext, String code, String comment)
Adds a UserContext parameter toSchemaService.updateSchema(Schema, String, String)
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.schema.SchemaService
authenticate, createNamespace, deleteSchema, deleteSchema, fromDefinition, fromDefinition, fromDefinition, fromDefinition, getLatestTableDefinitionRequired, getSchema, getSchemasForNamespaceSet, listNamespaces, listNamespaces, listTableNames, shutdown
Methods inherited from interface com.illumon.iris.db.schema.SchemaServiceUtilLayer
asElement, asSchemaXml, asSchemaXml, fromDefinition, fromElement
-
Field Details
-
kvPersistence
-
closed
protected boolean closed
-
-
Method Details
-
initializationStage
Description copied from interface:SchemaService
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.- Specified by:
initializationStage
in interfaceSchemaService
- Returns:
- a Future representing successful completion of initialization.
-
authenticate
public boolean authenticate(@NotNull String user, @NotNull String password, @NotNull String operateAs)Description copied from interface:SchemaService
Authenticate using the given user and password, operating as the operateAs user. Implementations are not required to allow re-authentication.- Specified by:
authenticate
in interfaceSchemaService
- 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
public boolean authenticate()Description copied from interface:SchemaService
Authenticate using default authentication. This will be using the default private key or howeverWAuthenticationClientManager.DEFAULT
has been authenticated.- Specified by:
authenticate
in interfaceSchemaService
- Returns:
- true only if the authentication succeeded
-
about
Description copied from interface:SchemaService
Information about a SchemaService instance. Useful for debugging.- Specified by:
about
in interfaceSchemaService
- Returns:
- a string containing information about the instance
-
getLatestSchema
Description copied from interface:SchemaService
Get the latest version of theSchema
defined by namespace and table name- Specified by:
getLatestSchema
in interfaceSchemaService
- Parameters:
namespaceName
- the namespace of the tabletableName
- the table name- Returns:
- the latest version of namespace.tablename or null if none was found
-
getLatestSchemaXml
@Nullable public SchemaXml getLatestSchemaXml(@NotNull String namespace, @NotNull String tableName)Description copied from interface:SchemaService
Get the latest version of theSchema
defined by namespace and table name, as an implementation supportingSchemaXml
.- Specified by:
getLatestSchemaXml
in interfaceSchemaService
- 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 public Schema getSchema(@NotNull String namespaceName, @NotNull String tableName, @NotNull SchemaVersion version)Description copied from interface:SchemaService
Get the specified version of theSchema
defined by namespace and table name- Specified by:
getSchema
in interfaceSchemaService
- Parameters:
namespaceName
- 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
Description copied from interface:SchemaService
Get a collection of all known schemas in the system. The latest version of each will be returned. // TODO: subject to ACL visibility?- Specified by:
getAllSchemas
in interfaceSchemaService
- Returns:
- a collection of all known schemas
-
getAllSchemas
public Collection<Schema> getAllSchemas(@NotNull Predicate<? super io.deephaven.kv.schema.SchemaStateAdapter.Namespace> filter) -
getSchemas
Description copied from interface:SchemaService
Get a collection of all known schemas in the system, with the given namespace set. The latest version of each will be returned.- Specified by:
getSchemas
in interfaceSchemaService
- Returns:
- a collection of all known schemas in the given namespace set
-
getSchemas
Description copied from interface:SchemaService
Get a collection of all known schemas in the given namespace. The latest version of each will be returned.- Specified by:
getSchemas
in interfaceSchemaService
- Returns:
- a collection of all known schemas in the given namespace
-
getLatestTableDefinitionSchema
@Nullable public TableDefinitionSchema getLatestTableDefinitionSchema(@NotNull String namespace, @NotNull String tableName)Description copied from interface:SchemaService
Get the latest version of theTableDefinitionSchema
defined by namespace and table name- Specified by:
getLatestTableDefinitionSchema
in interfaceSchemaService
- 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 public TableDefinition getLatestTableDefinition(@NotNull String namespace, @NotNull String tableName)Description copied from interface:SchemaService
Get the latest version of theSchema
for the namespace and table name, and return itsTableDefinition
.- Specified by:
getLatestTableDefinition
in interfaceSchemaService
- 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
-
containsNamespace
Description copied from interface:SchemaService
Find out whether the given namespace is known to the schema service.- Specified by:
containsNamespace
in interfaceSchemaService
- Parameters:
namespace
- the namespace in questionincludeDeleted
- true if deleted namespaces should be considered- Returns:
- true if the namespace is found
-
containsNamespace
Description copied from interface:SchemaService
Find out whether the given namespace is known to the schema service.- Specified by:
containsNamespace
in interfaceSchemaService
- Parameters:
namespace
- the namespace in question- Returns:
- true if the namespace is found
-
containsSchema
Description copied from interface:SchemaService
Find out if the given schema exists. Does not check for deleted schemas.- Specified by:
containsSchema
in interfaceSchemaService
- Parameters:
namespace
- the namespace of the tabletableName
- the table name- Returns:
- true if a schema is found for namespace.tableName
-
listNamespaces
Description copied from interface:SchemaService
Get a collection of the namespaces available.- Specified by:
listNamespaces
in interfaceSchemaService
- Parameters:
includeDeleted
- true if deleted namespaces should be included- Returns:
- a collection of namespace names
-
listNamespaces
Description copied from interface:SchemaService
Get a collection of the namespaces available in the given namespace set.- Specified by:
listNamespaces
in interfaceSchemaService
- Parameters:
namespaceSet
- list namespaces in this namespace set (User, System)- Returns:
- a collection of namespace names
-
listNamespaces
@NotNull public List<String> listNamespaces(@NotNull NamespaceSet namespaceSet, boolean includeDeleted)Description copied from interface:SchemaService
Get a collection of the namespaces available in the given namespace set.- Specified by:
listNamespaces
in interfaceSchemaService
- Parameters:
namespaceSet
- list namespaces in this set (User, System)includeDeleted
- true if deleted namespaces should be included- Returns:
- a collection of namespace names
-
listTableNames
Description copied from interface:SchemaService
Get a collection of all table names in the specified namespace.- Specified by:
listTableNames
in interfaceSchemaService
- 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
Description copied from interface:SchemaService
Get a map of all known tables in all known namespaces for all namespace sets.- Specified by:
listAllTables
in interfaceSchemaService
- Returns:
- all the table names, mapped by namespace set and namespace
-
getNamespaceSet
@NotNull public NamespaceSet getNamespaceSet(@NotNull String namespace) throws IllegalArgumentExceptionDescription copied from interface:SchemaService
Get theNamespaceSet
for a particular namespace.- Specified by:
getNamespaceSet
in interfaceSchemaService
- Parameters:
namespace
- The namespace name- Returns:
- the namespace set of the namespace
- Throws:
IllegalArgumentException
- if the namespace does not exist
-
createNamespace
Description copied from interface:SchemaService
Add 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.- Specified by:
createNamespace
in interfaceSchemaService
- 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.
-
createNamespace
public boolean createNamespace(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName, @NotNull String code, @NotNull String comment)Description copied from interface:SchemaService
Add 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.- Specified by:
createNamespace
in interfaceSchemaService
- 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.
-
createNamespace
public boolean createNamespace(@NotNull NamespaceSet namespaceSet, @NotNull String namespaceName, @NotNull com.fishlib.auth.UserContext userContext, @NotNull String code, @NotNull String comment)Description copied from interface:SchemaServiceAuthenticatedMutator
Adds a UserContext parameter toSchemaService.createNamespace(NamespaceSet, String, String, String)
- Specified by:
createNamespace
in interfaceSchemaServiceAuthenticatedMutator
- Parameters:
namespaceSet
- add namespaceName to this namespace setnamespaceName
- name of the new namespaceuserContext
- pass-thru to kv persistence, indicates the user making this changecode
- pass-thru to kv persistence, indicates the code source of this changecomment
- pass-thru to kv persistence - a comment for this change- Returns:
- true if the namespace was created, false if it already exists
-
removeNamespace
Description copied from interface:SchemaService
Remove the given namespace. The namespace must be empty (contain no schemas).- Specified by:
removeNamespace
in interfaceSchemaService
- Parameters:
namespaceName
- the namespace to remove
-
removeNamespace
public void removeNamespace(@NotNull String namespaceName, @NotNull String code, @NotNull String comment)Description copied from interface:SchemaService
Remove the given namespace. The namespace must be empty (contain no schemas).- Specified by:
removeNamespace
in interfaceSchemaService
- 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
-
removeNamespace
public void removeNamespace(@NotNull String namespaceName, @NotNull com.fishlib.auth.UserContext userContext, @NotNull String code, @NotNull String comment)Description copied from interface:SchemaServiceAuthenticatedMutator
Adds a UserContext parameter toSchemaService.removeNamespace(String, String, String)
- Specified by:
removeNamespace
in interfaceSchemaServiceAuthenticatedMutator
- Parameters:
namespaceName
- name of the namespaceuserContext
- pass-thru to kv persistence, indicates the user making this changecode
- pass-thru to kv persistence, indicates the code source of this changecomment
- pass-thru to kv persistence - a comment for this change
-
addSchema
Description copied from interface:SchemaService
Add the specified schema to the service.- Specified by:
addSchema
in interfaceSchemaService
- 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 public Schema addSchema(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws SchemaExceptionDescription copied from interface:SchemaService
Add the specified schema to the service.- Specified by:
addSchema
in interfaceSchemaService
- 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
@NotNull public Schema addSchema(@NotNull Schema newSchema, @NotNull com.fishlib.auth.UserContext userContext, @NotNull String code, @NotNull String comment) throws SchemaExceptionDescription copied from interface:SchemaServiceAuthenticatedMutator
Adds a UserContext parameter toSchemaService.addSchema(Schema, String, String)
- Specified by:
addSchema
in interfaceSchemaServiceAuthenticatedMutator
- Parameters:
newSchema
- the schema to adduserContext
- pass-thru to kv persistence, indicates the user making this changecode
- pass-thru to kv persistence, indicates the code source of this changecomment
- pass-thru to kv persistence - a comment for this change- Throws:
SchemaException
-
addSchema
Description copied from interface:SchemaService
Add the specified schema to the service.- Specified by:
addSchema
in interfaceSchemaService
- 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 public Schema addSchema(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws SchemaExceptionDescription copied from interface:SchemaService
Add the specified schema to the service.- Specified by:
addSchema
in interfaceSchemaService
- 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 public Schema updateSchema(@NotNull Schema newSchema) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Update the schema with the same namespace and table name with the specified new schema.- Specified by:
updateSchema
in interfaceSchemaService
- 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 public Schema updateSchema(@NotNull Schema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Update the schema with the same namespace and table name with the specified new schema.- Specified by:
updateSchema
in interfaceSchemaService
- 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 public Schema updateSchema(@NotNull Schema newSchema, @NotNull com.fishlib.auth.UserContext userContext, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaServiceAuthenticatedMutator
Adds a UserContext parameter toSchemaService.updateSchema(Schema, String, String)
- Specified by:
updateSchema
in interfaceSchemaServiceAuthenticatedMutator
- Parameters:
newSchema
- the schema to updateuserContext
- pass-thru to kv persistence, indicates the user making this changecode
- pass-thru to kv persistence, indicates the code source of this changecomment
- pass-thru to kv persistence - a comment for this change- Throws:
IllegalArgumentException
SchemaException
-
updateSchema
@NotNull public Schema updateSchema(@NotNull TableDefinitionSchema newSchema) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Update the schema with the same namespace and table name with the specified new schema.- Specified by:
updateSchema
in interfaceSchemaService
- 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 public Schema updateSchema(@NotNull TableDefinitionSchema newSchema, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Update the schema with the same namespace and table name with the specified new schema.- Specified by:
updateSchema
in interfaceSchemaService
- 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
public void deleteSchema(@NotNull String namespace, @NotNull String tableName) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Delete the specified schema.- Specified by:
deleteSchema
in interfaceSchemaService
- 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
public void deleteSchema(@NotNull String namespace, @NotNull String tableName, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaService
Delete the specified schema.- Specified by:
deleteSchema
in interfaceSchemaService
- 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
public void deleteSchema(@NotNull String namespace, @NotNull String tableName, @NotNull com.fishlib.auth.UserContext userContext, @NotNull String code, @NotNull String comment) throws IllegalArgumentException, SchemaExceptionDescription copied from interface:SchemaServiceAuthenticatedMutator
Adds a UserContext parameter toSchemaService.deleteSchema(String, String, String, String)
- Specified by:
deleteSchema
in interfaceSchemaServiceAuthenticatedMutator
- Parameters:
namespace
- the namespace of the schema to deletetableName
- the name of the schema to deleteuserContext
- pass-thru to kv persistence, indicates the user making this changecode
- pass-thru to kv persistence, indicates the code source of this changecomment
- pass-thru to kv persistence - a comment for this change- Throws:
IllegalArgumentException
SchemaException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSchemaService
-