List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient AmazonDynamoDBClient
AmazonDynamoDBClient(AwsSyncClientParams clientParams)
From source file:main.java.ddb.loader.DDBSampleLoader.java
License:Apache License
static void init() { log = LoggerFactory.getLogger(DDBSampleLoader.class); rand = new Random(seed); ddb_client = new AmazonDynamoDBClient(new ProfileCredentialsProvider()); ddb_mapper = new DynamoDBMapper(ddb_client); print_mapper = new ObjectMapper(); df3 = new DecimalFormat("#.###"); }
From source file:mx.iteso.desi.cloud.keyvalue.DynamoDBStorage.java
License:Apache License
public DynamoDBStorage(String dbName) { BasicAWSCredentials cred = new BasicAWSCredentials(Config.accessKeyID, Config.secretAccessKey); if (Config.DynamoDbClientType == Config.DYNAMODBCLIENTTYPE.Local) { client = new AmazonDynamoDBClient(cred); client.setRegion(Region.getRegion(Config.amazonRegion)); client.setEndpoint("http://localhost:8000"); } else {/*from www . j a v a 2 s . c o m*/ client = AmazonDynamoDBClientBuilder.standard().withRegion(Config.amazonRegion) .withCredentials(new AWSStaticCredentialsProvider(cred)).build(); } docClient = new DynamoDB(client); this.dbName = dbName; // Create a table CreateTableRequest createTableRequest = new CreateTableRequest().withTableName(dbName) .withKeySchema(new KeySchemaElement().withAttributeName("keyword").withKeyType(KeyType.HASH), new KeySchemaElement().withAttributeName("inx").withKeyType(KeyType.RANGE)) .withAttributeDefinitions( new AttributeDefinition().withAttributeName("keyword") .withAttributeType(ScalarAttributeType.S), new AttributeDefinition().withAttributeName("inx").withAttributeType(ScalarAttributeType.N)) .withProvisionedThroughput( new ProvisionedThroughput().withReadCapacityUnits(1L).withWriteCapacityUnits(1L)); // Create table if it does not exist yet TableUtils.createTableIfNotExists(client, createTableRequest); // Wait for the table to move into Active state try { TableUtils.waitUntilActive(client, dbName); } catch (Exception e) { // Do nothing... yet } //requestItems.put(dbName, requestList); }
From source file:nyu.twitter.lg.FentchTwitter.java
License:Open Source License
/** * The only information needed to create a client are security credentials * consisting of the AWS Access Key ID and Secret Access Key. All other * configuration, such as the service endpoints, are performed * automatically. Client parameters, such as proxies, can be specified in an * optional ClientConfiguration object when constructing a client. * * @see com.amazonaws.auth.BasicAWSCredentials * @see com.amazonaws.auth.ProfilesConfigFile * @see com.amazonaws.ClientConfiguration *///w ww. ja v a2 s . co m private static void init() throws Exception { /* * The ProfileCredentialsProvider will return your [New US East * (Virginia) Profile] credential profile by reading from the * credentials file located at (). */ // AWSCredentials credentials = null; AWSCredentialsProvider credentialsProvider = null; try { credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(); // credentials = new ProfileCredentialsProvider( // "New US East (Virginia) Profile").getCredentials(); } catch (Exception e) { throw new AmazonClientException( // "Cannot load the credentials from the credential profiles file. " // + "Please make sure that your credentials file is at the correct " // + "location (), and is in valid format.", e); } dynamoDB = new AmazonDynamoDBClient(credentialsProvider); Region usEast1 = Region.getRegion(Regions.US_EAST_1); dynamoDB.setRegion(usEast1); }
From source file:org.apache.gora.dynamodb.store.DynamoDBUtils.java
License:Apache License
/** * Method to create the specific client to be used * /*w w w . j a v a 2 s. c om*/ * @param clientType * @param credentials * @return */ public static AmazonDynamoDB getClient(String clientType, AWSCredentials credentials) { if (clientType.equals(SYNC_CLIENT_PROP)) return new AmazonDynamoDBClient(credentials); if (clientType.equals(ASYNC_CLIENT_PROP)) return new AmazonDynamoDBAsyncClient(credentials); return null; }
From source file:org.diksha.common.dyutils.DyDBUtils.java
License:Apache License
public static DynamoDB getDynamoDB() { AWSCredentials awsCredentials = getAwsCredentials(); DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(awsCredentials)); return dynamoDB; }
From source file:org.diksha.common.dyutils.DyDBUtils.java
License:Apache License
public static DynamoDBMapper getDynamoDBMapper() { AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(getAwsCredentials()); return new DynamoDBMapper(dynamoDBClient); }
From source file:org.kmbmicro.chatwebsocket.DbString.java
public static void init() { try {//ww w . ja v a 2s . c o m credentials = new ProfileCredentialsProvider("default").getCredentials(); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (/Users/sandiwibowo/.aws/credentials), and is in valid format.", e); } AmazonDynamoDBClient dynamoDBAWS = new AmazonDynamoDBClient(credentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); dynamoDBAWS.setRegion(usWest2); dynamoDB = new DynamoDB(dynamoDBAWS); }
From source file:org.onebusaway.alexa.storage.ObaDynamoDbClient.java
License:Apache License
public ObaDynamoDbClient(AWSCredentials creds) { dynamoDBClient = new AmazonDynamoDBClient(creds); }
From source file:org.openhab.persistence.dynamodb.internal.DynamoDBClient.java
License:Open Source License
public DynamoDBClient(AWSCredentials credentials, Region region) { client = new AmazonDynamoDBClient(credentials); client.setRegion(region);//w w w . j a v a 2 s . c om dynamo = new DynamoDB(client); }
From source file:org.selman.tweetamo.PersistentStore.java
License:Apache License
/** * The only information needed to create a client are security credentials * consisting of the AWS Access Key ID and Secret Access Key. All other * configuration, such as the service endpoints, are performed * automatically. Client parameters, such as proxies, can be specified in an * optional ClientConfiguration object when constructing a client. * //w w w . ja va 2 s. c o m * @see com.amazonaws.auth.BasicAWSCredentials * @see com.amazonaws.auth.PropertiesCredentials * @see com.amazonaws.ClientConfiguration */ private PersistentStore(Region region, long readCapacity, long writeCapacity) throws Exception { /* * This credentials provider implementation loads your AWS credentials * from a properties file at the root of your classpath. */ dynamoDB = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider()); dynamoDB.setRegion(region); try { if (!tablesExist()) { createTables(readCapacity, writeCapacity); } waitForTableToBecomeAvailable(TABLE_NAME); } catch (Exception e) { handleException(e); } }