public class DefaultSchemaUpdateHandler extends java.lang.Object implements SchemaUpdateHandler, IEndpointStateChangeSubscriber
Constructor and Description |
---|
DefaultSchemaUpdateHandler(java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback) |
DefaultSchemaUpdateHandler(MigrationCoordinator migrationCoordinator,
MessagingService messagingService,
boolean requireSchemas,
java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback) |
Modifier and Type | Method and Description |
---|---|
SchemaTransformation.SchemaTransformationResult |
apply(SchemaTransformation transformation,
boolean local)
Applies schema transformation in the underlying storage and synchronizes with other nodes.
|
void |
beforeChange(InetAddressAndPort endpoint,
EndpointState currentState,
ApplicationState newStateKey,
VersionedValue newValue) |
Awaitable |
clear()
When clear is called the update handler will flag that the clear was requested.
|
java.util.Map<java.util.UUID,java.util.Set<InetAddressAndPort>> |
getOutstandingSchemaVersions() |
void |
onAlive(InetAddressAndPort endpoint,
EndpointState state) |
void |
onChange(InetAddressAndPort endpoint,
ApplicationState state,
VersionedValue value) |
void |
onDead(InetAddressAndPort endpoint,
EndpointState state) |
void |
onJoin(InetAddressAndPort endpoint,
EndpointState epState)
Use to inform interested parties about the change in the state
for specified endpoint
|
void |
onRemove(InetAddressAndPort endpoint) |
void |
onRestart(InetAddressAndPort endpoint,
EndpointState state)
Called whenever a node is restarted.
|
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.
|
public DefaultSchemaUpdateHandler(java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback)
public DefaultSchemaUpdateHandler(MigrationCoordinator migrationCoordinator, MessagingService messagingService, boolean requireSchemas, java.util.function.BiConsumer<SchemaTransformation.SchemaTransformationResult,java.lang.Boolean> updateCallback)
public void start()
SchemaUpdateHandler
SchemaUpdateHandler.waitUntilReady(Duration)
.start
in interface SchemaUpdateHandler
public boolean waitUntilReady(java.time.Duration timeout)
SchemaUpdateHandler
false
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 passing Duration.ZERO
as the timeout - in such case it returns immediately.waitUntilReady
in interface SchemaUpdateHandler
timeout
- the maximum time to wait for schema readinesspublic void onRemove(InetAddressAndPort endpoint)
onRemove
in interface IEndpointStateChangeSubscriber
public void onChange(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value)
onChange
in interface IEndpointStateChangeSubscriber
public void onJoin(InetAddressAndPort endpoint, EndpointState epState)
IEndpointStateChangeSubscriber
onJoin
in interface IEndpointStateChangeSubscriber
endpoint
- endpoint for which the state change occurred.epState
- state that actually changed for the above endpoint.public void beforeChange(InetAddressAndPort endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue)
beforeChange
in interface IEndpointStateChangeSubscriber
public void onAlive(InetAddressAndPort endpoint, EndpointState state)
onAlive
in interface IEndpointStateChangeSubscriber
public void onDead(InetAddressAndPort endpoint, EndpointState state)
onDead
in interface IEndpointStateChangeSubscriber
public void onRestart(InetAddressAndPort endpoint, EndpointState state)
IEndpointStateChangeSubscriber
state.isAlive() == false
as state
is from before the restarted node is marked up.onRestart
in interface IEndpointStateChangeSubscriber
public SchemaTransformation.SchemaTransformationResult apply(SchemaTransformation transformation, boolean local)
SchemaUpdateHandler
apply
in interface SchemaUpdateHandler
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 testspublic void reset(boolean local)
SchemaUpdateHandler
reset
in interface SchemaUpdateHandler
local
- whether we should reset with locally stored schema or fetch the schema from other nodespublic Awaitable clear()
This way the clear is postponed until we really fetch any schema we can use as a replacement. Otherwise, nothing will happen. We will simply reset the flag after the timeout and throw exceptions to the caller.
clear
in interface SchemaUpdateHandler
public java.util.Map<java.util.UUID,java.util.Set<InetAddressAndPort>> getOutstandingSchemaVersions()
Copyright © 2009-2022 The Apache Software Foundation