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

ENH: add throttling service #325

Merged

Conversation

chenqi0805
Copy link
Collaborator

@chenqi0805 chenqi0805 commented Sep 29, 2021

Description

This PR

  • Registers ThrottlingService with strategy and reject handler.
  • Add test case on throttling based off max_pending_requests.

Issues Resolved

#323

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: qchea <qchea@amazon.com>
Signed-off-by: qchea <qchea@amazon.com>
Signed-off-by: qchea <qchea@amazon.com>
final LogHTTPService logHTTPService = new LogHTTPService(requestTimeoutInMillis, buffer);
sb.annotatedService(logHTTPService);
sb.annotatedService("/log/ingest", logHTTPService);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the second time this string is used. I would recommend defining a constant for "/log/ingest".

Copy link
Member

Choose a reason for hiding this comment

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

I think we eventually want this to be a configuration. It might be good to just make that change now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dlvenable Upon a second thought, allow customizing the URI path for log ingestion seems not adding value to the source plugin despite that FluentBit HTTP output plugin allows configuring custom URI path. We might even just replace this URI path with root path "/".

For now I will make it a constant and we could deal with this minor change in later cleanup PRs.

Signed-off-by: qchea <qchea@amazon.com>
Signed-off-by: qchea <qchea@amazon.com>
Signed-off-by: qchea <qchea@amazon.com>
try {
testWebClient.execute(testRequestHeaders, testHttpData).aggregate().join();
} catch (CompletionException e) {
assertThat(e.getCause()).isInstanceOf(ResponseTimeoutException.class);
Copy link
Member

Choose a reason for hiding this comment

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

I should have noted this in the last PR, but this assertThat will not be called unless an exception is actually thrown.

Please change to:

CompletionException actualException = assertThrows(CompletionException.class, () -> testWebClient.execute(testRequestHeaders, testHttpData).aggregate().join());
assertThat(actualException.getCause()).isInstanceOf(ResponseTimeoutException.class);

Also, below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great catch!

Signed-off-by: qchea <qchea@amazon.com>
@chenqi0805 chenqi0805 merged commit 1d67620 into opensearch-project:main Oct 6, 2021
@chenqi0805 chenqi0805 deleted the enh/add-throttling-service branch October 6, 2021 14:37
jianghancn pushed a commit to jianghancn/data-prepper that referenced this pull request Oct 27, 2021
* FEAT: load throttling service and add test cases

Signed-off-by: qchea <qchea@amazon.com>

* REF: URI path

Signed-off-by: qchea <qchea@amazon.com>

* MAINT: comment string

Signed-off-by: qchea <qchea@amazon.com>

* MAINT: DEFAULT_LOG_INGEST_URI

Signed-off-by: qchea <qchea@amazon.com>

* MAINT: clear up request after throttling

Signed-off-by: qchea <qchea@amazon.com>

* STY: spotless

Signed-off-by: qchea <qchea@amazon.com>

* MAINT: assertThrows exception

Signed-off-by: qchea <qchea@amazon.com>
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.

3 participants