Java Code Examples for com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient#setEndpoint()
The following examples show how to use
com.amazonaws.services.dynamodbv2.streamsadapter.AmazonDynamoDBStreamsAdapterClient#setEndpoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamoDBStreamsProxy.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * 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; }
Example 2
Source File: DynamoDBStreamsProxy.java From flink with Apache License 2.0 | 6 votes |
/** * 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; }
Example 3
Source File: DynamoDBStreamsProxy.java From flink with Apache License 2.0 | 6 votes |
/** * 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; }
Example 4
Source File: AmazonDynamoDBStreamstoIgnite.java From aws-big-data-blog with Apache License 2.0 | 4 votes |
public void run() throws Exception { adapterClient = new AmazonDynamoDBStreamsAdapterClient(new ClientConfiguration()); adapterClient.setEndpoint(streamsEndpoint); dynamoDBClient = new AmazonDynamoDBClient(new ClientConfiguration()); dynamoDBClient.setEndpoint(dynamodbEndpoint); cloudWatchClient = new AmazonCloudWatchClient(dynamoDBCredentials, new ClientConfiguration()); TcpDiscoverySpi spi = new TcpDiscoverySpi(); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); List<String> hostList = Arrays.asList(Properties.getString("hostList").split(",")); ipFinder.setAddresses(hostList); spi.setIpFinder(ipFinder); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setDiscoverySpi(spi); cfg.setClientMode(true); cfg.setPeerClassLoadingEnabled(true); @SuppressWarnings("unused") Ignite ignite = Ignition.start(cfg); cache = Ignition.ignite().cache(Properties.getString("cacheName")); LOG.info(">>> cache acquired"); recordProcessorFactory = new StreamsRecordProcessorFactory(cache); workerConfig = new KinesisClientLibConfiguration(Properties.getString("applicationName"), streamArn, streamsCredentials, "ddbstreamsworker") .withMaxRecords(Integer.parseInt(Properties.getString("maxRecords"))) .withInitialPositionInStream( InitialPositionInStream.valueOf(Properties.getString("initialPositionInStream"))); LOG.info("Creating worker for stream: " + streamArn); worker = new Worker(recordProcessorFactory, workerConfig, adapterClient, dynamoDBClient, cloudWatchClient); LOG.info("Starting worker..."); int exitCode = 0; try { worker.run(); } catch (Throwable t) { LOG.error("Caught throwable while processing data."); t.printStackTrace(); exitCode = 1; } System.exit(exitCode); }
Example 5
Source File: StreamsAdapterDemo.java From aws-dynamodb-examples with Apache License 2.0 | 4 votes |
/** * @param args */ public static void main(String[] args) throws Exception { System.out.println("Starting demo..."); String srcTable = tablePrefix + "-src"; String destTable = tablePrefix + "-dest"; streamsCredentials = new ProfileCredentialsProvider(); dynamoDBCredentials = new ProfileCredentialsProvider(); recordProcessorFactory = new StreamsRecordProcessorFactory(dynamoDBCredentials, dynamodbEndpoint, serviceName, destTable); /* ===== REQUIRED ===== * Users will have to explicitly instantiate and configure the adapter, then pass it to * the KCL worker. */ adapterClient = new AmazonDynamoDBStreamsAdapterClient(streamsCredentials, new ClientConfiguration()); adapterClient.setEndpoint(streamsEndpoint); dynamoDBClient = new AmazonDynamoDBClient(dynamoDBCredentials, new ClientConfiguration()); dynamoDBClient.setEndpoint(dynamodbEndpoint); cloudWatchClient = new AmazonCloudWatchClient(dynamoDBCredentials, new ClientConfiguration()); setUpTables(); workerConfig = new KinesisClientLibConfiguration("streams-adapter-demo", streamArn, streamsCredentials, "streams-demo-worker") .withMaxRecords(1) .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON); System.out.println("Creating worker for stream: " + streamArn); worker = new Worker(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); }