getAppliedSchemaChangeEvents() {
return appliedSchemaChangeEvents;
}
@@ -118,43 +68,21 @@ public boolean equals(Object o) {
}
SchemaChangeResponse response = (SchemaChangeResponse) o;
return Objects.equals(appliedSchemaChangeEvents, response.appliedSchemaChangeEvents)
- && responseCode == response.responseCode;
+ && Objects.equals(evolvedSchemas, response.evolvedSchemas);
}
@Override
public int hashCode() {
- return Objects.hash(appliedSchemaChangeEvents, responseCode);
+ return Objects.hash(appliedSchemaChangeEvents, evolvedSchemas);
}
@Override
public String toString() {
return "SchemaChangeResponse{"
- + "schemaChangeEvents="
+ + "appliedSchemaChangeEvents="
+ appliedSchemaChangeEvents
- + ", responseCode="
- + responseCode
+ + ", evolvedSchemas="
+ + evolvedSchemas
+ '}';
}
-
- /**
- * Schema Change Response status code.
- *
- * - Accepted: Requested schema change request has been accepted exclusively. Any other
- * schema change requests will be blocked.
- *
- *
- Busy: Schema registry is currently busy processing another schema change request.
- *
- *
- Duplicate: This schema change request has been submitted before, possibly by another
- * paralleled subTask.
- *
- *
- Ignored: This schema change request has been assessed, but no actual evolution is
- * required. Possibly caused by LENIENT mode or merging table strategies.
- */
- public enum ResponseCode {
- SUCCESS,
- BUSY,
- DUPLICATE,
- IGNORED,
- WAITING_FOR_FLUSH
- }
}
diff --git a/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/operators/sink/DataSinkOperatorWithSchemaEvolveTest.java b/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/operators/sink/DataSinkOperatorWithSchemaEvolveTest.java
index fbeb325066f..19753675101 100644
--- a/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/operators/sink/DataSinkOperatorWithSchemaEvolveTest.java
+++ b/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/operators/sink/DataSinkOperatorWithSchemaEvolveTest.java
@@ -87,16 +87,12 @@ private void processSchemaChangeEvent(
// Create the flush event to process before the schema change event
FlushEvent flushEvent = createFlushEvent(tableId, event);
- // Send schema change request to coordinator
- schemaOperatorHarness.requestSchemaChangeEvent(tableId, event);
-
// Send flush event to SinkWriterOperator
dataSinkWriterOperator.processElement(new StreamRecord<>(flushEvent));
- // Wait for coordinator to complete the schema change and get the finished schema change
- // events
+ // Send schema change request to coordinator
SchemaChangeResponse schemaEvolveResponse =
- schemaOperatorHarness.requestSchemaChangeResult(tableId, event);
+ schemaOperatorHarness.requestSchemaChangeEvent(tableId, event);
List finishedSchemaChangeEvents =
schemaEvolveResponse.getAppliedSchemaChangeEvents();
diff --git a/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/testutils/operators/RegularEventOperatorTestHarness.java b/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/testutils/operators/RegularEventOperatorTestHarness.java
index 11a97064984..ea4de7a14e7 100644
--- a/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/testutils/operators/RegularEventOperatorTestHarness.java
+++ b/flink-cdc-runtime/src/test/java/org/apache/flink/cdc/runtime/testutils/operators/RegularEventOperatorTestHarness.java
@@ -23,6 +23,7 @@
import org.apache.flink.cdc.common.event.SchemaChangeEventType;
import org.apache.flink.cdc.common.event.SchemaChangeEventTypeFamily;
import org.apache.flink.cdc.common.event.TableId;
+import org.apache.flink.cdc.common.pipeline.PipelineOptions;
import org.apache.flink.cdc.common.pipeline.SchemaChangeBehavior;
import org.apache.flink.cdc.common.schema.Schema;
import org.apache.flink.cdc.runtime.operators.schema.common.CoordinationResponseUtils;
@@ -66,10 +67,8 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
-import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
-import static org.apache.flink.cdc.common.pipeline.PipelineOptions.DEFAULT_SCHEMA_OPERATOR_RPC_TIMEOUT;
import static org.apache.flink.cdc.runtime.operators.schema.common.CoordinationResponseUtils.unwrap;
/**
@@ -91,6 +90,9 @@ public class RegularEventOperatorTestHarness with(OP operator, int numOutputs) {
operator,
numOutputs,
null,
- null,
+ DEFAULT_RPC_TIMEOUT,
SchemaChangeBehavior.EVOLVE,
Arrays.stream(SchemaChangeEventTypeFamily.ALL).collect(Collectors.toSet()),
Collections.emptySet());
@@ -143,7 +145,7 @@ RegularEventOperatorTestHarness withDuration(
operator,
numOutputs,
evolveDuration,
- null,
+ DEFAULT_RPC_TIMEOUT,
SchemaChangeBehavior.EVOLVE,
Arrays.stream(SchemaChangeEventTypeFamily.ALL).collect(Collectors.toSet()),
Collections.emptySet());
@@ -159,7 +161,7 @@ RegularEventOperatorTestHarness withDurationAndBehavior(
operator,
numOutputs,
evolveDuration,
- null,
+ DEFAULT_RPC_TIMEOUT,
behavior,
Arrays.stream(SchemaChangeEventTypeFamily.ALL).collect(Collectors.toSet()),
Collections.emptySet());
@@ -176,7 +178,7 @@ RegularEventOperatorTestHarness withDurationAndFineGrainedBehavior(
operator,
numOutputs,
evolveDuration,
- null,
+ DEFAULT_RPC_TIMEOUT,
behavior,
enabledEventTypes,
Collections.emptySet());
@@ -195,7 +197,7 @@ RegularEventOperatorTestHarness withDurationAndFineGrainedBehaviorWithErr
operator,
numOutputs,
evolveDuration,
- null,
+ DEFAULT_RPC_TIMEOUT,
behavior,
enabledEventTypes,
errorOnEventTypes);
@@ -240,31 +242,6 @@ public SchemaChangeResponse requestSchemaChangeEvent(TableId tableId, SchemaChan
.get());
}
- public SchemaChangeResponse requestSchemaChangeResult(TableId tableId, SchemaChangeEvent event)
- throws ExecutionException, InterruptedException, TimeoutException {
- long rpcTimeOutInMillis = DEFAULT_SCHEMA_OPERATOR_RPC_TIMEOUT.toMillis();
- long deadline = System.currentTimeMillis() + rpcTimeOutInMillis;
- while (true) {
- LOG.info("request schema change result");
- SchemaChangeResponse response = requestSchemaChangeEvent(tableId, event);
- if (System.currentTimeMillis() < deadline) {
- if (response.isRegistryBusy()) {
- LOG.info("{}> Schema Registry is busy now, waiting for next request...", 0);
- Thread.sleep(1000);
- } else if (response.isWaitingForFlush()) {
- LOG.info(
- "{}> Schema change event has not collected enough flush success events from writers, waiting...",
- 0);
- Thread.sleep(1000);
- } else {
- return response;
- }
- } else {
- throw new TimeoutException("Timeout when requesting schema change.");
- }
- }
- }
-
public Schema getLatestOriginalSchema(TableId tableId) throws Exception {
return ((GetOriginalSchemaResponse)
unwrap(