• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HSnapshotDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.HSnapshotDescription的典型用法代码示例。如果您正苦于以下问题:Java HSnapshotDescription类的具体用法?Java HSnapshotDescription怎么用?Java HSnapshotDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HSnapshotDescription类属于org.apache.hadoop.hbase.snapshot包,在下文中一共展示了HSnapshotDescription类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testDeleteSnapshot

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
@Test
public void testDeleteSnapshot() throws Exception {

  String snapshotName = "completed";
  SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();

  try {
    master.deleteSnapshot(new HSnapshotDescription(snapshot));
    fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist");
  } catch (IOException e) {
    LOG.debug("Correctly failed delete of non-existant snapshot:" + e.getMessage());
  }

  // write one snapshot to the fs
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescriptionUtils.writeSnapshotInfo(snapshot, snapshotDir, fs);

  // then delete the existing snapshot,which shouldn't cause an exception to be thrown
  master.deleteSnapshot(new HSnapshotDescription(snapshot));
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:21,代码来源:TestSnapshotFromMaster.java


示例2: listSnapshots

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * List completed snapshots.
 * @return a list of snapshot descriptors for completed snapshots
 * @throws IOException if a network error occurs
 */
public List<SnapshotDescription> listSnapshots() throws IOException {
  List<SnapshotDescription> snapshots = new LinkedList<SnapshotDescription>();
  try {
    for (HSnapshotDescription snapshot : getMaster().getCompletedSnapshots()) {
      snapshots.add(snapshot.getProto());
    }
  } catch (RemoteException e) {
    throw RemoteExceptionHandler.decodeRemoteException(e);
  }
  return snapshots;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:17,代码来源:HBaseAdmin.java


示例3: deleteSnapshot

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Delete an existing snapshot.
 * @param snapshotName name of the snapshot
 * @throws IOException if a remote or network exception occurs
 */
public void deleteSnapshot(final byte[] snapshotName) throws IOException {
  // make sure the snapshot is possibly valid
  HTableDescriptor.isLegalTableName(snapshotName);
  // do the delete
  SnapshotDescription snapshot = SnapshotDescription.newBuilder()
      .setName(Bytes.toString(snapshotName)).build();
  try {
    getMaster().deleteSnapshot(new HSnapshotDescription(snapshot));
  } catch (RemoteException e) {
    throw RemoteExceptionHandler.decodeRemoteException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:HBaseAdmin.java


示例4: getCompletedSnapshots

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * List the currently available/stored snapshots. Any in-progress snapshots are ignored
 */
@Override
public List<HSnapshotDescription> getCompletedSnapshots() throws IOException {
  List<HSnapshotDescription> availableSnapshots = new ArrayList<HSnapshotDescription>();
  List<SnapshotDescription> snapshots = snapshotManager.getCompletedSnapshots();

  // convert to writables
  for (SnapshotDescription snapshot: snapshots) {
    availableSnapshots.add(new HSnapshotDescription(snapshot));
  }

  return availableSnapshots;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:16,代码来源:HMaster.java


示例5: deleteSnapshot

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Execute Delete Snapshot operation.
 * @throws ServiceException wrapping SnapshotDoesNotExistException if specified snapshot did not
 * exist.
 */
@Override
public void deleteSnapshot(final HSnapshotDescription request) throws IOException {
  try {
    this.snapshotManager.checkSnapshotSupport();
  } catch (UnsupportedOperationException e) {
    throw new IOException(e);
  }

  snapshotManager.deleteSnapshot(request.getProto());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:16,代码来源:HMaster.java


示例6: testValidateSnapshotName

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Make sure that we validate the snapshot name and the table name before we pass anything across
 * the wire
 * @throws Exception on failure
 */
@Test
public void testValidateSnapshotName() throws Exception {
  HConnectionManager.HConnectionImplementation mockConnection = Mockito
      .mock(HConnectionManager.HConnectionImplementation.class);
  Configuration conf = HBaseConfiguration.create();
  Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
  HBaseAdmin admin = new HBaseAdmin(mockConnection);
  SnapshotDescription.Builder builder = SnapshotDescription.newBuilder();
  // check that invalid snapshot names fail
  failSnapshotStart(admin, builder.setName(HConstants.SNAPSHOT_DIR_NAME).build());
  failSnapshotStart(admin, builder.setName("-snapshot").build());
  failSnapshotStart(admin, builder.setName("snapshot fails").build());
  failSnapshotStart(admin, builder.setName("snap$hot").build());
  // check the table name also get verified
  failSnapshotStart(admin, builder.setName("snapshot").setTable(".table").build());
  failSnapshotStart(admin, builder.setName("snapshot").setTable("-table").build());
  failSnapshotStart(admin, builder.setName("snapshot").setTable("table fails").build());
  failSnapshotStart(admin, builder.setName("snapshot").setTable("tab%le").build());

  // mock the master connection
  HMasterInterface master = Mockito.mock(HMasterInterface.class);
  Mockito.when(mockConnection.getMaster()).thenReturn(master);

  Mockito.when(
    master.snapshot(Mockito.any(HSnapshotDescription.class))).thenReturn((long)0);
  Mockito.when(
    master.isSnapshotDone(
      Mockito.any(HSnapshotDescription.class))).thenReturn(true);

    // make sure that we can use valid names
  admin.snapshot(builder.setName("snapshot").setTable("table").build());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:38,代码来源:TestSnapshotFromAdmin.java


示例7: testGetCompletedSnapshots

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
@Test
public void testGetCompletedSnapshots() throws Exception {
  // first check when there are no snapshots
  List<HSnapshotDescription> snapshots = master.getCompletedSnapshots();
  assertEquals("Found unexpected number of snapshots", 0, snapshots.size());

  // write one snapshot to the fs
  String snapshotName = "completed";
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(snapshot, snapshotDir, fs);

  // check that we get one snapshot
  snapshots = master.getCompletedSnapshots();
  assertEquals("Found unexpected number of snapshots", 1, snapshots.size());
  List<HSnapshotDescription> expected = Lists.newArrayList(new HSnapshotDescription(snapshot));
  assertEquals("Returned snapshots don't match created snapshots", expected, snapshots);

  // write a second snapshot
  snapshotName = "completed_two";
  snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(snapshot, snapshotDir, fs);
  expected.add(new HSnapshotDescription(snapshot));

  // check that we get one snapshot
  snapshots = master.getCompletedSnapshots();
  assertEquals("Found unexpected number of snapshots", 2, snapshots.size());
  assertEquals("Returned snapshots don't match created snapshots", expected, snapshots);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:TestSnapshotFromMaster.java


示例8: listSnapshots

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * List completed snapshots.
 * @return a list of snapshot descriptors for completed snapshots
 * @throws IOException if a network error occurs
 */
public List<SnapshotDescription> listSnapshots() throws IOException {
  List<SnapshotDescription> snapshots = new LinkedList<SnapshotDescription>();
  try {
    for (HSnapshotDescription snapshot: getMaster().getCompletedSnapshots()) {
      snapshots.add(snapshot.getProto());
    }
  } catch (RemoteException e) {
    throw RemoteExceptionHandler.decodeRemoteException(e);
  }
  return snapshots;
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:17,代码来源:HBaseAdmin.java


示例9: deleteSnapshot

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Delete an existing snapshot.
 * @param snapshotName name of the snapshot
 * @throws IOException if a remote or network exception occurs
 */
public void deleteSnapshot(final byte[] snapshotName) throws IOException {
  // make sure the snapshot is possibly valid
  HTableDescriptor.isLegalTableName(snapshotName);
  // do the delete
  SnapshotDescription snapshot = SnapshotDescription.newBuilder()
    .setName(Bytes.toString(snapshotName)).build();
  try {
    getMaster().deleteSnapshot(new HSnapshotDescription(snapshot));
  } catch (RemoteException e) {
    throw RemoteExceptionHandler.decodeRemoteException(e);
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:18,代码来源:HBaseAdmin.java


示例10: waitForSnapshotToComplete

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Helper method for testing async snapshot operations. Just waits for the given snapshot to
 * complete on the server by repeatedly checking the master.
 * @param master running the snapshot
 * @param snapshot to check
 * @param sleep amount to sleep between checks to see if the snapshot is done
 * @throws IOException if the snapshot fails
 */
public static void waitForSnapshotToComplete(HMaster master, HSnapshotDescription snapshot,
    long sleep) throws IOException {
  boolean done = false;
  while (!done) {
    done = master.isSnapshotDone(snapshot);
    try {
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw new IOException(e);
    }
  }
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:21,代码来源:SnapshotTestingUtils.java


示例11: expectSnapshotDoneException

import org.apache.hadoop.hbase.snapshot.HSnapshotDescription; //导入依赖的package包/类
/**
 * Expect the snapshot to throw an error when checking if the snapshot is complete
 * @param master master to check
 * @param snapshot the {@link HSnapshotDescription} request to pass to the master
 * @param clazz expected exception from the master
 */
public static void expectSnapshotDoneException(HMaster master, HSnapshotDescription snapshot,
    Class<? extends HBaseSnapshotException> clazz) {
  try {
    boolean res = master.isSnapshotDone(snapshot);
    Assert.fail("didn't fail to lookup a snapshot: res=" + res);
  } catch (HBaseSnapshotException e) {
    assertEquals("Threw wrong snapshot exception!", clazz, e.getClass());
  } catch (Throwable t) {
    Assert.fail("Threw an unexpected exception:" + t);
  }
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:18,代码来源:SnapshotTestingUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnchorLinkNode类代码示例发布时间:2022-05-23
下一篇:
Java LinearConstraint类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap