@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStartingHashKey() == null) ? 0 : getStartingHashKey().hashCode()); hashCode = prime * hashCode + ((getEndingHashKey() == null) ? 0 : getEndingHashKey().hashCode()); return hashCode; }
public HashKeyRange unmarshall(JsonUnmarshallerContext context) throws Exception { HashKeyRange hashKeyRange = new HashKeyRange(); if (context.testExpression("StartingHashKey", targetDepth)) { context.nextToken(); hashKeyRange.setStartingHashKey(context.getUnmarshaller(String.class).unmarshall(context)); hashKeyRange.setEndingHashKey(context.getUnmarshaller(String.class).unmarshall(context));
@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; }
public int compare(Shard o1, Shard o2) { return new BigInteger(o1.getHashKeyRange().getStartingHashKey()) .compareTo(new BigInteger(o2.getHashKeyRange() .getStartingHashKey())); } });
/** * <p> * The starting hash key of the hash key range. * </p> * * @param startingHashKey * The starting hash key of the hash key range. * @return Returns a reference to this object so that method calls can be chained together. */ public HashKeyRange withStartingHashKey(String startingHashKey) { setStartingHashKey(startingHashKey); return this; }
/** * <p> * The ending hash key of the hash key range. * </p> * * @param endingHashKey * The ending hash key of the hash key range. * @return Returns a reference to this object so that method calls can be chained together. */ public HashKeyRange withEndingHashKey(String endingHashKey) { setEndingHashKey(endingHashKey); return this; }
if (other.getHashKeyRange() == null ^ this.getHashKeyRange() == null) return false; if (other.getHashKeyRange() != null && other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null)
private static final int compareShardsByStartHash(Shard o1, Shard o2) { return new BigInteger(o1.getHashKeyRange().getStartingHashKey()) .compareTo(new BigInteger(o2.getHashKeyRange().getStartingHashKey())); }
/** * <p> * The starting hash key of the hash key range. * </p> * * @param startingHashKey * The starting hash key of the hash key range. * @return Returns a reference to this object so that method calls can be chained together. */ public HashKeyRange withStartingHashKey(String startingHashKey) { setStartingHashKey(startingHashKey); return this; }
/** * <p> * The ending hash key of the hash key range. * </p> * * @param endingHashKey * The ending hash key of the hash key range. * @return Returns a reference to this object so that method calls can be chained together. */ public HashKeyRange withEndingHashKey(String endingHashKey) { setEndingHashKey(endingHashKey); return this; }
return false; if (other.getHashKeyRange() != null && other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null)
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof HashKeyRange == false) return false; HashKeyRange other = (HashKeyRange) obj; if (other.getStartingHashKey() == null ^ this.getStartingHashKey() == null) return false; if (other.getStartingHashKey() != null && other.getStartingHashKey().equals(this.getStartingHashKey()) == false) return false; if (other.getEndingHashKey() == null ^ this.getEndingHashKey() == null) return false; if (other.getEndingHashKey() != null && other.getEndingHashKey().equals(this.getEndingHashKey()) == false) return false; return true; }
public HashKeyRange unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } HashKeyRange hashKeyRange = new HashKeyRange(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("StartingHashKey")) { hashKeyRange.setStartingHashKey(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else if (name.equals("EndingHashKey")) { hashKeyRange.setEndingHashKey(StringJsonUnmarshaller.getInstance() .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return hashKeyRange; }
private void sentWatermarkToShards() { try { //refresh the list of available shards, if current state is too old if (System.currentTimeMillis() - lastShardRefreshTime >= SHARD_REFRESH_MILLIES) { refreshShards(); lastShardRefreshTime = System.currentTimeMillis(); } //send a watermark to every shard of the Kinesis stream shards.parallelStream() .map(shard -> new PutRecordRequest() .withStreamName(streamName) .withData(new WatermarkEvent(currentWatermark).toByteBuffer()) .withPartitionKey("23") .withExplicitHashKey(shard.getHashKeyRange().getStartingHashKey())) .map(kinesisClient::putRecord) .forEach(putRecordResult -> LOG.trace("send watermark {} to shard {}", new DateTime(currentWatermark), putRecordResult.getShardId())); LOG.debug("send watermark {}", new DateTime(currentWatermark)); } catch (LimitExceededException | ProvisionedThroughputExceededException e) { //if any request is throttled, just wait for the next iteration to submit another watermark LOG.warn("skipping watermark due to limit/throughput exceeded exception"); } }
@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; }
if (other.getHashKeyRange() == null ^ this.getHashKeyRange() == null) return false; if (other.getHashKeyRange() != null && other.getHashKeyRange().equals(this.getHashKeyRange()) == false) return false; if (other.getSequenceNumberRange() == null ^ this.getSequenceNumberRange() == null)
/** * 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 (getStartingHashKey() != null) sb.append("StartingHashKey: ").append(getStartingHashKey()).append(","); if (getEndingHashKey() != null) sb.append("EndingHashKey: ").append(getEndingHashKey()); sb.append("}"); return sb.toString(); }
/** * The underlying DynamoDB Streams model does not expose hash key range. To * ensure compatibility with the Kinesis Client Library, this method * returns dummy values. * * @return The range of possible hash key values for the shard. */ @Override public HashKeyRange getHashKeyRange() { HashKeyRange hashKeyRange = new HashKeyRange(); hashKeyRange.setStartingHashKey(java.math.BigInteger.ZERO.toString()); hashKeyRange.setEndingHashKey(java.math.BigInteger.ONE.toString()); return hashKeyRange; }
if (info.getShard().getHashKeyRange().getStartingHashKey().equals(targetHash.toString())) { higherShard = new ShardHashInfo(this.streamName, info.getShard()); break;
@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; }