From c71c592426ac4ae5fc0f3eca26c4787140c97903 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Thu, 30 Nov 2023 17:11:20 -0500 Subject: [PATCH] Refresh the upgrade code Align the upgrade code to match the main branch conventions/style, but keep it disabled for now, until it's working on the elasticity branch. --- .../apache/accumulo/server/AccumuloDataVersion.java | 3 ++- .../org/apache/accumulo/server/ServerContextTest.java | 10 ++-------- .../accumulo/manager/upgrade/UpgradeCoordinator.java | 8 ++++++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/server/base/src/main/java/org/apache/accumulo/server/AccumuloDataVersion.java b/server/base/src/main/java/org/apache/accumulo/server/AccumuloDataVersion.java index ee700c4208a..224cbde6af6 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/AccumuloDataVersion.java +++ b/server/base/src/main/java/org/apache/accumulo/server/AccumuloDataVersion.java @@ -83,7 +83,8 @@ public static int get() { } // ELASTICITY_TODO get upgrade working - // public static final Set CAN_RUN = Set.of(ROOT_TABLET_META_CHANGES, CURRENT_VERSION); + // public static final Set CAN_RUN = Set.of(ROOT_TABLET_META_CHANGES, + // REMOVE_DEPRECATIONS_FOR_VERSION_3, METADATA_FILE_JSON_ENCODING, CURRENT_VERSION); public static final Set CAN_RUN = Set.of(CURRENT_VERSION); /** diff --git a/server/base/src/test/java/org/apache/accumulo/server/ServerContextTest.java b/server/base/src/test/java/org/apache/accumulo/server/ServerContextTest.java index 7d2535579cc..d5909ecf99e 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/ServerContextTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/ServerContextTest.java @@ -133,15 +133,9 @@ public void testSasl() throws Exception { // ensure upgrades fail with older, unsupported versions, but pass with supported versions @Test public void testCanRun() { - // ensure this fails with older versions; the oldest supported version is hard-coded here - // to ensure we don't unintentionally break upgrade support; changing this should be a conscious - // decision and this check will ensure we don't overlook it - - final int oldestSupported = AccumuloDataVersion.ONDEMAND_TABLETS_FOR_VERSION_4; - // ELASTICITY_TODO basically disable check until upgrade to 3.1 is supported. Should be: - // final int oldestSupported = AccumuloDataVersion.oldestUpgradeableVersion(); + final int oldestSupported = AccumuloDataVersion.oldestUpgradeableVersion(); + // ELASTICITY_TODO basically disable check until upgrade is working. Should be: // assertEquals(10, oldestSupported); // make sure it hasn't changed accidentally - final int currentVersion = AccumuloDataVersion.get(); IntConsumer shouldPass = ServerContext::ensureDataVersionCompatible; IntConsumer shouldFail = v -> assertThrows(IllegalStateException.class, diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java index 94a81eaaf97..ffd6c4fba1f 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java @@ -18,6 +18,8 @@ */ package org.apache.accumulo.manager.upgrade; +import static org.apache.accumulo.server.AccumuloDataVersion.METADATA_FILE_JSON_ENCODING; +import static org.apache.accumulo.server.AccumuloDataVersion.REMOVE_DEPRECATIONS_FOR_VERSION_3; import static org.apache.accumulo.server.AccumuloDataVersion.ROOT_TABLET_META_CHANGES; import java.io.IOException; @@ -112,8 +114,10 @@ public boolean isParentLevelUpgraded(Ample.DataLevel level) { private int currentVersion; // map of "current version" -> upgrader to next version. // Sorted so upgrades execute in order from the oldest supported data version to current - private final Map upgraders = Collections - .unmodifiableMap(new TreeMap<>(Map.of(ROOT_TABLET_META_CHANGES, new Upgrader10to11()))); + private final Map upgraders = Collections.unmodifiableMap(new TreeMap<>( + Map.of(ROOT_TABLET_META_CHANGES, new Upgrader10to11(), REMOVE_DEPRECATIONS_FOR_VERSION_3, + new Upgrader11to12(), METADATA_FILE_JSON_ENCODING, new Upgrader12to13()))); private volatile UpgradeStatus status;