Skip to content

Inject PeerForwarderServer in to DataPrepper class#1764

Merged
asifsmohammed merged 2 commits intoopensearch-project:mainfrom
asifsmohammed:cpf-data-prepper
Sep 15, 2022
Merged

Inject PeerForwarderServer in to DataPrepper class#1764
asifsmohammed merged 2 commits intoopensearch-project:mainfrom
asifsmohammed:cpf-data-prepper

Conversation

@asifsmohammed
Copy link
Copy Markdown
Collaborator

@asifsmohammed asifsmohammed commented Sep 14, 2022

Signed-off-by: Asif Sohail Mohammed nsifmoh@amazon.com

Description

Start and stop peer forwarder server in DataPrepper

Issues Resolved

resolves #1608

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

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: Asif Sohail Mohammed <nsifmoh@amazon.com>
@asifsmohammed asifsmohammed requested a review from a team as a code owner September 14, 2022 17:23
/**
* Triggers shutdown of the Peer Forwarder server.
*/
public void shutdownPeerForwarderServer() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We abstract that Data Prepper starts this server, but then expose the shutdown.

It appears that the current split between shutdown and shutdownDataPrepperServer is to change the status code returned. Basically, if we shutdown the pipeline, we return 200, even if there is a problem shutting down the Data Prepper Core HTTP Server. What do we want to do when Core Peer Forwarder fails to shutdown? There might be some implications with the buffers here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there's a different status code for shutdown and shutdownDataPrepperServer. If shotdwon is successful we return 200 but if it fails we return 500. In both the cases we call shutdownDataPrepperServer in finally block

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, you are correct.

So my question is: What should we use for the behavior of the peer forwarder server? If it fails to shutdown should we return 500 or 200?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Status code is dependent on whether we are able to shutdown the pipeline successfully or not.

My thinking was if shutdown call to Data Prepper server doesn't affect the status code, why should shutdown call to Peer Forwarder server affect the return status code?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we need to abstract the shutdown call to Peer Forwarder Server, we can include that in the shutdownDataPrepperServer() method instead of having a separate method.

public void shutdownDataPrepperServer() {
    dataPrepperServer.stop();
    peerForwarderServer.stop();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My thinking was if shutdown call to Data Prepper server doesn't affect the status code, why should shutdown call to Peer Forwarder server affect the return status code?

The only reason I would think would be if it affects the buffers.

If we need to abstract the shutdown call to Peer Forwarder Server, we can include that in the shutdownDataPrepperServer() method instead of having a separate method.

I think I agree with this. Maybe we should rename the method as well since it is now shutting down multiple other components.

Copy link
Copy Markdown
Collaborator Author

@asifsmohammed asifsmohammed Sep 15, 2022

Choose a reason for hiding this comment

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

One way to make sure that all the data in buffers are empty is add it as part of shouldStop() method in ProcessWorker. We have to iterate all the peer forwarder buffers to make sure they are empty.

private boolean shouldStop() {
return pipeline.isStopRequested() && areComponentsReadyForShutdown();
}
private boolean areComponentsReadyForShutdown() {
return readBuffer.isEmpty() && processors.stream()
.map(Processor::isReadyForShutdown)
.allMatch(result -> result == true);

Signed-off-by: Asif Sohail Mohammed <nsifmoh@amazon.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 15, 2022

Codecov Report

Merging #1764 (b716a62) into main (b02a15e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #1764   +/-   ##
=========================================
  Coverage     93.99%   93.99%           
  Complexity     1414     1414           
=========================================
  Files           187      187           
  Lines          4162     4165    +3     
  Branches        330      330           
=========================================
+ Hits           3912     3915    +3     
  Misses          170      170           
  Partials         80       80           
Impacted Files Coverage Δ
...n/java/org/opensearch/dataprepper/DataPrepper.java 96.55% <100.00%> (+0.39%) ⬆️
...h/dataprepper/pipeline/server/ShutdownHandler.java 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Copy Markdown
Member

@dlvenable dlvenable 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 combining these shutdown calls!

@asifsmohammed asifsmohammed merged commit e614f06 into opensearch-project:main Sep 15, 2022
@asifsmohammed asifsmohammed deleted the cpf-data-prepper branch September 15, 2022 15:25
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.

Inject PeerForwarderServer and start in execute

4 participants