23
23
import org .apache .flink .table .connector .source .DynamicTableSource ;
24
24
import org .apache .flink .table .factories .DynamicTableSourceFactory ;
25
25
import org .apache .flink .table .factories .FactoryUtil ;
26
- import org .apache .flink .util .Preconditions ;
27
26
28
27
import com .ververica .cdc .connectors .mysql .source .config .MySqlSourceOptions ;
29
28
import com .ververica .cdc .connectors .mysql .source .config .ServerIdRange ;
@@ -109,7 +108,6 @@ public DynamicTableSource createDynamicTableSource(Context context) {
109
108
boolean enableParallelRead = config .get (SCAN_INCREMENTAL_SNAPSHOT_ENABLED );
110
109
if (enableParallelRead ) {
111
110
validatePrimaryKeyIfEnableParallel (physicalSchema );
112
- validateStartupOptionIfEnableParallel (startupOptions );
113
111
validateIntegerOption (SCAN_INCREMENTAL_SNAPSHOT_CHUNK_SIZE , splitSize , 1 );
114
112
validateIntegerOption (CHUNK_META_GROUP_SIZE , splitMetaGroupSize , 1 );
115
113
validateIntegerOption (SCAN_SNAPSHOT_FETCH_SIZE , fetchSize , 1 );
@@ -204,15 +202,15 @@ private static StartupOptions getStartupOptions(ReadableConfig config) {
204
202
return StartupOptions .latest ();
205
203
206
204
case SCAN_STARTUP_MODE_VALUE_EARLIEST :
205
+ return StartupOptions .earliest ();
206
+
207
207
case SCAN_STARTUP_MODE_VALUE_SPECIFIC_OFFSET :
208
+ return StartupOptions .specificOffset (
209
+ config .get (SCAN_STARTUP_SPECIFIC_OFFSET_FILE ),
210
+ config .get (SCAN_STARTUP_SPECIFIC_OFFSET_POS ));
211
+
208
212
case SCAN_STARTUP_MODE_VALUE_TIMESTAMP :
209
- throw new ValidationException (
210
- String .format (
211
- "Unsupported option value '%s', the options [%s, %s, %s] are not supported correctly, please do not use them until they're correctly supported" ,
212
- modeString ,
213
- SCAN_STARTUP_MODE_VALUE_EARLIEST ,
214
- SCAN_STARTUP_MODE_VALUE_SPECIFIC_OFFSET ,
215
- SCAN_STARTUP_MODE_VALUE_TIMESTAMP ));
213
+ return StartupOptions .timestamp (config .get (SCAN_STARTUP_TIMESTAMP_MILLIS ));
216
214
217
215
default :
218
216
throw new ValidationException (
@@ -234,17 +232,6 @@ private void validatePrimaryKeyIfEnableParallel(ResolvedSchema physicalSchema) {
234
232
}
235
233
}
236
234
237
- private void validateStartupOptionIfEnableParallel (StartupOptions startupOptions ) {
238
- // validate mode
239
- Preconditions .checkState (
240
- startupOptions .startupMode == StartupMode .INITIAL
241
- || startupOptions .startupMode == StartupMode .LATEST_OFFSET ,
242
- String .format (
243
- "MySql Parallel Source only supports startup mode 'initial' and 'latest-offset',"
244
- + " but actual is %s" ,
245
- startupOptions .startupMode ));
246
- }
247
-
248
235
private String validateAndGetServerId (ReadableConfig configuration ) {
249
236
final String serverIdValue = configuration .get (MySqlSourceOptions .SERVER_ID );
250
237
if (serverIdValue != null ) {
0 commit comments