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

changed some tests thread array list into executor and added timeout … #149

Merged
merged 15 commits into from
Mar 30, 2021
Merged

Conversation

OrHayat
Copy link
Contributor

@OrHayat OrHayat commented Mar 21, 2021

…and exception handling like asked in issue #142

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

Copy link
Contributor

@liran-funaro liran-funaro left a comment

Choose a reason for hiding this comment

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

Hi @OrHayat.

Thank you for your contribution.
It seems that your implementation is inlined with what we intended in #142.
However, it neglects to propagate the exceptions.
This was the main motivation behind this issue.

The idea to keep the Future objects in some collection, and call .get() for each of the futures once the test ends.
This will raise an exception if the thread raised an exception.
So the test will fail if one of the threads had an error.

core/src/test/java/com/yahoo/oak/ComputeTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/FillTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/ComputeTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/ComputeTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/ComputeTest.java Outdated Show resolved Hide resolved
@OrHayat
Copy link
Contributor Author

OrHayat commented Mar 23, 2021

Hi @OrHayat.

Thank you for your contribution.
It seems that your implementation is inlined with what we intended in #142.
However, it neglects to propagate the exceptions.
This was the main motivation behind this issue.

The idea to keep the Future objects in some collection, and call .get() for each of the futures once the test ends.
This will raise an exception if the thread raised an exception.
So the test will fail if one of the threads had an error.

@OrHayat
Copy link
Contributor Author

OrHayat commented Mar 23, 2021

Alright i fixed those things espically the error propergation with Future objects and in order to it to work you need to use callables instead of runnables (which cant propergate the errors in other threads) which i changed

Copy link
Contributor

@liran-funaro liran-funaro left a comment

Choose a reason for hiding this comment

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

Thanks. I tested your solution and it seems to work well.
Please attend to the minor issues before we can merge this PR.
In addition, pay attention to styling issues such as spacing before and after operators (e.g., "==", "=", "&&", etc.), redundant spaces and so on.
These can automatically be solved using Intellij (or any other IDE) auto-format feature.

long timeToWait = Math.max(10,
timeLimitInMs-Duration.between(startingTime, currentTime).toMillis());
task.get(timeToWait, TimeUnit.MILLISECONDS);
it.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we remove the item only if get() was successful?

Copy link
Contributor Author

@OrHayat OrHayat Mar 26, 2021

Choose a reason for hiding this comment

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

no because if get faill throw an exception which the function throw away i added catch finally to force close the executor in any case and to print the error which might not be wanted.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Please add a comment above it.remove() explaining this flow.

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

Copy link
Contributor

@liran-funaro liran-funaro left a comment

Choose a reason for hiding this comment

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

Thank you for addressing my comments.
We still have a few more issues to attend to before we can merge this PR.
Most of the following are style issues.
Thanks!

core/src/test/java/com/yahoo/oak/OffHeapOakTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/ComputeTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/OffHeapOakTest.java Outdated Show resolved Hide resolved
core/src/test/java/com/yahoo/oak/OffHeapOakTest.java Outdated Show resolved Hide resolved
@liran-funaro liran-funaro merged commit 2a2ff5f into yahoo:master Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants