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

AKI-692: Refactor Sync manager to use ExecutorService #1141

Merged
merged 6 commits into from
Apr 13, 2020

Conversation

AlexandraRoatis
Copy link
Contributor

Type of change

  • Bug fix.
  • New feature.
  • Enhancement.
  • Unit test.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

The ExecutorService maintains its own queue making the downloadedBlocks
queue redundant.
The downloadedHeaders became unnecessary and was removed.
@AlexandraRoatis AlexandraRoatis added the enhancement New feature or request label Apr 13, 2020
@AlexandraRoatis AlexandraRoatis added this to the 1.6 milestone Apr 13, 2020
@AlexandraRoatis AlexandraRoatis self-assigned this Apr 13, 2020
pool.shutdownNow(); // Cancel currently executing tasks
// Wait a while for tasks to respond to being cancelled
if (!pool.awaitTermination(60, TimeUnit.SECONDS)) {
log.error("Pool did not terminate");
Copy link
Collaborator

@AionJayT AionJayT Apr 13, 2020

Choose a reason for hiding this comment

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

Should we throw the exception if the kernel fall into this condition? Then we can interrupt the thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would an exception provide any additional information? I can add a stack trace to the log if you think it's useful?

Copy link
Collaborator

Choose a reason for hiding this comment

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

To throw the exception is not necessary, it mainly try to interrupt the thread. If the kernel thread stuck, we can dump the process threads info.

@@ -393,11 +439,32 @@ public long getNetworkBestBlockNumber() {
}

public synchronized void shutdown() {
if (p2pLog.isDebugEnabled()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: the check can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check here is actually an optimization to skip the other if statements when debug is disabled. Would you still want it removed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, because you call the method in the log argument. Just ignore my comment.

Copy link
Collaborator

@AionJayT AionJayT left a comment

Choose a reason for hiding this comment

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

LGTM, left two minor comments

@AlexandraRoatis AlexandraRoatis merged commit 63efe2d into master Apr 13, 2020
@AlexandraRoatis AlexandraRoatis deleted the sync-refactor branch April 13, 2020 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants