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


Java SnapshotDescriptionUtils.writeSnapshotInfo方法代码示例

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


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

示例1: testDeleteSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
@Test(timeout = 300000)
public void testDeleteSnapshot() throws Exception {

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

  DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  try {
    master.getMasterRpcServices().deleteSnapshot(null, request);
    fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist");
  } catch (ServiceException 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.getMasterRpcServices().deleteSnapshot(null, request);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestSnapshotFromMaster.java

示例2: testDeleteSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的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

示例3: testDeleteSnapshot

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
@Test(timeout = 300000)
public void testDeleteSnapshot() throws Exception {

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

  DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  try {
    master.deleteSnapshot(null, request);
    fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist");
  } catch (ServiceException 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(null, request);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:TestSnapshotFromMaster.java

示例4: testGetCompletedSnapshots

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
@Test(timeout = 300000)
public void testGetCompletedSnapshots() throws Exception {
  // first check when there are no snapshots
  GetCompletedSnapshotsRequest request = GetCompletedSnapshotsRequest.newBuilder().build();
  GetCompletedSnapshotsResponse response =
    master.getMasterRpcServices().getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 0, response.getSnapshotsCount());

  // 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
  response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 1, response.getSnapshotsCount());
  List<SnapshotDescription> snapshots = response.getSnapshotsList();
  List<SnapshotDescription> expected = Lists.newArrayList(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(snapshot);

  // check that we get one snapshot
  response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());
  snapshots = response.getSnapshotsList();
  assertEquals("Returned snapshots don't match created snapshots", expected, snapshots);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestSnapshotFromMaster.java

示例5: testGetCompletedSnapshots

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的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

示例6: testGetCompletedSnapshots

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
@Test(timeout = 300000)
public void testGetCompletedSnapshots() throws Exception {
  // first check when there are no snapshots
  GetCompletedSnapshotsRequest request = GetCompletedSnapshotsRequest.newBuilder().build();
  GetCompletedSnapshotsResponse response = master.getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 0, response.getSnapshotsCount());

  // 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
  response = master.getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 1, response.getSnapshotsCount());
  List<SnapshotDescription> snapshots = response.getSnapshotsList();
  List<SnapshotDescription> expected = Lists.newArrayList(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(snapshot);

  // check that we get one snapshot
  response = master.getCompletedSnapshots(null, request);
  assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());
  snapshots = response.getSnapshotsList();
  assertEquals("Returned snapshots don't match created snapshots", expected, snapshots);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:34,代码来源:TestSnapshotFromMaster.java

示例7: testIsDoneContract

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Test that the contract from the master for checking on a snapshot are valid.
 * <p>
 * <ol>
 * <li>If a snapshot fails with an error, we expect to get the source error.</li>
 * <li>If there is no snapshot name supplied, we should get an error.</li>
 * <li>If asking about a snapshot has hasn't occurred, you should get an error.</li>
 * </ol>
 */
@Test(timeout = 300000)
public void testIsDoneContract() throws Exception {

  IsSnapshotDoneRequest.Builder builder = IsSnapshotDoneRequest.newBuilder();

  String snapshotName = "asyncExpectedFailureTest";

  // check that we get an exception when looking up snapshot where one hasn't happened
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // and that we get the same issue, even if we specify a name
  SnapshotDescription desc = SnapshotDescription.newBuilder()
    .setName(snapshotName).setTable(TABLE_NAME.getNameAsString()).build();
  builder.setSnapshot(desc);
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // set a mock handler to simulate a snapshot
  DisabledTableSnapshotHandler mockHandler = Mockito.mock(DisabledTableSnapshotHandler.class);
  Mockito.when(mockHandler.getException()).thenReturn(null);
  Mockito.when(mockHandler.getSnapshot()).thenReturn(desc);
  Mockito.when(mockHandler.isFinished()).thenReturn(new Boolean(true));
  Mockito.when(mockHandler.getCompletionTimestamp())
    .thenReturn(EnvironmentEdgeManager.currentTime());

  master.getSnapshotManagerForTesting()
      .setSnapshotHandlerForTesting(TABLE_NAME, mockHandler);

  // if we do a lookup without a snapshot name, we should fail - you should always know your name
  builder = IsSnapshotDoneRequest.newBuilder();
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then do the lookup for the snapshot that it is done
  builder.setSnapshot(desc);
  IsSnapshotDoneResponse response =
    master.getMasterRpcServices().isSnapshotDone(null, builder.build());
  assertTrue("Snapshot didn't complete when it should have.", response.getDone());

  // now try the case where we are looking for a snapshot we didn't take
  builder.setSnapshot(SnapshotDescription.newBuilder().setName("Not A Snapshot").build());
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then create a snapshot to the fs and make sure that we can find it when checking done
  snapshotName = "completed";
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  desc = desc.toBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(desc, snapshotDir, fs);

  builder.setSnapshot(desc);
  response = master.getMasterRpcServices().isSnapshotDone(null, builder.build());
  assertTrue("Completed, on-disk snapshot not found", response.getDone());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:TestSnapshotFromMaster.java

示例8: testIsDoneContract

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Test that the contract from the master for checking on a snapshot are valid.
 * <p>
 * <ol>
 * <li>If a snapshot fails with an error, we expect to get the source error.</li>
 * <li>If there is no snapshot name supplied, we should get an error.</li>
 * <li>If asking about a snapshot has hasn't occurred, you should get an error.</li>
 * </ol>
 */
@Test(timeout = 60000)
public void testIsDoneContract() throws Exception {

  String snapshotName = "asyncExpectedFailureTest";

  // check that we get an exception when looking up snapshot where one hasn't happened
  SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(),
    UnknownSnapshotException.class);

  // and that we get the same issue, even if we specify a name
  SnapshotDescription desc = SnapshotDescription.newBuilder()
    .setName(snapshotName).setTable(STRING_TABLE_NAME).build();
  SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(desc),
    UnknownSnapshotException.class);

  // set a mock handler to simulate a snapshot
  DisabledTableSnapshotHandler mockHandler = Mockito.mock(DisabledTableSnapshotHandler.class);
  Mockito.when(mockHandler.getException()).thenReturn(null);
  Mockito.when(mockHandler.getSnapshot()).thenReturn(desc);
  Mockito.when(mockHandler.isFinished()).thenReturn(new Boolean(true));
  Mockito.when(mockHandler.getCompletionTimestamp())
    .thenReturn(EnvironmentEdgeManager.currentTimeMillis());

  master.getSnapshotManagerForTesting()
      .setSnapshotHandlerForTesting(STRING_TABLE_NAME, mockHandler);

  // if we do a lookup without a snapshot name, we should fail - you should always know your name
  SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(),
    UnknownSnapshotException.class);

  // then do the lookup for the snapshot that it is done
  boolean isDone = master.isSnapshotDone(new HSnapshotDescription(desc));
  assertTrue("Snapshot didn't complete when it should have.", isDone);

  // now try the case where we are looking for a snapshot we didn't take
  desc = SnapshotDescription.newBuilder().setName("Not A Snapshot").build();
  SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(desc),
    UnknownSnapshotException.class);

  // then create a snapshot to the fs and make sure that we can find it when checking done
  snapshotName = "completed";
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  desc = desc.toBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(desc, snapshotDir, fs);

  isDone = master.isSnapshotDone(new HSnapshotDescription(desc));
  assertTrue("Completed, on-disk snapshot not found", isDone);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:58,代码来源:TestSnapshotFromMaster.java

示例9: testIsDoneContract

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Test that the contract from the master for checking on a snapshot are valid.
 * <p>
 * <ol>
 * <li>If a snapshot fails with an error, we expect to get the source error.</li>
 * <li>If there is no snapshot name supplied, we should get an error.</li>
 * <li>If asking about a snapshot has hasn't occurred, you should get an error.</li>
 * </ol>
 */
@Test(timeout = 300000)
public void testIsDoneContract() throws Exception {

  IsSnapshotDoneRequest.Builder builder = IsSnapshotDoneRequest.newBuilder();

  String snapshotName = "asyncExpectedFailureTest";

  // check that we get an exception when looking up snapshot where one hasn't happened
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // and that we get the same issue, even if we specify a name
  SnapshotDescription desc = SnapshotDescription.newBuilder()
    .setName(snapshotName).setTable(TABLE_NAME.getNameAsString()).build();
  builder.setSnapshot(desc);
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // set a mock handler to simulate a snapshot
  DisabledTableSnapshotHandler mockHandler = Mockito.mock(DisabledTableSnapshotHandler.class);
  Mockito.when(mockHandler.getException()).thenReturn(null);
  Mockito.when(mockHandler.getSnapshot()).thenReturn(desc);
  Mockito.when(mockHandler.isFinished()).thenReturn(new Boolean(true));
  Mockito.when(mockHandler.getCompletionTimestamp())
    .thenReturn(EnvironmentEdgeManager.currentTimeMillis());

  master.getSnapshotManagerForTesting()
      .setSnapshotHandlerForTesting(TABLE_NAME, mockHandler);

  // if we do a lookup without a snapshot name, we should fail - you should always know your name
  builder = IsSnapshotDoneRequest.newBuilder();
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then do the lookup for the snapshot that it is done
  builder.setSnapshot(desc);
  IsSnapshotDoneResponse response = master.isSnapshotDone(null, builder.build());
  assertTrue("Snapshot didn't complete when it should have.", response.getDone());

  // now try the case where we are looking for a snapshot we didn't take
  builder.setSnapshot(SnapshotDescription.newBuilder().setName("Not A Snapshot").build());
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then create a snapshot to the fs and make sure that we can find it when checking done
  snapshotName = "completed";
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  desc = desc.toBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(desc, snapshotDir, fs);

  builder.setSnapshot(desc);
  response = master.isSnapshotDone(null, builder.build());
  assertTrue("Completed, on-disk snapshot not found", response.getDone());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:64,代码来源:TestSnapshotFromMaster.java

示例10: testIsDoneContract

import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils; //导入方法依赖的package包/类
/**
 * Test that the contract from the master for checking on a snapshot are valid.
 * <p>
 * <ol>
 * <li>If a snapshot fails with an error, we expect to get the source error.</li>
 * <li>If there is no snapshot name supplied, we should get an error.</li>
 * <li>If asking about a snapshot has hasn't occurred, you should get an error.</li>
 * </ol>
 */
@Test(timeout = 300000)
public void testIsDoneContract() throws Exception {

  IsSnapshotDoneRequest.Builder builder = IsSnapshotDoneRequest.newBuilder();

  String snapshotName = "asyncExpectedFailureTest";

  // check that we get an exception when looking up snapshot where one hasn't happened
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // and that we get the same issue, even if we specify a name
  SnapshotDescription desc = SnapshotDescription.newBuilder()
    .setName(snapshotName).setTable(TABLE_NAME.getNameAsString()).build();
  builder.setSnapshot(desc);
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // set a mock handler to simulate a snapshot
  DisabledTableSnapshotHandler mockHandler = Mockito.mock(DisabledTableSnapshotHandler.class);
  Mockito.when(mockHandler.getException()).thenReturn(null);
  Mockito.when(mockHandler.getSnapshot()).thenReturn(desc);
  Mockito.when(mockHandler.isFinished()).thenReturn(new Boolean(true));
  Mockito.when(mockHandler.getCompletionTimestamp())
    .thenReturn(EnvironmentEdgeManager.currentTimeMillis());

  master.getSnapshotManagerForTesting()
      .setSnapshotHandlerForTesting(TABLE_NAME, mockHandler);

  // if we do a lookup without a snapshot name, we should fail - you should always know your name
  builder = IsSnapshotDoneRequest.newBuilder();
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then do the lookup for the snapshot that it is done
  builder.setSnapshot(desc);
  IsSnapshotDoneResponse response =
    master.getMasterRpcServices().isSnapshotDone(null, builder.build());
  assertTrue("Snapshot didn't complete when it should have.", response.getDone());

  // now try the case where we are looking for a snapshot we didn't take
  builder.setSnapshot(SnapshotDescription.newBuilder().setName("Not A Snapshot").build());
  SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
    UnknownSnapshotException.class);

  // then create a snapshot to the fs and make sure that we can find it when checking done
  snapshotName = "completed";
  Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
  desc = desc.toBuilder().setName(snapshotName).build();
  SnapshotDescriptionUtils.writeSnapshotInfo(desc, snapshotDir, fs);

  builder.setSnapshot(desc);
  response = master.getMasterRpcServices().isSnapshotDone(null, builder.build());
  assertTrue("Completed, on-disk snapshot not found", response.getDone());
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:65,代码来源:TestSnapshotFromMaster.java


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