Java 类org.apache.hadoop.hbase.migration.NamespaceUpgrade 实例源码

项目:ditb    文件:TestMetaMigrationConvertingToPB.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start up our mini cluster on top of an 0.92 root.dir that has data from
  // a 0.92 hbase run -- it has a table with 100 rows in it  -- and see if
  // we can migrate from 0.92
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.startMiniDFSCluster(1);
  Path testdir = TEST_UTIL.getDataTestDir("TestMetaMigrationConvertToPB");
  // Untar our test dir.
  File untar = untar(new File(testdir.toString()));
  // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
  Configuration conf = TEST_UTIL.getConfiguration();
  FsShell shell = new FsShell(conf);
  FileSystem fs = FileSystem.get(conf);
  // find where hbase will root itself, so we can copy filesystem there
  Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
  if (!fs.isDirectory(hbaseRootDir.getParent())) {
    // mkdir at first
    fs.mkdirs(hbaseRootDir.getParent());
  }
  doFsCommand(shell,
    new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});

  // windows fix: tgz file has hbase:meta directory renamed as -META- since the original
  // is an illegal name under windows. So we rename it back.
  // See src/test/data//TestMetaMigrationConvertingToPB.README and
  // https://issues.apache.org/jira/browse/HBASE-6821
  doFsCommand(shell, new String [] {"-mv", new Path(hbaseRootDir, "-META-").toString(),
    new Path(hbaseRootDir, ".META.").toString()});
  // See whats in minihdfs.
  doFsCommand(shell, new String [] {"-lsr", "/"});

  //upgrade to namespace as well
  Configuration toolConf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
  ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});

  TEST_UTIL.startMiniHBaseCluster(1, 1);
  // Assert we are running against the copied-up filesystem.  The copied-up
  // rootdir should have had a table named 'TestTable' in it.  Assert it
  // present.
  HTable t = new HTable(TEST_UTIL.getConfiguration(), TESTTABLE);
  ResultScanner scanner = t.getScanner(new Scan());
  int count = 0;
  while (scanner.next() != null) {
    count++;
  }
  // Assert that we find all 100 rows that are in the data we loaded.  If
  // so then we must have migrated it from 0.90 to 0.92.
  Assert.assertEquals(ROW_COUNT, count);
  scanner.close();
  t.close();
}
项目:pbase    文件:TestMetaMigrationConvertingToPB.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start up our mini cluster on top of an 0.92 root.dir that has data from
  // a 0.92 hbase run -- it has a table with 100 rows in it  -- and see if
  // we can migrate from 0.92
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.startMiniDFSCluster(1);
  Path testdir = TEST_UTIL.getDataTestDir("TestMetaMigrationConvertToPB");
  // Untar our test dir.
  File untar = untar(new File(testdir.toString()));
  // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
  Configuration conf = TEST_UTIL.getConfiguration();
  FsShell shell = new FsShell(conf);
  FileSystem fs = FileSystem.get(conf);
  // find where hbase will root itself, so we can copy filesystem there
  Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
  if (!fs.isDirectory(hbaseRootDir.getParent())) {
    // mkdir at first
    fs.mkdirs(hbaseRootDir.getParent());
  }
  doFsCommand(shell,
    new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});

  // windows fix: tgz file has hbase:meta directory renamed as -META- since the original
  // is an illegal name under windows. So we rename it back.
  // See src/test/data//TestMetaMigrationConvertingToPB.README and
  // https://issues.apache.org/jira/browse/HBASE-6821
  doFsCommand(shell, new String [] {"-mv", new Path(hbaseRootDir, "-META-").toString(),
    new Path(hbaseRootDir, ".META.").toString()});
  // See whats in minihdfs.
  doFsCommand(shell, new String [] {"-lsr", "/"});

  //upgrade to namespace as well
  Configuration toolConf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
  ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});

  TEST_UTIL.startMiniHBaseCluster(1, 1);
  // Assert we are running against the copied-up filesystem.  The copied-up
  // rootdir should have had a table named 'TestTable' in it.  Assert it
  // present.
  HTable t = new HTable(TEST_UTIL.getConfiguration(), TESTTABLE);
  ResultScanner scanner = t.getScanner(new Scan());
  int count = 0;
  while (scanner.next() != null) {
    count++;
  }
  // Assert that we find all 100 rows that are in the data we loaded.  If
  // so then we must have migrated it from 0.90 to 0.92.
  Assert.assertEquals(ROW_COUNT, count);
  scanner.close();
  t.close();
}
项目:HIndex    文件:TestMetaMigrationConvertingToPB.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start up our mini cluster on top of an 0.92 root.dir that has data from
  // a 0.92 hbase run -- it has a table with 100 rows in it  -- and see if
  // we can migrate from 0.92
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.startMiniDFSCluster(1);
  Path testdir = TEST_UTIL.getDataTestDir("TestMetaMigrationConvertToPB");
  // Untar our test dir.
  File untar = untar(new File(testdir.toString()));
  // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
  Configuration conf = TEST_UTIL.getConfiguration();
  FsShell shell = new FsShell(conf);
  FileSystem fs = FileSystem.get(conf);
  // find where hbase will root itself, so we can copy filesystem there
  Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
  if (!fs.isDirectory(hbaseRootDir.getParent())) {
    // mkdir at first
    fs.mkdirs(hbaseRootDir.getParent());
  }
  doFsCommand(shell,
    new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});

  //windows fix: tgz file has hbase:meta directory renamed as -META- since the original is an illegal
  //name under windows. So we rename it back. See src/test/data//TestMetaMigrationConvertingToPB.README and
  //https://issues.apache.org/jira/browse/HBASE-6821
  doFsCommand(shell, new String [] {"-mv", new Path(hbaseRootDir, "-META-").toString(),
    new Path(hbaseRootDir, ".META.").toString()});
  // See whats in minihdfs.
  doFsCommand(shell, new String [] {"-lsr", "/"});

  //upgrade to namespace as well
  Configuration toolConf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
  ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});

  TEST_UTIL.startMiniHBaseCluster(1, 1);
  // Assert we are running against the copied-up filesystem.  The copied-up
  // rootdir should have had a table named 'TestTable' in it.  Assert it
  // present.
  HTable t = new HTable(TEST_UTIL.getConfiguration(), TESTTABLE);
  ResultScanner scanner = t.getScanner(new Scan());
  int count = 0;
  while (scanner.next() != null) {
    count++;
  }
  // Assert that we find all 100 rows that are in the data we loaded.  If
  // so then we must have migrated it from 0.90 to 0.92.
  Assert.assertEquals(ROW_COUNT, count);
  scanner.close();
  t.close();
}
项目:PyroDB    文件:TestMetaMigrationConvertingToPB.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start up our mini cluster on top of an 0.92 root.dir that has data from
  // a 0.92 hbase run -- it has a table with 100 rows in it  -- and see if
  // we can migrate from 0.92
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.startMiniDFSCluster(1);
  Path testdir = TEST_UTIL.getDataTestDir("TestMetaMigrationConvertToPB");
  // Untar our test dir.
  File untar = untar(new File(testdir.toString()));
  // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
  Configuration conf = TEST_UTIL.getConfiguration();
  FsShell shell = new FsShell(conf);
  FileSystem fs = FileSystem.get(conf);
  // find where hbase will root itself, so we can copy filesystem there
  Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
  if (!fs.isDirectory(hbaseRootDir.getParent())) {
    // mkdir at first
    fs.mkdirs(hbaseRootDir.getParent());
  }
  doFsCommand(shell,
    new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});

  //windows fix: tgz file has hbase:meta directory renamed as -META- since the original is an illegal
  //name under windows. So we rename it back. See src/test/data//TestMetaMigrationConvertingToPB.README and
  //https://issues.apache.org/jira/browse/HBASE-6821
  doFsCommand(shell, new String [] {"-mv", new Path(hbaseRootDir, "-META-").toString(),
    new Path(hbaseRootDir, ".META.").toString()});
  // See whats in minihdfs.
  doFsCommand(shell, new String [] {"-lsr", "/"});

  //upgrade to namespace as well
  Configuration toolConf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
  ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});

  TEST_UTIL.startMiniHBaseCluster(1, 1);
  // Assert we are running against the copied-up filesystem.  The copied-up
  // rootdir should have had a table named 'TestTable' in it.  Assert it
  // present.
  HTable t = new HTable(TEST_UTIL.getConfiguration(), TESTTABLE);
  ResultScanner scanner = t.getScanner(new Scan());
  int count = 0;
  while (scanner.next() != null) {
    count++;
  }
  // Assert that we find all 100 rows that are in the data we loaded.  If
  // so then we must have migrated it from 0.90 to 0.92.
  Assert.assertEquals(ROW_COUNT, count);
  scanner.close();
  t.close();
}
项目:c5    文件:TestMetaMigrationConvertingToPB.java   
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  // Start up our mini cluster on top of an 0.92 root.dir that has data from
  // a 0.92 hbase run -- it has a table with 100 rows in it  -- and see if
  // we can migrate from 0.92
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.startMiniDFSCluster(1);
  Path testdir = TEST_UTIL.getDataTestDir("TestMetaMigrationConvertToPB");
  // Untar our test dir.
  File untar = untar(new File(testdir.toString()));
  // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
  Configuration conf = TEST_UTIL.getConfiguration();
  FsShell shell = new FsShell(conf);
  FileSystem fs = FileSystem.get(conf);
  // find where hbase will root itself, so we can copy filesystem there
  Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
  if (!fs.isDirectory(hbaseRootDir.getParent())) {
    // mkdir at first
    fs.mkdirs(hbaseRootDir.getParent());
  }
  doFsCommand(shell,
    new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});

  //windows fix: tgz file has hbase:meta directory renamed as -META- since the original is an illegal
  //name under windows. So we rename it back. See src/test/data//TestMetaMigrationConvertingToPB.README and
  //https://issues.apache.org/jira/browse/HBASE-6821
  doFsCommand(shell, new String [] {"-mv", new Path(hbaseRootDir, "-META-").toString(),
    new Path(hbaseRootDir, ".META.").toString()});
  // See whats in minihdfs.
  doFsCommand(shell, new String [] {"-lsr", "/"});

  //upgrade to namespace as well
  Configuration toolConf = TEST_UTIL.getConfiguration();
  conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
  ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});

  TEST_UTIL.startMiniHBaseCluster(1, 1);
  // Assert we are running against the copied-up filesystem.  The copied-up
  // rootdir should have had a table named 'TestTable' in it.  Assert it
  // present.
  HTable t = new HTable(TEST_UTIL.getConfiguration(), TESTTABLE);
  ResultScanner scanner = t.getScanner(new Scan());
  int count = 0;
  while (scanner.next() != null) {
    count++;
  }
  // Assert that we find all 100 rows that are in the data we loaded.  If
  // so then we must have migrated it from 0.90 to 0.92.
  Assert.assertEquals(ROW_COUNT, count);
  scanner.close();
  t.close();
}