當前位置: 首頁>>代碼示例>>Java>>正文


Java AmazonDynamoDBClient.setRegion方法代碼示例

本文整理匯總了Java中com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.setRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java AmazonDynamoDBClient.setRegion方法的具體用法?Java AmazonDynamoDBClient.setRegion怎麽用?Java AmazonDynamoDBClient.setRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient的用法示例。


在下文中一共展示了AmazonDynamoDBClient.setRegion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: KafkaDynamoStreamAdapter

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public KafkaDynamoStreamAdapter(String regionName, String srcTable, IRecordProcessorFactory processorFactory) {
    sourceTable = srcTable;
    credentialsProvider = new DefaultAWSCredentialsProviderChain();
    recordProcessorFactory = processorFactory;

    adapterClient = new AmazonDynamoDBStreamsAdapterClient(credentialsProvider, new ClientConfiguration());
    dynamoDBClient = new AmazonDynamoDBClient(credentialsProvider, new ClientConfiguration());
    cloudWatchClient = new AmazonCloudWatchClient(credentialsProvider, new ClientConfiguration());

    if ("local".equalsIgnoreCase(regionName)) {
        setClientEndpoints(localddbEndpoint);
    } else if (regionName != null) {
        Region region = Region.getRegion(Regions.fromName(regionName));
        adapterClient.setRegion(region);
        dynamoDBClient.setRegion(region);
        cloudWatchClient.setRegion(region);
    }
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:19,代碼來源:KafkaDynamoStreamAdapter.java

示例2: PersistentStore

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
/**
 * 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.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);
	}
}
 
開發者ID:dselman,項目名稱:tweetamo,代碼行數:31,代碼來源:PersistentStore.java

示例3: getFromMSS

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public static DynamoEntry getFromMSS(String parameter)
{
	dynamoDB = new AmazonDynamoDBClient(new ProfileCredentialsProvider().getCredentials());
	dynamoDB.setRegion(Region.getRegion(Regions.EU_WEST_1));
	
	HashMap<String, Condition> keyConditions = new HashMap<String, Condition>();
	keyConditions.put("Parameter", new Condition().withComparisonOperator(ComparisonOperator.EQ)
			.withAttributeValueList(new AttributeValue(parameter)));
	
	QueryRequest queryRequest = new QueryRequest();
	queryRequest.setKeyConditions(keyConditions);
	queryRequest.withTableName("MSS");

	QueryResult result = dynamoDB.query(queryRequest);
	//se houver um pedido ja tratado no MSS getCount > 0, caso contrario nao existe
	if(result.getCount() == 0)
		return null;
	else
	{
		//vamos buscar o rank
		Map<String, AttributeValue> queryResult = result.getItems().get(0);
		String rank = "";
		boolean runningState = false;
		
        for (Map.Entry<String, AttributeValue> entry  : queryResult.entrySet()) 
        {
        	if(entry.getKey().equals("Rank"))
        		rank = entry.getValue().getN();
        	else if(entry.getKey().equals("Running"))
        		runningState = entry.getValue().getBOOL();
        }
		DynamoEntry rankResult = new DynamoEntry(new BigInteger(rank), runningState);			
		return rankResult;
	}
}
 
開發者ID:carlosfaria94,項目名稱:CloudPrime,代碼行數:36,代碼來源:DynamoEntry.java

示例4: run

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
@Override
public void run() {
	try {
		FileInputStream logFile = new FileInputStream("logIntermedio.txt");
		BufferedReader bufReader = new BufferedReader(new InputStreamReader(logFile));

		String line;

		while ((line = bufReader.readLine()) != null) {
			String[] parts = line.split(":");

			if (parts[0].equals(threadID)) {
				AmazonDynamoDBClient dynamoDB = new AmazonDynamoDBClient(new ProfileCredentialsProvider());
				dynamoDB.setRegion(Region.getRegion(Regions.EU_WEST_1));

				String[] parameterParts = parts[1].split("=");
				String parameter = parameterParts[1];

				QueryResult result = getEntryDynamo(parameter, dynamoDB);

				if (result.getCount() == 0) // se a query nao retornar nada significa que nao temos nada no dynamo sobre este parametro
				{
					putDynamo(parameter, metricas.i_count, metricas.b_count, metricas.fieldLoadCount,
							metricas.loadCount, dynamoDB, true, threadID, null);
				} else { //caso contrario vamos buscar as metricas que temos para atualiza las
					Map<String, AttributeValue> queryResult = result.getItems().get(0);
					// runningValue fica a true se Running estiver a true, se ja estiver a false entao ja temos as metricas finais para este parametro portanto nao atualizamos o dynamo
					boolean runningValue = queryResult.values().contains(new AttributeValue().withBOOL(true));
					if (runningValue) {
						putDynamo(parameter, metricas.i_count, metricas.b_count, metricas.fieldLoadCount,
								metricas.loadCount, dynamoDB, true, threadID, result);
					}
				}
				break;
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:carlosfaria94,項目名稱:CloudPrime,代碼行數:41,代碼來源:InstTool.java

示例5: DBConnector

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
/**
 * generate dynamo db mapper etc. to connect to database
 */
private DBConnector() {
    AWSPropertiesProvider awsPropertiesProvider = new AWSPropertiesProvider("dynamoDb.properties");
    AmazonDynamoDBClient dbClient = new AmazonDynamoDBClient(awsPropertiesProvider.getCredentials());
    dbClient.setRegion(awsPropertiesProvider.getRegion());
    dynamoDB = new DynamoDB(dbClient);
    dynamoDBMapper = new DynamoDBMapper(dbClient);
}
 
開發者ID:LogicalOverflow,項目名稱:MasterStats,代碼行數:11,代碼來源:DBConnector.java

示例6: AmazonDynamoDBDAO

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
protected AmazonDynamoDBDAO() {
	dynamoDB = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
       Region usWest2 = Region.getRegion(Regions.US_WEST_2);
       
       String local_db = EnvironmentUtils.getInstance().getLocal_db();
       if (local_db != null && local_db.trim().length() > 0) {
       	// LOCAL
       	dynamoDB.setEndpoint(local_db,"local","us-west-2"); 
       } else {
       	// PROD
       	dynamoDB.setRegion(usWest2);
       }
       mapper = new DynamoDBMapper(dynamoDB);
}
 
開發者ID:tahamsaglam,項目名稱:duckdns,代碼行數:15,代碼來源:AmazonDynamoDBDAO.java

示例7: requiredTablesExist

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
protected boolean requiredTablesExist() {
    AmazonDynamoDBClient amazonDynamoDB = new AmazonDynamoDBClient(credentialsProvider);
    amazonDynamoDB.setRegion(Regions.getCurrentRegion());
    try {
        ListTablesResult listResult = amazonDynamoDB.listTables();
        List<String> tableNames = listResult.getTableNames();
        boolean present = tableNames.containsAll(tablesWithPrefix);
        LOG.info("List db structure: {}", tableNames.toArray());
        LOG.info("Check db structure is present: {}", present);
        return present;
    } catch (AmazonServiceException e) {
        LOG.warn("Can't get a list of existed tables", e);
        throw new DataAccessException(CANT_GET_ACCESS_DYNAMODB, e);
    }
}
 
開發者ID:SungardAS,項目名稱:enhanced-snapshots,代碼行數:16,代碼來源:InitConfigurationServiceImpl.java

示例8: UserAuthentication

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
/**
 * Looks up table name and creates one if it does not exist
 */
public UserAuthentication() {
    ddb = new AmazonDynamoDBClient();
    ddb.setRegion(RegionUtils.getRegion(Configuration.REGION));

    try {
        if (!doesTableExist(USER_TABLE)) {
            createIdentityTable();
        }
    } catch (DataAccessException e) {
        throw new RuntimeException("Failed to create device table.", e);
    }
}
 
開發者ID:awslabs,項目名稱:amazon-cognito-developer-authentication-sample,代碼行數:16,代碼來源:UserAuthentication.java

示例9: DeviceAuthentication

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
/**
 * Looks up table name and creates one if it does not exist
 */
public DeviceAuthentication() {
    ddb = new AmazonDynamoDBClient();
    ddb.setRegion(RegionUtils.getRegion(Configuration.REGION));
    
    try {
        if (!doesTableExist(DEVICE_TABLE)) {
            createDeviceTable();
        }
    } catch (DataAccessException e) {
        throw new RuntimeException("Failed to create device table.", e);
    }
}
 
開發者ID:awslabs,項目名稱:amazon-cognito-developer-authentication-sample,代碼行數:16,代碼來源:DeviceAuthentication.java

示例10: getDynamoDBClient

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public AmazonDynamoDBClient getDynamoDBClient(Region dynamoDBTableRegion, boolean runOnDDBLocal) {
    AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(awsCredentials);
    dynamoDBClient.setRegion(dynamoDBTableRegion);
    if(runOnDDBLocal) {
        dynamoDBClient.setEndpoint(DDB_LOCAL_ENDPOINT);
    }
    return dynamoDBClient;
}
 
開發者ID:awslabs,項目名稱:dynamodb-online-index-violation-detector,代碼行數:9,代碼來源:AWSConnection.java

示例11: DynamoDBService

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
DynamoDBService(AWSCredentials credentials) throws Exception {

     dynamoDB = new AmazonDynamoDBClient(credentials);
     Region usEast1 = Region.getRegion(Regions.US_EAST_1);
     dynamoDB.setRegion(usEast1);
     
     createTable();
 }
 
開發者ID:cs553-cloud-computing,項目名稱:amazon-cloudengine,代碼行數:9,代碼來源:DynamoDBService.java

示例12: DynamodbUserStorage

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
@Inject
public DynamodbUserStorage(AWSConfig config, DynamodbUserConfig tableConfig) {
    dynamoDBClient = new AmazonDynamoDBClient(config.getCredentials());
    dynamoDBClient.setRegion(config.getAWSRegion());

    if (config.getDynamodbEndpoint() != null) {
        dynamoDBClient.setEndpoint(config.getDynamodbEndpoint());
    }
    this.tableConfig = tableConfig;
}
 
開發者ID:rakam-io,項目名稱:rakam,代碼行數:11,代碼來源:DynamodbUserStorage.java

示例13: DynamodbConfigManager

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
@Inject
public DynamodbConfigManager(AWSConfig config, DynamodbConfigManagerConfig tableConfig) {
    dynamoDBClient = new AmazonDynamoDBClient(config.getCredentials());
    dynamoDBClient.setRegion(config.getAWSRegion());
    if (config.getDynamodbEndpoint() != null) {
        dynamoDBClient.setEndpoint(config.getDynamodbEndpoint());
    }
    this.tableConfig = tableConfig;
}
 
開發者ID:rakam-io,項目名稱:rakam,代碼行數:10,代碼來源:DynamodbConfigManager.java

示例14: DynamodbQueryMetastore

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
@Inject
public DynamodbQueryMetastore(AWSConfig config, DynamodbQueryMetastoreConfig tableConfig) {
    dynamoDBClient = new AmazonDynamoDBClient(config.getCredentials());
    dynamoDBClient.setRegion(config.getAWSRegion());

    if (config.getDynamodbEndpoint() != null) {
        dynamoDBClient.setEndpoint(config.getDynamodbEndpoint());
    }
    this.tableConfig = tableConfig;
}
 
開發者ID:rakam-io,項目名稱:rakam,代碼行數:11,代碼來源:DynamodbQueryMetastore.java

示例15: DynamodbMetastore

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
@Inject
public DynamodbMetastore(AWSConfig config, DynamodbMetastoreConfig tableConfig, FieldDependencyBuilder.FieldDependency fieldDependency, EventBus eventBus) {
    super(eventBus);
    dynamoDBClient = new AmazonDynamoDBClient(config.getCredentials());
    dynamoDBClient.setRegion(config.getAWSRegion());

    if (config.getDynamodbEndpoint() != null) {
        dynamoDBClient.setEndpoint(config.getDynamodbEndpoint());
    }
    this.tableConfig = tableConfig;
}
 
開發者ID:rakam-io,項目名稱:rakam,代碼行數:12,代碼來源:DynamodbMetastore.java


注:本文中的com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.setRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。