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
@@ -0,0 +1,73 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.hdds.upgrade;

import java.util.Optional;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import org.apache.hadoop.ozone.upgrade.LayoutFeature;

/**
* List of HDDS Features.
*/
public enum HDDSLayoutFeature implements LayoutFeature {
////////////////////////////// //////////////////////////////
INITIAL_VERSION(0, "Initial Layout Version"),
FIRST_UPGRADE_VERSION(1, "First Layout Version After Upgrade");

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

private int layoutVersion;
private String description;
private HDDSUpgradeAction scmUpgradeAction;
private HDDSUpgradeAction datanodeUpgradeAction;

HDDSLayoutFeature(final int layoutVersion, String description) {
this.layoutVersion = layoutVersion;
this.description = description;
}

@SuppressFBWarnings("ME_ENUM_FIELD_SETTER")
public void setSCMUpgradeAction(HDDSUpgradeAction scmAction) {
this.scmUpgradeAction = scmAction;
}

@SuppressFBWarnings("ME_ENUM_FIELD_SETTER")
public void setDataNodeUpgradeAction(HDDSUpgradeAction datanodeAction) {
this.datanodeUpgradeAction = datanodeAction;
}

@Override
public int layoutVersion() {
return layoutVersion;
}

@Override
public String description() {
return description;
}

public Optional<? extends HDDSUpgradeAction> onFinalizeSCMAction() {
return Optional.ofNullable(scmUpgradeAction);
}

public Optional<? extends HDDSUpgradeAction> onFinalizeDataNodeAction() {
return Optional.ofNullable(datanodeUpgradeAction);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
import java.io.IOException;

import org.apache.hadoop.ozone.common.Storage;
import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeatureCatalog.HDDSLayoutFeature;
import org.apache.hadoop.ozone.upgrade.AbstractLayoutVersionManager;
import org.apache.hadoop.ozone.upgrade.LayoutVersionManager;

import com.google.common.annotations.VisibleForTesting;

/**
* Class to manage layout versions and features for Storage Container Manager
Expand All @@ -36,44 +32,7 @@
public class HDDSLayoutVersionManager extends
AbstractLayoutVersionManager<HDDSLayoutFeature> {

private static HDDSLayoutVersionManager hddsLayoutVersionManager;

private HDDSLayoutVersionManager() {
}

/**
* Read only instance to HDDS Version Manager.
* @return version manager instance.
*/
public static synchronized LayoutVersionManager getInstance() {
if (hddsLayoutVersionManager == null) {
throw new RuntimeException("HDDS Layout Version Manager not yet " +
"initialized.");
}
return hddsLayoutVersionManager;
}


/**
* Initialize HDDS version manager from scmstorage.
* @return version manager instance.
*/
public static synchronized HDDSLayoutVersionManager initialize(
Storage hddsStorage)
throws IOException {
if (hddsLayoutVersionManager == null) {
hddsLayoutVersionManager = new HDDSLayoutVersionManager();
hddsLayoutVersionManager.init(hddsStorage.getLayoutVersion(),
HDDSLayoutFeature.values());
}
return hddsLayoutVersionManager;
}

@VisibleForTesting
protected synchronized static void resetLayoutVersionManager() {
if (hddsLayoutVersionManager != null) {
hddsLayoutVersionManager.reset();
hddsLayoutVersionManager = null;
}
public HDDSLayoutVersionManager(Storage hddsStorage) throws IOException {
init(hddsStorage.getLayoutVersion(), HDDSLayoutFeature.values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@ public interface LayoutVersionManager {
LayoutFeature getFeature(String name);

Iterable<? extends LayoutFeature> unfinalizedFeatures();

/**
* Generic API for returning a registered handler for a given type.
* @param type String type
* @return
*/
default Object getHandler(String type) {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
import org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient;
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
import org.apache.hadoop.ozone.HddsDatanodeStopService;
import org.apache.hadoop.ozone.container.common.DataNodeStorageConfig;
Expand All @@ -56,8 +57,7 @@
import org.apache.hadoop.ozone.container.replication.DownloadAndImportReplicator;
import org.apache.hadoop.ozone.container.replication.ReplicationSupervisor;
import org.apache.hadoop.ozone.container.replication.SimpleContainerDownloader;
import org.apache.hadoop.ozone.container.upgrade.DataNodeLayoutActionCatalog.DataNodeLayoutAction;
import org.apache.hadoop.ozone.container.upgrade.DataNodeLayoutVersionManager;
import org.apache.hadoop.ozone.container.upgrade.DataNodeLayoutAction;
import org.apache.hadoop.ozone.container.upgrade.DataNodeUpgradeFinalizer;
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages;
Expand Down Expand Up @@ -95,7 +95,7 @@ public class DatanodeStateMachine implements Closeable {
private CertificateClient dnCertClient;
private final HddsDatanodeStopService hddsDatanodeStopService;

private DataNodeLayoutVersionManager dataNodeVersionManager;
private HDDSLayoutVersionManager dataNodeVersionManager;
private DataNodeStorageConfig dataNodeStorageConfig;
private DataNodeUpgradeFinalizer upgradeFinalizer;

Expand Down Expand Up @@ -130,8 +130,8 @@ public DatanodeStateMachine(DatanodeDetails datanodeDetails,
if (dataNodeStorageConfig.getState() != INITIALIZED) {
dataNodeStorageConfig.initialize();
}
dataNodeVersionManager = DataNodeLayoutVersionManager
.initialize(dataNodeStorageConfig);
dataNodeVersionManager =
new HDDSLayoutVersionManager(dataNodeStorageConfig);
upgradeFinalizer = new DataNodeUpgradeFinalizer(dataNodeVersionManager);

executorService = Executors.newFixedThreadPool(
Expand Down Expand Up @@ -582,7 +582,7 @@ public ReplicationSupervisor getSupervisor() {
}

@VisibleForTesting
public DataNodeLayoutVersionManager getDataNodeVersionManager() {
public HDDSLayoutVersionManager getDataNodeVersionManager() {
return dataNodeVersionManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto;
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.ozone.container.common.helpers
.DeletedContainerBlocksSummary;
import org.apache.hadoop.ozone.container.common.statemachine
.EndpointStateMachine;
import org.apache.hadoop.ozone.container.common.statemachine
.EndpointStateMachine.EndPointStates;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.upgrade.DataNodeLayoutVersionManager;
import org.apache.hadoop.ozone.protocol.commands.CloseContainerCommand;
import org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand;
import org.apache.hadoop.ozone.protocol.commands.CreatePipelineCommand;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class HeartbeatEndpointTask
private StateContext context;
private int maxContainerActionsPerHB;
private int maxPipelineActionsPerHB;
private DataNodeLayoutVersionManager layoutVersionManager;
private HDDSLayoutVersionManager layoutVersionManager;

/**
* Constructs a SCM heart beat.
Expand All @@ -112,7 +112,7 @@ public HeartbeatEndpointTask(EndpointStateMachine rpcEndpoint,
*/
public HeartbeatEndpointTask(EndpointStateMachine rpcEndpoint,
ConfigurationSource conf, StateContext context,
DataNodeLayoutVersionManager versionManager) {
HDDSLayoutVersionManager versionManager) {
this.rpcEndpoint = rpcEndpoint;
this.conf = conf;
this.context = context;
Expand Down Expand Up @@ -392,7 +392,7 @@ public static class Builder {
private ConfigurationSource conf;
private DatanodeDetails datanodeDetails;
private StateContext context;
private DataNodeLayoutVersionManager versionManager;
private HDDSLayoutVersionManager versionManager;

/**
* Constructs the builder class.
Expand All @@ -417,9 +417,8 @@ public Builder setEndpointStateMachine(EndpointStateMachine rpcEndPoint) {
* @param versionMgr - config
* @return Builder
*/
public Builder setLayoutVersionManager(
DataNodeLayoutVersionManager versionMgr) {
this.versionManager = versionMgr;
public Builder setLayoutVersionManager(HDDSLayoutVersionManager lvm) {
this.versionManager = lvm;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto
.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
import org.apache.hadoop.hdds.upgrade.HDDSLayoutVersionManager;
import org.apache.hadoop.ozone.container.common.statemachine
.EndpointStateMachine;
import org.apache.hadoop.hdds.protocol.proto
Expand All @@ -37,7 +38,6 @@
.StorageContainerDatanodeProtocolProtos.LayoutVersionProto;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
import org.apache.hadoop.ozone.container.upgrade.DataNodeLayoutVersionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,7 +59,7 @@ public final class RegisterEndpointTask implements
private DatanodeDetails datanodeDetails;
private final OzoneContainer datanodeContainerManager;
private StateContext stateContext;
private DataNodeLayoutVersionManager layoutVersionManager;
private HDDSLayoutVersionManager layoutVersionManager;

/**
* Creates a register endpoint task.
Expand Down Expand Up @@ -90,7 +90,7 @@ public RegisterEndpointTask(EndpointStateMachine rpcEndPoint,
@VisibleForTesting
public RegisterEndpointTask(EndpointStateMachine rpcEndPoint,
ConfigurationSource conf, OzoneContainer ozoneContainer,
StateContext context, DataNodeLayoutVersionManager versionManager) {
StateContext context, HDDSLayoutVersionManager versionManager) {
this.rpcEndPoint = rpcEndPoint;
this.conf = conf;
this.datanodeContainerManager = ozoneContainer;
Expand Down Expand Up @@ -205,7 +205,7 @@ public static class Builder {
private DatanodeDetails datanodeDetails;
private OzoneContainer container;
private StateContext context;
private DataNodeLayoutVersionManager versionManager;
private HDDSLayoutVersionManager versionManager;

/**
* Constructs the builder class.
Expand Down Expand Up @@ -241,9 +241,8 @@ public Builder setConfig(ConfigurationSource config) {
* @param versionMgr - config
* @return Builder.
*/
public Builder setLayoutVersionManager(
DataNodeLayoutVersionManager versionMgr) {
this.versionManager = versionMgr;
public Builder setLayoutVersionManager(HDDSLayoutVersionManager lvm) {
this.versionManager = lvm;
return this;
}

Expand Down
Loading