Skip to content

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

Merged
AlexandraRoatis merged 6 commits intomasterfrom
sync-refactor
Apr 13, 2020
Merged

AKI-692: Refactor Sync manager to use ExecutorService #1141
AlexandraRoatis merged 6 commits intomasterfrom
sync-refactor

Conversation

@AlexandraRoatis
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

}

public synchronized void shutdown() {
if (p2pLog.isDebugEnabled()) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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