HDDS-433. ContainerStateMachine#readStateMachineData should properly build LogEntryProto. Contributed by Lokesh Jain.
This commit is contained in:
parent
5e64e62dee
commit
47299ce23f
@ -268,7 +268,7 @@ public CompletableFuture<Message> query(Message request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogEntryProto readStateMachineData(SMLogEntryProto smLogEntryProto,
|
private LogEntryProto readStateMachineData(LogEntryProto entry,
|
||||||
ContainerCommandRequestProto requestProto) {
|
ContainerCommandRequestProto requestProto) {
|
||||||
WriteChunkRequestProto writeChunkRequestProto =
|
WriteChunkRequestProto writeChunkRequestProto =
|
||||||
requestProto.getWriteChunk();
|
requestProto.getWriteChunk();
|
||||||
@ -307,18 +307,18 @@ private LogEntryProto readStateMachineData(SMLogEntryProto smLogEntryProto,
|
|||||||
ContainerCommandRequestProto.newBuilder(requestProto)
|
ContainerCommandRequestProto.newBuilder(requestProto)
|
||||||
.setWriteChunk(dataWriteChunkProto);
|
.setWriteChunk(dataWriteChunkProto);
|
||||||
|
|
||||||
return recreateLogEntryProto(smLogEntryProto,
|
return recreateLogEntryProto(entry,
|
||||||
newStateMachineProto.build().toByteString());
|
newStateMachineProto.build().toByteString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogEntryProto recreateLogEntryProto(SMLogEntryProto smLogEntryProto,
|
private LogEntryProto recreateLogEntryProto(LogEntryProto entry,
|
||||||
ByteString stateMachineData) {
|
ByteString stateMachineData) {
|
||||||
// recreate the log entry
|
// recreate the log entry
|
||||||
final SMLogEntryProto log =
|
final SMLogEntryProto log =
|
||||||
SMLogEntryProto.newBuilder(smLogEntryProto)
|
SMLogEntryProto.newBuilder(entry.getSmLogEntry())
|
||||||
.setStateMachineData(stateMachineData)
|
.setStateMachineData(stateMachineData)
|
||||||
.build();
|
.build();
|
||||||
return LogEntryProto.newBuilder().setSmLogEntry(log).build();
|
return LogEntryProto.newBuilder(entry).setSmLogEntry(log).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,11 +360,11 @@ public CompletableFuture<LogEntryProto> readStateMachineData(
|
|||||||
|
|
||||||
if (requestProto.getCmdType() == Type.WriteChunk) {
|
if (requestProto.getCmdType() == Type.WriteChunk) {
|
||||||
return CompletableFuture.supplyAsync(() ->
|
return CompletableFuture.supplyAsync(() ->
|
||||||
readStateMachineData(smLogEntryProto, requestProto),
|
readStateMachineData(entry, requestProto),
|
||||||
chunkExecutor);
|
chunkExecutor);
|
||||||
} else if (requestProto.getCmdType() == Type.CreateContainer) {
|
} else if (requestProto.getCmdType() == Type.CreateContainer) {
|
||||||
LogEntryProto log =
|
LogEntryProto log =
|
||||||
recreateLogEntryProto(smLogEntryProto, requestProto.toByteString());
|
recreateLogEntryProto(entry, requestProto.toByteString());
|
||||||
return CompletableFuture.completedFuture(log);
|
return CompletableFuture.completedFuture(log);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Cmd type:" + requestProto.getCmdType()
|
throw new IllegalStateException("Cmd type:" + requestProto.getCmdType()
|
||||||
|
Loading…
Reference in New Issue
Block a user