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


Java HBaseAdmin.deleteSnapshot方法代码示例

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


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

示例1: deleteOldSnapshots

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void deleteOldSnapshots(HBaseAdmin admin, String tableName) throws IOException {
    if (args.keepCount(tableName) == SnapshotArgs.KEEP_UNLIMITED
            || args.has(Args.OPTION_TEST) && !tableName.startsWith("UNIT_TEST_")) {
        System.out.println(timestamp(TimestampFormat.log)
                + " - Table \"" + tableName + "\" - Delete Snapshot - Keep Unlimited - SKIPPED");
        return;
    }

    List<SnapshotDescription> sd = SnapshotAdapter.getSnapshotDescriptions(admin, getPrefix(tableName) + ".*");
    int snapshotCounter = sd.size();
    tableSnapshotCountMaxMap.put(tableName, snapshotCounter);
    for (SnapshotDescription d : sd) {
        if (snapshotCounter-- > args.keepCount(tableName)) {
            String snapshotName = d.getName();
            System.out.print(timestamp(TimestampFormat.log)
                    + " - Table \"" + tableName + "\" - Delete Snapshot - Keep "
                    + args.keepCount(tableName) + " - \"" + snapshotName + "\" - ");
            admin.deleteSnapshot(snapshotName);
            System.out.println("OK");
        }
    }
}
 
开发者ID:kakao,项目名称:hbase-tools,代码行数:23,代码来源:Snapshot.java

示例2: deleteAllSnapshots

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void deleteAllSnapshots(final HBaseAdmin admin)
    throws IOException {
  // Delete all the snapshots
  for (SnapshotDescription snapshot: admin.listSnapshots()) {
    admin.deleteSnapshot(snapshot.getName());
  }
  SnapshotTestingUtils.assertNoSnapshots(admin);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:9,代码来源:SnapshotTestingUtils.java

示例3: testAsyncFlushSnapshot

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test(timeout = 60000)
public void testAsyncFlushSnapshot() throws Exception {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("asyncSnapshot")
      .setTable(STRING_TABLE_NAME).setType(SnapshotDescription.Type.FLUSH).build();

  // take the snapshot async
  admin.takeSnapshotAsync(snapshot);

  // constantly loop, looking for the snapshot to complete
  HMaster master = UTIL.getMiniHBaseCluster().getMaster();
  SnapshotTestingUtils.waitForSnapshotToComplete(master, new HSnapshotDescription(snapshot), 200);
  LOG.info(" === Async Snapshot Completed ===");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  // make sure we get the snapshot
  SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot);

  // test that we can delete the snapshot
  admin.deleteSnapshot(snapshot.getName());
  LOG.info(" === Async Snapshot Deleted ===");
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
  // make sure we don't have any snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  LOG.info(" === Async Snapshot Test Completed ===");

}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:29,代码来源:TestFlushSnapshotFromClient.java

示例4: testSnapshotOperations

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testSnapshotOperations() throws Exception {
  MiniHBaseCluster cluster = UTIL.getHBaseCluster();
  HMaster master = cluster.getMaster();
  MasterCoprocessorHost host = master.getCoprocessorHost();
  CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
      CPMasterObserver.class.getName());
  cp.resetStates();

  // create a table
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
  HBaseAdmin admin = UTIL.getHBaseAdmin();

  // delete table if exists
  if (admin.tableExists(TEST_TABLE)) {
    UTIL.deleteTable(TEST_TABLE);
  }

  admin.createTable(htd);
  admin.disableTable(TEST_TABLE);
  assertTrue(admin.isTableDisabled(TEST_TABLE));

  try {
    // Test snapshot operation
    assertFalse("Coprocessor should not have been called yet",
      cp.wasSnapshotCalled());
    admin.snapshot(TEST_SNAPSHOT, TEST_TABLE);
    assertTrue("Coprocessor should have been called on snapshot",
      cp.wasSnapshotCalled());

    // Test clone operation
    admin.cloneSnapshot(TEST_SNAPSHOT, TEST_CLONE);
    assertTrue("Coprocessor should have been called on snapshot clone",
      cp.wasCloneSnapshotCalled());
    assertFalse("Coprocessor restore should not have been called on snapshot clone",
      cp.wasRestoreSnapshotCalled());
    admin.disableTable(TEST_CLONE);
    assertTrue(admin.isTableDisabled(TEST_TABLE));
    admin.deleteTable(TEST_CLONE);

    // Test restore operation
    cp.resetStates();
    admin.restoreSnapshot(TEST_SNAPSHOT);
    assertTrue("Coprocessor should have been called on snapshot restore",
      cp.wasRestoreSnapshotCalled());
    assertFalse("Coprocessor clone should not have been called on snapshot restore",
      cp.wasCloneSnapshotCalled());

    admin.deleteSnapshot(TEST_SNAPSHOT);
    assertTrue("Coprocessor should have been called on snapshot delete",
      cp.wasDeleteSnapshotCalled());
  } finally {
    admin.deleteTable(TEST_TABLE);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:57,代码来源:TestMasterObserver.java

示例5: cleanupSnapshot

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void cleanupSnapshot(HBaseAdmin admin, String snapshotName)
    throws IOException {
  // delete the taken snapshot
  admin.deleteSnapshot(snapshotName);
  assertNoSnapshots(admin);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:7,代码来源:SnapshotTestingUtils.java

示例6: testFlushTableSnapshot

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * Test simple flush snapshotting a table that is online
 * @throws Exception
 */
@Test
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);
  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 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);

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

示例7: testFlushCreateListDestroy

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * Basic end-to-end test of simple-flush-based snapshots
 */
@Test
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
  UTIL.loadTable(new HTable(UTIL.getConfiguration(), TABLE_NAME), TEST_FAM);
  // and wait until everything stabilizes
  waitForTableToBeOnline(TABLE_NAME);

  String snapshotName = "flushSnapshotCreateListDestroy";
  // test creating the snapshot
  admin.snapshot(snapshotName, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);
  logFSTree(new Path(UTIL.getConfiguration().get(HConstants.HBASE_DIR)));

  // make sure we only have 1 matching snapshot
  List<SnapshotDescription> snapshots = SnapshotTestingUtils.assertOneSnapshotThatMatches(admin,
    snapshotName, STRING_TABLE_NAME);

  // check the directory structure
  FileSystem fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
  Path rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshots.get(0), rootDir);
  assertTrue(fs.exists(snapshotDir));
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(), snapshotDir, LOG);
  Path snapshotinfo = new Path(snapshotDir, SnapshotDescriptionUtils.SNAPSHOTINFO_FILE);
  assertTrue(fs.exists(snapshotinfo));

  // check the table info
  HTableDescriptor desc = FSTableDescriptors.getTableDescriptor(fs, rootDir, TABLE_NAME);
  HTableDescriptor snapshotDesc = FSTableDescriptors.getTableDescriptor(fs,
    SnapshotDescriptionUtils.getSnapshotsDir(rootDir), Bytes.toBytes(snapshotName));
  assertEquals(desc, snapshotDesc);

  // check the region snapshot for all the regions
  List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
  for (HRegionInfo info : regions) {
    String regionName = info.getEncodedName();
    Path regionDir = new Path(snapshotDir, regionName);
    HRegionInfo snapshotRegionInfo = HRegion.loadDotRegionInfoFileContent(fs, regionDir);
    assertEquals(info, snapshotRegionInfo);
    // check to make sure we have the family
    Path familyDir = new Path(regionDir, Bytes.toString(TEST_FAM));
    assertTrue(fs.exists(familyDir));
    // make sure we have some file references
    assertTrue(fs.listStatus(familyDir).length > 0);
  }

  // test that we can delete the snapshot
  admin.deleteSnapshot(snapshotName);
  FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
    FSUtils.getRootDir(UTIL.getConfiguration()), LOG);

  // make sure we don't have any snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  LOG.debug("------- Flush-Snapshot Create List Destroy-------------");
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:62,代码来源:TestFlushSnapshotFromClient.java

示例8: testSnapshotOperations

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testSnapshotOperations() throws Exception {
  MiniHBaseCluster cluster = UTIL.getHBaseCluster();
  HMaster master = cluster.getMaster();
  MasterCoprocessorHost host = master.getCoprocessorHost();
  CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
      CPMasterObserver.class.getName());
  cp.resetStates();

  // create a table
  HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
  HBaseAdmin admin = UTIL.getHBaseAdmin();

  tableCreationLatch = new CountDownLatch(1);
  admin.createTable(htd);
  tableCreationLatch.await();
  tableCreationLatch = new CountDownLatch(1);

  admin.disableTable(TEST_TABLE);
  assertTrue(admin.isTableDisabled(TEST_TABLE));

  try {
    // Test snapshot operation
    assertFalse("Coprocessor should not have been called yet",
      cp.wasSnapshotCalled());
    admin.snapshot(TEST_SNAPSHOT, TEST_TABLE);
    assertTrue("Coprocessor should have been called on snapshot",
      cp.wasSnapshotCalled());

    // Test clone operation
    admin.cloneSnapshot(TEST_SNAPSHOT, TEST_CLONE);
    assertTrue("Coprocessor should have been called on snapshot clone",
      cp.wasCloneSnapshotCalled());
    assertFalse("Coprocessor restore should not have been called on snapshot clone",
      cp.wasRestoreSnapshotCalled());
    admin.disableTable(TEST_CLONE);
    assertTrue(admin.isTableDisabled(TEST_TABLE));
    admin.deleteTable(TEST_CLONE);

    // Test restore operation
    cp.resetStates();
    admin.restoreSnapshot(TEST_SNAPSHOT);
    assertTrue("Coprocessor should have been called on snapshot restore",
      cp.wasRestoreSnapshotCalled());
    assertFalse("Coprocessor clone should not have been called on snapshot restore",
      cp.wasCloneSnapshotCalled());

    admin.deleteSnapshot(TEST_SNAPSHOT);
    assertTrue("Coprocessor should have been called on snapshot delete",
      cp.wasDeleteSnapshotCalled());
  } finally {
    admin.deleteTable(TEST_TABLE);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:56,代码来源:TestMasterObserver.java


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