in src/main/java/com/amazonaws/gdcreplication/util/DDBUtil.java [44:81]
public boolean trackTableImportStatus(TableReplicationStatus tableStatus, String sourceGlueCatalogId,
String targetGlueCatalogId, long importRunId, String exportBatchId, String ddbTblName) {
boolean itemInserted = false;
ClientConfiguration cc = new ClientConfiguration();
cc.setMaxErrorRetry(10);
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withClientConfiguration(cc).build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable(ddbTblName);
Item item = new Item().withPrimaryKey("table_id", tableStatus.getTableName().concat("|").concat(tableStatus.getDbName()))
.withNumber("import_run_id", importRunId)
.withString("export_batch_id", exportBatchId)
.withString("table_name", tableStatus.getTableName())
.withString("database_name", tableStatus.getDbName())
.withString("table_schema", tableStatus.getTableSchema())
.withString("target_glue_catalog_id", targetGlueCatalogId)
.withString("source_glue_catalog_id", sourceGlueCatalogId)
.withBoolean("table_created", tableStatus.isCreated())
.withBoolean("table_updated", tableStatus.isUpdated())
.withBoolean("export_has_partitions", tableStatus.isExportHasPartitions())
.withBoolean("partitions_updated", tableStatus.isPartitionsReplicated());
// Write the item to the table
try {
PutItemOutcome outcome = table.putItem(item);
int statusCode = outcome.getPutItemResult().getSdkHttpMetadata().getHttpStatusCode();
if (statusCode == 200) {
itemInserted = true;
System.out
.println("Table item inserted to DynamoDB table. Table name: " + tableStatus.getTableName());
}
} catch(Exception e) {
e.printStackTrace();
System.out.println("Could not insert a Table import status to DynamoDB table: " + ddbTblName);
}
dynamoDB.shutdown();
return itemInserted;
}