ctubbsii commented on code in PR #5438:
URL: https://github.com/apache/accumulo/pull/5438#discussion_r2029300046


##########
server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java:
##########
@@ -0,0 +1,146 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.server.util;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.cli.Help;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.conf.SiteConfiguration;
+import org.apache.accumulo.core.data.InstanceId;
+import org.apache.accumulo.core.fate.zookeeper.ServiceLock;
+import org.apache.accumulo.core.fate.zookeeper.ServiceLock.ServiceLockPath;
+import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
+import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.core.volume.VolumeConfiguration;
+import org.apache.accumulo.server.fs.VolumeManager;
+import org.apache.accumulo.server.security.SecurityUtil;
+import org.apache.accumulo.start.spi.KeywordExecutable;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+import com.google.auto.service.AutoService;
+
+@AutoService(KeywordExecutable.class)
+public class UpgradeUtil implements KeywordExecutable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(UpgradeUtil.class);
+
+  static class Opts extends Help {
+    @Parameter(names = "--prepare",
+        description = "prepare an older version instance for an upgrade to a 
newer non-bugfix release."
+            + " This command should be run using the older version of software 
after the instance is shut down.")
+    boolean prepare = false;
+  }
+
+  @Override
+  public String keyword() {
+    return "upgrade";
+  }
+
+  @Override
+  public String description() {
+    return "utility used to perform various upgrade steps for an Accumulo 
instance";
+  }
+
+  @Override
+  public void execute(String[] args) throws Exception {
+    Opts opts = new Opts();
+    opts.parseArgs(keyword(), args);
+
+    if (!opts.prepare) {
+      new JCommander(opts).usage();
+      return;
+    }
+
+    var siteConf = SiteConfiguration.auto();
+    // Login as the server on secure HDFS
+    if (siteConf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
+      SecurityUtil.serverLogin(siteConf);
+    }
+
+    String volDir = 
VolumeConfiguration.getVolumeUris(siteConf).iterator().next();
+    Path instanceDir = new Path(volDir, "instance_id");
+    InstanceId iid = VolumeManager.getInstanceIDFromHdfs(instanceDir, new 
Configuration());
+    ZooReaderWriter zoo = new ZooReaderWriter(siteConf);
+
+    if (opts.prepare) {
+      final String zUpgradepath = Constants.ZROOT + "/" + iid + 
Constants.ZPREPARE_FOR_UPGRADE;

Review Comment:
   This is fine for now, but we'll probably want to reorganize the body of this 
if statement into a separate method when we add more functions, so we don't 
have one big massive execute method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to