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 @@ -41,8 +41,8 @@ public enum HDDSVersion implements ComponentVersion {

ZDU(100, "Version that supports zero downtime upgrade"),

FUTURE_VERSION(-1, "Used internally in the client when the server side is "
+ " newer and an unknown server version has arrived to the client.");
UNKNOWN_VERSION(-1, "Used when a version cannot be deserialized to any version recognized by this" +
" component, which may indicate it came from a component in a newer version");

////////////////////////////// //////////////////////////////

Expand Down Expand Up @@ -85,11 +85,11 @@ public int serialize() {

/**
* @param value The serialized version to convert.
* @return The version corresponding to this serialized value, or {@link #FUTURE_VERSION} if no matching version is
* @return The version corresponding to this serialized value, or {@link #UNKNOWN_VERSION} if no matching version is
* found.
*/
public static HDDSVersion deserialize(int value) {
return BY_VALUE.getOrDefault(value, FUTURE_VERSION);
return BY_VALUE.getOrDefault(value, UNKNOWN_VERSION);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum ClientVersion implements ComponentVersion {
"This client version has support for Object Store and File " +
"System Optimized Bucket Layouts."),

FUTURE_VERSION(-1, "Used internally when the server side is older and an"
FUTURE_VERSION(-1, "Used internally by the server when the server side is older and an"
+ " unknown client version has arrived from the client.");

private static final SortedMap<Integer, ClientVersion> BY_VALUE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public enum OzoneManagerVersion implements ComponentVersion {

ZDU(100, "OzoneManager version that supports zero downtime upgrade"),

FUTURE_VERSION(-1, "Used internally in the client when the server side is "
+ " newer and an unknown server version has arrived to the client.");
UNKNOWN_VERSION(-1, "Used when a version cannot be deserialized to any version recognized by this" +
" component, which may indicate it came from a component in a newer version");

private static final SortedMap<Integer, OzoneManagerVersion> BY_VALUE =
Arrays.stream(values())
Expand Down Expand Up @@ -93,11 +93,11 @@ public int serialize() {

/**
* @param value The serialized version to convert.
* @return The version corresponding to this serialized value, or {@link #FUTURE_VERSION} if no matching version is
* @return The version corresponding to this serialized value, or {@link #UNKNOWN_VERSION} if no matching version is
* found.
*/
public static OzoneManagerVersion deserialize(int value) {
return BY_VALUE.getOrDefault(value, FUTURE_VERSION);
return BY_VALUE.getOrDefault(value, UNKNOWN_VERSION);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected ComponentVersion getDefaultVersion() {

@Override
protected ComponentVersion getFutureVersion() {
return HDDSVersion.FUTURE_VERSION;
return HDDSVersion.UNKNOWN_VERSION;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected ComponentVersion getDefaultVersion() {

@Override
protected ComponentVersion getFutureVersion() {
return OzoneManagerVersion.FUTURE_VERSION;
return OzoneManagerVersion.UNKNOWN_VERSION;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DatanodeStorage extends Storage {
public DatanodeStorage(ConfigurationSource conf, String dataNodeId)
throws IOException {
super(NodeType.DATANODE, ServerUtils.getOzoneMetaDirPath(conf),
DATANODE_LAYOUT_VERSION_DIR, dataNodeId, getDefaultLayoutVersion(conf));
DATANODE_LAYOUT_VERSION_DIR, dataNodeId, getDefaultApparentVersion(conf));
}

public DatanodeStorage(OzoneConfiguration conf, String dataNodeId,
Expand All @@ -56,7 +56,7 @@ public DatanodeStorage(OzoneConfiguration conf, String dataNodeId,
public DatanodeStorage(ConfigurationSource conf)
throws IOException {
super(NodeType.DATANODE, ServerUtils.getOzoneMetaDirPath(conf),
DATANODE_LAYOUT_VERSION_DIR, getDefaultLayoutVersion(conf));
DATANODE_LAYOUT_VERSION_DIR, getDefaultApparentVersion(conf));
}

@Override
Expand Down Expand Up @@ -94,15 +94,14 @@ public void setClusterId(String clusterId) throws IOException {
* @return The layout version that should be used for the datanode if no
* layout version is found on disk.
*/
private static int getDefaultLayoutVersion(ConfigurationSource conf) {
int defaultLayoutVersion = maxLayoutVersion();
private static int getDefaultApparentVersion(ConfigurationSource conf) {
int defaultApparentVersion = maxLayoutVersion();

File dnIdFile = new File(HddsServerUtil.getDatanodeIdFilePath(conf));
if (dnIdFile.exists()) {
defaultLayoutVersion =
HDDSLayoutFeature.INITIAL_VERSION.layoutVersion();
defaultApparentVersion = HDDSLayoutFeature.INITIAL_VERSION.layoutVersion();
}

return defaultLayoutVersion;
return defaultApparentVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_CONTAINER_ACTION_MAX_LIMIT_DEFAULT;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_PIPELINE_ACTION_MAX_LIMIT;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_PIPELINE_ACTION_MAX_LIMIT_DEFAULT;
import static org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto.Type.finalizeNewLayoutVersionCommand;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toVersionProto;

import com.google.common.base.Preconditions;
import com.google.protobuf.Descriptors;
Expand Down Expand Up @@ -129,13 +128,13 @@ public EndpointStateMachine.EndPointStates call() throws Exception {
try {
Preconditions.checkState(this.datanodeDetailsProto != null);

LayoutVersionProto layoutinfo = toLayoutVersionProto(
versionManager.getApparentVersion().serialize(),
versionManager.getSoftwareVersion().serialize());
LayoutVersionProto versionInfo = toVersionProto(
versionManager.getApparentVersion(),
versionManager.getSoftwareVersion());

requestBuilder = SCMHeartbeatRequestProto.newBuilder()
.setDatanodeDetails(datanodeDetailsProto)
.setDataNodeLayoutVersion(layoutinfo);
.setDataNodeLayoutVersion(versionInfo);
addReports(requestBuilder);
addContainerActions(requestBuilder);
addPipelineActions(requestBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.hadoop.ozone.container.upgrade;

import org.apache.hadoop.hdds.ComponentVersion;
import org.apache.hadoop.hdds.HDDSVersion;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.LayoutVersionProto;

Expand All @@ -28,16 +29,24 @@ public final class UpgradeUtils {
private UpgradeUtils() {
}

public static LayoutVersionProto defaultLayoutVersionProto() {
public static LayoutVersionProto defaultVersionProto() {
int softwareVersion = HDDSVersion.SOFTWARE_VERSION.serialize();
return LayoutVersionProto.newBuilder()
.setMetadataLayoutVersion(softwareVersion)
.setSoftwareLayoutVersion(softwareVersion).build();
}

public static LayoutVersionProto toLayoutVersionProto(int mLv, int sLv) {
public static LayoutVersionProto toVersionProto(ComponentVersion apparentVersion, ComponentVersion softwareVersion) {
return LayoutVersionProto.newBuilder()
.setMetadataLayoutVersion(mLv)
.setSoftwareLayoutVersion(sLv).build();
.setMetadataLayoutVersion(apparentVersion.serialize())
.setSoftwareLayoutVersion(softwareVersion.serialize())
.build();
}

public static LayoutVersionProto toVersionProto(int metadataLayoutVersion, int softwareLayoutVersion) {
return LayoutVersionProto.newBuilder()
.setMetadataLayoutVersion(metadataLayoutVersion)
.setSoftwareLayoutVersion(softwareLayoutVersion)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.hadoop.ozone.protocolPB;

import static org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.INITIAL_VERSION;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toVersionProto;

import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
Expand Down Expand Up @@ -71,17 +71,16 @@ public SCMRegisteredResponseProto register(
.getContainerReport();
NodeReportProto dnNodeReport = request.getNodeReport();
PipelineReportsProto pipelineReport = request.getPipelineReports();
LayoutVersionProto layoutInfo = null;
LayoutVersionProto versionInfo = null;
if (request.hasDataNodeLayoutVersion()) {
layoutInfo = request.getDataNodeLayoutVersion();
versionInfo = request.getDataNodeLayoutVersion();
} else {
// Backward compatibility to make sure old Datanodes can still talk to
// SCM.
layoutInfo = toLayoutVersionProto(INITIAL_VERSION.layoutVersion(),
INITIAL_VERSION.layoutVersion());
versionInfo = toVersionProto(INITIAL_VERSION, INITIAL_VERSION);
}
return impl.register(request.getExtendedDatanodeDetails(), dnNodeReport,
containerRequestProto, pipelineReport, layoutInfo);
containerRequestProto, pipelineReport, versionInfo);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TestDatanodeVersionManager extends AbstractComponentVersionManagerTest {

for (HDDSVersion version : HDDSVersion.values()) {
// Add all defined versions after and including ZDU to get the complete version list.
if (HDDSVersion.ZDU.isSupportedBy(version) && version != HDDSVersion.FUTURE_VERSION) {
if (HDDSVersion.ZDU.isSupportedBy(version) && version != HDDSVersion.UNKNOWN_VERSION) {
ALL_VERSIONS.add(version);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected HDDSVersionManager(Storage storage) throws IOException {
private static ComponentVersion computeApparentVersion(int serializedApparentVersion) throws IOException {
if (serializedApparentVersion >= HDDSVersion.ZDU.serialize()) {
HDDSVersion fromHdds = HDDSVersion.deserialize(serializedApparentVersion);
if (fromHdds != HDDSVersion.FUTURE_VERSION) {
if (fromHdds != HDDSVersion.UNKNOWN_VERSION) {
return fromHdds;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testIsSupportedByFeatureBoundary() {
public void testAllLayoutFeaturesAreSupportedByFutureVersions() {
for (HDDSLayoutFeature feature : HDDSLayoutFeature.values()) {
assertSupportedBy(feature, HDDSVersion.ZDU);
assertSupportedBy(feature, HDDSVersion.FUTURE_VERSION);
assertSupportedBy(feature, HDDSVersion.UNKNOWN_VERSION);
// No ComponentVersion instance represents an arbitrary future version.
assertTrue(feature.isSupportedBy(Integer.MAX_VALUE));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.hadoop.hdds.scm.node;

import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toLayoutVersionProto;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.toVersionProto;

import com.google.common.annotations.VisibleForTesting;
import java.util.Collections;
Expand Down Expand Up @@ -67,16 +67,16 @@ public class DatanodeInfo extends DatanodeDetails {
* Constructs DatanodeInfo from DatanodeDetails.
*
* @param datanodeDetails Details about the datanode
* @param layoutInfo Details about the LayoutVersionProto
* @param versionInfo Details about the LayoutVersionProto
*/
public DatanodeInfo(DatanodeDetails datanodeDetails, NodeStatus nodeStatus,
LayoutVersionProto layoutInfo, long containerRollIntervalMs) {
LayoutVersionProto versionInfo, long containerRollIntervalMs) {
super(datanodeDetails);
this.lock = new ReentrantReadWriteLock();
this.lastHeartbeatTime = Time.monotonicNow();
lastKnownLayoutVersion = toLayoutVersionProto(
layoutInfo != null ? layoutInfo.getMetadataLayoutVersion() : 0,
layoutInfo != null ? layoutInfo.getSoftwareLayoutVersion() : 0);
lastKnownLayoutVersion = toVersionProto(
versionInfo != null ? versionInfo.getMetadataLayoutVersion() : 0,
versionInfo != null ? versionInfo.getSoftwareLayoutVersion() : 0);
this.storageReports = Collections.emptyList();
this.nodeStatus = nodeStatus;
this.metadataStorageReports = Collections.emptyList();
Expand Down Expand Up @@ -108,15 +108,15 @@ public void updateLastHeartbeatTime(long milliSecondsSinceEpoch) {
}

/**
* Updates the last LayoutVersion.
* Updates the last known version reported by this datanode.
*/
public void updateLastKnownLayoutVersion(LayoutVersionProto version) {
public void updateLastKnownVersions(LayoutVersionProto version) {
if (version == null) {
return;
}
try {
lock.writeLock().lock();
lastKnownLayoutVersion = toLayoutVersionProto(
lastKnownLayoutVersion = toVersionProto(
version.getMetadataLayoutVersion(),
version.getSoftwareLayoutVersion());
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.hadoop.hdds.scm.node;

import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.defaultLayoutVersionProto;
import static org.apache.hadoop.ozone.container.upgrade.UpgradeUtils.defaultVersionProto;

import jakarta.annotation.Nullable;
import java.io.Closeable;
Expand Down Expand Up @@ -91,7 +91,7 @@ default RegisteredCommand register(
DatanodeDetails datanodeDetails, NodeReportProto nodeReport,
PipelineReportsProto pipelineReportsProto) {
return register(datanodeDetails, nodeReport, pipelineReportsProto,
defaultLayoutVersionProto());
defaultVersionProto());
}

/**
Expand Down Expand Up @@ -372,8 +372,8 @@ void processNodeReport(DatanodeDetails datanodeDetails,
* @param datanodeDetails
* @param layoutReport
*/
void processLayoutVersionReport(DatanodeDetails datanodeDetails,
LayoutVersionProto layoutReport);
void processVersionReport(DatanodeDetails datanodeDetails,
LayoutVersionProto layoutReport);

/**
* Get the number of commands of the given type queued on the datanode at the
Expand Down Expand Up @@ -476,7 +476,7 @@ default Collection<DatanodeDetails> getPeerList(DatanodeDetails dn) {
default HDDSLayoutVersionManager getLayoutVersionManager() {
return null;
}

/**
* This API allows removal of only DECOMMISSIONED, IN_MAINTENANCE and DEAD nodes
* from NodeManager data structures and cleanup memory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void addNode(DatanodeDetails datanodeDetails,
LayoutVersionProto layoutInfo) throws NodeAlreadyExistsException {
nodeStateMap.addNode(newDatanodeInfo(datanodeDetails, layoutInfo));
try {
updateLastKnownLayoutVersion(datanodeDetails, layoutInfo);
updateLastKnownVersionInfo(datanodeDetails, layoutInfo);
} catch (NodeNotFoundException ex) {
throw new IllegalStateException("Inconsistent NodeStateMap! Datanode "
+ datanodeDetails.getID() + " was added but not found in map: " + nodeStateMap);
Expand Down Expand Up @@ -318,11 +318,10 @@ public void updateLastHeartbeatTime(DatanodeDetails datanodeDetails)
*
* @throws NodeNotFoundException if the node is not present
*/
public void updateLastKnownLayoutVersion(DatanodeDetails datanodeDetails,
LayoutVersionProto layoutInfo)
throws NodeNotFoundException {
public void updateLastKnownVersionInfo(DatanodeDetails datanodeDetails,
LayoutVersionProto layoutInfo) throws NodeNotFoundException {
nodeStateMap.getNodeInfo(datanodeDetails.getID())
.updateLastKnownLayoutVersion(layoutInfo);
.updateLastKnownVersions(layoutInfo);
}

/**
Expand All @@ -339,7 +338,7 @@ public void updateNode(DatanodeDetails datanodeDetails,
final DatanodeInfo oldInfo = nodeStateMap.updateNode(newInfo);
LOG.info("Updated datanode {} {} to {} {}",
oldInfo, oldInfo.getNodeStatus(), newInfo, newInfo.getNodeStatus());
updateLastKnownLayoutVersion(datanodeDetails, layoutInfo);
updateLastKnownVersionInfo(datanodeDetails, layoutInfo);
}

/**
Expand Down
Loading