sumitagrawl commented on code in PR #12115:
URL: https://github.com/apache/ozone/pull/12115#discussion_r4703759661
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java:
##########
@@ -245,15 +256,74 @@ private int determinePort(String key, int defaultValue) {
}
private ContainerStateMachine getStateMachine(RaftGroupId gid) {
- ReplicationType type = addingGroups.get(gid);
- if (type == null) {
- // The type is unknown when the group is reloaded on restart or added by
a peer.
- // TODO HDDS-17845: support restart for CHAINED.
- LOG.info("{}: ReplicationType is unknown, use {}", gid,
ReplicationType.RATIS);
- type = ReplicationType.RATIS;
+ return new ContainerStateMachine(datanodeService, gid,
getReplicationTypeForNewGroup(gid), dispatcher,
+ containerController, chunkExecutors, this, conf,
datanodeDetails.threadNamePrefix());
+ }
+
+ private ReplicationType getReplicationTypeForNewGroup(RaftGroupId gid) {
+ final ReplicationType adding = addingGroups.get(gid);
+ if (adding != null) {
+ return adding;
+ }
+ // The group is reloaded on restart or added by a peer.
+ final Table<PipelineID, PipelineCreateInfoProto> table =
getPipelineCreateInfoTable();
+ if (table != null) {
+ final PipelineCreateInfoProto stored;
+ try {
+ stored = table.get(PipelineID.valueOf(gid.getUuid()));
+ } catch (IOException e) {
+ throw new UncheckedIOException(gid + ": Failed to get ReplicationType
from PipelineCreateInfoTable", e);
+ }
+ if (stored != null) {
+ return stored.getReplicationType();
+ }
+ }
+ LOG.debug("{}: ReplicationType not found, use {}", gid, RATIS);
+ return RATIS;
+ }
+
+ /** @return PipelineCreateInfoTable, or null if it is unavailable. */
+ private Table<PipelineID, PipelineCreateInfoProto>
getPipelineCreateInfoTable() {
+ final WitnessedContainerMetadataStore store = containerController == null
? null
+ : containerController.getContainerMetadataStore();
+ return store == null ? null : store.getPipelineCreateInfoTable();
+ }
+
+ /** Remove the PipelineCreateInfoTable entries without a group, e.g. the
datanode crashed during {@link #addGroup}. */
+ private void cleanupPipelineCreateInfoTable() throws IOException {
+ final Table<PipelineID, PipelineCreateInfoProto> table =
getPipelineCreateInfoTable();
+ if (table == null) {
+ return;
+ }
+ final Set<RaftGroupId> groupIds = new HashSet<>();
+ server.getGroupIds().forEach(groupIds::add);
+ final List<PipelineID> toDelete = new ArrayList<>();
+ try (TableIterator<PipelineID, PipelineID> i = table.keyIterator()) {
+ while (i.hasNext()) {
+ final PipelineID id = i.next();
+ if (!groupIds.contains(id.getGroupId())) {
+ toDelete.add(id);
+ }
+ }
+ }
+ for (PipelineID id : toDelete) {
+ LOG.info("{}: Remove {} from PipelineCreateInfoTable since its group
does not exist", name, id);
+ table.delete(id);
Review Comment:
do we need trigger close of these pipeline ?
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java:
##########
@@ -576,6 +646,8 @@ public void start() throws IOException {
executor.prestartAllCoreThreads();
}
server.start();
+ cleanupPipelineCreateInfoTable();
+ closeChainedPipelines();
Review Comment:
1. why do we need close CHAINED pipeline ?
2. What happens if there is a delay in close pipeline ? Do the one initiated
earlier will be success?
3. What happens to on-going transfer on this DN as intermediate and other
DNs as initiator ?
--
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]