use of com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient in project flink by apache.
the class DynamoDBStreamsProxy method createKinesisClient.
/**
* Creates an AmazonDynamoDBStreamsAdapterClient. Uses it as the internal client interacting
* with the DynamoDB streams.
*
* @param configProps configuration properties
* @return an AWS DynamoDB streams adapter client
*/
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
setAwsClientConfigProperties(awsClientConfig, configProps);
AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
awsClientConfig.setUserAgentPrefix(String.format(USER_AGENT_FORMAT, EnvironmentInformation.getVersion(), EnvironmentInformation.getRevisionInformation().commitId));
AmazonDynamoDBStreamsAdapterClient adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);
if (configProps.containsKey(AWS_ENDPOINT)) {
adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
} else {
adapterClient.setRegion(Region.getRegion(Regions.fromName(configProps.getProperty(AWS_REGION))));
}
return adapterClient;
}
use of com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient in project aws-doc-sdk-examples by awsdocs.
the class StreamsAdapterDemo method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
System.out.println("Starting demo...");
dynamoDBClient = AmazonDynamoDBClientBuilder.standard().withRegion(awsRegion).build();
cloudWatchClient = AmazonCloudWatchClientBuilder.standard().withRegion(awsRegion).build();
dynamoDBStreamsClient = AmazonDynamoDBStreamsClientBuilder.standard().withRegion(awsRegion).build();
adapterClient = new AmazonDynamoDBStreamsAdapterClient(dynamoDBStreamsClient);
String srcTable = tablePrefix + "-src";
String destTable = tablePrefix + "-dest";
recordProcessorFactory = new StreamsRecordProcessorFactory(dynamoDBClient, destTable);
setUpTables();
workerConfig = new KinesisClientLibConfiguration("streams-adapter-demo", streamArn, awsCredentialsProvider, "streams-demo-worker").withMaxRecords(1000).withIdleTimeBetweenReadsInMillis(500).withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON);
System.out.println("Creating worker for stream: " + streamArn);
worker = StreamsWorkerFactory.createDynamoDbStreamsWorker(recordProcessorFactory, workerConfig, adapterClient, dynamoDBClient, cloudWatchClient);
System.out.println("Starting worker...");
Thread t = new Thread(worker);
t.start();
Thread.sleep(25000);
worker.shutdown();
t.join();
if (StreamsAdapterDemoHelper.scanTable(dynamoDBClient, srcTable).getItems().equals(StreamsAdapterDemoHelper.scanTable(dynamoDBClient, destTable).getItems())) {
System.out.println("Scan result is equal.");
} else {
System.out.println("Tables are different!");
}
System.out.println("Done.");
cleanupAndExit(0);
}
Aggregations