Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public void loadGraph() {
"sending edges", e);
}).join();
this.sendManager.finishSend(MessageType.EDGE);
this.sendManager.checkFatal();
this.sendManager.clearBuffer();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public synchronized void close() {
LOG.error("Error occurred while closing master service", e);
}

if (!failed && this.bsp4Master != null) {
if (this.inited && !failed && this.bsp4Master != null) {
this.bsp4Master.waitWorkersCloseDone();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void startSend(MessageType type) {
.map(this.partitioner::workerId)
.collect(Collectors.toSet());
this.sendControlMessageToWorkers(workerIds, MessageType.START);
this.sender.checkFatal();
LOG.info("Start sending message(type={})", type);
}

Expand All @@ -166,6 +167,7 @@ public void finishSend(MessageType type) {
.map(this.partitioner::workerId)
.collect(Collectors.toSet());
this.sendControlMessageToWorkers(workerIds, MessageType.FINISH);
this.sender.checkFatal();
LOG.info("Finish sending message(type={},count={},bytes={})",
type, stat.messageCount(), stat.messageBytes());
}
Expand All @@ -178,6 +180,10 @@ public void clearBuffer() {
this.buffers.clear();
}

public void checkFatal() {
this.checkException();
}

private void sortIfTargetBufferIsFull(WriteBuffers buffer,
int partitionId,
MessageType type) {
Expand Down Expand Up @@ -286,6 +292,7 @@ private void sendControlMessageToWorkers(Set<Integer> workerIds,
}

private void checkException() {
this.sender.checkFatal();
if (this.exception.get() != null) {
throw new ComputerException("Failed to send message",
this.exception.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ CompletableFuture<Void> send(int workerId, MessageType type)
* an exception is thrown processing message.
*/
void transportExceptionCaught(TransportException cause, ConnectionId connectionId);

/**
* Check whether the sender has encountered a fatal error. Implementations
* that run background threads should propagate the first fatal error to
* callers so that the caller can fail fast instead of hanging on a future
* or barrier.
*/
default void checkFatal() {
// no-op by default
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hugegraph.computer.core.sender;

import java.nio.ByteBuffer;
import java.util.concurrent.CompletableFuture;

import org.apache.hugegraph.computer.core.network.message.MessageType;

Expand All @@ -26,11 +27,18 @@ public class QueuedMessage {
private final int partitionId;
private final MessageType type;
private final ByteBuffer buffer;
private final CompletableFuture<Void> controlFuture;

public QueuedMessage(int partitionId, MessageType type, ByteBuffer buffer) {
this(partitionId, type, buffer, null);
}

QueuedMessage(int partitionId, MessageType type, ByteBuffer buffer,
CompletableFuture<Void> controlFuture) {
this.partitionId = partitionId;
this.type = type;
this.buffer = buffer;
this.controlFuture = controlFuture;
}

public int partitionId() {
Expand All @@ -44,4 +52,8 @@ public MessageType type() {
public ByteBuffer buffer() {
return this.buffer;
}

CompletableFuture<Void> controlFuture() {
return this.controlFuture;
}
}
Loading
Loading