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


Java AmazonDynamoDBClient.describeTable方法代碼示例

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


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

示例1: enableStreamForTable

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
private String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) {
    DescribeTableRequest describeTableRequest = new DescribeTableRequest()
        .withTableName(tableName);
    DescribeTableResult describeResult = client.describeTable(describeTableRequest);
    if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) {
        //TODO: what if the viewtype doesn't match
        return describeResult.getTable().getLatestStreamId();
    }

    StreamSpecification streamSpecification = new StreamSpecification();
    streamSpecification.setStreamEnabled(true);
    streamSpecification.setStreamViewType(viewType);
    UpdateTableRequest updateTableRequest = new UpdateTableRequest()
        .withTableName(tableName)
        .withStreamSpecification(streamSpecification);

    UpdateTableResult result = client.updateTable(updateTableRequest);
    return result.getTableDescription().getLatestStreamId();
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:20,代碼來源:KafkaDynamoStreamAdapter.java

示例2: enableStreamForTable

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public static String enableStreamForTable(AmazonDynamoDBClient client, StreamViewType viewType, String tableName) {
    DescribeTableRequest describeTableRequest = new DescribeTableRequest()
        .withTableName(tableName);
    DescribeTableResult describeResult = client.describeTable(describeTableRequest);
    if (describeResult.getTable().getStreamSpecification().isStreamEnabled()) {
        //TODO: what if the viewtype doesn't match
        return describeResult.getTable().getLatestStreamId();
    }

    StreamSpecification streamSpecification = new StreamSpecification();
    streamSpecification.setStreamEnabled(true);
    streamSpecification.setStreamViewType(viewType);
    UpdateTableRequest updateTableRequest = new UpdateTableRequest()
        .withTableName(tableName)
        .withStreamSpecification(streamSpecification);

    UpdateTableResult result = client.updateTable(updateTableRequest);
    return result.getTableDescription().getLatestStreamId();
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:20,代碼來源:StreamAdapterDemoHelper.java

示例3: getTestTableStatus

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public static String getTestTableStatus() {

        try {
            AmazonDynamoDBClient ddb = UserPreferenceDemoActivity.clientManager
                    .ddb();

            DescribeTableRequest request = new DescribeTableRequest()
                    .withTableName(Constants.TEST_TABLE_NAME);
            DescribeTableResult result = ddb.describeTable(request);

            String status = result.getTable().getTableStatus();
            return status == null ? "" : status;

        } catch (ResourceNotFoundException e) {
        } catch (AmazonServiceException ex) {
            UserPreferenceDemoActivity.clientManager
                    .wipeCredentialsOnAuthError(ex);
        }

        return "";
    }
 
開發者ID:awslabs,項目名稱:aws-sdk-android-samples,代碼行數:22,代碼來源:DynamoDBManager.java

示例4: CreateDonationDataTable

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
protected void CreateDonationDataTable (AmazonDynamoDBClient client) {

        ArrayList<AttributeDefinition> attributeDefinitions= new ArrayList<AttributeDefinition>();
        attributeDefinitions.add(new AttributeDefinition().withAttributeName("DonorId").withAttributeType("N"));
        attributeDefinitions.add(new AttributeDefinition().withAttributeName("Category").withAttributeType("S"));

        ArrayList<KeySchemaElement> ks = new ArrayList<KeySchemaElement>();
        ks.add(new KeySchemaElement().withAttributeName("DonorId").withKeyType(KeyType.HASH));
        ks.add(new KeySchemaElement().withAttributeName("Category").withKeyType(KeyType.RANGE));

        ProvisionedThroughput provisionedThroughput = new ProvisionedThroughput()
                .withReadCapacityUnits(10L)
                .withWriteCapacityUnits(10L);

        CreateTableRequest request = new CreateTableRequest()
                .withTableName(doantionDataTableName)
                .withAttributeDefinitions(attributeDefinitions)
                .withKeySchema(ks)
                .withProvisionedThroughput(provisionedThroughput);

        CreateTableResult result = client.createTable(request);

        //wait until the table is Active
        try {
        DescribeTableResult describeTableResult = client.describeTable(new DescribeTableRequest(doantionDataTableName));
        while (describeTableResult.getTable().getTableStatus()!="ACTIVE")
        {
            Thread.sleep(500);
        }
        }
        catch (Exception e)
        {
            throw new RuntimeException();
        }
    }
 
開發者ID:aws-reinvent-hackathon-2013-team,項目名稱:UnitedWayRESTBackend,代碼行數:36,代碼來源:DataAccess.java

示例5: describeTable

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public static DescribeTableResult describeTable(AmazonDynamoDBClient client, String tableName) {
    return client.describeTable(new DescribeTableRequest().withTableName(tableName));
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:4,代碼來源:StreamAdapterDemoHelper.java

示例6: importDonationData

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入方法依賴的package包/類
public  void importDonationData () {
DynamoServiceFactory dsf = new DynamoServiceFactory();
AmazonDynamoDBClient client = dsf.createDynamoClient();

try {
    //TODO: it could be tat we get here while tble is creating (i.e. not active), this code will not work!!!!!
    DescribeTableResult describeTableResult = client.describeTable(new DescribeTableRequest(doantionDataTableName));
}
catch (Exception e)
{
    //create table
    CreateDonationDataTable(client);
}


 try {

        HashMap<String,String> donorIdUUidMap = new  HashMap<String,String>();
        //populate table
        BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("DonationData.csv")));

        for (String line = in.readLine(); line != null; line = in.readLine()) {
            String [] fields = line.split(",");
            String donorId  = fields[0].trim();
            String Category = fields[5].trim();
            float Amount = Float.parseFloat(fields[4].trim());
            String DonorName =  fields[1].trim() + " " + fields[2].trim() ;

            SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy");
            Date d = f.parse(fields[3].trim());

            long DonationDate =  d.getTime();

            String uuid = UUID.randomUUID().toString();
            String existingUid = donorIdUUidMap.get(donorId);

            if (existingUid!=null) {
                uuid = existingUid;
            }
            else {
                donorIdUUidMap.put(donorId,uuid);
            }


            Map<String, AttributeValue> item = new HashMap<String, AttributeValue>();
            item.put("DonorUUID", new AttributeValue().withS(uuid));
            item.put("DonorId", new AttributeValue().withN(donorId));
            item.put("Category", new AttributeValue().withS(Category));
            item.put("Amount", new AttributeValue().withN(String.valueOf(Amount)));
            item.put("DonorName", new AttributeValue().withS(DonorName));
            item.put("DonationDate", new AttributeValue().withN(String.valueOf(DonationDate)));


            PutItemRequest putItemRequest = new PutItemRequest()
                    .withTableName(doantionDataTableName)
                    .withItem(item);

            PutItemResult result = client.putItem(putItemRequest);

        }
    }
    catch (Exception e1)
    {

    }

}
 
開發者ID:aws-reinvent-hackathon-2013-team,項目名稱:UnitedWayRESTBackend,代碼行數:68,代碼來源:DataAccess.java


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