This is an automated email from the ASF dual-hosted git repository.
avijayan pushed a commit to branch HDDS-3698-upgrade
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git
The following commit(s) were added to refs/heads/HDDS-3698-upgrade by this push:
new 0731098 HDDS-4173. Implement HDDS Version management using the
LayoutVersionManager interface. (#1392)
0731098 is described below
commit 073109869bbf2791ec2cc9dee35e2eb51cb4e2a5
Author: prashantpogde <[email protected]>
AuthorDate: Wed Sep 9 09:46:18 2020 -0700
HDDS-4173. Implement HDDS Version management using the
LayoutVersionManager interface. (#1392)
---
.../hdds/upgrade/HDDSLayoutFeatureCatalog.java | 69 ++++++++++++++++
.../hdds/upgrade/HDDSLayoutVersionManager.java | 92 ++++++++++++++++++++++
.../hadoop/hdds/upgrade/HDDSUpgradeAction.java | 27 +++++++
.../apache/hadoop/hdds/upgrade/package-info.java | 23 ++++++
.../server/upgrade/NewSCMFeatureUpgradeAction.java | 34 ++++++++
.../hdds/scm/server/upgrade/SCMUpgradeAction.java | 29 +++++++
.../hdds/scm/server/upgrade/package-info.java | 23 ++++++
7 files changed, 297 insertions(+)
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutFeatureCatalog.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutFeatureCatalog.java
new file mode 100644
index 0000000..9793f5d
--- /dev/null
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutFeatureCatalog.java
@@ -0,0 +1,69 @@
+/**
+ * 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 org.apache.hadoop.ozone.upgrade.LayoutFeature;
+
+/**
+ * Catalog of HDDS features.
+ */
+public class HDDSLayoutFeatureCatalog {
+
+ /**
+ * List of HDDS Features.
+ */
+ public enum HDDSLayoutFeature implements LayoutFeature {
+ INITIAL_VERSION(0, "Initial Layout Version");
+
+
+ private int layoutVersion;
+ private String description;
+ private Optional<HDDSUpgradeAction> hddsUpgradeAction = Optional.empty();
+
+ HDDSLayoutFeature(final int layoutVersion, String description) {
+ this.layoutVersion = layoutVersion;
+ this.description = description;
+ }
+
+ HDDSLayoutFeature(final int layoutVersion, String description,
+ HDDSUpgradeAction upgradeAction) {
+ this.layoutVersion = layoutVersion;
+ this.description = description;
+ hddsUpgradeAction = Optional.of(upgradeAction);
+ }
+
+ @Override
+ public int layoutVersion() {
+ return layoutVersion;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public Optional<? extends HDDSUpgradeAction> onFinalizeAction() {
+ return hddsUpgradeAction;
+ }
+ }
+}
+
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutVersionManager.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutVersionManager.java
new file mode 100644
index 0000000..3ed28b2
--- /dev/null
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutVersionManager.java
@@ -0,0 +1,92 @@
+/**
+ * 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.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
+ * and DataNodes.
+ */
+public final class HDDSLayoutVersionManager extends
+ AbstractLayoutVersionManager {
+
+ 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);
+ }
+ return hddsLayoutVersionManager;
+ }
+
+ /**
+ * Initialize the HDDS Layout Features and current Layout Version.
+ * @param storage to read the current layout version.
+ * @throws IOException on error.
+ */
+ private void init(Storage storage) throws IOException {
+ init(storage.getLayoutVersion(), HDDSLayoutFeature.values());
+ if (metadataLayoutVersion > softwareLayoutVersion) {
+ throw new IOException(
+ String.format("Cannot initialize VersionManager. Metadata " +
+ "layout version (%d) > software layout version (%d)",
+ metadataLayoutVersion, softwareLayoutVersion));
+ }
+ }
+
+ @VisibleForTesting
+ protected synchronized static void resetLayoutVersionManager() {
+ if (hddsLayoutVersionManager != null) {
+ hddsLayoutVersionManager.reset();
+ hddsLayoutVersionManager = null;
+ }
+ }
+}
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSUpgradeAction.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSUpgradeAction.java
new file mode 100644
index 0000000..0808b0f
--- /dev/null
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSUpgradeAction.java
@@ -0,0 +1,27 @@
+/**
+ * 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 org.apache.hadoop.ozone.upgrade.LayoutFeature.UpgradeAction;
+
+/**
+ * Upgrade Action for SCM and DataNodes.
+ */
+public interface HDDSUpgradeAction<T> extends UpgradeAction<T> {
+}
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/package-info.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/package-info.java
new file mode 100644
index 0000000..74b9638
--- /dev/null
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+/**
+ * This package contains SCM Upgrade related classes.
+ */
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/NewSCMFeatureUpgradeAction.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/NewSCMFeatureUpgradeAction.java
new file mode 100644
index 0000000..88afad1
--- /dev/null
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/NewSCMFeatureUpgradeAction.java
@@ -0,0 +1,34 @@
+/**
+ * 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.scm.server.upgrade;
+
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.hdds.upgrade.HDDSUpgradeAction;
+
+/**
+ * Example SCM Action class to help with understanding.
+ */
+public class NewSCMFeatureUpgradeAction implements
+ HDDSUpgradeAction<StorageContainerManager> {
+
+ @Override
+ public void executeAction(StorageContainerManager scm) {
+ // Do blah....
+ }
+}
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeAction.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeAction.java
new file mode 100644
index 0000000..809c3dd
--- /dev/null
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeAction.java
@@ -0,0 +1,29 @@
+/**
+ * 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.scm.server.upgrade;
+
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.hdds.upgrade.HDDSUpgradeAction;
+
+/**
+ * Upgrade Action for StorageContainerManager which takes in an 'SCM' instance.
+ */
+public interface SCMUpgradeAction<T> extends
+ HDDSUpgradeAction<StorageContainerManager> {
+}
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/package-info.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/package-info.java
new file mode 100644
index 0000000..23b45cf
--- /dev/null
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/package-info.java
@@ -0,0 +1,23 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.scm.server.upgrade;
+
+/**
+ * This package contains SCM Upgrade related classes.
+ */
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]