HBASE-14193 Remove support for direct upgrade from pre-0.96 versions (Lars Francke)
This commit is contained in:
parent
6840c5fa6c
commit
7b9d88f9d7
|
@ -87,8 +87,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"
|
||||
|
@ -305,7 +304,9 @@ elif [ "$COMMAND" = "hfile" ] ; then
|
|||
elif [ "$COMMAND" = "zkcli" ] ; then
|
||||
CLASS="org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer"
|
||||
elif [ "$COMMAND" = "upgrade" ] ; then
|
||||
CLASS="org.apache.hadoop.hbase.migration.UpgradeTo96"
|
||||
echo "This command was used to upgrade to HBase 0.96, it was removed in HBase 2.0.0."
|
||||
echo "Please follow the documentation at http://hbase.apache.org/book.html#upgrading."
|
||||
exit 1
|
||||
elif [ "$COMMAND" = "snapshot" ] ; then
|
||||
CLASS="org.apache.hadoop.hbase.snapshot.CreateSnapshot"
|
||||
elif [ "$COMMAND" = "snapshotinfo" ] ; then
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
@ -486,10 +485,6 @@ public class MasterFileSystem {
|
|||
// 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);
|
||||
}
|
||||
|
||||
// Create tableinfo-s for hbase:meta if not already there.
|
||||
|
|
|
@ -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<Path> 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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue