Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,12 @@
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.TOKEN_ERROR_OTHER;
import static org.apache.hadoop.ozone.om.lock.OzoneManagerLock.Resource.VOLUME_LOCK;
import static org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer.RaftServerStatus.LEADER_AND_READY;
import static org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer.getRaftGroupIdFromOmServiceId;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerInterServiceProtocolProtos.OzoneManagerInterService;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OzoneManagerService;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus;
import org.apache.ratis.proto.RaftProtos.RaftPeerRole;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.ratis.util.FileUtils;
import org.apache.ratis.util.LifeCycle;
Expand Down Expand Up @@ -1142,6 +1144,35 @@ private void initializeRatisDirs(OzoneConfiguration conf) throws IOException {
omRatisSnapshotDir.toPath());
}

File omRatisDir = new File(omRatisDirectory);
String groupIDfromServiceID = RaftGroupId.valueOf(
getRaftGroupIdFromOmServiceId(getOMServiceId())).getUuid().toString();

// If a directory exists in ratis storage dir
// Check the Ratis group Dir is same as the one generated from
// om service id.

// This will help to catch if some one has changed service id later on.
File[] ratisDirFiles = omRatisDir.listFiles();
if (ratisDirFiles != null) {
for (File ratisGroupDir : ratisDirFiles) {
if (ratisGroupDir.isDirectory()) {
if (!ratisGroupDir.getName().equals(groupIDfromServiceID)) {
throw new IOException("Ratis group Dir on disk "
+ ratisGroupDir.getName() + " does not match with RaftGroupID"
+ groupIDfromServiceID + " generated from service id "
+ getOMServiceId() + ". Looks like there is a change to " +
OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY + " value after the " +
"cluster is setup. Currently change to this value is not " +
"supported.");
}
} else {
LOG.warn("Unknown file {} exists in ratis storage dir {}",
ratisGroupDir, omRatisDir);
}
}
}

if (peerNodesMap != null && !peerNodesMap.isEmpty()) {
this.omSnapshotProvider = new OzoneManagerSnapshotProvider(
configuration, omRatisSnapshotDir, peerNodesMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ public RaftPeerId getRaftPeerId() {
return this.raftPeerId;
}

private UUID getRaftGroupIdFromOmServiceId(String omServiceId) {
public static UUID getRaftGroupIdFromOmServiceId(String omServiceId) {
return UUID.nameUUIDFromBytes(omServiceId.getBytes(StandardCharsets.UTF_8));
}

Expand Down