CDC 采集开发
这个提交包含在:
+65
@@ -0,0 +1,65 @@
|
||||
package cn.aixunkeji.datagov.integration.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/** Internal owner-authorized CDC execution contract; never exposed as a public request. */
|
||||
public interface RealtimeCollectionService {
|
||||
Check check(Command command);
|
||||
Result execute(Command command, String action, String externalId, String restoreId);
|
||||
List<RelayOption> relays(long actorId,long orgId,long sourceId);
|
||||
record RelayOption(String id,String name,String schema,String table,String format) implements Serializable { }
|
||||
record Spec(String name, long sourceId, long sourceVersion, String sourceDatabase, String sourceTable,
|
||||
long targetResourceId, long targetSpaceId, String targetTable, int httpPort,
|
||||
String startupMode, int checkpointSeconds, long serverId, String sourceSchema,
|
||||
String oracleDatabase,String cdcChannel,String oraclePdb,String oracleCdbService) implements Serializable {
|
||||
public Spec(String name,long sourceId,long sourceVersion,String sourceDatabase,String sourceTable,
|
||||
long targetResourceId,long targetSpaceId,String targetTable,int httpPort,String startupMode,
|
||||
int checkpointSeconds,long serverId,String sourceSchema,String oracleDatabase,String cdcChannel) {
|
||||
this(name,sourceId,sourceVersion,sourceDatabase,sourceTable,targetResourceId,targetSpaceId,targetTable,
|
||||
httpPort,startupMode,checkpointSeconds,serverId,sourceSchema,oracleDatabase,cdcChannel,null,null);
|
||||
}
|
||||
public Spec(String name,long sourceId,long sourceVersion,String sourceDatabase,String sourceTable,
|
||||
long targetResourceId,long targetSpaceId,String targetTable,int httpPort,String startupMode,
|
||||
int checkpointSeconds,long serverId,String sourceSchema,String oracleDatabase) {
|
||||
this(name,sourceId,sourceVersion,sourceDatabase,sourceTable,targetResourceId,targetSpaceId,targetTable,
|
||||
httpPort,startupMode,checkpointSeconds,serverId,sourceSchema,oracleDatabase,null);
|
||||
}
|
||||
public Spec(String name, long sourceId, long sourceVersion, String sourceDatabase, String sourceTable,
|
||||
long targetResourceId, long targetSpaceId, String targetTable, int httpPort,
|
||||
String startupMode, int checkpointSeconds, long serverId) {
|
||||
this(name, sourceId, sourceVersion, sourceDatabase, sourceTable, targetResourceId, targetSpaceId,
|
||||
targetTable, httpPort, startupMode, checkpointSeconds, serverId, null, null);
|
||||
}
|
||||
/** Keep existing MySQL checkpoint fingerprints stable across the contract extension. */
|
||||
public String fingerprintText() {
|
||||
String legacy = "Spec[name="+name+", sourceId="+sourceId+", sourceVersion="+sourceVersion+
|
||||
", sourceDatabase="+sourceDatabase+", sourceTable="+sourceTable+", targetResourceId="+targetResourceId+
|
||||
", targetSpaceId="+targetSpaceId+", targetTable="+targetTable+", httpPort="+httpPort+
|
||||
", startupMode="+startupMode+", checkpointSeconds="+checkpointSeconds+", serverId="+serverId+"]";
|
||||
if(oraclePdb!=null || oracleCdbService!=null)return toString();
|
||||
String previous=toString().replace(", oraclePdb=null, oracleCdbService=null]","]");
|
||||
if(cdcChannel!=null)return previous;
|
||||
return sourceSchema == null && oracleDatabase == null ? legacy : previous.replace(", cdcChannel=null]","]");
|
||||
}
|
||||
}
|
||||
record Command(long actorId, long orgId, long taskId, long attempt, Spec spec,
|
||||
DataCollectionIntegrationService.StorageExecutionProfile target, String fingerprint,
|
||||
RecoveryEvidence recovery) implements Serializable {
|
||||
public Command(long actorId,long orgId,long taskId,long attempt,Spec spec,
|
||||
DataCollectionIntegrationService.StorageExecutionProfile target,String fingerprint) {
|
||||
this(actorId,orgId,taskId,attempt,spec,target,fingerprint,null);
|
||||
}
|
||||
}
|
||||
/** Supplied only by DataOps from its locked, owner-authorized persisted task. */
|
||||
record RecoveryEvidence(String jobId,String status,String checkpointId) implements Serializable { }
|
||||
record Check(boolean ready, String summary, String fingerprint, List<String> fields, List<String> primaryKeys)
|
||||
implements Serializable { }
|
||||
record Result(String status, String externalId, String summary, String checkpointId, Long readRows,
|
||||
Long writeRows) implements Serializable { }
|
||||
static String identity(long org, long task, long attempt) { return "realtime:" + org + ':' + task + ':' + attempt; }
|
||||
static String jobName(long task, long attempt) { return "aixun_cdc_" + task + '_' + attempt; }
|
||||
static String jobId(long org, long task, long attempt) {
|
||||
return Long.toString(DataCollectionIntegrationService.stableJobId(identity(org, task, attempt)));
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户