Package org.apache.cassandra.schema
Class OfflineSchemaUpdateHandler
- java.lang.Object
-
- org.apache.cassandra.schema.OfflineSchemaUpdateHandler
-
- All Implemented Interfaces:
SchemaUpdateHandler
public class OfflineSchemaUpdateHandler extends java.lang.Object implements SchemaUpdateHandler
Update handler which works only in memory. It does not load or save the schema anywhere. It is used in client mode applications.
-
-
Constructor Summary
Constructors Constructor Description OfflineSchemaUpdateHandler(java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaTransformation.SchemaTransformationResult
apply(SchemaTransformation transformation, boolean local)
Applies schema transformation in the underlying storage and synchronizes with other nodes.Awaitable
clear()
Marks the local schema to be cleared and refreshed.void
reset(boolean local)
Resets the schema either by reloading data from the local storage or from the other nodes.void
start()
Starts actively synchronizing schema with the rest of the cluster.boolean
waitUntilReady(java.time.Duration timeout)
Waits until the schema update handler is ready and returns the result.
-
-
-
Constructor Detail
-
OfflineSchemaUpdateHandler
public OfflineSchemaUpdateHandler(java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback)
-
-
Method Detail
-
start
public void start()
Description copied from interface:SchemaUpdateHandler
Starts actively synchronizing schema with the rest of the cluster. It is called in the very beginning of the node startup. It is not expected to block - to await for the startup completion we have another methodSchemaUpdateHandler.waitUntilReady(Duration)
.- Specified by:
start
in interfaceSchemaUpdateHandler
-
waitUntilReady
public boolean waitUntilReady(java.time.Duration timeout)
Description copied from interface:SchemaUpdateHandler
Waits until the schema update handler is ready and returns the result. If the method returnsfalse
it means that readiness could not be achieved within the specified period of time. The method can be used just to check if schema is ready by passingDuration.ZERO
as the timeout - in such case it returns immediately.- Specified by:
waitUntilReady
in interfaceSchemaUpdateHandler
- Parameters:
timeout
- the maximum time to wait for schema readiness- Returns:
- whether readiness is achieved
-
apply
public SchemaTransformation.SchemaTransformationResult apply(SchemaTransformation transformation, boolean local)
Description copied from interface:SchemaUpdateHandler
Applies schema transformation in the underlying storage and synchronizes with other nodes.- Specified by:
apply
in interfaceSchemaUpdateHandler
- Parameters:
transformation
- schema transformation to be performedlocal
- if true, the caller does not require synchronizing schema with other nodes - in practise local is used only in some tests- Returns:
- transformation result
-
reset
public void reset(boolean local)
Description copied from interface:SchemaUpdateHandler
Resets the schema either by reloading data from the local storage or from the other nodes. Once the schema is refreshed, the callbacks provided in the factory method are executed, and the updated schema version is announced.- Specified by:
reset
in interfaceSchemaUpdateHandler
- Parameters:
local
- whether we should reset with locally stored schema or fetch the schema from other nodes
-
clear
public Awaitable clear()
Description copied from interface:SchemaUpdateHandler
Marks the local schema to be cleared and refreshed. Since calling this method, the update handler tries to obtain a fresh schema definition from a remote source. Once the schema definition is received, the local schema is replaced (instead of being merged which usually happens when the update is received). The returned awaitable is fulfilled when the schema is received and applied.- Specified by:
clear
in interfaceSchemaUpdateHandler
-
-