Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables property for setting AT_TIMESTAMP shard iterator initial time… #342

Merged
merged 3 commits into from
May 29, 2018

Conversation

marcinc
Copy link
Contributor

@marcinc marcinc commented May 25, 2018

…stamp (#341)

Issue #341

Description of changes:

Added DatePropertyValueDecoder for use in KinesisClientLibConfigurator which enables timestampAtInitialPositionInStream property for setting initial timestamp for AT_TIMESTAMP shard iterator.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -0,0 +1,49 @@
/*
* Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update this to 2018?

@pfifer
Copy link
Contributor

pfifer commented May 25, 2018

Could you also add a basic unit test?

Thanks

@marcinc
Copy link
Contributor Author

marcinc commented May 25, 2018

Hi @pfifer. Fixup commit added with update header and tests.

@marcinc
Copy link
Contributor Author

marcinc commented May 29, 2018

Hi @pfifer. Please let me know if there is anything else I should address in this PR. Otherwise, if you're happy with the change, it would be great to get it merged. Thanks.

Copy link
Contributor

@pfifer pfifer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

assertEquals(timestamp, new Date(Long.parseLong(TEST_VALUE) * 1000L));
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: You can do

@Test(expected = IllegalArgumentException.class)`

which would remove the requirement for the try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Fixed.

@Override
public Date decodeValue(String value) {
try {
return new Date(Long.parseLong(value) * 1000L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just calling this out for myself, and any future readers:

If someone accidentally uses milliseconds this won't work the way they expect. In the future it might make sense to use Instant from java.time. Instant#parse can deal with textual date representations, and can be converted to a java.util.Date pretty easily.

"streamName = a",
"applicationName = b",
"AWSCredentialsProvider = ABCD," + credentialName1,
"timestampAtInitialPositionInStream = 123abc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this out for myself, and future readers:

Looking at the code this will at least log a warning. That isn't part of your code, but I don't know if that is a good outcome. If the InitialPositionInStream is set to AT_TIMESTAMP then the KCL will be unable to startup if the lease table doesn't exist or isn't populated. Otherwise the KCL should be able to startup, but that could be really confusing.

@pfifer
Copy link
Contributor

pfifer commented May 29, 2018

Thanks for providing the change. I'm going to start the process for accepting this on my side.

For my own information which of the MultiLang clients do you use?

@pfifer pfifer added this to the v1.9.2 milestone May 29, 2018
@pfifer pfifer merged commit a84885d into awslabs:master May 29, 2018
@marcinc
Copy link
Contributor Author

marcinc commented May 29, 2018

For my own information which of the MultiLang clients do you use?

I'm using ruby client for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants