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


Java DisabledTableSnapshotHandler类代码示例

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


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

示例1: testIsDoneContract

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

示例2: testIsDoneContract

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

示例3: testIsDoneContract

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

示例4: testIsDoneContract

import org.apache.hadoop.hbase.master.snapshot.DisabledTableSnapshotHandler; //导入依赖的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(Boolean.TRUE);
  Mockito.when(mockHandler.getCompletionTimestamp())
    .thenReturn(EnvironmentEdgeManager.currentTime());

  master.getSnapshotManager()
      .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";
  desc = createSnapshot(snapshotName);

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

示例5: testIsDoneContract

import org.apache.hadoop.hbase.master.snapshot.DisabledTableSnapshotHandler; //导入依赖的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.master.snapshot.DisabledTableSnapshotHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。