forked from apache/seatunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c5ef2d
commit 8d1e46d
Showing
13 changed files
with
982 additions
and
232 deletions.
There are no files selected for viewing
102 changes: 0 additions & 102 deletions
102
.../src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBDialect.java
This file was deleted.
Oops, something went wrong.
108 changes: 0 additions & 108 deletions
108
...java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBIncrementalSource.java
This file was deleted.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
...b/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source; | ||
|
||
import org.apache.seatunnel.api.common.JobContext; | ||
import org.apache.seatunnel.api.configuration.ReadonlyConfig; | ||
import org.apache.seatunnel.api.source.Boundedness; | ||
import org.apache.seatunnel.api.source.SeaTunnelSource; | ||
import org.apache.seatunnel.api.source.SourceReader; | ||
import org.apache.seatunnel.api.source.SourceSplitEnumerator; | ||
import org.apache.seatunnel.api.source.SupportColumnProjection; | ||
import org.apache.seatunnel.api.source.SupportParallelism; | ||
import org.apache.seatunnel.api.table.catalog.CatalogTable; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelDataType; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelRow; | ||
import org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source.config.TiDBSourceConfig; | ||
import org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source.config.TiDBSourceOptions; | ||
import org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source.enumerator.TiDBSourceCheckpointState; | ||
import org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source.enumerator.TiDBSourceSplitEnumerator; | ||
import org.apache.seatunnel.connectors.seatunnel.cdc.tidb.source.split.TiDBSourceSplit; | ||
|
||
import java.util.List; | ||
|
||
public class TiDBSource | ||
implements SeaTunnelSource<SeaTunnelRow, TiDBSourceSplit, TiDBSourceCheckpointState>, | ||
SupportParallelism, | ||
SupportColumnProjection { | ||
|
||
private JobContext jobContext; | ||
private SeaTunnelDataType<SeaTunnelRow> seaTunnelDataType; | ||
private TiDBSourceConfig config; | ||
static final String IDENTIFIER = "TIDB-CDC"; | ||
|
||
public TiDBSource( | ||
ReadonlyConfig config, | ||
SeaTunnelDataType<SeaTunnelRow> seaTunnelDataType, | ||
List<CatalogTable> catalogTables) { | ||
|
||
this.config = | ||
TiDBSourceConfig.builder() | ||
.startupMode(config.get(TiDBSourceOptions.STARTUP_MODE)) | ||
.databaseName(config.get(TiDBSourceOptions.DATABASE_NAME)) | ||
.tableName(config.get(TiDBSourceOptions.TABLE_NAME)) | ||
.tiConfiguration(TiDBSourceOptions.getTiConfiguration(config)) | ||
.build(); | ||
this.seaTunnelDataType = seaTunnelDataType; | ||
} | ||
|
||
/** | ||
* Returns a unique identifier among same factory interfaces. | ||
* | ||
* <p>For consistency, an identifier should be declared as one lower case word (e.g. {@code | ||
* kafka}). If multiple factories exist for different versions, a version should be appended | ||
* using "-" (e.g. {@code elasticsearch-7}). | ||
*/ | ||
@Override | ||
public String getPluginName() { | ||
return IDENTIFIER; | ||
} | ||
|
||
@Override | ||
public void setJobContext(JobContext jobContext) { | ||
this.jobContext = jobContext; | ||
} | ||
|
||
/** | ||
* Get the boundedness of this source. | ||
* | ||
* @return the boundedness of this source. | ||
*/ | ||
@Override | ||
public Boundedness getBoundedness() { | ||
return Boundedness.UNBOUNDED; | ||
} | ||
|
||
/** | ||
* Create source reader, used to produce data. | ||
* | ||
* @param context reader context. | ||
* @return source reader. | ||
* @throws Exception when create reader failed. | ||
*/ | ||
@Override | ||
public SourceReader<SeaTunnelRow, TiDBSourceSplit> createReader(SourceReader.Context context) | ||
throws Exception { | ||
return null; | ||
} | ||
|
||
/** | ||
* Create source split enumerator, used to generate splits. This method will be called only once | ||
* when start a source. | ||
* | ||
* @param context enumerator context. | ||
* @return source split enumerator. | ||
* @throws Exception when create enumerator failed. | ||
*/ | ||
@Override | ||
public SourceSplitEnumerator<TiDBSourceSplit, TiDBSourceCheckpointState> createEnumerator( | ||
SourceSplitEnumerator.Context<TiDBSourceSplit> context) throws Exception { | ||
return new TiDBSourceSplitEnumerator(context, config); | ||
} | ||
|
||
/** | ||
* Create source split enumerator, used to generate splits. This method will be called when | ||
* restore from checkpoint. | ||
* | ||
* @param context enumerator context. | ||
* @param checkpointState checkpoint state. | ||
* @return source split enumerator. | ||
* @throws Exception when create enumerator failed. | ||
*/ | ||
@Override | ||
public SourceSplitEnumerator<TiDBSourceSplit, TiDBSourceCheckpointState> restoreEnumerator( | ||
SourceSplitEnumerator.Context<TiDBSourceSplit> context, | ||
TiDBSourceCheckpointState checkpointState) | ||
throws Exception { | ||
return new TiDBSourceSplitEnumerator(context, config, checkpointState); | ||
} | ||
} |
Oops, something went wrong.