From 336bc02d46d2326e3504dfab139dd4121d9823eb Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Fri, 7 Aug 2015 18:46:07 +0200 Subject: [PATCH] [HBASE-14193] Remove support for direct upgrade from pre-0.96 versions --- bin/hbase | 5 +- bin/hbase.cmd | 7 +- .../hadoop/hbase/master/MasterFileSystem.java | 9 +- .../util/FSTableDescriptorMigrationToSubdir.java | 136 --------------------- 4 files changed, 3 insertions(+), 154 deletions(-) delete mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptorMigrationToSubdir.java diff --git a/bin/hbase b/bin/hbase index f0c0c75..0c26529 100755 --- a/bin/hbase +++ b/bin/hbase @@ -86,8 +86,7 @@ if [ $# = 0 ]; then echo " wal Write-ahead-log analyzer" echo " hfile Store file analyzer" echo " zkcli Run the ZooKeeper shell" - echo " upgrade Upgrade hbase" - echo " master Run an HBase HMaster node" + echo " master Run an HBase HMaster node" echo " regionserver Run an HBase HRegionServer node" echo " zookeeper Run a Zookeeper server" echo " rest Run an HBase REST server" @@ -303,8 +302,6 @@ elif [ "$COMMAND" = "hfile" ] ; then CLASS='org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter' elif [ "$COMMAND" = "zkcli" ] ; then CLASS="org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer" -elif [ "$COMMAND" = "upgrade" ] ; then - CLASS="org.apache.hadoop.hbase.migration.UpgradeTo96" elif [ "$COMMAND" = "snapshot" ] ; then CLASS="org.apache.hadoop.hbase.snapshot.CreateSnapshot" elif [ "$COMMAND" = "master" ] ; then diff --git a/bin/hbase.cmd b/bin/hbase.cmd index da7bcd9..d5f39a4 100644 --- a/bin/hbase.cmd +++ b/bin/hbase.cmd @@ -211,7 +211,7 @@ goto :MakeCmdArgsLoop set hbase-command-arguments=%_hbasearguments% @rem figure out which class to run -set corecommands=shell master regionserver thrift thrift2 rest avro hlog wal hbck hfile zookeeper zkcli upgrade mapredcp +set corecommands=shell master regionserver thrift thrift2 rest avro hlog wal hbck hfile zookeeper zkcli mapredcp for %%i in ( %corecommands% ) do ( if "%hbase-command%"=="%%i" set corecommand=true ) @@ -393,10 +393,6 @@ goto :eof set CLASS=org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer goto :eof -:upgrade - set CLASS=org.apache.hadoop.hbase.migration.UpgradeTo96 - goto :eof - :mapredcp set CLASS=org.apache.hadoop.hbase.util.MapreduceDependencyClasspathTool goto :eof @@ -425,7 +421,6 @@ goto :eof echo wal Write-ahead-log analyzer echo hfile Store file analyzer echo zkcli Run the ZooKeeper shell - echo upgrade Upgrade hbase echo master Run an HBase HMaster node echo regionserver Run an HBase HRegionServer node echo zookeeper Run a Zookeeper server diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java index 9b95ae7..5058c37 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java @@ -419,7 +419,6 @@ public class MasterFileSystem { * needed populating the directory with necessary bootup files). * @throws IOException */ - @SuppressWarnings("deprecation") private Path checkRootDir(final Path rd, final Configuration c, final FileSystem fs) throws IOException { @@ -484,13 +483,7 @@ public class MasterFileSystem { clusterId = FSUtils.getClusterId(fs, rd); // Make sure the meta region directory exists! - if (!FSUtils.metaRegionExists(fs, rd)) { - bootstrap(rd, c); - } else { - // Migrate table descriptor files if necessary - org.apache.hadoop.hbase.util.FSTableDescriptorMigrationToSubdir - .migrateFSTableDescriptorsIfNecessary(fs, rd); - } + bootstrap(rd, c); // Create tableinfo-s for hbase:meta if not already there. // assume, created table descriptor is for enabling table diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptorMigrationToSubdir.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptorMigrationToSubdir.java deleted file mode 100644 index b22f39a..0000000 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptorMigrationToSubdir.java +++ /dev/null @@ -1,136 +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.hbase.util; - -import java.io.IOException; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; - -/** - * A class to migrate table descriptor files to a dedicated subdir. - * Invoked by HMaster.finishInitialization before accessing table descriptors. - * Migrates snapshots, user tables, and system tables. - * - * @deprecated will be removed for the major release after 0.96. - */ -@Deprecated -public class FSTableDescriptorMigrationToSubdir { - - private static final Log LOG = LogFactory.getLog(FSTableDescriptorMigrationToSubdir.class); - - public static void migrateFSTableDescriptorsIfNecessary(FileSystem fs, Path rootDir) - throws IOException { - if (needsMigration(fs, rootDir)) { - migrateFsTableDescriptors(fs, rootDir); - LOG.info("Migration complete."); - } - } - - /** - * Determines if migration is required by checking to see whether the hbase:meta table has been - * migrated. - */ - private static boolean needsMigration(FileSystem fs, Path rootDir) throws IOException { - Path metaTableDir = FSUtils.getTableDir(rootDir, - TableName.META_TABLE_NAME); - FileStatus metaTableInfoStatus = - FSTableDescriptors.getTableInfoPath(fs, metaTableDir); - return metaTableInfoStatus == null; - } - - /** - * Migrates all snapshots, user tables and system tables that require migration. - * First migrates snapshots. - * Then migrates each user table in order, - * then attempts ROOT (should be gone) - * Migrates hbase:meta last to indicate migration is complete. - */ - private static void migrateFsTableDescriptors(FileSystem fs, Path rootDir) throws IOException { - // First migrate snapshots - will migrate any snapshot dir that contains a table info file - Path snapshotsDir = SnapshotDescriptionUtils.getSnapshotsDir(rootDir); - if (fs.exists(snapshotsDir)) { - LOG.info("Migrating snapshots"); - FileStatus[] snapshots = fs.listStatus(snapshotsDir, - new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs)); - for (FileStatus snapshot : snapshots) { - migrateTable(fs, snapshot.getPath()); - } - } - - LOG.info("Migrating user tables"); - List userTableDirs = FSUtils.getTableDirs(fs, rootDir); - for (Path userTableDir : userTableDirs) { - migrateTable(fs, userTableDir); - } - - LOG.info("Migrating system tables"); - // migrate meta last because that's what we check to see if migration is complete - migrateTableIfExists(fs, rootDir, TableName.META_TABLE_NAME); - } - - private static void migrateTableIfExists(FileSystem fs, Path rootDir, TableName tableName) - throws IOException { - Path tableDir = FSUtils.getTableDir(rootDir, tableName); - if (fs.exists(tableDir)) { - migrateTable(fs, tableDir); - } - } - - /** - * Migrates table info files. - * Moves the latest table info file (is present) from the table dir to the table info subdir. - * Removes any older table info files from the table dir and any existing table info subdir. - */ - private static void migrateTable(FileSystem fs, Path tableDir) throws IOException { - FileStatus oldTableStatus = FSTableDescriptors.getCurrentTableInfoStatus(fs, tableDir, true); - if (oldTableStatus == null) { - LOG.debug("No table info file to migrate for " + tableDir); - return; - } - - Path tableInfoDir = new Path(tableDir, FSTableDescriptors.TABLEINFO_DIR); - // remove table info subdir if it already exists - boolean removedExistingSubdir = FSUtils.deleteDirectory(fs, tableInfoDir); - if (removedExistingSubdir) { - LOG.info("Removed existing subdir at: " + tableInfoDir); - } - boolean createdSubdir = fs.mkdirs(tableInfoDir); - if (!createdSubdir) { - throw new IOException("Unable to create new table info directory: " + tableInfoDir); - } - - Path oldTableInfoPath = oldTableStatus.getPath(); - Path newTableInfoPath = new Path(tableInfoDir, oldTableInfoPath.getName()); - boolean renamedInfoFile = fs.rename(oldTableInfoPath, newTableInfoPath); - if (!renamedInfoFile) { - throw new IOException("Failed to move table info file from old location: " - + oldTableInfoPath + " to new location: " + newTableInfoPath); - } - - LOG.info("Migrated table info from: " + oldTableInfoPath - + " to new location: " + newTableInfoPath); - } - -} -- 2.4.3