List of usage examples for com.amazonaws.regions ServiceAbbreviations Dynamodb
String Dynamodb
To view the source code for com.amazonaws.regions ServiceAbbreviations Dynamodb.
Click Source Link
From source file:com.optimalbi.AmazonAccount.java
License:Apache License
private void populateDynamoDB() throws AmazonClientException { getRegions().stream().filter(region -> region.isServiceSupported(ServiceAbbreviations.Dynamodb)) .forEach(region -> {/*from w ww . ja v a 2 s. c o m*/ AmazonDynamoDBClient DDB = new AmazonDynamoDBClient(credentials.getCredentials()); DDB.setRegion(region); DynamoDB dynamoDB = new DynamoDB(DDB); TableCollection<ListTablesResult> tables = dynamoDB.listTables(); tables.forEach(table -> services.add(new LocalDynamoDBService(table.getTableName(), credentials, region, table.describe(), logger))); }); }
From source file:org.apache.hadoop.dynamodb.DynamoDBUtil.java
License:Open Source License
/** * Calculates DynamoDB end-point.//from w ww .j ava 2 s. c om * * Algorithm details: * <ol> * <li> Use endpoint in job configuration "dynamodb.endpoint" value if available * <li> Use endpoint from region in job configuration "dynamodb.region" value if available * <li> Use endpoint from region in job configuration "dynamodb.regionid" value if available * <li> Use endpoint from EC2 Metadata of instance if available * <li> If all previous attempts at retrieving endpoint fail, default to us-east-1 endpoint * </ol> * * @param conf Job Configuration * @param region optional preferred region * @return end-point for DynamoDb service */ public static String getDynamoDBEndpoint(Configuration conf, String region) { String endpoint = getValueFromConf(conf, DynamoDBConstants.ENDPOINT); if (Strings.isNullOrEmpty(endpoint)) { if (Strings.isNullOrEmpty(region)) { region = getValueFromConf(conf, DynamoDBConstants.REGION); } if (Strings.isNullOrEmpty(region)) { region = getValueFromConf(conf, DynamoDBConstants.REGION_ID); } if (Strings.isNullOrEmpty(region)) { try { region = EC2MetadataUtils.getEC2InstanceRegion(); } catch (Exception e) { log.warn(String.format("Exception when attempting to get AWS region information. Will " + "ignore and default " + "to %s", DynamoDBConstants.DEFAULT_AWS_REGION), e); } } if (Strings.isNullOrEmpty(region)) { region = DynamoDBConstants.DEFAULT_AWS_REGION; } endpoint = RegionUtils.getRegion(region).getServiceEndpoint(ServiceAbbreviations.Dynamodb); } log.info("Using endpoint for DynamoDB: " + endpoint); return endpoint; }