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


Java AmazonDynamoDBClient類代碼示例

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


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

示例1: start

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public void start()  {
    int mb = 1024 * 1024;

    LOG.info("Max memory:           {} mb", Runtime.getRuntime().maxMemory() / mb);
    LOG.info("Starting up Kinesis Consumer... (may take a few seconds)");
    AmazonKinesisClient kinesisClient = new AmazonKinesisClient(kinesisCfg.getKinesisCredentialsProvider(),
            kinesisCfg.getKinesisClientConfiguration());
    AmazonDynamoDBClient dynamoDBClient = new AmazonDynamoDBClient(kinesisCfg.getDynamoDBCredentialsProvider(),
            kinesisCfg.getDynamoDBClientConfiguration());
    AmazonCloudWatch cloudWatchClient = new AmazonCloudWatchClient(kinesisCfg.getCloudWatchCredentialsProvider(),
            kinesisCfg.getCloudWatchClientConfiguration());

    Worker worker = new Worker.Builder()
            .recordProcessorFactory(() -> new RecordProcessor(unitOfWorkListener, exceptionStrategy, metricsCallback, dry))
            .config(kinesisCfg)
            .kinesisClient(kinesisClient)
            .dynamoDBClient(dynamoDBClient)
            .cloudWatchClient(cloudWatchClient)
            .build();

    worker.run();

}
 
開發者ID:sonyxperiadev,項目名稱:lumber-mill,代碼行數:24,代碼來源:KinesisConsumerBootstrap.java

示例2: createRepository

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public static ContentRepository createRepository(boolean reset) {
    if (isDynamoDBStore()) {
        AmazonDynamoDBClient dynamodb = new AmazonDynamoDBClient(new DefaultAWSCredentialsProviderChain());
        dynamodb.setEndpoint("http://localhost:8000");
        performReset(reset, dynamodb);
        NodeStore store = new DocumentMK.Builder()
                .setDynamoDB(dynamodb)
                .open().getNodeStore();
        return new Oak(store)
                .with(new InitialContent())
                .with(new OpenSecurityProvider())
                .createContentRepository();

    }
    return null;
}
 
開發者ID:denismo,項目名稱:jackrabbit-dynamodb-store,代碼行數:17,代碼來源:DynamoDBStoreBaseTest.java

示例3: locate

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
@Override
public PropertySource<?> locate(final Environment environment) {
    final AmazonDynamoDBClient amazonDynamoDBClient = getAmazonDynamoDbClient(environment);
    createSettingsTable(amazonDynamoDBClient, false);

    final ScanRequest scan = new ScanRequest(TABLE_NAME);
    LOGGER.debug("Scanning table with request [{}]", scan);
    final ScanResult result = amazonDynamoDBClient.scan(scan);
    LOGGER.debug("Scanned table with result [{}]", scan);

    final Properties props = new Properties();
    result.getItems()
            .stream()
            .map(DynamoDbCloudConfigBootstrapConfiguration::retrieveSetting)
            .forEach(p -> props.put(p.getKey(), p.getValue()));
    return new PropertiesPropertySource(getClass().getSimpleName(), props);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:18,代碼來源:DynamoDbCloudConfigBootstrapConfiguration.java

示例4: handleRequest

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
@Override
public Void handleRequest(S3Event s3Event, Context context){

    Collection<Partition>requiredPartitions = new HashSet<>();
    TableService tableService = new TableService();
    DynamoDB dynamoDBClient=new DynamoDB(new AmazonDynamoDBClient(new EnvironmentVariableCredentialsProvider()));

    for(S3EventNotification.S3EventNotificationRecord record:s3Event.getRecords()){

        String bucket=record.getS3().getBucket().getName();
        String key=record.getS3().getObject().getKey();

        System.out.printf("S3event[Event:%s,Bucket:%s,Key:%s]%n",record.getEventName(),bucket,key);

        S3Object s3Object=new S3Object(bucket,key);

        if(s3Object.hasDateTimeKey()){
            Partition partition = partitionConfig.createPartitionFor(s3Object);

            //Check if the partition exists in DynamoDBtable, if not add the partition details to the table, skip otherwise
            if (tryAddMissingPartition(partitionConfig.dynamoDBTableName(), dynamoDBClient, partition)) {
                requiredPartitions.add(partition);
            }
        }
    }

    if(!requiredPartitions.isEmpty()){
        tableService.addPartitions(partitionConfig.tableName(),requiredPartitions, true);
    }

    return null;
}
 
開發者ID:awslabs,項目名稱:serverless-cf-analysis,代碼行數:33,代碼來源:CreateAthenaPartitionsBasedOnS3EventWithDDB.java

示例5: DdbSchema

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
@Inject
protected DdbSchema(@Assisted SchemaBuilder builder,
                    AmazonWebServiceClients amazonWebServiceClients,
                    ClientConfigurations clientConfigurations,
                    AWSCredentialsProviderFactory awsCredentialsProviderFactory)
{
    _tableNameFormat = builder.getTableNameFormat();

    AmazonDynamoDBClient client = amazonWebServiceClients.withEndpoint(
        new AmazonDynamoDBClient(
            awsCredentialsProviderFactory.create(builder.getCredProvider()),
            clientConfigurations.withProxy(
                new ClientConfiguration(),
                builder.getProxyEndpoint())),
        builder.getEndpoint());

    _dynamodb = new DynamoDB(client);
}
 
開發者ID:Distelli,項目名稱:java-persistence,代碼行數:19,代碼來源:DdbSchema.java

示例6: configure

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
@Override
public void configure(String name, Properties props, NameSpace ns)
		throws LDAPException {
	this.name = name;
	this.accessKey = props.getProperty("accessKey");
	this.secretKey = props.getProperty("secretKey");
	this.userTable = props.getProperty("userTable");
	this.groupTable = props.getProperty("groupTable");
	
	this.userDN = new DN("ou=users," + ns.getBase().getDN().toString());
	this.groupDN = new DN("ou=groups," + ns.getBase().getDN().toString());
	this.baseDN = new DN(ns.getBase().getDN().toString());
	
	this.db = new AmazonDynamoDBClient(new BasicAWSCredentials(accessKey,secretKey));

}
 
開發者ID:TremoloSecurity,項目名稱:OpenUnison,代碼行數:17,代碼來源:AmazonDynamoDB.java

示例7: 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

示例8: 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

示例9: 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

示例10: updateItem

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public static void updateItem(AmazonDynamoDBClient client, String tableName, String id, String val) {
    java.util.Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("Id", new AttributeValue().withN(id));

    Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
    AttributeValueUpdate update = new AttributeValueUpdate()
        .withAction(AttributeAction.PUT)
        .withValue(new AttributeValue().withS(val));
    attributeUpdates.put("attribute-2", update);

    UpdateItemRequest updateItemRequest = new UpdateItemRequest()
        .withTableName(tableName)
        .withKey(key)
        .withAttributeUpdates(attributeUpdates);
    client.updateItem(updateItemRequest);
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:17,代碼來源:StreamAdapterDemoHelper.java

示例11: awaitTableCreation

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public static void awaitTableCreation(AmazonDynamoDBClient dynamoDBClient, String tableName) {
    Integer retries = 0;
    Boolean created = false;
    while(!created && retries < 100) {
        DescribeTableResult result = StreamAdapterDemoHelper.describeTable(dynamoDBClient, tableName);
        created = result.getTable().getTableStatus().equals("ACTIVE");
        if (created) {
            System.out.println("Table is active.");
            return;
        } else {
            retries++;
            try {
                Thread.sleep(1000);
            } catch(InterruptedException e) {
                // do nothing
            }
        }
    }
    System.out.println("Timeout after table creation. Exiting...");
    cleanupAndExit(dynamoDBClient, tableName, 1);
}
 
開發者ID:gnethercutt,項目名稱:dynamodb-streams-kafka,代碼行數:22,代碼來源:StreamAdapterDemoHelper.java

示例12: DynamoDBBootstrapWorker

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
/**
 * Creates the DynamoDBBootstrapWorker, calculates the number of segments a
 * table should have, and creates a thread pool to prepare to scan.
 * 
 * @throws Exception
 */
public DynamoDBBootstrapWorker(AmazonDynamoDBClient client,
        double rateLimit, String tableName, ExecutorService exec,
        int section, int totalSections, int numSegments,
        boolean consistentScan) throws SectionOutOfRangeException {
    if (section > totalSections - 1 || section < 0) {
        throw new SectionOutOfRangeException(
                "Section of scan must be within [0...totalSections-1]");
    }

    this.client = client;
    this.rateLimit = rateLimit;
    this.tableName = tableName;

    this.numSegments = numSegments;
    this.section = section;
    this.totalSections = totalSections;
    this.consistentScan = consistentScan;

    super.threadPool = exec;
}
 
開發者ID:awslabs,項目名稱:dynamodb-import-export-tool,代碼行數:27,代碼來源:DynamoDBBootstrapWorker.java

示例13: scanDynamoDB

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
/**
 * Collect data for DynamoDB.
 *
 * @param stats
 *            current statistics object.
 * @param account
 *            currently used credentials object.
 * @param region
 *            currently used aws region.
 */
public static void scanDynamoDB(AwsStats stats, AwsAccount account, Regions region) {
	LOG.debug("Scan for DynamoDB in region " + region.getName() + " in account " + account.getAccountId());

	/*
	 * Amazon DynamoDB
	 */
	try {
		AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(account.getCredentials());
		dynamoDB.setRegion(Region.getRegion(region));

		List<String> list = dynamoDB.listTables().getTableNames();

		int totalItems = list.size();
		for (String tableName : list) {
			AwsResource res = new AwsResource(tableName, account.getAccountId(), AwsResourceType.DynamoDB, region);
			stats.add(res);
		}

		LOG.info(totalItems + " DynamoDB tables in region " + region.getName() + " in account " + account.getAccountId());
	} catch (AmazonServiceException ase) {
		LOG.error("Exception of DynamoDB: " + ase.getMessage());
	}
}
 
開發者ID:janloeffler,項目名稱:aws-utilization-monitor,代碼行數:34,代碼來源:AwsScan.java

示例14: TableReader

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public TableReader(Options options, AmazonDynamoDBClient dynamoDBClient, TableHelper tableHelper, boolean isRunningOnDDBLocal)
        throws IOException, IllegalArgumentException {
    TableReader.options = options;
    TableReader.dynamoDBClient = dynamoDBClient;
    TableReader.tableHelper = tableHelper;
    attributesToGet = tableHelper.getListOfAttributesToFetch(options.getGsiHashKeyName(), options.getGsiRangeKeyName());
    itemsScanned = new AtomicLong(0);
    itemsScanLimit = options.getNumOfRecords();
    violationsFound = new AtomicLong(0);
    violationsFindLimit = options.getNumOfViolations();
    violationsDeleted = new AtomicLong(0);
    if (options.recordDetails()) {
        createViolationWriter();
    }
    TableReader.isRunningOnDDBLocal = isRunningOnDDBLocal;
}
 
開發者ID:awslabs,項目名稱:dynamodb-online-index-violation-detector,代碼行數:17,代碼來源:TableReader.java

示例15: violationDetection

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; //導入依賴的package包/類
public void violationDetection(boolean delete) {
    try {
        AmazonDynamoDBClient dynamoDBClient = awsConnection.getDynamoDBClient(options.getDynamoDBRegion(), runOnDDBLocal);
        tableHelper = new TableHelper(dynamoDBClient, options.getTableName());
        tableReader = new TableReader(options, dynamoDBClient, tableHelper, runOnDDBLocal);
        validateKeyNames();
        tableReader.scanTable(delete);
    } catch (Exception e) {
        logger.error("Exception!", e);
        e.printStackTrace();
        System.exit(1);
    }

    if (options.isDetectionOutputS3Path()) {
        putOutputFileToS3(options.getDetectionOutputPath(), options.getTmpDetectionOutputPath());
    }
}
 
開發者ID:awslabs,項目名稱:dynamodb-online-index-violation-detector,代碼行數:18,代碼來源:ViolationDetector.java


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