List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient AmazonDynamoDBClient
AmazonDynamoDBClient(AwsSyncClientParams clientParams)
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
License:Apache License
/** * Returns a client instance for AWS DynamoDB. * @return a client that talks to DynamoDB *//* w w w. j a va 2 s.c o m*/ public static AmazonDynamoDBClient getClient() { if (ddbClient != null) { return ddbClient; } if (Config.IN_PRODUCTION) { Region region = Regions.getCurrentRegion(); region = region != null ? region : Region.getRegion(Regions.fromName(Config.AWS_REGION)); ddbClient = new AmazonDynamoDBClient( new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY)).withRegion(region); } else { ddbClient = new AmazonDynamoDBClient(new BasicAWSCredentials("local", "null")) .withEndpoint(LOCAL_ENDPOINT); } if (!existsTable(Config.APP_NAME_NS)) { createTable(Config.APP_NAME_NS); } ddb = new DynamoDB(ddbClient); Para.addDestroyListener(new DestroyListener() { public void onDestroy() { shutdownClient(); } }); return ddbClient; }
From source file:com.example.kwang27.secmap.AmazonClientManager.java
License:Open Source License
private void initClients() { CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider(context, Constants.IDENTITY_POOL_ID, Regions.US_EAST_1); ddb = new AmazonDynamoDBClient(credentials); ddb.setRegion(Region.getRegion(Regions.US_WEST_2)); }
From source file:com.example.rafa.myapplication.AmazonClientManager.java
License:Open Source License
private void initClients() { /****credentials***/ BasicAWSCredentials credentials = new BasicAWSCredentials("AKIAIFAXGBW3HDEGKF2Q", "AIaVirpRfFkwAyuqN38OviapQTGAZnVOPtB1Pg6G"); ddb = new AmazonDynamoDBClient(credentials); // Amazon Database ddb.setRegion(Region.getRegion(Regions.US_EAST_1)); // Local Database //ddb.setEndpoint("http://192.168.0.19:8000"); }
From source file:com.exorath.service.lastserver.dynamodb.LocalDynamoDBCreationRule.java
License:Apache License
@Override protected void before() throws Throwable { try {/* www .j a va 2 s. com*/ final String port = getAvailablePort(); this.server = ServerRunner.createServerFromCommandLineArgs(new String[] { "-inMemory", "-port", port }); server.start(); amazonDynamoDB = new AmazonDynamoDBClient(new BasicAWSCredentials("access", "secret")); amazonDynamoDB.setEndpoint("http://localhost:" + port); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.exorath.service.lobbymsg.impl.DynamoDBProvider.java
License:Apache License
public DynamoDB getDB() { AWSCredentials credentials = new EnvironmentVariableCredentialsProvider().getCredentials(); return new DynamoDB(new AmazonDynamoDBClient(credentials).withRegion(Regions.EU_CENTRAL_1)); }
From source file:com.facebook.presto.dynamodb.DynamodbClient.java
License:Apache License
@Inject public DynamodbClient(DynamodbConfig config) throws IOException { requireNonNull(config, "config is null"); dynamoDBClient = new AmazonDynamoDBClient(config.getCredentials()); dynamoDBClient.setRegion(config.getAWSRegion()); if (config.getDynamodbEndpoint() != null) { dynamoDBClient.setEndpoint(config.getDynamodbEndpoint()); }//w w w .j a va 2 s .c o m }
From source file:com.facebook.presto.kinesis.KinesisClientManager.java
License:Apache License
@Inject KinesisClientManager(@Named("connectorId") String connectorId, KinesisConnectorConfig kinesisConnectorConfig) { log.info("Creating new client for Consuner"); if (kinesisConnectorConfig.getAccessKey() == null || kinesisConnectorConfig.getSecretKey() == null) { this.kinesisAwsCredentials = null; this.client = new AmazonKinesisClient(new DefaultAWSCredentialsProviderChain()); this.dynamoDBClient = new AmazonDynamoDBClient(new DefaultAWSCredentialsProviderChain()); } else {/* w ww .j ava2s . com*/ this.kinesisAwsCredentials = new KinesisAwsCredentials(kinesisConnectorConfig.getAccessKey(), kinesisConnectorConfig.getSecretKey()); this.client = new AmazonKinesisClient(this.kinesisAwsCredentials); this.dynamoDBClient = new AmazonDynamoDBClient(this.kinesisAwsCredentials); } this.client.setEndpoint("kinesis." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com"); this.dynamoDBClient.setEndpoint("dynamodb." + kinesisConnectorConfig.getAwsRegion() + ".amazonaws.com"); }
From source file:com.github.sdmcraft.slingdynamo.demo.App.java
License:Open Source License
/** * Inits the./*w w w.j a va 2 s .c om*/ */ public static void init() { Scanner reader = new Scanner(System.in); System.out.println("Enter access key:"); accessKey = reader.next(); System.out.println("Enter secret access key:"); secretAccessKey = reader.next(); System.out.println("Access Key:" + accessKey); System.out.println("Secret access Key:" + secretAccessKey); reader.close(); AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretAccessKey); dynamoDB = new AmazonDynamoDBClient(awsCredentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); dynamoDB.setRegion(usWest2); }
From source file:com.github.sdmcraft.slingdynamo.impl.DynamoDBResourceProviderFactory.java
License:Open Source License
/** * Activate.//from w w w .ja v a2s. c o m * * @param context the context * @param config the config */ @Activate protected void activate(BundleContext context, Map<String, Object> config) { this.root = PropertiesUtil.toString(config.get(ResourceProvider.ROOTS), DEFAULT_ROOT); if ((this.root == null) || this.root.isEmpty()) { this.root = DEFAULT_ROOT; } this.resourceType = PropertiesUtil.toString(config.get(SlingConstants.PROPERTY_RESOURCE_TYPE), Constants.DEFAULT_GET_SERVLET); if ((this.resourceType == null) || this.resourceType.isEmpty()) { this.resourceType = Constants.DEFAULT_GET_SERVLET; } dynamoDBClient = new AmazonDynamoDBClient(awsCredentialsProvider.getCredentials()); this.region = PropertiesUtil.toString(config.get(PROP_REGION), Constants.DEFAULT_REGION); if ((this.region != null) && !this.region.isEmpty()) { Region awsRegion = Region.getRegion(Regions.fromName(region)); dynamoDBClient.setRegion(awsRegion); } this.endpoint = PropertiesUtil.toString(config.get(PROP_ENDPOINT), Constants.DEFAULT_ENDPOINT); if ((this.endpoint != null) && !this.endpoint.isEmpty()) { dynamoDBClient.setEndpoint(this.endpoint); } dynamoDB = new DynamoDB(dynamoDBClient); }
From source file:com.github.sporcina.mule.modules.DynamoDBConnector.java
License:Open Source License
/** * Creates a DynamoDB client using the security values from the AWSCredentials.properties file * * @throws ConnectionException/*from w w w . ja va 2 s. c o m*/ */ private void createDynamoDBClient() throws ConnectionException { AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider(); try { credentialsProvider.getCredentials(); } catch (AmazonClientException e) { LOG.warn( "AWSCredentials.properties file was not found. Attempting to acquire credentials from the default provider chain."); throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, null, e.getMessage(), e); } catch (Exception e) { LOG.warn(e.getMessage() + " Are you missing the AWSCredentials.properties file?"); throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, null, e.getMessage(), e); } try { setDynamoDBClient(new AmazonDynamoDBClient(credentialsProvider)); } catch (Exception e) { throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, null, e.getMessage(), e); } }