当前位置: 首页>>代码示例>>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;未经允许,请勿转载。