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


Java AmazonDynamoDB.setEndpoint方法代碼示例

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


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

示例1: create

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
/**
 * Creates tables.
 * @throws IOException if something goes wrong
 */
public void create() throws IOException {
    final AmazonDynamoDB aws = new AmazonDynamoDBClient(
        new BasicAWSCredentials(this.key, this.secret)
    );
    aws.setEndpoint(String.format("%s:%d", this.endpoint, this.port));
    for (final String table : this.locations) {
        final JsonObject json = this.readJson(table);
        if (json.containsKey("TableName")) {
            final String name = json.getString("TableName");
            if (Tables.exists(aws, name)) {
                Logger.info(
                    this, "Table '%s' already exists, skipping...", name
                );
            } else {
                this.createTable(aws, json);
            }
        } else {
            throw new IOException(
                String.format(
                    "File '%s' does not specify TableName attribute", table
                )
            );
        }
    }
}
 
開發者ID:jcabi,項目名稱:jcabi-dynamodb-maven-plugin,代碼行數:30,代碼來源:Tables.java

示例2: testFindOne

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
@Test
public void testFindOne() throws Exception {
    AWSCredentials credentials = new BasicAWSCredentials("qwe", "qwe");
    AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);

    client.setEndpoint("http://localhost:3210");

    DynamoDbClientFactory clientFactory = Mockito.mock(DynamoDbClientFactory.class);
    Mockito.when(clientFactory.client()).thenReturn(client);


    SQLite.setLibraryPath((this.getClass().getClassLoader().getResource("lib").getPath()));
    final String[] localArgs = {"-inMemory", "-port", "3210"};
    DynamoDBProxyServer server = ServerRunner.createServerFromCommandLineArgs(localArgs);
    server.start();

    log.info("tables: ");
    client.listTables().getTableNames().forEach(log::info);

    UUID uuid = UUID.randomUUID();
    LeagueRecord record = LeagueRecord.builder()
            .id(uuid.toString())
            .name("foosball singles")
            .teamSize(1).build();

    LeagueDao instance = new LeagueDao(clientFactory);
    LeagueRecord created = instance.create(record);
    log.info("created league record:" + created.toString());
    LeagueRecord actual = instance.findOne(uuid.toString());

    Assert.assertEquals(record, actual);
    server.stop();
}
 
開發者ID:wakingrufus,項目名稱:elo-api,代碼行數:34,代碼來源:LeagueDaoTest.java

示例3: testFindByType

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
@Test
public void testFindByType() throws Exception {
    AWSCredentials credentials = new BasicAWSCredentials("qwe", "qwe");
    AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);

    client.setEndpoint("http://localhost:3210");

    DynamoDbClientFactory clientFactory = Mockito.mock(DynamoDbClientFactory.class);
    Mockito.when(clientFactory.client()).thenReturn(client);


    SQLite.setLibraryPath((this.getClass().getClassLoader().getResource("lib").getPath()));
    final String[] localArgs = {"-inMemory", "-port", "3210"};
    DynamoDBProxyServer server = ServerRunner.createServerFromCommandLineArgs(localArgs);
    server.start();

    log.info("tables: ");
    client.listTables().getTableNames().forEach(log::info);

    UUID uuid = UUID.randomUUID();
    LeagueRecord record = LeagueRecord.builder()
            .id(uuid.toString())
            .name("foosball singles")
            .gameType(GameType.FOOSBALL)
            .teamSize(1).build();

    LeagueDao instance = new LeagueDao(clientFactory);
    LeagueRecord created = instance.create(record);
    log.info("created league record:" + created.toString());
    List<LeagueRecord> actuals = instance.byType(record.getGameType());

    LeagueRecord actual = actuals.get(0);
    log.info("expected: " + record.toString());
    log.info("actual:   " + actual.toString());
    Assert.assertEquals("has same id", record.getId(), actual.getId());
    Assert.assertNull("lookup does not have name data", actual.getName());
    Assert.assertEquals("has same game type", record.getGameType(), actual.getGameType());
    server.stop();
}
 
開發者ID:wakingrufus,項目名稱:elo-api,代碼行數:40,代碼來源:LeagueDaoTest.java

示例4: setUp

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
@Before
public void setUp() {
    AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(new BasicAWSCredentials("AWS-Key", ""));
    dynamoDB.setEndpoint(String.format("http://localhost:%s", DynamoDBTemplateIT.PORT));

    this.dynamoDBTemplate = new DynamoDBTemplate(dynamoDB);
}
 
開發者ID:michaellavelle,項目名稱:spring-data-dynamodb,代碼行數:8,代碼來源:DynamoDBTemplateIT.java

示例5: open

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
private void open(boolean batchLoading)
{
    if(type == GraphDatabaseType.TITAN_DYNAMODB && config.getDynamodbPrecreateTables()) {
        List<CreateTableRequest> requests = new LinkedList<>();
        long wcu = config.getDynamodbTps();
        long rcu = Math.max(1, config.dynamodbConsistentRead() ? wcu : (wcu / 2));
        for(String store : Constants.REQUIRED_BACKEND_STORES) {
            final String tableName = config.getDynamodbTablePrefix() + "_" + store;
            if(BackendDataModel.MULTI == config.getDynamodbDataModel()) {
                requests.add(DynamoDBStore.createTableRequest(tableName,
                    rcu, wcu));
            } else if(BackendDataModel.SINGLE == config.getDynamodbDataModel()) {
                requests.add(DynamoDBSingleRowStore.createTableRequest(tableName, rcu, wcu));
            }
        }
        //TODO is this autocloseable?
        final AmazonDynamoDB client =
            new AmazonDynamoDBClient(Client.createAWSCredentialsProvider(config.getDynamodbCredentialsFqClassName(),
                config.getDynamodbCredentialsCtorArguments() == null ? null : config.getDynamodbCredentialsCtorArguments().split(",")));
        client.setEndpoint(config.getDynamodbEndpoint());
        for(CreateTableRequest request : requests) {
            try {
                client.createTable(request);
            } catch(ResourceInUseException ignore) {
                //already created, good
            }
        }
        client.shutdown();
    }
    titanGraph = buildTitanGraph(type, dbStorageDirectory, config, batchLoading);
}
 
開發者ID:socialsensor,項目名稱:graphdb-benchmarks,代碼行數:32,代碼來源:TitanGraphDatabase.java

示例6: startsAndStops

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; //導入方法依賴的package包/類
/**
 * Instances can start and stop.
 * @throws Exception If something is wrong
 */
@Test
public void startsAndStops() throws Exception {
    final int port = this.reserve();
    final Instances instances = new Instances();
    instances.start(
        new File(InstancesTest.DIST), port,
        new File(System.getProperty("java.home")),
        Collections.singletonList("-inMemory")
    );
    try {
        final AmazonDynamoDB aws = new AmazonDynamoDBClient(
            new BasicAWSCredentials("AWS-key", "AWS-secret")
        );
        aws.setEndpoint(String.format("http://localhost:%d", port));
        final String table = "test";
        final String attr = "key";
        final CreateTableResult result = aws.createTable(
            new CreateTableRequest()
                .withTableName(table)
                .withProvisionedThroughput(
                    new ProvisionedThroughput()
                        .withReadCapacityUnits(1L)
                        .withWriteCapacityUnits(1L)
                )
                .withAttributeDefinitions(
                    new AttributeDefinition()
                        .withAttributeName(attr)
                        .withAttributeType(ScalarAttributeType.S)
                )
                .withKeySchema(
                    new KeySchemaElement()
                        .withAttributeName(attr)
                        .withKeyType(KeyType.HASH)
                )
        );
        MatcherAssert.assertThat(
            result.getTableDescription().getTableName(),
            Matchers.equalTo(table)
        );
        aws.putItem(
            new PutItemRequest()
                .withTableName(table)
                .addItemEntry(attr, new AttributeValue("testvalue"))
        );
    } finally {
        instances.stop(port);
    }
}
 
開發者ID:jcabi,項目名稱:jcabi-dynamodb-maven-plugin,代碼行數:53,代碼來源:InstancesTest.java


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