Example usage for com.amazonaws.services.dynamodbv2.model TableDescription getLatestStreamArn

List of usage examples for com.amazonaws.services.dynamodbv2.model TableDescription getLatestStreamArn

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model TableDescription getLatestStreamArn.

Prototype


public String getLatestStreamArn() 

Source Link

Document

The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table.

Usage

From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.DbTableDetail.java

License:Open Source License

private void buildUI(DescribeTableResult detail) {

    this.add(primaryScrollPane, BorderLayout.CENTER);

    if (detail.getTable() != null) {

        TableDescription table = detail.getTable();

        if (table.getCreationDateTime() != null) {
            primaryTableModel.addRow(new Object[] { "Created", getDateString(table.getCreationDateTime()) });
        }//  w  ww.j av a2s  .c o  m
        if (table.getItemCount() != null) {
            primaryTableModel.addRow(new Object[] { "Item Count", table.getItemCount() });
        }
        if (table.getLatestStreamArn() != null) {
            primaryTableModel.addRow(new Object[] { "Latest Stream Arn", table.getLatestStreamArn() });
        }
        if (table.getLatestStreamLabel() != null) {
            primaryTableModel.addRow(new Object[] { "Latest Stream Label", table.getLatestStreamLabel() });
        }
        if (table.getTableArn() != null) {
            primaryTableModel.addRow(new Object[] { "Arn", table.getTableArn() });
        }
        if (table.getTableName() != null) {
            primaryTableModel.addRow(new Object[] { "Name", table.getTableName() });
        }
        if (table.getTableSizeBytes() != null) {
            primaryTableModel.addRow(new Object[] { "Size (bytes)", table.getTableSizeBytes() });
        }
        if (table.getTableStatus() != null) {
            primaryTableModel.addRow(new Object[] { "Status", table.getTableStatus() });
        }
    }
}

From source file:dynamok.source.DynamoDbSourceConnector.java

License:Apache License

@Override
public List<Map<String, String>> taskConfigs(int maxTasks) {
    return ConnectorUtils.groupPartitions(new ArrayList<>(streamShards.keySet()), maxTasks).stream()
            .map(taskShards -> {/*  ww w . j  a  v a2  s. c o m*/
                final Map<String, String> taskConfig = new HashMap<>();
                taskConfig.put(TaskConfig.Keys.REGION, config.region.getName());
                taskConfig.put(TaskConfig.Keys.TOPIC_FORMAT, config.topicFormat);
                taskConfig.put(TaskConfig.Keys.SHARDS,
                        taskShards.stream().map(Shard::getShardId).collect(Collectors.joining(",")));
                taskShards.forEach(shard -> {
                    final TableDescription tableDesc = streamShards.get(shard);
                    taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.TABLE, tableDesc.getTableName());
                    taskConfig.put(shard.getShardId() + "." + TaskConfig.Keys.STREAM_ARN,
                            tableDesc.getLatestStreamArn());
                });
                return taskConfig;
            }).collect(Collectors.toList());
}

From source file:dynamok.source.DynamoDbSourceConnector.java

License:Apache License

@Override
public void start(Map<String, String> props) {
    config = new ConnectorConfig(props);
    streamShards = new HashMap<>();

    final AmazonDynamoDBClient client;
    final AmazonDynamoDBStreamsClient streamsClient;

    if (config.accessKeyId.value().isEmpty() || config.secretKeyId.value().isEmpty()) {
        client = new AmazonDynamoDBClient();
        streamsClient = new AmazonDynamoDBStreamsClient();
        log.debug("AmazonDynamoDB clients created with default credentials");
    } else {/*  w  w w.  j a v  a 2s. c  o  m*/
        BasicAWSCredentials awsCreds = new BasicAWSCredentials(config.accessKeyId.value(),
                config.secretKeyId.value());
        client = new AmazonDynamoDBClient(awsCreds);
        streamsClient = new AmazonDynamoDBStreamsClient(awsCreds);
        log.debug("AmazonDynamoDB clients created with AWS credentials from connector configuration");
    }

    client.configureRegion(config.region);
    streamsClient.configureRegion(config.region);

    final Set<String> ignoredTables = new HashSet<>();
    final Set<String> consumeTables = new HashSet<>();

    String lastEvaluatedTableName = null;
    do {
        final ListTablesResult listResult = client.listTables(lastEvaluatedTableName);

        for (String tableName : listResult.getTableNames()) {
            if (!acceptTable(tableName)) {
                ignoredTables.add(tableName);
                continue;
            }

            final TableDescription tableDesc = client.describeTable(tableName).getTable();

            final StreamSpecification streamSpec = tableDesc.getStreamSpecification();

            if (streamSpec == null || !streamSpec.isStreamEnabled()) {
                throw new ConnectException(
                        String.format("DynamoDB table `%s` does not have streams enabled", tableName));
            }

            final String streamViewType = streamSpec.getStreamViewType();
            if (!streamViewType.equals(StreamViewType.NEW_IMAGE.name())
                    && !streamViewType.equals(StreamViewType.NEW_AND_OLD_IMAGES.name())) {
                throw new ConnectException(String.format("DynamoDB stream view type for table `%s` is %s",
                        tableName, streamViewType));
            }

            final DescribeStreamResult describeStreamResult = streamsClient
                    .describeStream(new DescribeStreamRequest().withStreamArn(tableDesc.getLatestStreamArn()));

            for (Shard shard : describeStreamResult.getStreamDescription().getShards()) {
                streamShards.put(shard, tableDesc);
            }

            consumeTables.add(tableName);
        }

        lastEvaluatedTableName = listResult.getLastEvaluatedTableName();
    } while (lastEvaluatedTableName != null);

    log.info("Tables to ignore: {}", ignoredTables);
    log.info("Tables to ingest: {}", consumeTables);

    client.shutdown();
    streamsClient.shutdown();
}