/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getShardId() != null) sb.append("ShardId: ").append(getShardId()).append(","); if (getParentShardId() != null) sb.append("ParentShardId: ").append(getParentShardId()).append(","); if (getAdjacentParentShardId() != null) sb.append("AdjacentParentShardId: ").append(getAdjacentParentShardId()).append(","); if (getHashKeyRange() != null) sb.append("HashKeyRange: ").append(getHashKeyRange()).append(","); if (getSequenceNumberRange() != null) sb.append("SequenceNumberRange: ").append(getSequenceNumberRange()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getShardId() == null) ? 0 : getShardId().hashCode()); hashCode = prime * hashCode + ((getParentShardId() == null) ? 0 : getParentShardId().hashCode()); hashCode = prime * hashCode + ((getAdjacentParentShardId() == null) ? 0 : getAdjacentParentShardId().hashCode()); hashCode = prime * hashCode + ((getHashKeyRange() == null) ? 0 : getHashKeyRange().hashCode()); hashCode = prime * hashCode + ((getSequenceNumberRange() == null) ? 0 : getSequenceNumberRange().hashCode()); return hashCode; }
/** * Marshall the given parameter object. */ public void marshall(Shard shard, ProtocolMarshaller protocolMarshaller) { if (shard == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(shard.getShardId(), SHARDID_BINDING); protocolMarshaller.marshall(shard.getParentShardId(), PARENTSHARDID_BINDING); protocolMarshaller.marshall(shard.getAdjacentParentShardId(), ADJACENTPARENTSHARDID_BINDING); protocolMarshaller.marshall(shard.getHashKeyRange(), HASHKEYRANGE_BINDING); protocolMarshaller.marshall(shard.getSequenceNumberRange(), SEQUENCENUMBERRANGE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
if (other.getHashKeyRange() != null && other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null) return false; if (other.getSequenceNumberRange() != null && other.getSequenceNumberRange().equals(this.getSequenceNumberRange()) == false) return false; return true;
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getShardId() != null) sb.append("ShardId: " + getShardId() + ","); if (getParentShardId() != null) sb.append("ParentShardId: " + getParentShardId() + ","); if (getAdjacentParentShardId() != null) sb.append("AdjacentParentShardId: " + getAdjacentParentShardId() + ","); if (getHashKeyRange() != null) sb.append("HashKeyRange: " + getHashKeyRange() + ","); if (getSequenceNumberRange() != null) sb.append("SequenceNumberRange: " + getSequenceNumberRange()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getShardId() == null) ? 0 : getShardId().hashCode()); hashCode = prime * hashCode + ((getParentShardId() == null) ? 0 : getParentShardId().hashCode()); hashCode = prime * hashCode + ((getAdjacentParentShardId() == null) ? 0 : getAdjacentParentShardId().hashCode()); hashCode = prime * hashCode + ((getHashKeyRange() == null) ? 0 : getHashKeyRange().hashCode()); hashCode = prime * hashCode + ((getSequenceNumberRange() == null) ? 0 : getSequenceNumberRange().hashCode()); return hashCode; }
&& other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null) return false; if (other.getSequenceNumberRange() != null && other.getSequenceNumberRange().equals(this.getSequenceNumberRange()) == false) return false; return true;
boolean isShardClosed() { return shard.getSequenceNumberRange() != null && shard.getSequenceNumberRange().getEndingSequenceNumber() != null; }
boolean isShardClosed() { return shard.getSequenceNumberRange() != null && shard.getSequenceNumberRange().getEndingSequenceNumber() != null; }
public void marshall(Shard shard, AwsJsonWriter jsonWriter) throws Exception { jsonWriter.beginObject(); if (shard.getShardId() != null) { String shardId = shard.getShardId(); jsonWriter.name("ShardId"); jsonWriter.value(shardId); } if (shard.getParentShardId() != null) { String parentShardId = shard.getParentShardId(); jsonWriter.name("ParentShardId"); jsonWriter.value(parentShardId); } if (shard.getAdjacentParentShardId() != null) { String adjacentParentShardId = shard.getAdjacentParentShardId(); jsonWriter.name("AdjacentParentShardId"); jsonWriter.value(adjacentParentShardId); } if (shard.getHashKeyRange() != null) { HashKeyRange hashKeyRange = shard.getHashKeyRange(); jsonWriter.name("HashKeyRange"); HashKeyRangeJsonMarshaller.getInstance().marshall(hashKeyRange, jsonWriter); } if (shard.getSequenceNumberRange() != null) { SequenceNumberRange sequenceNumberRange = shard.getSequenceNumberRange(); jsonWriter.name("SequenceNumberRange"); SequenceNumberRangeJsonMarshaller.getInstance().marshall(sequenceNumberRange, jsonWriter); } jsonWriter.endObject(); }
/** * Helper method to construct the list of inconsistent shards, which are open shards with non-closed ancestor * parent(s). * @param shardIdToChildShardIdsMap * @param shardIdToShardMap * @return Set of inconsistent open shard ids for shards having open parents. */ private static Set<String> findInconsistentShardIds(Map<String, Set<String>> shardIdToChildShardIdsMap, Map<String, Shard> shardIdToShardMap) { Set<String> result = new HashSet<String>(); for (String parentShardId : shardIdToChildShardIdsMap.keySet()) { Shard parentShard = shardIdToShardMap.get(parentShardId); if ((parentShardId == null) || (parentShard.getSequenceNumberRange().getEndingSequenceNumber() == null)) { Set<String> childShardIdsMap = shardIdToChildShardIdsMap.get(parentShardId); result.addAll(childShardIdsMap); } } return result; }
/** * Helper method to return all the open shards for a stream. * Note: Package level access only for testing purposes. * * @param allShards All shards returved via DescribeStream. We assume this to represent a consistent shard list. * @return List of open shards (shards at the tip of the stream) - may include shards that are not yet active. */ static List<Shard> getOpenShards(List<Shard> allShards) { List<Shard> openShards = new ArrayList<Shard>(); for (Shard shard : allShards) { String endingSequenceNumber = shard.getSequenceNumberRange().getEndingSequenceNumber(); if (endingSequenceNumber == null) { openShards.add(shard); LOG.debug("Found open shard: " + shard.getShardId()); } } return openShards; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getShardId() != null) sb.append("ShardId: ").append(getShardId()).append(","); if (getParentShardId() != null) sb.append("ParentShardId: ").append(getParentShardId()).append(","); if (getAdjacentParentShardId() != null) sb.append("AdjacentParentShardId: ").append(getAdjacentParentShardId()).append(","); if (getHashKeyRange() != null) sb.append("HashKeyRange: ").append(getHashKeyRange()).append(","); if (getSequenceNumberRange() != null) sb.append("SequenceNumberRange: ").append(getSequenceNumberRange()); sb.append("}"); return sb.toString(); }
new BigInteger(shard1.getSequenceNumberRange().getStartingSequenceNumber()); BigInteger sequenceNumber2 = new BigInteger(shard2.getSequenceNumberRange().getStartingSequenceNumber()); result = sequenceNumber1.compareTo(sequenceNumber2);
public KinesisPlayer(VcrConfiguration vcrConfiguration, AmazonS3 s3, AmazonKinesis kinesis) { this.vcrConfiguration = vcrConfiguration; this.s3 = s3; this.kinesis = kinesis; // Check everything: S3 and Kinesis if (!s3.doesBucketExist(vcrConfiguration.bucket)) { LOGGER.error("Specified S3 bucket '{}' does not exist", vcrConfiguration.bucket); throw new IllegalArgumentException("Bucket not found"); } try { DescribeStreamResult describeStreamResult = kinesis.describeStream(vcrConfiguration.targetStream); numberOfShards = (int) describeStreamResult .getStreamDescription() .getShards() .stream() /* only take into account open shards */ .filter(shard -> shard.getSequenceNumberRange().getEndingSequenceNumber() == null) .count(); } catch (ResourceNotFoundException e) { LOGGER.error("Specified Kinesis stream '{}' not found", vcrConfiguration.targetStream); throw e; } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getShardId() == null) ? 0 : getShardId().hashCode()); hashCode = prime * hashCode + ((getParentShardId() == null) ? 0 : getParentShardId().hashCode()); hashCode = prime * hashCode + ((getAdjacentParentShardId() == null) ? 0 : getAdjacentParentShardId().hashCode()); hashCode = prime * hashCode + ((getHashKeyRange() == null) ? 0 : getHashKeyRange().hashCode()); hashCode = prime * hashCode + ((getSequenceNumberRange() == null) ? 0 : getSequenceNumberRange().hashCode()); return hashCode; }
String endingSequenceNumber = shard.getSequenceNumberRange().getEndingSequenceNumber(); if (endingSequenceNumber == null) { throw new KinesisClientLibIOException("Shard " + shardIdsOfClosedShards
if (shard.getSequenceNumberRange().getEndingSequenceNumber() != null) { closedShards.add(shard); break;
/** * Marshall the given parameter object. */ public void marshall(Shard shard, ProtocolMarshaller protocolMarshaller) { if (shard == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(shard.getShardId(), SHARDID_BINDING); protocolMarshaller.marshall(shard.getParentShardId(), PARENTSHARDID_BINDING); protocolMarshaller.marshall(shard.getAdjacentParentShardId(), ADJACENTPARENTSHARDID_BINDING); protocolMarshaller.marshall(shard.getHashKeyRange(), HASHKEYRANGE_BINDING); protocolMarshaller.marshall(shard.getSequenceNumberRange(), SEQUENCENUMBERRANGE_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
if (other.getHashKeyRange() != null && other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null) return false; if (other.getSequenceNumberRange() != null && other.getSequenceNumberRange().equals(this.getSequenceNumberRange()) == false) return false; return true;