Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -32,6 +32,7 @@

import java.util.Optional;

import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static com.google.common.util.concurrent.Futures.nonCancellationPropagating;
import static org.apache.iotdb.db.mpp.metric.DataExchangeCostMetricSet.SINK_HANDLE_SEND_TSBLOCK_LOCAL;

Expand Down Expand Up @@ -83,6 +84,9 @@ public long getBufferRetainedSizeInBytes() {
@Override
public synchronized ListenableFuture<?> isFull() {
checkState();
if (closed) {
return immediateVoidFuture();
}
return nonCancellationPropagating(blocked);
}

Expand Down Expand Up @@ -115,6 +119,9 @@ public void send(TsBlock tsBlock) {
Validate.notNull(tsBlock, "tsBlocks is null");
synchronized (this) {
checkState();
if (closed) {
return;
}
if (!blocked.isDone()) {
throw new IllegalStateException("Sink handle is blocked.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ public synchronized ListenableFuture<?> isFull() {
public synchronized void send(TsBlock tsBlock) {
long startTime = System.nanoTime();
try {
checkState();
if (closed) {
return;
}
ISinkChannel currentChannel =
downStreamChannelList.get(downStreamChannelIndex.getCurrentIndex());
checkState();
currentChannel.send(tsBlock);
} finally {
switchChannelIfNecessary();
Expand Down Expand Up @@ -248,8 +251,6 @@ public void setMaxBytesCanReserve(long maxBytesCanReserve) {
private void checkState() {
if (aborted) {
throw new IllegalStateException("ShuffleSinkHandle is aborted.");
} else if (closed) {
throw new IllegalStateException("ShuffleSinkHandle is closed.");
}
}

Expand Down