com.amazonaws.services.dynamodbv2.model.StreamViewType Java Examples
The following examples show how to use
com.amazonaws.services.dynamodbv2.model.StreamViewType.
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: StreamsAdapterDemoHelper.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
/** * @return StreamArn */ public static String createTable(AmazonDynamoDB client, String tableName) { java.util.List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>(); attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N")); java.util.List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>(); keySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH)); // Partition // key ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput().withReadCapacityUnits(2L) .withWriteCapacityUnits(2L); StreamSpecification streamSpecification = new StreamSpecification(); streamSpecification.setStreamEnabled(true); streamSpecification.setStreamViewType(StreamViewType.NEW_IMAGE); CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(tableName) .withAttributeDefinitions(attributeDefinitions).withKeySchema(keySchema) .withProvisionedThroughput(provisionedThroughput).withStreamSpecification(streamSpecification); try { System.out.println("Creating table " + tableName); CreateTableResult result = client.createTable(createTableRequest); return result.getTableDescription().getLatestStreamArn(); } catch (ResourceInUseException e) { System.out.println("Table already exists."); return describeTable(client, tableName).getTable().getLatestStreamArn(); } }
Example #2
Source File: DynamoDBConnectorUtilities.java From dynamodb-cross-region-library with Apache License 2.0 | 5 votes |
/** * Check whether Streams is enabled on the given argument with the given stream view type * * @param streamsClient * streams client used to access the given stream * @param streamArn * the stream ARN to check against * @param viewType * the stream view type to check against * @return a boolean indicating whether the given stream is enabled and matches the given stream view type */ public static boolean isStreamsEnabled(AmazonDynamoDBStreams streamsClient, String streamArn, StreamViewType viewType) { // Get and check stream description StreamDescription result = streamsClient.describeStream(new DescribeStreamRequest().withStreamArn(streamArn)) .getStreamDescription(); if (result.getStreamStatus().equalsIgnoreCase(DynamoDBConnectorConstants.ENABLED_STRING) && result.getStreamViewType().equalsIgnoreCase(viewType.toString())) { return true; } log.error(DynamoDBConnectorConstants.STREAM_NOT_READY + " StreamARN: " + streamArn); return false; }
Example #3
Source File: DynamoDBUtils.java From wildfly-camel with Apache License 2.0 | 5 votes |
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException { CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName) .withKeySchema(new KeySchemaElement("Id", KeyType.HASH)) .withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N)) .withProvisionedThroughput(new ProvisionedThroughput(10L, 10L)) .withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES)); DynamoDB dynamoDB = new DynamoDB(client); Table table = dynamoDB.createTable(tableReq); return table.waitForActive(); }
Example #4
Source File: StreamsAdapterDemoHelper.java From aws-dynamodb-examples with Apache License 2.0 | 5 votes |
/** * @return StreamArn */ public static String createTable(AmazonDynamoDBClient client, String tableName) { java.util.List<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>(); attributeDefinitions.add(new AttributeDefinition().withAttributeName("Id").withAttributeType("N")); java.util.List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>(); keySchema.add(new KeySchemaElement().withAttributeName("Id").withKeyType(KeyType.HASH)); ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput() .withReadCapacityUnits(2L).withWriteCapacityUnits(2L); StreamSpecification streamSpecification = new StreamSpecification(); streamSpecification.setStreamEnabled(true); streamSpecification.setStreamViewType(StreamViewType.NEW_IMAGE); CreateTableRequest createTableRequest = new CreateTableRequest() .withTableName(tableName) .withAttributeDefinitions(attributeDefinitions) .withKeySchema(keySchema) .withProvisionedThroughput(provisionedThroughput) .withStreamSpecification(streamSpecification); try { System.out.println("Creating table " + tableName); CreateTableResult result = client.createTable(createTableRequest); return result.getTableDescription().getLatestStreamArn(); } catch(ResourceInUseException e) { System.out.println("Table already exists."); return describeTable(client, tableName).getTable().getLatestStreamArn(); } }
Example #5
Source File: DynamodbEventDeserializer.java From bender with Apache License 2.0 | 4 votes |
@JsonIgnore public void setStreamViewType(StreamViewType streamViewType);
Example #6
Source File: DynamoDBStreamsRecordObjectMapper.java From dynamodb-cross-region-library with Apache License 2.0 | 4 votes |
@JsonIgnore public abstract void setStreamViewType(StreamViewType streamViewType);
Example #7
Source File: CrossRegionReplicationIntegrationTests.java From dynamodb-cross-region-library with Apache License 2.0 | 4 votes |
@Test public void testBothTablesAddStreamAfterCreation() throws InterruptedException { //create table one in one region final CreateTableRequest iadCreateTableRequest = createTableRequest(INVENTORY_TABLE_IAD); dynamoDbIad.createTable(iadCreateTableRequest .withStreamSpecification(new StreamSpecification() .withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES) .withStreamEnabled(true))); //create table two in another region final CreateTableRequest pdxCreateTableRequest = createTableRequest(INVENTORY_TABLE_PDX); dynamoDbPdx.createTable(pdxCreateTableRequest); //create and start the command line client and worker final List<String> commandLineArgs = Lists.newArrayList( "--sourceEndpoint", DYNAMODB_LOCAL_ENDPOINT, // override the signing region as DynamoDB Local uses it to create different table namespaces "--sourceSigningRegion", Regions.US_EAST_1.getName(), "--sourceTable", INVENTORY_TABLE_IAD, "--destinationEndpoint", DYNAMODB_LOCAL_ENDPOINT, // override the signing region as DynamoDB Local uses it to create different table namespaces "--destinationSigningRegion", Regions.US_WEST_2.getName(), "--destinationTable", INVENTORY_TABLE_PDX, "--taskName", CRR_INTEGRATION_TEST, // 100ms - override to reduce the time to sleep "--parentShardPollIntervalMillis", "100", "--dontPublishCloudwatch"); final String[] args = commandLineArgs.toArray(new String[commandLineArgs.size()]); final Worker worker = CommandLineInterface.mainUnsafe(args).get(); final Thread workerThread = new Thread(worker, "KCLWorker"); workerThread.start(); //perform the updates on the source table final Item asin1sea = new Item().withString(SKU_CODE, ASIN_1).withString(STORE, SEA); iadTable.putItem(asin1sea); final Item asin1seaRead = iadTable.getItem(SKU_CODE, ASIN_1, STORE, SEA); assertEquals(asin1sea, asin1seaRead); //verify the updates on the destination table //wait for the worker to start and the update to propagate Thread.sleep(10000); final List<Item> pdxItems = new ArrayList<>(); for(Item item : pdxTable.scan()) { pdxItems.add(item); } assertEquals(1, pdxItems.size()); final Item copied = Iterables.getOnlyElement(pdxItems); assertEquals(asin1sea, copied); //close the worker worker.shutdown(); //this leaks threads, I wonder }