private void validate () { if (streamName == null || streamName.length() < 1) { throw new IllegalArgumentException("streamName is required and cannot be of length 0."); } if (shardIteratorType == null || shardIteratorType.equals(ShardIteratorType.AFTER_SEQUENCE_NUMBER) || shardIteratorType.equals(ShardIteratorType .AT_SEQUENCE_NUMBER)) { throw new IllegalArgumentException("shardIteratorType has to be one of the " + ShardIteratorType.AT_TIMESTAMP + "," + ShardIteratorType.LATEST + "," + ShardIteratorType.TRIM_HORIZON); } if (shardIteratorType.equals(ShardIteratorType.AT_TIMESTAMP) && timestamp == null) { throw new IllegalArgumentException("timestamp must be provided if shardIteratorType is " + ShardIteratorType.AT_TIMESTAMP); } if (recordToTupleMapper == null) { throw new IllegalArgumentException("recordToTupleMapper cannot be null"); } if (failedMessageRetryHandler == null) { throw new IllegalArgumentException("failedMessageRetryHandler cannot be null"); } if (zkInfo == null) { throw new IllegalArgumentException("zkInfo cannot be null"); } if (kinesisConnectionInfo == null) { throw new IllegalArgumentException("kinesisConnectionInfo cannot be null"); } if (maxUncommittedRecords == null || maxUncommittedRecords < 1) { throw new IllegalArgumentException("maxUncommittedRecords has to be a positive integer"); } }
String getShardIterator (String stream, String shardId, ShardIteratorType shardIteratorType, String sequenceNumber, Date timestamp) { String shardIterator = ""; try { GetShardIteratorRequest getShardIteratorRequest = new GetShardIteratorRequest(); getShardIteratorRequest.setStreamName(stream); getShardIteratorRequest.setShardId(shardId); getShardIteratorRequest.setShardIteratorType(shardIteratorType); if (shardIteratorType.equals(ShardIteratorType.AFTER_SEQUENCE_NUMBER) || shardIteratorType.equals(ShardIteratorType.AT_SEQUENCE_NUMBER)) { getShardIteratorRequest.setStartingSequenceNumber(sequenceNumber); } else if (shardIteratorType.equals(ShardIteratorType.AT_TIMESTAMP)) { getShardIteratorRequest.setTimestamp(timestamp); } GetShardIteratorResult getShardIteratorResult = kinesisClient.getShardIterator(getShardIteratorRequest); if (getShardIteratorResult != null) { shardIterator = getShardIteratorResult.getShardIterator(); } } catch (Exception e) { LOG.warn("Exception occured while getting shardIterator for shard " + shardId + " shardIteratorType " + shardIteratorType + " sequence number " + sequenceNumber + " timestamp " + timestamp, e); } LOG.warn("Returning shardIterator " + shardIterator + " for shardId " + shardId + " shardIteratorType " + shardIteratorType + " sequenceNumber " + sequenceNumber + " timestamp" + timestamp); return shardIterator; }
kinesisShardOffset = new KinesisShardOffset(iteratorType); if (typeValue.length > 1) { if (ShardIteratorType.AT_TIMESTAMP.equals(iteratorType)) { kinesisShardOffset .setTimestamp(new Date(Long.parseLong(typeValue[1])));
kinesisShardOffset = new KinesisShardOffset(iteratorType); if (typeValue.length > 1) { if (ShardIteratorType.AT_TIMESTAMP.equals(iteratorType)) { kinesisShardOffset.setTimestamp(new Date(Long.parseLong(typeValue[1])));