当前位置: 首页>>代码示例>>Java>>正文


Java SnapshotTestingUtils.assertNoSnapshots方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.assertNoSnapshots方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotTestingUtils.assertNoSnapshots方法的具体用法?Java SnapshotTestingUtils.assertNoSnapshots怎么用?Java SnapshotTestingUtils.assertNoSnapshots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils的用法示例。


在下文中一共展示了SnapshotTestingUtils.assertNoSnapshots方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFlushCreateListDestroy

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Basic end-to-end test of simple-flush-based snapshots
 */
@Test (timeout=300000)
public void testFlushCreateListDestroy() throws Exception {
  LOG.debug("------- Starting Snapshot test -------------");
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, DEFAULT_NUM_ROWS, TEST_FAM);

  String snapshotName = "flushSnapshotCreateListDestroy";
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  SnapshotTestingUtils.createSnapshotAndValidate(admin,
    TableName.valueOf(STRING_TABLE_NAME), Bytes.toString(TEST_FAM),
    snapshotName, rootDir, fs, true);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:20,代码来源:TestFlushSnapshotFromClient.java

示例2: testSnapshotDeletionWithRegex

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test HBaseAdmin#deleteSnapshots(String) which deletes snapshots whose names match the parameter
 *
 * @throws Exception
 */
@Test (timeout=300000)
public void testSnapshotDeletionWithRegex() throws Exception {
  Admin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM);
  table.close();

  byte[] snapshot1 = Bytes.toBytes("TableSnapshot1");
  admin.snapshot(snapshot1, TABLE_NAME);
  LOG.debug("Snapshot1 completed.");

  byte[] snapshot2 = Bytes.toBytes("TableSnapshot2");
  admin.snapshot(snapshot2, TABLE_NAME);
  LOG.debug("Snapshot2 completed.");

  String snapshot3 = "3rdTableSnapshot";
  admin.snapshot(Bytes.toBytes(snapshot3), TABLE_NAME);
  LOG.debug(snapshot3 + " completed.");

  // delete the first two snapshots
  admin.deleteSnapshots("TableSnapshot.*");
  List<SnapshotDescription> snapshots = admin.listSnapshots();
  assertEquals(1, snapshots.size());
  assertEquals(snapshots.get(0).getName(), snapshot3);

  admin.deleteSnapshot(snapshot3);
  admin.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:TestSnapshotFromClient.java

示例3: testSnapshotDeletionWithRegex

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test HBaseAdmin#deleteSnapshots(String) which deletes snapshots whose names match the parameter
 *
 * @throws Exception
 */
@Test (timeout=300000)
public void testSnapshotDeletionWithRegex() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM);
  table.close();

  byte[] snapshot1 = Bytes.toBytes("TableSnapshot1");
  admin.snapshot(snapshot1, TABLE_NAME);
  LOG.debug("Snapshot1 completed.");

  byte[] snapshot2 = Bytes.toBytes("TableSnapshot2");
  admin.snapshot(snapshot2, TABLE_NAME);
  LOG.debug("Snapshot2 completed.");

  String snapshot3 = "3rdTableSnapshot";
  admin.snapshot(Bytes.toBytes(snapshot3), TABLE_NAME);
  LOG.debug(snapshot3 + " completed.");

  // delete the first two snapshots
  admin.deleteSnapshots("TableSnapshot.*");
  List<SnapshotDescription> snapshots = admin.listSnapshots();
  assertEquals(1, snapshots.size());
  assertEquals(snapshots.get(0).getName(), snapshot3);

  admin.deleteSnapshot(snapshot3);
  admin.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:38,代码来源:TestSnapshotFromClient.java

示例4: testSnapshotDeletionWithRegex

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test HBaseAdmin#deleteSnapshots(String) which deletes snapshots whose names match the parameter
 *
 * @throws Exception
 */
@Test (timeout=300000)
public void testSnapshotDeletionWithRegex() throws Exception {
  Admin admin = UTIL.getAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  Table table = UTIL.getConnection().getTable(TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM);
  table.close();

  byte[] snapshot1 = Bytes.toBytes("TableSnapshot1");
  admin.snapshot(snapshot1, TABLE_NAME);
  LOG.debug("Snapshot1 completed.");

  byte[] snapshot2 = Bytes.toBytes("TableSnapshot2");
  admin.snapshot(snapshot2, TABLE_NAME);
  LOG.debug("Snapshot2 completed.");

  String snapshot3 = "3rdTableSnapshot";
  admin.snapshot(Bytes.toBytes(snapshot3), TABLE_NAME);
  LOG.debug(snapshot3 + " completed.");

  // delete the first two snapshots
  admin.deleteSnapshots(Pattern.compile("TableSnapshot.*"));
  List<SnapshotDescription> snapshots = admin.listSnapshots();
  assertEquals(1, snapshots.size());
  assertEquals(snapshot3, snapshots.get(0).getName());

  admin.deleteSnapshot(snapshot3);
  admin.close();
}
 
开发者ID:apache,项目名称:hbase,代码行数:38,代码来源:TestSnapshotFromClient.java

示例5: testFlushTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  admin.snapshot(snapshotString, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:39,代码来源:TestFlushSnapshotFromClient.java

示例6: testFlushTableSnapshotWithProcedure

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshotWithProcedure() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  Map<String, String> props = new HashMap<String, String>();
  props.put("table", STRING_TABLE_NAME);
  admin.execProcedure(SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION,
      snapshotString, props);


  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs);
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:44,代码来源:TestFlushSnapshotFromClient.java

示例7: testOfflineTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test snapshotting a table that is offline
 * @throws Exception
 */
@Test (timeout=300000)
public void testOfflineTableSnapshot() throws Exception {
  Admin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM, false);

  LOG.debug("FS state before disable:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  // XXX if this is flakey, might want to consider using the async version and looping as
  // disableTable can succeed and still timeout.
  admin.disableTable(TABLE_NAME);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the disabled table
  final String SNAPSHOT_NAME = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(SNAPSHOT_NAME);

  SnapshotDescription desc = SnapshotDescription.newBuilder()
    .setType(SnapshotDescription.Type.DISABLED)
    .setTable(STRING_TABLE_NAME)
    .setName(SNAPSHOT_NAME)
    .setVersion(SnapshotManifestV1.DESCRIPTOR_VERSION)
    .build();
  admin.snapshot(desc);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
    admin, fs);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:57,代码来源:TestSnapshotFromClient.java

示例8: testOfflineTableSnapshotWithEmptyRegions

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testOfflineTableSnapshotWithEmptyRegions() throws Exception {
  // test with an empty table with one region

  Admin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  LOG.debug("FS state before disable:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  admin.disableTable(TABLE_NAME);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the disabled table
  byte[] snapshot = Bytes.toBytes("testOfflineTableSnapshotWithEmptyRegions");
  admin.snapshot(snapshot, TABLE_NAME);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  List<byte[]> emptyCfs = Lists.newArrayList(TEST_FAM); // no file in the region
  List<byte[]> nonEmptyCfs = Lists.newArrayList();
  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, nonEmptyCfs, emptyCfs,
    rootDir, admin, fs);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:43,代码来源:TestSnapshotFromClient.java

示例9: testOfflineTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test snapshotting a table that is offline
 * @throws Exception
 */
@Test
public void testOfflineTableSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM);

  // get the name of all the regionservers hosting the snapshotted table
  Set<String> snapshotServers = new HashSet<String>();
  List<RegionServerThread> servers = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads();
  for (RegionServerThread server : servers) {
    if (server.getRegionServer().getOnlineRegions(TABLE_NAME).size() > 0) {
      snapshotServers.add(server.getRegionServer().getServerName().toString());
    }
  }

  LOG.debug("FS state before disable:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  // XXX if this is flakey, might want to consider using the async version and looping as
  // disableTable can succeed and still timeout.
  admin.disableTable(TABLE_NAME);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the disabled table
  byte[] snapshot = Bytes.toBytes("offlineTableSnapshot");
  admin.snapshot(snapshot, TABLE_NAME);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
    admin, fs, false, new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), snapshotServers);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:58,代码来源:TestSnapshotFromClient.java

示例10: testOfflineTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test snapshotting a table that is offline
 * @throws Exception
 */
@Test (timeout=300000)
public void testOfflineTableSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  UTIL.loadTable(table, TEST_FAM, false);

  // get the name of all the regionservers hosting the snapshotted table
  Set<String> snapshotServers = new HashSet<String>();
  List<RegionServerThread> servers = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads();
  for (RegionServerThread server : servers) {
    if (server.getRegionServer().getOnlineRegions(TABLE_NAME).size() > 0) {
      snapshotServers.add(server.getRegionServer().getServerName().toString());
    }
  }

  LOG.debug("FS state before disable:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  // XXX if this is flakey, might want to consider using the async version and looping as
  // disableTable can succeed and still timeout.
  admin.disableTable(TABLE_NAME);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the disabled table
  byte[] snapshot = Bytes.toBytes("offlineTableSnapshot");
  admin.snapshot(snapshot, TABLE_NAME);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
    admin, fs, false, new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), snapshotServers);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:58,代码来源:TestSnapshotFromClient.java

示例11: testOfflineTableSnapshotWithEmptyRegions

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testOfflineTableSnapshotWithEmptyRegions() throws Exception {
  // test with an empty table with one region

  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // get the name of all the regionservers hosting the snapshotted table
  Set<String> snapshotServers = new HashSet<String>();
  List<RegionServerThread> servers = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads();
  for (RegionServerThread server : servers) {
    if (server.getRegionServer().getOnlineRegions(TABLE_NAME).size() > 0) {
      snapshotServers.add(server.getRegionServer().getServerName().toString());
    }
  }

  LOG.debug("FS state before disable:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  admin.disableTable(TABLE_NAME);

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the disabled table
  byte[] snapshot = Bytes.toBytes("testOfflineTableSnapshotWithEmptyRegions");
  admin.snapshot(snapshot, TABLE_NAME);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  List<byte[]> emptyCfs = Lists.newArrayList(TEST_FAM); // no file in the region
  List<byte[]> nonEmptyCfs = Lists.newArrayList();
  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, nonEmptyCfs, emptyCfs, rootDir,
    admin, fs, false, new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), snapshotServers);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:52,代码来源:TestSnapshotFromClient.java

示例12: testFlushTableSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  // get the name of all the regionservers hosting the snapshotted table
  Set<String> snapshotServers = new HashSet<String>();
  List<RegionServerThread> servers = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads();
  for (RegionServerThread server : servers) {
    if (server.getRegionServer().getOnlineRegions(TABLE_NAME).size() > 0) {
      snapshotServers.add(server.getRegionServer().getServerName().toString());
    }
  }

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  admin.snapshot(snapshotString, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);
  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs, false, new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), snapshotServers);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:48,代码来源:TestFlushSnapshotFromClient.java

示例13: testFlushTableSnapshotWithProcedure

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test (timeout=300000)
public void testFlushTableSnapshotWithProcedure() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);

  // put some stuff in the table
  HTable table = new HTable(UTIL.getConfiguration(), TABLE_NAME);
  SnapshotTestingUtils.loadData(UTIL, table, DEFAULT_NUM_ROWS, TEST_FAM);

  // get the name of all the regionservers hosting the snapshotted table
  Set<String> snapshotServers = new HashSet<String>();
  List<RegionServerThread> servers = UTIL.getMiniHBaseCluster().getLiveRegionServerThreads();
  for (RegionServerThread server : servers) {
    if (server.getRegionServer().getOnlineRegions(TABLE_NAME).size() > 0) {
      snapshotServers.add(server.getRegionServer().getServerName().toString());
    }
  }

  LOG.debug("FS state before snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // take a snapshot of the enabled table
  String snapshotString = "offlineTableSnapshot";
  byte[] snapshot = Bytes.toBytes(snapshotString);
  Map<String, String> props = new HashMap<String, String>();
  props.put("table", STRING_TABLE_NAME);
  admin.execProcedure(SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION,
      snapshotString, props);


  LOG.debug("Snapshot completed.");

  // make sure we have the snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshot, TABLE_NAME);

  // make sure its a valid snapshot
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  LOG.debug("FS state after snapshot:");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  SnapshotTestingUtils.confirmSnapshotValid(snapshots.get(0), TABLE_NAME, TEST_FAM, rootDir,
      admin, fs, false, new Path(rootDir, HConstants.HREGION_LOGDIR_NAME), snapshotServers);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:53,代码来源:TestFlushSnapshotFromClient.java

示例14: testSnapshotStateAfterMerge

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testSnapshotStateAfterMerge() throws Exception {
  int numRows = DEFAULT_NUM_ROWS;
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, numRows, TEST_FAM);

  // Take a snapshot
  String snapshotBeforeMergeName = "snapshotBeforeMerge";
  admin.snapshot(snapshotBeforeMergeName, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);

  // Clone the table
  String cloneBeforeMergeName = "cloneBeforeMerge";
  admin.cloneSnapshot(snapshotBeforeMergeName, cloneBeforeMergeName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneBeforeMergeName));

  // Merge two regions
  List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
  Collections.sort(regions, new Comparator<HRegionInfo>() {
    public int compare(HRegionInfo r1, HRegionInfo r2) {
      return Bytes.compareTo(r1.getStartKey(), r2.getStartKey());
    }
  });

  int numRegions = admin.getTableRegions(TABLE_NAME).size();
  int numRegionsAfterMerge = numRegions - 2;
  admin.mergeRegions(regions.get(1).getEncodedNameAsBytes(),
      regions.get(2).getEncodedNameAsBytes(), true);
  admin.mergeRegions(regions.get(5).getEncodedNameAsBytes(),
      regions.get(6).getEncodedNameAsBytes(), true);

  // Verify that there's one region less
  waitRegionsAfterMerge(numRegionsAfterMerge);
  assertEquals(numRegionsAfterMerge, admin.getTableRegions(TABLE_NAME).size());

  // Clone the table
  String cloneAfterMergeName = "cloneAfterMerge";
  admin.cloneSnapshot(snapshotBeforeMergeName, cloneAfterMergeName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneAfterMergeName));

  SnapshotTestingUtils.verifyRowCount(UTIL, TABLE_NAME, numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneBeforeMergeName), numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneAfterMergeName), numRows);

  // test that we can delete the snapshot
  UTIL.deleteTable(cloneAfterMergeName);
  UTIL.deleteTable(cloneBeforeMergeName);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:51,代码来源:TestFlushSnapshotFromClient.java

示例15: testTakeSnapshotAfterMerge

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testTakeSnapshotAfterMerge() throws Exception {
  int numRows = DEFAULT_NUM_ROWS;
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, numRows, TEST_FAM);

  // Merge two regions
  List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
  Collections.sort(regions, new Comparator<HRegionInfo>() {
    public int compare(HRegionInfo r1, HRegionInfo r2) {
      return Bytes.compareTo(r1.getStartKey(), r2.getStartKey());
    }
  });

  int numRegions = admin.getTableRegions(TABLE_NAME).size();
  int numRegionsAfterMerge = numRegions - 2;
  admin.mergeRegions(regions.get(1).getEncodedNameAsBytes(),
      regions.get(2).getEncodedNameAsBytes(), true);
  admin.mergeRegions(regions.get(5).getEncodedNameAsBytes(),
      regions.get(6).getEncodedNameAsBytes(), true);

  waitRegionsAfterMerge(numRegionsAfterMerge);
  assertEquals(numRegionsAfterMerge, admin.getTableRegions(TABLE_NAME).size());

  // Take a snapshot
  String snapshotName = "snapshotAfterMerge";
  SnapshotTestingUtils.snapshot(admin, snapshotName, STRING_TABLE_NAME,
    SnapshotDescription.Type.FLUSH, 3);

  // Clone the table
  String cloneName = "cloneMerge";
  admin.cloneSnapshot(snapshotName, cloneName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneName));

  SnapshotTestingUtils.verifyRowCount(UTIL, TABLE_NAME, numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneName), numRows);

  // test that we can delete the snapshot
  UTIL.deleteTable(cloneName);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:44,代码来源:TestFlushSnapshotFromClient.java


注:本文中的org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.assertNoSnapshots方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。