Java 类com.amazonaws.geo.GeoDataManagerConfiguration 实例源码

项目:reinvent2013-mobile-photo-share    文件:Utilities.java   
public void setupTable() {
    setupGeoDataManager();

    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();
    DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());

    try {
        config.getDynamoDBClient().describeTable(describeTableRequest);

        if (status == Status.NOT_STARTED) {
            status = Status.READY;
        }
    } catch (ResourceNotFoundException e) {
        PhotoLocationsTable photoLocationsTable = new PhotoLocationsTable();
        photoLocationsTable.start();
    }

}
项目:dynamodb-geo    文件:Utilities.java   
public void setupTable() {
    setupGeoDataManager();

    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();
    DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());

    try {
        config.getDynamoDBClient().describeTable(describeTableRequest);

        if (status == Status.NOT_STARTED) {
            status = Status.READY;
        }
    } catch (ResourceNotFoundException e) {
        SchoolDataLoader schoolDataLoader = new SchoolDataLoader();
        schoolDataLoader.start();
    }

}
项目:reinvent2013-mobile-photo-share    文件:Utilities.java   
private void waitForTableToBeReady() {
    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();

    DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());
    DescribeTableResult describeTableResult = config.getDynamoDBClient().describeTable(describeTableRequest);

    while (!describeTableResult.getTable().getTableStatus().equalsIgnoreCase("ACTIVE")) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        describeTableResult = config.getDynamoDBClient().describeTable(describeTableRequest);
    }
}
项目:dynamodb-geo    文件:GeohashRange.java   
public boolean tryMerge(GeohashRange range) {
    if (range.getRangeMin() - this.rangeMax <= GeoDataManagerConfiguration.MERGE_THRESHOLD
            && range.getRangeMin() - this.rangeMax > 0) {
        this.rangeMax = range.getRangeMax();
        return true;
    }

    if (this.rangeMin - range.getRangeMax() <= GeoDataManagerConfiguration.MERGE_THRESHOLD
            && this.rangeMin - range.getRangeMax() > 0) {
        this.rangeMin = range.getRangeMin();
        return true;
    }

    return false;
}
项目:dynamodb-geo    文件:GeoTableUtil.java   
/**
 * <p>
 * Construct a create table request object based on GeoDataManagerConfiguration. The users can update any aspect of
 * the request and call it.
 * </p>
 * Example:
 * 
 * <pre>
 * AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
 * Region usWest2 = Region.getRegion(Regions.US_WEST_2);
 * ddb.setRegion(usWest2);
 * 
 * CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);
 * CreateTableResult createTableResult = ddb.createTable(createTableRequest);
 * </pre>
 * 
 * @return Generated create table request.
 */
public static CreateTableRequest getCreateTableRequest(GeoDataManagerConfiguration config) {
    CreateTableRequest createTableRequest = new CreateTableRequest()
            .withTableName(config.getTableName())
            .withProvisionedThroughput(
                    new ProvisionedThroughput().withReadCapacityUnits(10L).withWriteCapacityUnits(5L))
            .withKeySchema(
                    new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(
                            config.getHashKeyAttributeName()),
                    new KeySchemaElement().withKeyType(KeyType.RANGE).withAttributeName(
                            config.getRangeKeyAttributeName()))
            .withAttributeDefinitions(
                    new AttributeDefinition().withAttributeType(ScalarAttributeType.N).withAttributeName(
                            config.getHashKeyAttributeName()),
                    new AttributeDefinition().withAttributeType(ScalarAttributeType.S).withAttributeName(
                            config.getRangeKeyAttributeName()),
                    new AttributeDefinition().withAttributeType(ScalarAttributeType.N).withAttributeName(
                            config.getGeohashAttributeName()))
            .withLocalSecondaryIndexes(
                    new LocalSecondaryIndex()
                            .withIndexName(config.getGeohashIndexName())
                            .withKeySchema(
                                    new KeySchemaElement().withKeyType(KeyType.HASH).withAttributeName(
                                            config.getHashKeyAttributeName()),
                                    new KeySchemaElement().withKeyType(KeyType.RANGE).withAttributeName(
                                            config.getGeohashAttributeName()))
                            .withProjection(new Projection().withProjectionType(ProjectionType.ALL)));

    return createTableRequest;
}
项目:dynamodb-geo    文件:GeoDynamoDBServlet.java   
private void setupGeoDataManager() {
    String accessKey = System.getProperty("AWS_ACCESS_KEY_ID");
    String secretKey = System.getProperty("AWS_SECRET_KEY");
    String tableName = System.getProperty("PARAM1");
    String regionName = System.getProperty("PARAM2");

    AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
    AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentials);
    Region region = Region.getRegion(Regions.fromName(regionName));
    ddb.setRegion(region);

    config = new GeoDataManagerConfiguration(ddb, tableName);
    geoDataManager = new GeoDataManager(config);
}
项目:dynamodb-geo    文件:Utilities.java   
private void waitForTableToBeReady() {
    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();

    DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(config.getTableName());
    DescribeTableResult describeTableResult = config.getDynamoDBClient().describeTable(describeTableRequest);

    while (!describeTableResult.getTable().getTableStatus().equalsIgnoreCase("ACTIVE")) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        describeTableResult = config.getDynamoDBClient().describeTable(describeTableRequest);
    }
}
项目:UnitedWayRESTBackend    文件:DynamoServiceFactory.java   
public DynamoGeoService createDynamoGeoService(String tableName) {
    GeoDataManagerConfiguration config = new GeoDataManagerConfiguration(createDynamoClient(), tableName);
    return new DynamoGeoService(new GeoDataManager(config));
}
项目:UnitedWayRESTBackend    文件:DynamoGeoService.java   
private GeoDataManagerConfiguration config() {
    return geoDataManager.getGeoDataManagerConfiguration();
}
项目:dynamodb-geo    文件:DynamoDBManager.java   
public DynamoDBManager(GeoDataManagerConfiguration config) {
    this.config = config;
}
项目:reinvent2013-mobile-photo-share    文件:Utilities.java   
public void run() {
    status = Status.CREATING_TABLE;

    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();

    CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);
    config.getDynamoDBClient().createTable(createTableRequest);

    waitForTableToBeReady();
}
项目:dynamodb-geo    文件:Utilities.java   
public void run() {
    status = Status.CREATING_TABLE;

    GeoDataManagerConfiguration config = geoDataManager.getGeoDataManagerConfiguration();

    CreateTableRequest createTableRequest = GeoTableUtil.getCreateTableRequest(config);
    config.getDynamoDBClient().createTable(createTableRequest);

    waitForTableToBeReady();

    insertData();
}