1996fanrui commented on code in PR #27375:
URL: https://github.com/apache/flink/pull/27375#discussion_r2679509789
##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/RuntimeEnvironment.java:
##########
@@ -408,4 +411,14 @@ public CheckpointStorageAccess
getCheckpointStorageAccess() {
public ChannelStateWriteRequestExecutorFactory
getChannelStateExecutorFactory() {
return channelStateExecutorFactory;
}
+
+ public void setChannelStateWriter(ChannelStateWriter channelStateWriter) {
+ checkState(this.channelStateWriter == null, "Can not set
channelStateWriter twice!");
+ this.channelStateWriter = channelStateWriter;
+ }
+
+ @Override
+ public @Nullable ChannelStateWriter getChannelStateWriter() {
Review Comment:
nit: generally annotation is placed before `public`
##########
flink-runtime/src/main/java/org/apache/flink/runtime/taskmanager/Task.java:
##########
@@ -1011,6 +1024,15 @@ private void releaseResources() {
}
closeAllResultPartitions();
closeAllInputGates();
+ if (this.channelStateWriter != null) {
+ LOG.debug("Closing channelStateWriter for task {}",
taskNameWithSubtask);
+ try {
+ this.channelStateWriter.close();
+ } catch (IOException e) {
+ LOG.error(
+ "Failed to close channelStateWriter for task {}.",
taskNameWithSubtask, e);
+ }
Review Comment:
I am thinking should we catch `Throwable` and call
`ExceptionUtils.rethrowIfFatalError` to ensure subsequent closes logic can be
executed as expected.
Both of `closeAllResultPartitions` and `closeAllInputGates` have similar
catch blocks.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/taskmanager/TaskTest.java:
##########
@@ -1762,4 +1791,38 @@ void awaitTriggerLatch() {
}
}
}
+
+ private static class ChannelStateWriterWithCloseCounter
+ extends ChannelStateWriter.NoOpChannelStateWriter {
+ private final AtomicInteger closeCalledCounter = new AtomicInteger(0);
+
+ @Override
+ public void close() {
+ closeCalledCounter.incrementAndGet();
+ }
+
+ public boolean isOpen() {
+ return closeCalledCounter.get() == 0;
+ }
+
+ public boolean isClosed() {
+ return closeCalledCounter.get() == 1;
Review Comment:
Why using AtomicInteger instead of AtomicBoolean? Does it prevent call
close twice?
If so, is it needed to introduce some checks inside of close?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]