Java Code Examples for com.amazonaws.services.dynamodbv2.AmazonDynamoDB#shutdown()
The following examples show how to use
com.amazonaws.services.dynamodbv2.AmazonDynamoDB#shutdown() .
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: Aws1ITest.java From java-specialagent with Apache License 2.0 | 6 votes |
public static void main(final String[] args) throws Exception { System.getProperties().setProperty("sqlite4java.library.path", "src/test/resources/libs"); final DynamoDBProxyServer server = ServerRunner.createServerFromCommandLineArgs(new String[] {"-inMemory", "-port", "8000"}); server.start(); final AmazonDynamoDB dbClient = buildClient(); try { createTable(dbClient, "tableName-" + ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)); } catch (final Exception e) { System.out.println("Exception: " + e.getMessage() + "\nIgnoring."); } server.stop(); dbClient.shutdown(); TestUtil.checkSpan(new ComponentSpanCount("java-aws-sdk", 1)); System.exit(0); }
Example 2
Source File: EncryptionContextOverridesWithDynamoDBMapper.java From aws-dynamodb-encryption-java with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws GeneralSecurityException { final String cmkArn = args[0]; final String region = args[1]; final String encryptionContextTableName = args[2]; AmazonDynamoDB ddb = null; AWSKMS kms = null; try { ddb = AmazonDynamoDBClientBuilder.standard().withRegion(region).build(); kms = AWSKMSClientBuilder.standard().withRegion(region).build(); encryptRecord(cmkArn, encryptionContextTableName, ddb, kms); } finally { if (ddb != null) { ddb.shutdown(); } if (kms != null) { kms.shutdown(); } } }
Example 3
Source File: DynamoDBEmbeddedTest.java From aws-dynamodb-examples with Apache License 2.0 | 6 votes |
@Test public void createTableTest() { AmazonDynamoDB ddb = DynamoDBEmbedded.create().amazonDynamoDB(); try { String tableName = "Movies"; String hashKeyName = "film_id"; CreateTableResult res = createTable(ddb, tableName, hashKeyName); TableDescription tableDesc = res.getTableDescription(); assertEquals(tableName, tableDesc.getTableName()); assertEquals("[{AttributeName: " + hashKeyName + ",KeyType: HASH}]", tableDesc.getKeySchema().toString()); assertEquals("[{AttributeName: " + hashKeyName + ",AttributeType: S}]", tableDesc.getAttributeDefinitions().toString()); assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getReadCapacityUnits()); assertEquals(Long.valueOf(1000L), tableDesc.getProvisionedThroughput().getWriteCapacityUnits()); assertEquals("ACTIVE", tableDesc.getTableStatus()); assertEquals("arn:aws:dynamodb:ddblocal:000000000000:table/Movies", tableDesc.getTableArn()); ListTablesResult tables = ddb.listTables(); assertEquals(1, tables.getTableNames().size()); } finally { ddb.shutdown(); } }
Example 4
Source File: DynamoDBLocalFixture.java From aws-dynamodb-examples with Apache License 2.0 | 6 votes |
/** * You can use mvn to run DynamoDBLocalFixture, e.g. * <p> * $ mvn clean package * <p> * $ mvn exec:java -Dexec.mainClass="com.amazonaws.services.dynamodbv2.DynamoDBLocalFixture" \ * -Dexec.classpathScope="test" \ * -Dsqlite4java.library.path=target/dependencies * <p> * It's recommended to run "aws configure" one time before you run DynamoDBLocalFixture * * @param args - no args * @throws Exception */ public static void main(String[] args) throws Exception { AmazonDynamoDB dynamodb = null; try { // Create an in-memory and in-process instance of DynamoDB Local that skips HTTP dynamodb = DynamoDBEmbedded.create().amazonDynamoDB(); // use the DynamoDB API with DynamoDBEmbedded listTables(dynamodb.listTables(), "DynamoDB Embedded"); } finally { // Shutdown the thread pools in DynamoDB Local / Embedded if(dynamodb != null) { dynamodb.shutdown(); } } // Create an in-memory and in-process instance of DynamoDB Local that runs over HTTP final String[] localArgs = { "-inMemory" }; DynamoDBProxyServer server = null; try { server = ServerRunner.createServerFromCommandLineArgs(localArgs); server.start(); dynamodb = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration( // we can use any region here new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2")) .build(); // use the DynamoDB API over HTTP listTables(dynamodb.listTables(), "DynamoDB Local over HTTP"); } finally { // Stop the DynamoDB Local endpoint if(server != null) { server.stop(); } } }
Example 5
Source File: TitanGraphDatabase.java From graphdb-benchmarks with Apache License 2.0 | 5 votes |
private void open(boolean batchLoading) { if(type == GraphDatabaseType.TITAN_DYNAMODB && config.getDynamodbPrecreateTables()) { List<CreateTableRequest> requests = new LinkedList<>(); long wcu = config.getDynamodbTps(); long rcu = Math.max(1, config.dynamodbConsistentRead() ? wcu : (wcu / 2)); for(String store : Constants.REQUIRED_BACKEND_STORES) { final String tableName = config.getDynamodbTablePrefix() + "_" + store; if(BackendDataModel.MULTI == config.getDynamodbDataModel()) { requests.add(DynamoDBStore.createTableRequest(tableName, rcu, wcu)); } else if(BackendDataModel.SINGLE == config.getDynamodbDataModel()) { requests.add(DynamoDBSingleRowStore.createTableRequest(tableName, rcu, wcu)); } } //TODO is this autocloseable? final AmazonDynamoDB client = new AmazonDynamoDBClient(Client.createAWSCredentialsProvider(config.getDynamodbCredentialsFqClassName(), config.getDynamodbCredentialsCtorArguments() == null ? null : config.getDynamodbCredentialsCtorArguments().split(","))); client.setEndpoint(config.getDynamodbEndpoint()); for(CreateTableRequest request : requests) { try { client.createTable(request); } catch(ResourceInUseException ignore) { //already created, good } } client.shutdown(); } titanGraph = buildTitanGraph(type, dbStorageDirectory, config, batchLoading); }
Example 6
Source File: ITTracingRequestHandler.java From zipkin-aws with Apache License 2.0 | 4 votes |
@Override protected void closeClient(AmazonDynamoDB dynamoDB) { dynamoDB.shutdown(); }