This is an automated email from the ASF dual-hosted git repository.
erose pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 28e202b873a HDDS-14568. Remove unused LayoutVersionInstanceFactory
from the upgrade framework (#9714)
28e202b873a is described below
commit 28e202b873ac04b8457007b0550f31c2409705d7
Author: Ethan Rose <[email protected]>
AuthorDate: Thu Feb 5 19:01:08 2026 -0500
HDDS-14568. Remove unused LayoutVersionInstanceFactory from the upgrade
framework (#9714)
Generated-By: Cursor
---
.../docs/content/design/upgrade-dev-primer.md | 6 -
.../upgrade/LayoutVersionInstanceFactory.java | 250 ---------------------
.../hadoop/ozone/upgrade/VersionFactoryKey.java | 69 ------
.../upgrade/TestLayoutVersionInstanceFactory.java | 192 ----------------
.../ozone/om/upgrade/OMLayoutVersionManager.java | 19 --
.../TestOmVersionManagerRequestFactory.java | 77 -------
6 files changed, 613 deletions(-)
diff --git a/hadoop-hdds/docs/content/design/upgrade-dev-primer.md
b/hadoop-hdds/docs/content/design/upgrade-dev-primer.md
index 8ae39916f1c..1a47b2f729e 100644
--- a/hadoop-hdds/docs/content/design/upgrade-dev-primer.md
+++ b/hadoop-hdds/docs/content/design/upgrade-dev-primer.md
@@ -50,12 +50,6 @@ Method level annotation used to "disallow" an API if current
layout version does
## @BelongsToLayoutVersion Annotation
Annotation to mark an OM request class that it belongs to a specific Layout
Version. Until that version is available post finalize, this request will not
be supported. A newer version of an existing OM request can be created (by
inheritance or a fully new class) and marked with a newer layout version. Until
finalizing this layout version, the older request class is used. Post
finalizing, the newer version of the request class is used.
-## LayoutVersionInstanceFactory<T>
-Generic factory which stores different instances of Type 'T' sharded by a key
& version. A single key can be associated with different versions of 'T'.
-
-### Why does this class exist?
-A typical use case during upgrade is to have multiple versions of a class /
method / object and choose them based on the current layout version at
runtime. Before finalizing, an older version is typically needed, and after
finalization, a newer version is needed. This class serves this purpose in a
generic way. For example, we can create a Factory to create multiple versions
of OMRequests sharded by Request Type & Layout Version Supported.
-
## Upgrade Action (UpgradeActionOm & UpgradeActionHdds)
Annotation to specify upgrade action run during specific upgrade phases. Each
layout feature can optionally define an upgrade action for every supported
phase. These are the supported phases of action callbacks.
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
deleted file mode 100644
index a6996ea3496..00000000000
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/LayoutVersionInstanceFactory.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * 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.ozone.upgrade;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.stream.Collectors.toList;
-
-import com.google.common.annotations.VisibleForTesting;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.PriorityQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Generic factory which stores different instances of Type 'T' sharded by
- * a key and version. A single key can be associated with different versions
- * of 'T'.
- * Why does this class exist?
- * A typical use case during upgrade is to have multiple versions of a class
- * / method / object and chose them based on current layout
- * version at runtime. Before finalizing, an older version is typically
- * needed, and after finalize, a newer version is needed. This class serves
- * this purpose in a generic way.
- * For example, we can create a Factory to create multiple versions of
- * OMRequests sharded by Request Type and Layout Version Supported.
- */
-public class LayoutVersionInstanceFactory<T> {
-
- private static final Logger LOG =
- LoggerFactory.getLogger(LayoutVersionInstanceFactory.class);
-
- /**
- * The factory will maintain ALL instances > MLV and 1 instance <= MLV in a
- * priority queue (ordered by version). By doing that it guarantees O(1)
- * lookup at all times, since we always would lookup the first element (top
- * of the PQ).
- * Multiple entries will be there ONLY during pre-finalized state.
- * On finalization, we will be removing the entry one by one until we reach
- * a single entry. On a regular component instance (finalized), there will
- * be a single request version associated with a request always.
- */
- private final Map<String, PriorityQueue<VersionedInstance<T>>> instances =
- new HashMap<>();
-
- /**
- * Register an instance with a given factory key (key + version).
- * For safety reasons we dont allow (1) re-registering, (2) registering an
- * instance with version > SLV.
- *
- * @param lvm LayoutVersionManager
- * @param key VersionFactoryKey key to associate with instance.
- * @param instance instance to register.
- */
- public boolean register(LayoutVersionManager lvm, VersionFactoryKey key,
- T instance) {
- // If version is not passed in, go defensive and set the highest possible
- // version (SLV).
- int version = key.getVersion() == null ?
- lvm.getSoftwareLayoutVersion() : key.getVersion();
-
- checkArgument(lvm.getSoftwareLayoutVersion() >= key.getVersion(),
- String.format("Cannot register key %s since the version is greater " +
- "than the Software layout version %d",
- key, lvm.getSoftwareLayoutVersion()));
-
- // If we reach here, we know that the passed in version belongs to
- // [0, SLV].
- String primaryKey = key.getKey();
- instances.computeIfAbsent(primaryKey, s ->
- new PriorityQueue<>(Comparator.comparingInt(o -> o.version)));
-
- PriorityQueue<VersionedInstance<T>> versionedInstances =
- instances.get(primaryKey);
- Optional<VersionedInstance<T>> existingInstance =
- versionedInstances.parallelStream()
- .filter(v -> v.version == key.getVersion()).findAny();
-
- if (existingInstance.isPresent()) {
- throw new IllegalArgumentException(String.format("Cannot register key " +
- "%s since there is an existing entry already.", key));
- }
-
- if (!versionedInstances.isEmpty() && isValid(lvm, version)) {
- VersionedInstance<T> currentPeek = versionedInstances.peek();
- if (currentPeek.version < version) {
- // Current peek < passed in version (and <= MLV). Hence, we can
- // remove it, since the passed in a better candidate.
- versionedInstances.poll();
- // Add the passed in instance.
- versionedInstances.offer(new VersionedInstance<>(version, instance));
- return true;
- } else if (currentPeek.version > lvm.getMetadataLayoutVersion()) {
- // Current peak is > MLV, hence we don't need to remove that. Just
- // add passed in instance.
- versionedInstances.offer(new VersionedInstance<>(version, instance));
- return true;
- } else {
- // Current peek <= MLV and > passed in version, and hence a better
- // canidate. Retaining the peek, and ignoring the passed in instance.
- return false;
- }
- } else {
- // Passed in instance version > MLV (or the first version to be
- // registered), hence can be registered.
- versionedInstances.offer(new VersionedInstance<>(version, instance));
- return true;
- }
- }
-
- private boolean isValid(LayoutVersionManager lvm, int version) {
- return version <= lvm.getMetadataLayoutVersion();
- }
-
- /**
- * <pre>
- * From the list of versioned instances for a given "key", this
- * returns the "floor" value corresponding to the given version.
- * For example, if we have key = "CreateKey", entry -> [(1, CreateKeyV1),
- * (3, CreateKeyV2), and if the passed in key = CreateKey & version = 2,
we
- * return CreateKeyV1.
- * Since this is a priority queue based implementation, we use a O(1) peek()
- * lookup to get the current valid version.
- * </pre>
- * @param lvm LayoutVersionManager
- * @param key Key and Version.
- * @return instance.
- */
- public T get(LayoutVersionManager lvm, VersionFactoryKey key) {
- Integer version = key.getVersion();
- // If version is not passed in, go defensive and set the highest allowed
- // version (MLV).
- if (version == null) {
- version = lvm.getMetadataLayoutVersion();
- }
-
- checkArgument(lvm.getMetadataLayoutVersion() >= version,
- String.format("Cannot get key %s since the version is greater " +
- "than the Metadata layout version %d",
- key, lvm.getMetadataLayoutVersion()));
-
- String primaryKey = key.getKey();
- PriorityQueue<VersionedInstance<T>> versionedInstances =
- instances.get(primaryKey);
- if (versionedInstances == null || versionedInstances.isEmpty()) {
- throw new IllegalArgumentException(
- "No suitable instance found for request : " + key);
- }
-
- VersionedInstance<T> value = versionedInstances.peek();
- if (value == null || value.version > version) {
- throw new IllegalArgumentException(
- "No suitable instance found for request : " + key);
- } else {
- return value.instance;
- }
- }
-
- /**
- * To be called on finalization of a new LayoutFeature.
- * Unregisters all the requests handlers that are there for layout versions
- * before the feature's layout version.
- * If the feature's layout version does not define a new handler for a
- * request type, the previously registered handler remains registered.
- *
- * @param feature the feature to be finalized.
- */
- public void finalizeFeature(LayoutFeature feature) {
- Iterator<Map.Entry<String, PriorityQueue<VersionedInstance<T>>>> iterator =
- instances.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry<String, PriorityQueue<VersionedInstance<T>>> next =
- iterator.next();
- PriorityQueue<VersionedInstance<T>> vInstances = next.getValue();
- VersionedInstance<T> prevInstance = null;
- while (!vInstances.isEmpty() &&
- vInstances.peek().version < feature.layoutVersion()) {
- prevInstance = vInstances.poll();
- LOG.info("Unregistering {} from factory. ", prevInstance.instance);
- }
-
- if ((vInstances.isEmpty() ||
- vInstances.peek().version > feature.layoutVersion())
- && prevInstance != null) {
- LOG.info("Re-registering {} with factory. ", prevInstance.instance);
- vInstances.offer(prevInstance);
- }
-
- if (vInstances.isEmpty()) {
- LOG.info("Unregistering '{}' from factory since it has no entries.",
- next.getKey());
- iterator.remove();
- }
- }
- }
-
- @VisibleForTesting
- protected Map<String, List<T>> getInstances() {
- Map<String, List<T>> instancesCopy = new HashMap<>();
- instances.forEach((key, value) -> {
- List<T> collect =
- value.stream().map(v -> v.instance).collect(toList());
- instancesCopy.put(key, collect);
- });
- return Collections.unmodifiableMap(instancesCopy);
- }
-
- /**
- * Class to encapsulate a instance with version. Not meant to be exposed
- * outside this class.
- * @param <T> instance
- */
- static class VersionedInstance<T> {
- private int version;
- private T instance;
-
- VersionedInstance(int version, T instance) {
- this.version = version;
- this.instance = instance;
- }
-
- public long getVersion() {
- return version;
- }
-
- public T getInstance() {
- return instance;
- }
- }
-}
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
deleted file mode 100644
index 94729a108bb..00000000000
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/upgrade/VersionFactoryKey.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.ozone.upgrade;
-
-/**
- * "Key" element to the Version specific instance factory. Currently it has 2
- * dimensions -> a 'key' string and a version. This is to support a factory
- * which returns an instance for a given "key" and "version".
- */
-public class VersionFactoryKey {
- private String key;
- private Integer version;
-
- public VersionFactoryKey(String key, Integer version) {
- this.key = key;
- this.version = version;
- }
-
- public String getKey() {
- return key;
- }
-
- public Integer getVersion() {
- return version;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + " : [" + key + ", "
- + version + "]";
- }
-
- /**
- * Builder for above key.
- */
- public static class Builder {
- private String key;
- private Integer version;
-
- public Builder key(String k) {
- this.key = k;
- return this;
- }
-
- public Builder version(Integer v) {
- this.version = v;
- return this;
- }
-
- public VersionFactoryKey build() {
- return new VersionFactoryKey(key, version);
- }
- }
-}
diff --git
a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/TestLayoutVersionInstanceFactory.java
b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/TestLayoutVersionInstanceFactory.java
deleted file mode 100644
index f759b26dbf8..00000000000
---
a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/ozone/upgrade/TestLayoutVersionInstanceFactory.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.ozone.upgrade;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.function.Supplier;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test out APIs of VersionSpecificInstanceFactory.
- */
-public class TestLayoutVersionInstanceFactory {
-
- private final MockInterface m1 = new MockClassV1();
- private final MockInterface m2 = new MockClassV2();
-
- @Test
- void testRegister() {
- LayoutVersionManager lvm = getMockLvm(1, 2);
- LayoutVersionInstanceFactory<MockInterface> factory =
- new LayoutVersionInstanceFactory<>();
-
- assertTrue(factory.register(lvm, getKey("key", 0), m1));
- assertTrue(factory.register(lvm, getKey("key", 1), m1));
- assertTrue(factory.register(lvm, getKey("key", 2), m2));
-
- assertEquals(1, factory.getInstances().size());
- assertEquals(2, factory.getInstances().get("key").size());
-
- // Should fail on re-registration.
- IllegalArgumentException exception =
- assertThrows(IllegalArgumentException.class,
- () -> factory.register(lvm, getKey("key", 1), new MockClassV1()));
-
- assertThat(exception).hasMessageContaining("existing entry already");
- assertEquals(1, factory.getInstances().size());
-
- // Verify SLV check.
- exception = assertThrows(IllegalArgumentException.class,
- () -> factory.register(lvm, getKey("key2", 4), new MockClassV2()));
- assertThat(exception).hasMessageContaining("version is greater");
-
- }
-
- @Test
- void testGet() {
- LayoutVersionManager lvm = getMockLvm(2, 3);
- LayoutVersionInstanceFactory<MockInterface> factory =
- new LayoutVersionInstanceFactory<>();
- assertTrue(factory.register(lvm, getKey("key", 0), null));
- assertTrue(factory.register(lvm, getKey("key", 1), m1));
- assertTrue(factory.register(lvm, getKey("key", 3), m2));
-
- MockInterface val = factory.get(lvm, getKey("key", 2));
- assertInstanceOf(MockClassV1.class, val);
-
- // Not passing in version --> Use MLV.
- val = factory.get(lvm, getKey("key", null));
- assertInstanceOf(MockClassV1.class, val);
-
- // MLV check.
- IllegalArgumentException exception =
- assertThrows(IllegalArgumentException.class,
- () -> factory.get(lvm, getKey("key", 3)));
- assertThat(exception).hasMessageContaining("version is greater");
-
- // Verify failure on Unknown request.
- exception = assertThrows(IllegalArgumentException.class,
- () -> factory.get(lvm, getKey("key1", 1)));
- assertThat(exception).hasMessageContaining("No suitable instance found");
- }
-
- @Test
- void testMethodBasedVersionFactory() {
- LayoutVersionManager lvm = getMockLvm(1, 2);
- LayoutVersionInstanceFactory<Supplier<String>> factory =
- new LayoutVersionInstanceFactory<>();
-
- MockClassWithVersionedAPIs m = new MockClassWithVersionedAPIs();
- factory.register(lvm, getKey("method", 1), m::mockMethodV1);
- factory.register(lvm, getKey("method", 2), m::mockMethodV2);
-
- Supplier<String> method = factory.get(lvm, getKey("method", 1));
- assertEquals("v1", method.get());
- }
-
- private VersionFactoryKey getKey(String key, Integer version) {
- VersionFactoryKey.Builder vfKey = new VersionFactoryKey.Builder().key(key);
- if (version != null) {
- vfKey.version(version);
- }
- return vfKey.build();
- }
-
- @Test
- void testOnFinalize() {
- LayoutVersionManager lvm = getMockLvm(1, 3);
- LayoutVersionInstanceFactory<MockInterface> factory =
- new LayoutVersionInstanceFactory<>();
- assertTrue(factory.register(lvm, getKey("key", 1), m1));
- assertTrue(factory.register(lvm, getKey("key", 3), m2));
- assertTrue(factory.register(lvm, getKey("key2", 1), m1));
- assertTrue(factory.register(lvm, getKey("key2", 2), m2));
-
- MockInterface val = factory.get(lvm, getKey("key", null));
- assertInstanceOf(MockClassV1.class, val);
- assertEquals(2, factory.getInstances().size());
- assertEquals(2, factory.getInstances().get("key").size());
-
- val = factory.get(lvm, getKey("key2", null));
- assertInstanceOf(MockClassV1.class, val);
-
- // Finalize the layout version.
- LayoutFeature toFeature = getMockFeatureWithVersion(3);
- factory.finalizeFeature(toFeature);
- lvm = getMockLvm(3, 3);
-
- val = factory.get(lvm, getKey("key", null));
- assertInstanceOf(MockClassV2.class, val);
- assertEquals(2, factory.getInstances().size());
- assertEquals(1, factory.getInstances().get("key").size());
-
- val = factory.get(lvm, getKey("key2", null));
- assertInstanceOf(MockClassV2.class, val);
- }
-
- private LayoutFeature getMockFeatureWithVersion(int layoutVersion) {
- LayoutFeature feature = mock(LayoutFeature.class);
- when(feature.layoutVersion()).thenReturn(layoutVersion);
- return feature;
- }
-
- private LayoutVersionManager getMockLvm(int mlv, int slv) {
- LayoutVersionManager lvm = mock(LayoutVersionManager.class);
- when(lvm.getMetadataLayoutVersion()).thenReturn(mlv);
- when(lvm.getSoftwareLayoutVersion()).thenReturn(slv);
- return lvm;
- }
-
- /**
- * Mock Interface.
- */
- interface MockInterface {
- }
-
- /**
- * Mock Impl v1.
- */
- static class MockClassV1 implements MockInterface {
- }
-
- /**
- * Mock Impl v2.
- */
- private static class MockClassV2 extends MockClassV1 {
- }
-
- /**
- * Mock class with a v1 and v2 method.
- */
- static class MockClassWithVersionedAPIs {
- public String mockMethodV1() {
- return "v1";
- }
-
- public String mockMethodV2() {
- return "v2";
- }
- }
-}
diff --git
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutVersionManager.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutVersionManager.java
index 7cad5c94311..b1e680f7c18 100644
---
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutVersionManager.java
+++
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/OMLayoutVersionManager.java
@@ -27,8 +27,6 @@
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.request.OMClientRequest;
import org.apache.hadoop.ozone.upgrade.AbstractLayoutVersionManager;
-import org.apache.hadoop.ozone.upgrade.LayoutVersionInstanceFactory;
-import org.apache.hadoop.ozone.upgrade.VersionFactoryKey;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.TypeAnnotationsScanner;
@@ -52,16 +50,12 @@ public final class OMLayoutVersionManager
OM_CLASS_PACKAGE + ".request";
public static final String OM_UPGRADE_CLASS_PACKAGE =
OM_CLASS_PACKAGE + ".upgrade";
- private LayoutVersionInstanceFactory<Class<? extends OMClientRequest>>
- requestFactory;
public OMLayoutVersionManager(int layoutVersion) throws OMException {
- requestFactory = new LayoutVersionInstanceFactory<>();
init(layoutVersion);
}
public OMLayoutVersionManager() throws IOException {
- requestFactory = new LayoutVersionInstanceFactory<>();
OMLayoutFeature[] features = OMLayoutFeature.values();
init(features[features.length - 1].layoutVersion(), features);
}
@@ -142,22 +136,9 @@ public static Set<Class<? extends OMClientRequest>>
getRequestClasses(
return validRequests;
}
- /**
- * Given a type and version, get the corresponding request class type.
- * @param type type string
- * @return class type.
- */
- @Override
- public Class<? extends OMClientRequest> getHandler(String type) {
- VersionFactoryKey versionFactoryKey = new VersionFactoryKey.Builder()
- .key(type).build();
- return requestFactory.get(this, versionFactoryKey);
- }
-
@Override
public void finalized(OMLayoutFeature layoutFeature) {
super.finalized(layoutFeature);
- requestFactory.finalizeFeature(layoutFeature);
}
public static int maxLayoutVersion() {
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOmVersionManagerRequestFactory.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOmVersionManagerRequestFactory.java
deleted file mode 100644
index db1114494fc..00000000000
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/upgrade/TestOmVersionManagerRequestFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.ozone.om.upgrade;
-
-import static
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type.CreateKey;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
-import java.util.Set;
-import org.apache.hadoop.ozone.om.exceptions.OMException;
-import org.apache.hadoop.ozone.om.request.OMClientRequest;
-import org.apache.hadoop.ozone.om.request.key.OMKeyCreateRequest;
-import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
-import org.apache.ozone.test.tag.Unhealthy;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.reflections.Reflections;
-
-/**
- * Test OmVersionFactory.
- */
-@Unhealthy("Ignored since this is incompatible" +
- " with HDDS-2939 work. Potentially revisit later.")
-public class TestOmVersionManagerRequestFactory {
-
- private static OMLayoutVersionManager omVersionManager;
-
- @BeforeAll
- public static void setup() throws OMException {
- omVersionManager = new OMLayoutVersionManager(0);
- }
-
- @Test
- public void testKeyCreateRequest() throws Exception {
-
- // Try getting v1 of 'CreateKey'.
- Class<? extends OMClientRequest> requestType =
- omVersionManager.getHandler(CreateKey.name());
- assertEquals(requestType, OMKeyCreateRequest.class);
- }
-
- @Test
- public void testOmClientRequestHasExpectedConstructor()
- throws NoSuchMethodException {
- Reflections reflections = new Reflections(
- "org.apache.hadoop.ozone.om.request");
- Set<Class<? extends OMClientRequest>> subTypes =
- reflections.getSubTypesOf(OMClientRequest.class);
-
- for (Class<? extends OMClientRequest> requestClass : subTypes) {
- if (Modifier.isAbstract(requestClass.getModifiers())) {
- continue;
- }
-
- Constructor<? extends OMClientRequest> constructorWithOmRequestArg =
- requestClass.getDeclaredConstructor(OMRequest.class);
- assertNotNull(constructorWithOmRequestArg);
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]