@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStreamArn() == null) ? 0 : getStreamArn().hashCode()); hashCode = prime * hashCode + ((getStreamLabel() == null) ? 0 : getStreamLabel().hashCode()); hashCode = prime * hashCode + ((getStreamStatus() == null) ? 0 : getStreamStatus().hashCode()); hashCode = prime * hashCode + ((getStreamViewType() == null) ? 0 : getStreamViewType().hashCode()); hashCode = prime * hashCode + ((getCreationRequestDateTime() == null) ? 0 : getCreationRequestDateTime().hashCode()); hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getKeySchema() == null) ? 0 : getKeySchema().hashCode()); hashCode = prime * hashCode + ((getShards() == null) ? 0 : getShards().hashCode()); hashCode = prime * hashCode + ((getLastEvaluatedShardId() == null) ? 0 : getLastEvaluatedShardId().hashCode()); return hashCode; }
public StreamDescription unmarshall(JsonUnmarshallerContext context) throws Exception { StreamDescription streamDescription = new StreamDescription(); if (context.testExpression("StreamArn", targetDepth)) { context.nextToken(); streamDescription.setStreamArn(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamLabel(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamStatus(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamViewType(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setCreationRequestDateTime(DateJsonUnmarshallerFactory.getInstance("unixTimestamp").unmarshall(context)); streamDescription.setTableName(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setKeySchema(new ListUnmarshaller<KeySchemaElement>(KeySchemaElementJsonUnmarshaller.getInstance()).unmarshall(context)); streamDescription.setShards(new ListUnmarshaller<Shard>(ShardJsonUnmarshaller.getInstance()).unmarshall(context)); streamDescription.setLastEvaluatedShardId(context.getUnmarshaller(String.class).unmarshall(context));
throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisDescribeStream(e); if (result.getStreamDescription().getStreamStatus().equals("DISABLED")) { markLeafShardsAsActive(allShards); StreamDescription newStreamDescription = new StreamDescription().withShards(allShards).withLastEvaluatedShardId(null).withCreationRequestDateTime(result.getStreamDescription().getCreationRequestDateTime()) .withKeySchema(result.getStreamDescription().getKeySchema()).withStreamArn(result.getStreamDescription().getStreamArn()) .withStreamLabel(result.getStreamDescription().getStreamLabel()).withStreamStatus(result.getStreamDescription().getStreamStatus()) .withTableName(result.getStreamDescription().getTableName()).withStreamViewType(result.getStreamDescription().getStreamViewType()); result = new com.amazonaws.services.dynamodbv2.model.DescribeStreamResult().withStreamDescription(newStreamDescription);
private List<Shard> getAllShardsForDisabledStream(com.amazonaws.services.dynamodbv2.model.DescribeStreamResult initialResult) { List<Shard> shards = new ArrayList<Shard>(); shards.addAll(initialResult.getStreamDescription().getShards()); com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest request; com.amazonaws.services.dynamodbv2.model.DescribeStreamResult result = initialResult; // Allowing KCL to paginate calls will not allow us to correctly determine the // leaf nodes. In order to avoid pagination issues when feigning shard activity, we collect all // shards in the adapter and return them at once. while (result.getStreamDescription().getLastEvaluatedShardId() != null) { request = new com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest().withStreamArn(result.getStreamDescription().getStreamArn()) .withExclusiveStartShardId(result.getStreamDescription().getLastEvaluatedShardId()); try { result = internalClient.describeStream(request); } catch (AmazonServiceException e) { throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisDescribeStream(e); } shards.addAll(result.getStreamDescription().getShards()); } return shards; }
/** * Check whether Streams is enabled on the given argument with the given stream view type * * @param streamsClient * streams client used to access the given stream * @param streamArn * the stream ARN to check against * @param viewType * the stream view type to check against * @return a boolean indicating whether the given stream is enabled and matches the given stream view type */ public static boolean isStreamsEnabled(AmazonDynamoDBStreams streamsClient, String streamArn, StreamViewType viewType) { // Get and check stream description StreamDescription result = streamsClient.describeStream(new DescribeStreamRequest().withStreamArn(streamArn)) .getStreamDescription(); if (result.getStreamStatus().equalsIgnoreCase(DynamoDBConnectorConstants.ENABLED_STRING) && result.getStreamViewType().equalsIgnoreCase(viewType.toString())) { return true; } log.error(DynamoDBConnectorConstants.STREAM_NOT_READY + " StreamARN: " + streamArn); return false; } }
.withStreamArn(myStreamArn)); String streamArn = describeStreamResult.getStreamDescription().getStreamArn(); List<Shard> shards = describeStreamResult.getStreamDescription().getShards();
/** * @return The name of the stream being described. */ @Override public String getStreamName() { return internalDescription.getStreamArn(); }
/** * Constructs a new description using a DynamoDBStreams object. * * @param streamDescription Instance of DynamoDBStreams StreamDescription */ public StreamDescriptionAdapter(com.amazonaws.services.dynamodbv2.model.StreamDescription streamDescription) { internalDescription = streamDescription; shards = new ArrayList<Shard>(); for (com.amazonaws.services.dynamodbv2.model.Shard shard : streamDescription.getShards()) { shards.add(new ShardAdapter(shard)); } }
/** * @return The current status of the stream being described. */ @Override public String getStreamStatus() { String status = internalDescription.getStreamStatus(); if (STREAM_STATUS_DYNAMODB_ENABLED.equals(status)) { status = STREAM_STATUS_KINESIS_ACTIVE; } else if (STREAM_STATUS_DYNAMODB_ENABLING.equals(status)) { status = STREAM_STATUS_KINESIS_CREATING; } else if (STREAM_STATUS_DYNAMODB_DISABLED.equals(status)) { // streams are valid for 24hrs after disabling and // will continue to support read operations status = STREAM_STATUS_KINESIS_ACTIVE; } else if (STREAM_STATUS_DYNAMODB_DISABLING.equals(status)) { status = STREAM_STATUS_KINESIS_ACTIVE; } else { throw new UnsupportedOperationException("Unsupported StreamStatus: " + status); } return status; }
/** * @return If true there are more shards in the stream * available to describe. */ @Override public Boolean isHasMoreShards() { return internalDescription.getLastEvaluatedShardId() != null; }
throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisDescribeStream(e); if (result.getStreamDescription().getStreamStatus().equals("DISABLED")) { markLeafShardsAsActive(allShards); StreamDescription newStreamDescription = new StreamDescription().withShards(allShards).withLastEvaluatedShardId(null).withCreationRequestDateTime(result.getStreamDescription().getCreationRequestDateTime()) .withKeySchema(result.getStreamDescription().getKeySchema()).withStreamArn(result.getStreamDescription().getStreamArn()) .withStreamLabel(result.getStreamDescription().getStreamLabel()).withStreamStatus(result.getStreamDescription().getStreamStatus()) .withTableName(result.getStreamDescription().getTableName()).withStreamViewType(result.getStreamDescription().getStreamViewType()); result = new com.amazonaws.services.dynamodbv2.model.DescribeStreamResult().withStreamDescription(newStreamDescription);
private List<Shard> getAllShardsForDisabledStream(com.amazonaws.services.dynamodbv2.model.DescribeStreamResult initialResult) { List<Shard> shards = new ArrayList<Shard>(); shards.addAll(initialResult.getStreamDescription().getShards()); com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest request; com.amazonaws.services.dynamodbv2.model.DescribeStreamResult result = initialResult; // Allowing KCL to paginate calls will not allow us to correctly determine the // leaf nodes. In order to avoid pagination issues when feigning shard activity, we collect all // shards in the adapter and return them at once. while (result.getStreamDescription().getLastEvaluatedShardId() != null) { request = new com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest().withStreamArn(result.getStreamDescription().getStreamArn()) .withExclusiveStartShardId(result.getStreamDescription().getLastEvaluatedShardId()); try { result = internalClient.describeStream(request); } catch (AmazonServiceException e) { throw AmazonServiceExceptionTransformer.transformDynamoDBStreamsToKinesisDescribeStream(e); } shards.addAll(result.getStreamDescription().getShards()); } return shards; }
/** * @return The Amazon Resource Name (ARN) for the stream being described. */ @Override public String getStreamARN() { return internalDescription.getStreamArn(); }
/** * Constructs a new description using a DynamoDBStreams object. * * @param streamDescription Instance of DynamoDBStreams StreamDescription */ public StreamDescriptionAdapter(com.amazonaws.services.dynamodbv2.model.StreamDescription streamDescription) { internalDescription = streamDescription; shards = new ArrayList<Shard>(); for (com.amazonaws.services.dynamodbv2.model.Shard shard : streamDescription.getShards()) { shards.add(new ShardAdapter(shard)); } }
/** * @return The current status of the stream being described. */ @Override public String getStreamStatus() { String status = internalDescription.getStreamStatus(); if (STREAM_STATUS_DYNAMODB_ENABLED.equals(status)) { status = STREAM_STATUS_KINESIS_ACTIVE; } else if (STREAM_STATUS_DYNAMODB_ENABLING.equals(status)) { status = STREAM_STATUS_KINESIS_CREATING; } else if (STREAM_STATUS_DYNAMODB_DISABLED.equals(status)) { // streams are valid for 24hrs after disabling and // will continue to support read operations status = STREAM_STATUS_KINESIS_ACTIVE; } else if (STREAM_STATUS_DYNAMODB_DISABLING.equals(status)) { status = STREAM_STATUS_KINESIS_ACTIVE; } else { throw new UnsupportedOperationException("Unsupported StreamStatus: " + status); } return status; }
/** * @return If true there are more shards in the stream * available to describe. */ @Override public Boolean getHasMoreShards() { return internalDescription.getLastEvaluatedShardId() != null; }
return false; StreamDescription other = (StreamDescription) obj; if (other.getStreamArn() == null ^ this.getStreamArn() == null) return false; if (other.getStreamArn() != null && other.getStreamArn().equals(this.getStreamArn()) == false) return false; if (other.getStreamLabel() == null ^ this.getStreamLabel() == null) return false; if (other.getStreamLabel() != null && other.getStreamLabel().equals(this.getStreamLabel()) == false) return false; if (other.getStreamStatus() == null ^ this.getStreamStatus() == null) return false; if (other.getStreamStatus() != null && other.getStreamStatus().equals(this.getStreamStatus()) == false) return false; if (other.getStreamViewType() == null ^ this.getStreamViewType() == null) return false; if (other.getStreamViewType() != null && other.getStreamViewType().equals(this.getStreamViewType()) == false) return false; if (other.getCreationRequestDateTime() == null ^ this.getCreationRequestDateTime() == null) return false; if (other.getCreationRequestDateTime() != null && other.getCreationRequestDateTime().equals(this.getCreationRequestDateTime()) == false) return false; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false)
public StreamDescription unmarshall(JsonUnmarshallerContext context) throws Exception { StreamDescription streamDescription = new StreamDescription(); if (context.testExpression("StreamArn", targetDepth)) { context.nextToken(); streamDescription.setStreamArn(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamLabel(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamStatus(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setStreamViewType(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setCreationRequestDateTime(DateJsonUnmarshallerFactory.getInstance("unixTimestamp").unmarshall(context)); streamDescription.setTableName(context.getUnmarshaller(String.class).unmarshall(context)); streamDescription.setKeySchema(new ListUnmarshaller<KeySchemaElement>(KeySchemaElementJsonUnmarshaller.getInstance()).unmarshall(context)); streamDescription.setShards(new ListUnmarshaller<Shard>(ShardJsonUnmarshaller.getInstance()).unmarshall(context)); streamDescription.setLastEvaluatedShardId(context.getUnmarshaller(String.class).unmarshall(context));
/** * @return The Amazon Resource Name (ARN) for the stream being described. */ @Override public String getStreamARN() { return internalDescription.getStreamArn(); }
/** * @return If true there are more shards in the stream * available to describe. */ @Override public Boolean getHasMoreShards() { return internalDescription.getLastEvaluatedShardId() != null; }