Package com.illumon.iris.db.schema
Class CachingSchemasKvAccessorShim
java.lang.Object
com.illumon.iris.db.schema.CachingSchemasKvAccessorShim
- All Implemented Interfaces:
CachingSchemasKvAccessorInterface
public class CachingSchemasKvAccessorShim
extends Object
implements CachingSchemasKvAccessorInterface
Preload DbInternal and other namespaces in order to bootstrap faster.
Certain read-only schema operations on the preloaded namespaces can be serviced while CachingSchemasKvAccessorImpl
is loading, and any others will block. Once the main implementation is loaded, all operations delegate to it.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddSchema(@NotNull Schema newSchema, @NotNull UserContext userContext, @NotNull String code, @NotNull String comment) Add the given schemaTable.voidclose()Releases resources when this instance will no longer be used.booleancontainsNamespace(@NotNull String namespaceName) Determine whether the named namespace exists.booleancontainsSchemaTable(@NotNull String namespaceName, @NotNull String tableName) Determine whether the named schemaTable exists in the given namespace.voidcreateNamespace(@NotNull NamespaceType namespaceType, @NotNull String namespaceName, @NotNull UserContext userContext, @NotNull String code, @NotNull String comment) Create the given namespace.voiddeleteSchema(@NotNull String namespaceName, @NotNull String tableName, @NotNull UserContext userContext, @NotNull String code, @NotNull String comment) Delete the named schema.@NotNull Collection<SchemaTable>getAllSchemaTables(@NotNull Predicate<? super SchemaStateAdapter.Namespace> namespaceFilter) Get all the schemaTables in namespaces matching the filter (namespace name, namespace type, etc).@Nullable NamespaceTypegetNamespaceType(@NotNull String namespaceName) Get the NamespaceType of the given namespace.@Nullable SchemaTablegetSchemaTable(@NotNull String namespaceName, @NotNull String tableName) Get a schemaTable.Get the single Future to be used to check initialization status.booleanisClosed()Determine if close() has been called.@NotNull Map<NamespaceType,Map<String, Collection<String>>> Return a map of namespaceName to schemaTable name, by NamespaceType.Get a list of all namespaces.listNamespaces(@NotNull NamespaceType namespaceType) Get a list of namespaces with the given type.listSchemaTables(@NotNull String namespace) Get a list of schemaTables in the named namespace.static @NotNull CachingSchemasKvAccessorInterfacemake(@NotNull com.fishlib.io.logger.Logger log, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull ClientCreator clientCreator, @NotNull SchemaContext schemaContext) Factory to construct the shim accessor, and start the full implementation asynchronously.voidremoveNamespace(@NotNull String namespaceName, @NotNull UserContext userContext, @NotNull String code, @NotNull String comment) Remove the given namespace.voidupdateSchema(@NotNull Schema newSchema, @NotNull UserContext userContext, @NotNull String code, @NotNull String comment) Update the given schema.
-
Method Details
-
initializationStage
Get the single Future to be used to check initialization status.- Specified by:
initializationStagein interfaceCachingSchemasKvAccessorInterface- Returns:
- a Future that will indicate completion and will throw on failure.
-
make
@NotNull public static @NotNull CachingSchemasKvAccessorInterface make(@NotNull @NotNull com.fishlib.io.logger.Logger log, @NotNull @NotNull com.fishlib.configuration.Configuration configuration, @NotNull @NotNull ClientCreator clientCreator, @NotNull @NotNull SchemaContext schemaContext) Factory to construct the shim accessor, and start the full implementation asynchronously.- Parameters:
log- the logger to useconfiguration- the configuration to useclientCreator- the kv client and watch creator - this determines the kv implementation (ro/rw, etcd/in-mem)schemaContext- the kvContext - root of the schemas storage- Returns:
- the new CachingSchemasKvAccessorInterface
-
getSchemaTable
@Nullable public @Nullable SchemaTable getSchemaTable(@NotNull @NotNull String namespaceName, @NotNull @NotNull String tableName) Description copied from interface:CachingSchemasKvAccessorInterfaceGet a schemaTable.- Specified by:
getSchemaTablein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace containing the tabletableName- the name of the table- Returns:
- the current SchemaTable, or null if either the namespace or table does not exist
-
getAllSchemaTables
@NotNull public @NotNull Collection<SchemaTable> getAllSchemaTables(@NotNull @NotNull Predicate<? super SchemaStateAdapter.Namespace> namespaceFilter) Description copied from interface:CachingSchemasKvAccessorInterfaceGet all the schemaTables in namespaces matching the filter (namespace name, namespace type, etc).- Specified by:
getAllSchemaTablesin interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceFilter- predicate for filtering namespaces- Returns:
- a collection of schemaTables matching the filter
-
containsNamespace
Description copied from interface:CachingSchemasKvAccessorInterfaceDetermine whether the named namespace exists.- Specified by:
containsNamespacein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace to check- Returns:
- true if the namespace exists
-
containsSchemaTable
public boolean containsSchemaTable(@NotNull @NotNull String namespaceName, @NotNull @NotNull String tableName) Description copied from interface:CachingSchemasKvAccessorInterfaceDetermine whether the named schemaTable exists in the given namespace.- Specified by:
containsSchemaTablein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace to checktableName- the name of the schemaTable- Returns:
- true if the schema exists
-
listNamespaces
Description copied from interface:CachingSchemasKvAccessorInterfaceGet a list of all namespaces.- Specified by:
listNamespacesin interfaceCachingSchemasKvAccessorInterface- Returns:
- a list of all namespaces
-
listNamespaces
Description copied from interface:CachingSchemasKvAccessorInterfaceGet a list of namespaces with the given type.- Specified by:
listNamespacesin interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceType- the NamespaceType to filter on- Returns:
- a list of all namespaces matching the NamespaceType
-
listSchemaTables
Description copied from interface:CachingSchemasKvAccessorInterfaceGet a list of schemaTables in the named namespace. If the namespace does not exist, the list will be empty.- Specified by:
listSchemaTablesin interfaceCachingSchemasKvAccessorInterface- Parameters:
namespace- the namespace to check- Returns:
- a list of all schemaTables in the given namespace
-
listAllTables
Description copied from interface:CachingSchemasKvAccessorInterfaceReturn a map of namespaceName to schemaTable name, by NamespaceType.- Specified by:
listAllTablesin interfaceCachingSchemasKvAccessorInterface- Returns:
- a map of NamespaceType to map of namespace to schemaTable names
-
getNamespaceType
Description copied from interface:CachingSchemasKvAccessorInterfaceGet the NamespaceType of the given namespace.- Specified by:
getNamespaceTypein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace to check- Returns:
- the namespaceType of the namespace, or null if the namespace does not exist.
-
createNamespace
public void createNamespace(@NotNull @NotNull NamespaceType namespaceType, @NotNull @NotNull String namespaceName, @NotNull @NotNull UserContext userContext, @NotNull @NotNull String code, @NotNull @NotNull String comment) Description copied from interface:CachingSchemasKvAccessorInterfaceCreate the given namespace.- Specified by:
createNamespacein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceType- create the namespace with this namespace typenamespaceName- the name of the namespace to createuserContext- the user making the changecode- pass-thru to the kv layercomment- pass-thru to the kv layer
-
removeNamespace
public void removeNamespace(@NotNull @NotNull String namespaceName, @NotNull @NotNull UserContext userContext, @NotNull @NotNull String code, @NotNull @NotNull String comment) Description copied from interface:CachingSchemasKvAccessorInterfaceRemove the given namespace. Throws SchemaException if the namespace does not exist.- Specified by:
removeNamespacein interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace to removeuserContext- the user making the changecode- pass-thru to the kv layercomment- pass-thru to the kv layer
-
addSchema
public void addSchema(@NotNull @NotNull Schema newSchema, @NotNull @NotNull UserContext userContext, @NotNull @NotNull String code, @NotNull @NotNull String comment) Description copied from interface:CachingSchemasKvAccessorInterfaceAdd the given schemaTable. The namespace must exist and have the type indicated in the schema. The schema must not exist. This does not validate CopyTable delegates.- Specified by:
addSchemain interfaceCachingSchemasKvAccessorInterface- Parameters:
newSchema- the schemaTable to adduserContext- the user making the changecode- pass-thru to the kv layercomment- pass-thru to the kv layer
-
updateSchema
public void updateSchema(@NotNull @NotNull Schema newSchema, @NotNull @NotNull UserContext userContext, @NotNull @NotNull String code, @NotNull @NotNull String comment) Description copied from interface:CachingSchemasKvAccessorInterfaceUpdate the given schema. The namespace must exist and have the type indicated in the schema. The schemaTable must exist. This does not validate CopyTable delegates.- Specified by:
updateSchemain interfaceCachingSchemasKvAccessorInterface- Parameters:
newSchema- the schema to updateuserContext- the user making the changecode- pass-thru to the kv layercomment- pass-thru to the kv layer
-
deleteSchema
public void deleteSchema(@NotNull @NotNull String namespaceName, @NotNull @NotNull String tableName, @NotNull @NotNull UserContext userContext, @NotNull @NotNull String code, @NotNull @NotNull String comment) Description copied from interface:CachingSchemasKvAccessorInterfaceDelete the named schema.- Specified by:
deleteSchemain interfaceCachingSchemasKvAccessorInterface- Parameters:
namespaceName- the namespace of the schema to deletetableName- the name of the schema to deleteuserContext- the user making the changecode- pass-thru to the kv layercomment- pass-thru to the kv layer
-
close
public void close()Description copied from interface:CachingSchemasKvAccessorInterfaceReleases resources when this instance will no longer be used.- Specified by:
closein interfaceCachingSchemasKvAccessorInterface
-
isClosed
public boolean isClosed()Description copied from interface:CachingSchemasKvAccessorInterfaceDetermine if close() has been called.- Specified by:
isClosedin interfaceCachingSchemasKvAccessorInterface- Returns:
- true if close has been called.
-