@Internal public abstract class SchemaRegistry extends Object implements org.apache.flink.runtime.operators.coordination.OperatorCoordinator, org.apache.flink.runtime.operators.coordination.CoordinationRequestHandler
SchemaEvolutionClient.
A legit schema registry should be able to:
SchemaEvolutionClients
SchemaRegistry. All methods
will run in given ExecutorService asynchronously except SchemaRegistry#restore.org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Context, org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Provider, org.apache.flink.runtime.operators.coordination.OperatorCoordinator.SubtaskGateway| 限定符和类型 | 字段和说明 |
|---|---|
protected Set<Integer> |
activeSinkWriters |
protected org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior |
behavior |
protected org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Context |
context |
protected ExecutorService |
coordinatorExecutor |
protected int |
currentParallelism |
protected Map<Integer,Throwable> |
failedReasons |
protected org.apache.flink.cdc.common.sink.MetadataApplier |
metadataApplier |
protected String |
operatorName |
protected TableIdRouter |
router |
protected List<org.apache.flink.cdc.common.route.RouteRule> |
routingRules |
protected java.time.Duration |
rpcTimeout |
protected SchemaManager |
schemaManager |
| 限定符 | 构造器和说明 |
|---|---|
protected |
SchemaRegistry(org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Context context,
String operatorName,
ExecutorService coordinatorExecutor,
org.apache.flink.cdc.common.sink.MetadataApplier metadataApplier,
List<org.apache.flink.cdc.common.route.RouteRule> routingRules,
org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior schemaChangeBehavior,
java.time.Duration rpcTimeout) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
checkpointCoordinator(long checkpointId,
CompletableFuture<byte[]> completableFuture) |
void |
close() |
void |
emplaceEvolvedSchema(org.apache.flink.cdc.common.event.TableId tableId,
org.apache.flink.cdc.common.schema.Schema schema) |
void |
emplaceOriginalSchema(org.apache.flink.cdc.common.event.TableId tableId,
org.apache.flink.cdc.common.schema.Schema schema) |
void |
executionAttemptFailed(int subTaskId,
int attemptNumber,
Throwable reason) |
void |
executionAttemptReady(int subTaskId,
int attemptNumber,
org.apache.flink.runtime.operators.coordination.OperatorCoordinator.SubtaskGateway gateway) |
protected <T extends Throwable> |
failJob(String taskDescription,
T t) |
CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> |
handleCoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest request) |
protected abstract void |
handleCustomCoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest request,
CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture)
Coordination handler for customized
CoordinationRequests. |
void |
handleEventFromOperator(int subTaskId,
int attemptNumber,
org.apache.flink.runtime.operators.coordination.OperatorEvent event) |
protected abstract void |
handleFlushSuccessEvent(FlushSuccessEvent event)
Overridable handler for
FlushSuccessEvents. |
protected void |
handleGetEvolvedSchemaRequest(GetEvolvedSchemaRequest request,
CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture)
Overridable handler for
GetEvolvedSchemaRequests. |
protected void |
handleGetOriginalSchemaRequest(GetOriginalSchemaRequest request,
CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture)
Overridable handler for
GetOriginalSchemaRequests. |
protected void |
handleSinkWriterRegisterEvent(SinkWriterRegisterEvent event)
Overridable handler for
SinkWriterRegisterEvents. |
protected void |
handleUnrecoverableError(String taskDescription,
Throwable t)
Last chance to execute codes before job fails globally.
|
protected void |
loopUntil(java.util.function.BooleanSupplier conditionChecker,
Runnable message,
java.time.Duration timeout,
java.time.Duration interval)
Keeps checking if
conditionChecker is satisfied. |
protected void |
loopWhen(java.util.function.BooleanSupplier conditionChecker,
Runnable message,
java.time.Duration timeout,
java.time.Duration interval)
Keeps checking if
conditionChecker is satisfied. |
void |
notifyCheckpointComplete(long checkpointId) |
void |
resetToCheckpoint(long checkpointId,
byte[] checkpointData) |
protected abstract void |
restore(byte[] checkpointData)
Restore schema registry state from byte array.
|
protected void |
runInEventLoop(org.apache.flink.util.function.ThrowingRunnable<Throwable> action,
String actionName,
Object... actionNameFormatParameters)
Run a time-consuming task in given
ExecutorService. |
protected abstract void |
snapshot(CompletableFuture<byte[]> resultFuture)
Snapshot current schema registry state in byte array form.
|
void |
start() |
void |
subtaskReset(int subTaskId,
long checkpointId) |
protected final org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Context context
protected final String operatorName
protected final ExecutorService coordinatorExecutor
protected final org.apache.flink.cdc.common.sink.MetadataApplier metadataApplier
protected final java.time.Duration rpcTimeout
protected final List<org.apache.flink.cdc.common.route.RouteRule> routingRules
protected final org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior behavior
protected transient int currentParallelism
protected transient SchemaManager schemaManager
protected transient TableIdRouter router
protected SchemaRegistry(org.apache.flink.runtime.operators.coordination.OperatorCoordinator.Context context,
String operatorName,
ExecutorService coordinatorExecutor,
org.apache.flink.cdc.common.sink.MetadataApplier metadataApplier,
List<org.apache.flink.cdc.common.route.RouteRule> routingRules,
org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior schemaChangeBehavior,
java.time.Duration rpcTimeout)
public void start()
throws Exception
start 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorExceptionpublic void close()
throws Exception
close 在接口中 AutoCloseableclose 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorExceptionprotected abstract void snapshot(CompletableFuture<byte[]> resultFuture) throws Exception
Exceptionprotected abstract void restore(byte[] checkpointData)
throws Exception
Exceptionprotected void handleSinkWriterRegisterEvent(SinkWriterRegisterEvent event) throws Exception
SinkWriterRegisterEvents.Exceptionprotected abstract void handleFlushSuccessEvent(FlushSuccessEvent event) throws Exception
FlushSuccessEvents.Exceptionprotected void handleGetEvolvedSchemaRequest(GetEvolvedSchemaRequest request, CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture) throws Exception
GetEvolvedSchemaRequests.Exceptionprotected void handleGetOriginalSchemaRequest(GetOriginalSchemaRequest request, CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture) throws Exception
GetOriginalSchemaRequests.Exceptionprotected abstract void handleCustomCoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest request,
CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> responseFuture)
throws Exception
CoordinationRequests.Exceptionprotected void handleUnrecoverableError(String taskDescription, Throwable t)
public final CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> handleCoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest request)
handleCoordinationRequest 在接口中 org.apache.flink.runtime.operators.coordination.CoordinationRequestHandlerpublic final void handleEventFromOperator(int subTaskId,
int attemptNumber,
org.apache.flink.runtime.operators.coordination.OperatorEvent event)
handleEventFromOperator 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorpublic final void subtaskReset(int subTaskId,
long checkpointId)
subtaskReset 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorpublic final void executionAttemptFailed(int subTaskId,
int attemptNumber,
@Nullable
Throwable reason)
executionAttemptFailed 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorpublic final void executionAttemptReady(int subTaskId,
int attemptNumber,
org.apache.flink.runtime.operators.coordination.OperatorCoordinator.SubtaskGateway gateway)
executionAttemptReady 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorpublic final void checkpointCoordinator(long checkpointId,
CompletableFuture<byte[]> completableFuture)
throws Exception
checkpointCoordinator 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorExceptionpublic final void notifyCheckpointComplete(long checkpointId)
notifyCheckpointComplete 在接口中 org.apache.flink.api.common.state.CheckpointListenernotifyCheckpointComplete 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorpublic final void resetToCheckpoint(long checkpointId,
@Nullable
byte[] checkpointData)
throws Exception
resetToCheckpoint 在接口中 org.apache.flink.runtime.operators.coordination.OperatorCoordinatorExceptionprotected void runInEventLoop(org.apache.flink.util.function.ThrowingRunnable<Throwable> action, String actionName, Object... actionNameFormatParameters)
ExecutorService. All overridable functions have
been wrapped inside already, so there's no need to call this method again. However, if you're
overriding methods from OperatorCoordinator or CoordinationRequestHandler
directly, make sure you're running heavy logics inside, or the entire job might hang!protected void loopUntil(java.util.function.BooleanSupplier conditionChecker, Runnable message, java.time.Duration timeout, java.time.Duration interval) throws TimeoutException
conditionChecker is satisfied. If not, emit a message and retry.TimeoutExceptionprotected void loopWhen(java.util.function.BooleanSupplier conditionChecker, Runnable message, java.time.Duration timeout, java.time.Duration interval) throws TimeoutException
conditionChecker is satisfied. Otherwise, emit a message and retry.TimeoutException@VisibleForTesting
public void emplaceOriginalSchema(org.apache.flink.cdc.common.event.TableId tableId,
org.apache.flink.cdc.common.schema.Schema schema)
@VisibleForTesting
public void emplaceEvolvedSchema(org.apache.flink.cdc.common.event.TableId tableId,
org.apache.flink.cdc.common.schema.Schema schema)
Copyright © 2025 The Apache Software Foundation. All rights reserved.