Java 类org.apache.hadoop.hbase.snapshot.SnapshotManifestV1 实例源码

项目:ditb    文件:TestSnapshotFromClient.java   
/**
 * 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);
}
项目:pbase    文件:TestSnapshotFromClient.java   
/**
 * 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);
}
项目:hbase    文件:TestSnapshotFromClient.java   
/**
 * Test snapshotting a table that is offline
 * @throws Exception
 */
@Test (timeout=300000)
public void testOfflineTableSnapshot() 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, 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);

  admin.snapshot(new SnapshotDescription(SNAPSHOT_NAME, TABLE_NAME,
      SnapshotType.DISABLED, null, -1, SnapshotManifestV1.DESCRIPTOR_VERSION));
  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(
    ProtobufUtil.createHBaseProtosSnapshotDesc(snapshots.get(0)), TABLE_NAME, TEST_FAM,
    rootDir, admin, fs);

  admin.deleteSnapshot(snapshot);
  snapshots = admin.listSnapshots();
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
项目:PyroDB    文件:TestSnapshotFromClient.java   
/**
 * 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);

  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);
}