-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for time based iterators. Time based iterators are only used if there is no current checkpoint for that shard, otherwise the sequence number of the checkpoint is used.
- Loading branch information
Showing
32 changed files
with
1,040 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
AmazonKinesisClientLibrary | ||
Copyright 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
.../amazonaws/services/kinesis/clientlibrary/lib/worker/InitialPositionInStreamExtended.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Amazon Software License (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/asl/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
package com.amazonaws.services.kinesis.clientlibrary.lib.worker; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Class that houses the entities needed to specify the position in the stream from where a new application should | ||
* start. | ||
*/ | ||
class InitialPositionInStreamExtended { | ||
|
||
private final InitialPositionInStream position; | ||
private final Date timestamp; | ||
|
||
/** | ||
* This is scoped as private to forbid callers from using it directly and to convey the intent to use the | ||
* static methods instead. | ||
* | ||
* @param position One of LATEST, TRIM_HORIZON, or AT_TIMESTAMP. The Amazon Kinesis Client Library will start | ||
* fetching records from this position when the application starts up if there are no checkpoints. | ||
* If there are checkpoints, we will process records from the checkpoint position. | ||
* @param timestamp The timestamp to use with the AT_TIMESTAMP value for initialPositionInStream. | ||
*/ | ||
private InitialPositionInStreamExtended(final InitialPositionInStream position, final Date timestamp) { | ||
this.position = position; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
/** | ||
* Get the initial position in the stream where the application should start from. | ||
* | ||
* @return The initial position in stream. | ||
*/ | ||
protected InitialPositionInStream getInitialPositionInStream() { | ||
return this.position; | ||
} | ||
|
||
/** | ||
* Get the timestamp from where we need to start the application. | ||
* Valid only for initial position of type AT_TIMESTAMP, returns null for other positions. | ||
* | ||
* @return The timestamp from where we need to start the application. | ||
*/ | ||
protected Date getTimestamp() { | ||
return this.timestamp; | ||
} | ||
|
||
protected static InitialPositionInStreamExtended newInitialPosition(final InitialPositionInStream position) { | ||
switch (position) { | ||
case LATEST: | ||
return new InitialPositionInStreamExtended(InitialPositionInStream.LATEST, null); | ||
case TRIM_HORIZON: | ||
return new InitialPositionInStreamExtended(InitialPositionInStream.TRIM_HORIZON, null); | ||
default: | ||
throw new IllegalArgumentException("Invalid InitialPosition: " + position); | ||
} | ||
} | ||
|
||
protected static InitialPositionInStreamExtended newInitialPositionAtTimestamp(final Date timestamp) { | ||
if (timestamp == null) { | ||
throw new IllegalArgumentException("Timestamp must be specified for InitialPosition AT_TIMESTAMP"); | ||
} | ||
return new InitialPositionInStreamExtended(InitialPositionInStream.AT_TIMESTAMP, timestamp); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.