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

Allow configuration of IdleQueueRetentionPeriodSeconds on temporary queue client #42

Merged
merged 10 commits into from
Jul 3, 2020
Merged

Conversation

adam-aws
Copy link
Contributor

Issue #38

Description of changes:
Allow configuration of IdleQueueRetentionPeriodSeconds on temporary queue client

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@adam-aws adam-aws requested a review from robin-aws June 19, 2020 20:12
@VeniXuan
Copy link

Glad to see this code check in. We are using this library for our non production set up and saw high amounts of the sqs throttling exception. Wish to use this commit soon! Thanks!

Copy link
Contributor

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! A couple of things to fix, and I still want to block all PRs until we address #41.

.withQueueRetentionPeriodSeconds("500");
client = AmazonSQSTemporaryQueuesClient.make(requesterBuilder);

Assert.fail("Shouldn't be able to create a temporary queue with QueueRetentionPeriodSeconds not between 1 and 300 seconds");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we upgrade to JUnit 5 and use assertThrows instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added assertThrows, will create a separate issue to upgrade all tests to junit5.

@@ -16,6 +16,7 @@

private int idleQueueSweepingPeriod = 5;
private TimeUnit idleQueueSweepingTimeUnit = TimeUnit.MINUTES;
private String queueRetentionPeriodSeconds = AmazonSQSTemporaryQueuesClientBuilder.QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should definitely be a Long everywhere instead. It was only a String before because it was hard-coded and only every used as a queue attribute, but now we should only be converting to and from strings in the code that reads and writes that queue attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change to long

@adam-aws
Copy link
Contributor Author

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 38157a9
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@adam-aws adam-aws requested a review from robin-aws June 25, 2020 19:42
@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: ae3dc3e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: ae3dc3e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 3568df0
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 7dd482b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: f1b8b2f
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 45a460a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

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

Thanks for the additional test coverage! :)

}

@Test
public void createQueueWithUnsupportedAttributes() {
try {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thanks for applying assertThrows here :)

Comment on lines 62 to 74
AmazonSQSRequesterClientBuilder requesterBuilder;
if (idleQueueRetentionPeriod != null) {
requesterBuilder =
AmazonSQSRequesterClientBuilder.standard()
.withAmazonSQS(sqs)
.withInternalQueuePrefix(queueNamePrefix)
.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod);
} else {
requesterBuilder =
AmazonSQSRequesterClientBuilder.standard()
.withAmazonSQS(sqs)
.withInternalQueuePrefix(queueNamePrefix);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
AmazonSQSRequesterClientBuilder requesterBuilder;
if (idleQueueRetentionPeriod != null) {
requesterBuilder =
AmazonSQSRequesterClientBuilder.standard()
.withAmazonSQS(sqs)
.withInternalQueuePrefix(queueNamePrefix)
.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod);
} else {
requesterBuilder =
AmazonSQSRequesterClientBuilder.standard()
.withAmazonSQS(sqs)
.withInternalQueuePrefix(queueNamePrefix);
}
AmazonSQSRequesterClientBuilder requesterBuilder =
AmazonSQSRequesterClientBuilder.standard()
.withAmazonSQS(sqs)
.withInternalQueuePrefix(queueNamePrefix);
if (idleQueueRetentionPeriod != null) {
requesterBuilder = requesterBuilder.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated setup function

client = AmazonSQSTemporaryQueuesClient.make(requesterBuilder);
}

private void createQueue(Long idleQueueRetentionPeriod) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consider renaming this to something more descriptive, since its not just a helper creating a queue for further testing, but actually doing the important assertions itself. Perhaps createQueueShouldSetRetentionPeriod?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed the function

@@ -17,6 +17,7 @@
private int idleQueueSweepingPeriod = 5;
private long queueHeartbeatInterval = AmazonSQSIdleQueueDeletingClient.HEARTBEAT_INTERVAL_SECONDS_DEFAULT;
private TimeUnit idleQueueSweepingTimeUnit = TimeUnit.MINUTES;
private long queueRetentionPeriodSeconds = AmazonSQSTemporaryQueuesClientBuilder.QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies for not spotting this earlier, but this should really be idleQueueRetentionPeriodSeconds in all these new places. The distinction has caused confusion for customers in the past. You can't change the existing public constants, but at least new references can be more precise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated queueRetentionPeriodSeconds to idleQueueRetentionPeriodSeconds in all the new places

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 980605e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@@ -5,6 +5,8 @@

public class AmazonSQSTemporaryQueuesClientBuilder {

public final static long QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public final static long QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300;
public final static long IDLE_QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300;

(and the references too of course :))

@aws-sqs-awslabs-ci
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: Java-Temporary-Client-CI
  • Commit ID: 25ee02f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@adam-aws adam-aws merged commit adcb1ae into awslabs:master Jul 3, 2020
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.

None yet

4 participants