sumitagrawl commented on code in PR #10416:
URL: https://github.com/apache/ozone/pull/10416#discussion_r3353043733
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java:
##########
@@ -790,29 +790,49 @@ private ExecutorService
getChunkExecutor(WriteChunkRequestProto req) {
@Override
public CompletableFuture<Message> write(LogEntryProto entry,
TransactionContext trx) {
try {
- metrics.incNumWriteStateMachineOps();
- long writeStateMachineStartTime = Time.monotonicNowNanos();
- final Context context = (Context) trx.getStateMachineContext();
- Objects.requireNonNull(context, "context == null");
- final ContainerCommandRequestProto requestProto =
context.getRequestProto();
- final Type cmdType = requestProto.getCmdType();
-
- // For only writeChunk, there will be writeStateMachineData call.
- // CreateContainer will happen as a part of writeChunk only.
- switch (cmdType) {
- case WriteChunk:
- return writeStateMachineData(requestProto, entry.getIndex(),
- entry.getTerm(), writeStateMachineStartTime);
- default:
- throw new IllegalStateException("Cmd Type:" + cmdType
- + " should not have state machine data");
- }
- } catch (Exception e) {
+ return writeImpl(entry, trx).whenComplete((r, e) -> {
+ if (e != null) {
+ closeServer(e);
+ }
+ });
+ } catch (Throwable e) {
metrics.incNumWriteStateMachineFails();
+ closeServer(e);
Review Comment:
done
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java:
##########
@@ -790,29 +790,49 @@ private ExecutorService
getChunkExecutor(WriteChunkRequestProto req) {
@Override
public CompletableFuture<Message> write(LogEntryProto entry,
TransactionContext trx) {
try {
- metrics.incNumWriteStateMachineOps();
- long writeStateMachineStartTime = Time.monotonicNowNanos();
- final Context context = (Context) trx.getStateMachineContext();
- Objects.requireNonNull(context, "context == null");
- final ContainerCommandRequestProto requestProto =
context.getRequestProto();
- final Type cmdType = requestProto.getCmdType();
-
- // For only writeChunk, there will be writeStateMachineData call.
- // CreateContainer will happen as a part of writeChunk only.
- switch (cmdType) {
- case WriteChunk:
- return writeStateMachineData(requestProto, entry.getIndex(),
- entry.getTerm(), writeStateMachineStartTime);
- default:
- throw new IllegalStateException("Cmd Type:" + cmdType
- + " should not have state machine data");
- }
- } catch (Exception e) {
+ return writeImpl(entry, trx).whenComplete((r, e) -> {
+ if (e != null) {
+ closeServer(e);
+ }
+ });
+ } catch (Throwable e) {
metrics.incNumWriteStateMachineFails();
+ closeServer(e);
return completeExceptionally(e);
}
}
+ public CompletableFuture<Message> writeImpl(LogEntryProto entry,
TransactionContext trx) {
+ metrics.incNumWriteStateMachineOps();
+ long writeStateMachineStartTime = Time.monotonicNowNanos();
+ final Context context = (Context) trx.getStateMachineContext();
+ Objects.requireNonNull(context, "context == null");
+ final ContainerCommandRequestProto requestProto =
context.getRequestProto();
+ final Type cmdType = requestProto.getCmdType();
+
+ // For only writeChunk, there will be writeStateMachineData call.
+ // CreateContainer will happen as a part of writeChunk only.
+ switch (cmdType) {
+ case WriteChunk:
+ return writeStateMachineData(requestProto, entry.getIndex(),
+ entry.getTerm(), writeStateMachineStartTime);
+ default:
+ throw new IllegalStateException("Cmd Type:" + cmdType
+ + " should not have state machine data");
+ }
+ }
+
+ private void closeServer(Throwable e) {
+ metrics.incNumWriteStateMachineFails();
+ try {
+ LOG.error("{}: Failed, close server", getId(), e);
Review Comment:
done
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java:
##########
@@ -790,29 +790,49 @@ private ExecutorService
getChunkExecutor(WriteChunkRequestProto req) {
@Override
public CompletableFuture<Message> write(LogEntryProto entry,
TransactionContext trx) {
try {
- metrics.incNumWriteStateMachineOps();
- long writeStateMachineStartTime = Time.monotonicNowNanos();
- final Context context = (Context) trx.getStateMachineContext();
- Objects.requireNonNull(context, "context == null");
- final ContainerCommandRequestProto requestProto =
context.getRequestProto();
- final Type cmdType = requestProto.getCmdType();
-
- // For only writeChunk, there will be writeStateMachineData call.
- // CreateContainer will happen as a part of writeChunk only.
- switch (cmdType) {
- case WriteChunk:
- return writeStateMachineData(requestProto, entry.getIndex(),
- entry.getTerm(), writeStateMachineStartTime);
- default:
- throw new IllegalStateException("Cmd Type:" + cmdType
- + " should not have state machine data");
- }
- } catch (Exception e) {
+ return writeImpl(entry, trx).whenComplete((r, e) -> {
+ if (e != null) {
+ closeServer(e);
+ }
+ });
+ } catch (Throwable e) {
metrics.incNumWriteStateMachineFails();
+ closeServer(e);
return completeExceptionally(e);
}
}
+ public CompletableFuture<Message> writeImpl(LogEntryProto entry,
TransactionContext trx) {
Review Comment:
done
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]