ibessonov commented on code in PR #3614:
URL: https://github.com/apache/ignite-3/pull/3614#discussion_r1570265763
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java:
##########
@@ -357,36 +402,94 @@ private static LocalPartitionStateEnum convertState(State
nodeState) {
default:
// Unrecognized state, better safe than sorry.
- return LocalPartitionStateEnum.BROKEN;
+ return BROKEN;
}
}
/**
* Replaces some healthy states with a {@link
LocalPartitionStateEnum#CATCHING_UP},it can only be done once the state of all
peers is
* known.
*/
- private Map<TablePartitionId, Map<String, LocalPartitionState>> normalize(
- Map<TablePartitionId, Map<String, LocalPartitionState>> result
+ private static Map<TablePartitionId, Map<String, LocalPartitionState>>
normalizeLocal(
+ Map<TablePartitionId, Map<String, LocalPartitionStateMessage>>
result,
+ Catalog catalog
) {
return
result.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry ->
{
- Map<String, LocalPartitionState> map = entry.getValue();
+ TablePartitionId tablePartitionId = entry.getKey();
+ Map<String, LocalPartitionStateMessage> map = entry.getValue();
// noinspection OptionalGetWithoutIsPresent
- long maxLogIndex =
map.values().stream().mapToLong(LocalPartitionState::logIndex).max().getAsLong();
+ long maxLogIndex =
map.values().stream().mapToLong(LocalPartitionStateMessage::logIndex).max().getAsLong();
return
map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry2 -> {
- LocalPartitionState state = entry2.getValue();
+ LocalPartitionStateMessage stateMsg = entry2.getValue();
- if (state.state() != LocalPartitionStateEnum.HEALTHY ||
maxLogIndex - state.logIndex() < CATCH_UP_THRESHOLD) {
- return state;
+ LocalPartitionStateEnum stateEnum = stateMsg.state();
+
+ if (stateMsg.state() == HEALTHY && maxLogIndex -
stateMsg.logIndex() >= CATCH_UP_THRESHOLD) {
+ stateEnum = CATCHING_UP;
}
- return MSG_FACTORY.localPartitionState()
- .state(LocalPartitionStateEnum.CATCHING_UP)
- .partitionId(state.partitionId())
- .logIndex(state.logIndex())
- .build();
+ CatalogTableDescriptor tableDescriptor =
catalog.table(tablePartitionId.tableId());
+ return new LocalPartitionState(tableDescriptor.name(),
tablePartitionId.partitionId(), stateEnum);
}));
}));
}
+
+ private static Map<TablePartitionId, GlobalPartitionState> normalizeGlobal(
+ Map<TablePartitionId, Map<String, LocalPartitionState>>
localResult,
+ Catalog catalog
+ ) {
+ Map<Integer, Integer> tableIdToPartitions = new HashMap<>();
+
+ Map<TablePartitionId, GlobalPartitionState> result =
localResult.entrySet().stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
+ TablePartitionId tablePartitionId = entry.getKey();
Review Comment:
Sure! I don't know if I'll follow your recommendation fully, but I will
simplify the code
--
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]