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

add BspEvent and LockEvent #7

Closed
wants to merge 2 commits into from
Closed

add BspEvent and LockEvent #7

wants to merge 2 commits into from

Conversation

houzhizhen
Copy link
Contributor

No description provided.

this.lock.lock();
try {
while (!this.signaled) {
time = deadline - System.currentTimeMillis();
Copy link
Contributor

Choose a reason for hiding this comment

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

deal with time<0


public class LockEvent implements BspEvent {

private Lock lock = new ReentrantLock();
Copy link
Contributor

Choose a reason for hiding this comment

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

set final

}

@Override
public boolean waitMillis(long time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how to wait without timeout


@Override
public void waitOrFail(long time) {
E.checkArgument(time >= 0L, "The time must be >= 0, but got %d.",
Copy link
Contributor

Choose a reason for hiding this comment

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

wrap line

}
}
} catch (InterruptedException e) {
throw new ComputerException( "Interrupted while waiting %d. ", e,
Copy link
Contributor

Choose a reason for hiding this comment

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

code style:
remove unused " " and "."

Copy link
Contributor

Choose a reason for hiding this comment

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

also improve message: "Interrupted while waiting 10" is confusing

long deadline = System.currentTimeMillis() + time;
while (!this.waitMillis(time)) {
if (System.currentTimeMillis() > deadline) {
throw new ComputerException("Timeout waiting, time = '%d'.",
Copy link
Contributor

Choose a reason for hiding this comment

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

improve message: wait for what?

boolean waitMillis(long time);

/**
* Wait specified time in millisecond, for throw ComputerException if

Choose a reason for hiding this comment

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

for -> or

}

@Override
public void signal() {

Choose a reason for hiding this comment

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

signalAll

@Test
public void testWaitOrFail() {
LockEvent lockEvent = new LockEvent();
Assert.assertThrows(ComputerException.class, () -> {

Choose a reason for hiding this comment

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

try e to assert e.getMessage()

@houzhizhen houzhizhen closed this Jan 11, 2021
@houzhizhen
Copy link
Contributor Author

commit to hugegraph-common apache/incubator-hugegraph-commons#60

@houzhizhen houzhizhen deleted the bsp-event branch January 11, 2021 06:06
yandababa2 pushed a commit to yandababa2/hugegraph-computer that referenced this pull request Oct 22, 2021
* add HugeInputSplitFetcher#client timeout

* skip edge when fail to convert
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