Example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient setEndpoint

List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient setEndpoint

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient setEndpoint.

Prototype

@Deprecated
public void setEndpoint(String endpoint) throws IllegalArgumentException 

Source Link

Document

Overrides the default endpoint for this client.

Usage

From source file:awskinesis.AmazonKinesisApplicationSample.java

License:Apache License

public static void deleteResources() {
    AWSCredentials credentials = credentialsProvider.getCredentials();

    // Delete the stream
    AmazonKinesis kinesis = new AmazonKinesisClient(credentials);
    kinesis.setEndpoint("kinesis.cn-north-1.amazonaws.com.cn");
    System.out.printf("Deleting the Amazon Kinesis stream used by the sample. Stream Name = %s.\n",
            SAMPLE_APPLICATION_STREAM_NAME);
    try {/*from   w  w  w.  jav  a  2s .c  om*/
        kinesis.deleteStream(SAMPLE_APPLICATION_STREAM_NAME);
    } catch (ResourceNotFoundException ex) {
        // The stream doesn't exist.
    }

    // Delete the table
    AmazonDynamoDBClient dynamoDB = new AmazonDynamoDBClient(credentialsProvider.getCredentials());
    dynamoDB.setEndpoint("dynamodb.cn-north-1.amazonaws.com.cn");
    System.out.printf(
            "Deleting the Amazon DynamoDB table used by the Amazon Kinesis Client Library. Table Name = %s.\n",
            SAMPLE_APPLICATION_NAME);
    try {
        dynamoDB.deleteTable(SAMPLE_APPLICATION_NAME);
    } catch (com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException ex) {
        // The table doesn't exist.
    }
}

From source file:ch.qos.logback.more.appenders.DynamoDBLogbackAppender.java

License:Apache License

private boolean initializeAppender() {
    try {//from  w  w  w . j a v  a 2  s. c  om
        PropertiesCredentials credentials = new PropertiesCredentials(
                getClass().getClassLoader().getResourceAsStream(dynamodbCredentialFilePath));
        AmazonDynamoDBClient dynamoClient = new AmazonDynamoDBClient(credentials);
        dynamoClient.setEndpoint(dynamodbEndpoint);
        appender = new DynamoDBDaemonAppender(outputTableName, instanceName,
                getLastId(outputTableName, instanceName, dynamoClient), dynamoClient, layout, maxQueueSize);
        return true;
    } catch (Exception e) {
        System.err.println("Could not initialize " + DynamoDBLogbackAppender.class.getCanonicalName()
                + " ( will try to initialize again later ): " + e);
        return false;
    }
}

From source file:com.cfelde.aws.ddb.management.TableThroughput.java

License:Open Source License

public static void main(String... args) {
    loadPartitionState();//from   w  w  w.j  a  va 2s. c o m

    // TODO: All these parameters should be loaded from a config file!
    String accessKey = "YOUR ACCESS KEY";
    String secretKey = "YOUR SECRET KEY";

    AmazonCloudWatch client = new AmazonCloudWatchClient(new BasicAWSCredentials(accessKey, secretKey));
    AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(new BasicAWSCredentials(accessKey, secretKey));

    client.setEndpoint("https://monitoring.eu-west-1.amazonaws.com");
    ddb.setEndpoint("https://dynamodb.eu-west-1.amazonaws.com");

    // Do one per table you want to manage
    initTableThroughput(client, ddb, "table1", 2, 100, 2, 100);
    initTableThroughput(client, ddb, "table2", 2, 100, 2, 100);

    executor.scheduleWithFixedDelay(new Runnable() {
        @Override
        public void run() {
            storePartitionState();
        }
    }, 16, 61, TimeUnit.MINUTES);
}

From source file:com.rorrell.personrest.data.DynamoDbConnector.java

private DynamoDbConnector() {
    BasicAWSCredentials cred = new BasicAWSCredentials("AKIAIBHWKCCV7G6N3MEA",
            "DVtEDwvUSS7xFVH4ATY0JohxhQLesJjD2V4i25kC");
    AmazonDynamoDBClient client = new AmazonDynamoDBClient(cred);
    client.setEndpoint("dynamodb.us-west-2.amazonaws.com");
    db = new DynamoDBMapper(client);

}

From source file:io.exemplary.aws.DynamoDBServer.java

License:Apache License

private void deleteAllTables() {
    AmazonDynamoDBClient client = new AmazonDynamoDBClient(new BasicAWSCredentials("accessKey", "secretKey"));
    client.setEndpoint(getEndpoint());
    ListTablesResult result = client.listTables(new ListTablesRequest());
    for (String tableName : result.getTableNames()) {
        client.deleteTable(new DeleteTableRequest(tableName));
    }//from w  w w . j a v  a 2s  .  c om
    client.shutdown();
}

From source file:jp.buyee.glover.KinesisConnectorExecutor.java

License:Open Source License

/**
 * Helper method to create the Amazon DynamoDB table.
 * //from  ww w .  j  av  a 2 s  . com
 * @param key
 *        The name of the hashkey field in the Amazon DynamoDB table
 * @param readCapacityUnits
 *        Read capacity of the Amazon DynamoDB table
 * @param writeCapacityUnits
 *        Write capacity of the Amazon DynamoDB table
 */
private void createDynamoDBTable(String key, long readCapacityUnits, long writeCapacityUnits) {
    LOG.info("Creating Amazon DynamoDB table " + config.DYNAMODB_DATA_TABLE_NAME);
    AmazonDynamoDBClient dynamodbClient = new AmazonDynamoDBClient(config.AWS_CREDENTIALS_PROVIDER);
    dynamodbClient.setEndpoint(config.DYNAMODB_ENDPOINT);
    DynamoDBUtils.createTable(dynamodbClient, config.DYNAMODB_DATA_TABLE_NAME, key, readCapacityUnits,
            writeCapacityUnits);
}