• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java IsSnapshotDoneResponse类的典型用法和代码示例

java 2次浏览

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

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

示例1: waitForSnapshotToComplete

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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: the master running the snapshot
 * @param snapshot: the snapshot to check
 * @param sleep: amount to sleep between checks to see if the snapshot is done
 * @throws ServiceException if the snapshot fails
 */
public static void waitForSnapshotToComplete(HMaster master,
    SnapshotDescription snapshot, long sleep) throws ServiceException {
  final IsSnapshotDoneRequest request = IsSnapshotDoneRequest.newBuilder()
      .setSnapshot(snapshot).build();
  IsSnapshotDoneResponse done = IsSnapshotDoneResponse.newBuilder()
      .buildPartial();
  while (!done.getDone()) {
    done = master.getMasterRpcServices().isSnapshotDone(null, request);
    try {
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw new ServiceException(e);
    }
  }
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:25,
代码来源:SnapshotTestingUtils.java

示例2: isSnapshotDone

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Checks if the specified snapshot is done.
 * @return true if the snapshot is in file system ready to use,
 *   false if the snapshot is in the process of completing
 * @throws ServiceException wrapping UnknownSnapshotException if invalid snapshot, or
 *  a wrapped HBaseSnapshotException with progress failure reason.
 */
@Override
public IsSnapshotDoneResponse isSnapshotDone(RpcController controller,
    IsSnapshotDoneRequest request) throws ServiceException {
  LOG.debug("Checking to see if snapshot from request:" +
    ClientSnapshotDescriptionUtils.toString(request.getSnapshot()) + " is done");
  try {
    master.checkInitialized();
    IsSnapshotDoneResponse.Builder builder = IsSnapshotDoneResponse.newBuilder();
    boolean done = master.snapshotManager.isSnapshotDone(request.getSnapshot());
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:23,
代码来源:MasterRpcServices.java

示例3: waitForSnapshotToComplete

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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: the master running the snapshot
 * @param snapshot: the snapshot to check
 * @param sleep: amount to sleep between checks to see if the snapshot is done
 * @throws ServiceException if the snapshot fails
 */
public static void waitForSnapshotToComplete(HMaster master,
    SnapshotDescription snapshot, long sleep) throws ServiceException {
  final IsSnapshotDoneRequest request = IsSnapshotDoneRequest.newBuilder()
      .setSnapshot(snapshot).build();
  IsSnapshotDoneResponse done = IsSnapshotDoneResponse.newBuilder()
      .buildPartial();
  while (!done.getDone()) {
    done = master.isSnapshotDone(null, request);
    try {
      Thread.sleep(sleep);
    } catch (InterruptedException e) {
      throw new ServiceException(e);
    }
  }
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:25,
代码来源:SnapshotTestingUtils.java

示例4: testValidateSnapshotName

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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 {
  ConnectionManager.HConnectionImplementation mockConnection = Mockito
      .mock(ConnectionManager.HConnectionImplementation.class);
  Configuration conf = HBaseConfiguration.create();
  Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
  Admin 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());
  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
  MasterKeepAliveConnection master = Mockito.mock(MasterKeepAliveConnection.class);
  Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master);
  SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build();
  Mockito.when(
    master.snapshot((RpcController) Mockito.isNull(), Mockito.any(SnapshotRequest.class)))
      .thenReturn(response);
  IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build();
  Mockito.when(
    master.isSnapshotDone((RpcController) Mockito.isNull(),
        Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(doneResponse);

    // make sure that we can use valid names
  admin.snapshot(builder.setName("snapshot").setTable("table").build());
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:41,
代码来源:TestSnapshotFromAdmin.java

示例5: isSnapshotDone

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Checks if the specified snapshot is done.
 * @return true if the snapshot is in file system ready to use,
 *   false if the snapshot is in the process of completing
 * @throws ServiceException wrapping UnknownSnapshotException if invalid snapshot, or
 *  a wrapped HBaseSnapshotException with progress failure reason.
 */
@Override
public IsSnapshotDoneResponse isSnapshotDone(RpcController controller,
    IsSnapshotDoneRequest request) throws ServiceException {
  LOG.debug("Checking to see if snapshot from request:" +
      ClientSnapshotDescriptionUtils.toString(request.getSnapshot()) + " is done");
  try {
    IsSnapshotDoneResponse.Builder builder = IsSnapshotDoneResponse.newBuilder();
    boolean done = snapshotManager.isSnapshotDone(request.getSnapshot());
    builder.setDone(done);
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:22,
代码来源:HMaster.java

示例6: testValidateSnapshotName

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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());
  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
  MasterKeepAliveConnection master = Mockito.mock(MasterKeepAliveConnection.class);
  Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master);
  SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build();
  Mockito.when(
    master.snapshot((RpcController) Mockito.isNull(), Mockito.any(SnapshotRequest.class)))
      .thenReturn(response);
  IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build();
  Mockito.when(
    master.isSnapshotDone((RpcController) Mockito.isNull(),
        Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(doneResponse);

    // make sure that we can use valid names
  admin.snapshot(builder.setName("snapshot").setTable("table").build());
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:41,
代码来源:TestSnapshotFromAdmin.java

示例7: testValidateSnapshotName

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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 {
  ConnectionManager.HConnectionImplementation mockConnection = Mockito
      .mock(ConnectionManager.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());
  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
  MasterKeepAliveConnection master = Mockito.mock(MasterKeepAliveConnection.class);
  Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master);
  SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build();
  Mockito.when(
    master.snapshot((RpcController) Mockito.isNull(), Mockito.any(SnapshotRequest.class)))
      .thenReturn(response);
  IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build();
  Mockito.when(
    master.isSnapshotDone((RpcController) Mockito.isNull(),
        Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(doneResponse);

    // make sure that we can use valid names
  admin.snapshot(builder.setName("snapshot").setTable("table").build());
}
 

开发者ID:shenli-uiuc,
项目名称:PyroDB,
代码行数:41,
代码来源:TestSnapshotFromAdmin.java

示例8: testIsDoneContract

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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

示例9: testValidateSnapshotName

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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 {
  ConnectionManager.HConnectionImplementation mockConnection = Mockito
      .mock(ConnectionManager.HConnectionImplementation.class);
  Configuration conf = HBaseConfiguration.create();
  Mockito.when(mockConnection.getConfiguration()).thenReturn(conf);
  // we need a real retrying caller
  RpcRetryingCallerFactory callerFactory = new RpcRetryingCallerFactory(conf);
  RpcControllerFactory controllerFactory = Mockito.mock(RpcControllerFactory.class);
  Mockito.when(controllerFactory.newController()).thenReturn(
    Mockito.mock(PayloadCarryingRpcController.class));
  Mockito.when(mockConnection.getRpcRetryingCallerFactory()).thenReturn(callerFactory);
  Mockito.when(mockConnection.getRpcControllerFactory()).thenReturn(controllerFactory);
  Admin 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());
  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
  MasterKeepAliveConnection master = Mockito.mock(MasterKeepAliveConnection.class);
  Mockito.when(mockConnection.getKeepAliveMasterService()).thenReturn(master);
  SnapshotResponse response = SnapshotResponse.newBuilder().setExpectedTimeout(0).build();
  Mockito.when(
    master.snapshot((RpcController) Mockito.any(), Mockito.any(SnapshotRequest.class)))
      .thenReturn(response);
  IsSnapshotDoneResponse doneResponse = IsSnapshotDoneResponse.newBuilder().setDone(true).build();
  Mockito.when(
    master.isSnapshotDone((RpcController) Mockito.any(),
        Mockito.any(IsSnapshotDoneRequest.class))).thenReturn(doneResponse);

    // make sure that we can use valid names
  admin.snapshot(builder.setName("snapshot").setTable("table").build());
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:48,
代码来源:TestSnapshotFromAdmin.java

示例10: testIsDoneContract

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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

示例11: testIsDoneContract

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的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

示例12: isSnapshotFinished

点赞 1

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Check the current state of the passed snapshot.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the snapshot to fail</li>
 * </ol>
 * <p>
 * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
 * run/started since the snapshot your are checking, you will recieve an
 * {@link UnknownSnapshotException}.
 * @param snapshot description of the snapshot to check
 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
 *         running
 * @throws IOException if we have a network issue
 * @throws HBaseSnapshotException if the snapshot failed
 * @throws UnknownSnapshotException if the requested snapshot is unknown
 */
@Override
public boolean isSnapshotFinished(final SnapshotDescription snapshot)
    throws IOException, HBaseSnapshotException, UnknownSnapshotException {

  return executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection()) {
    @Override
    public IsSnapshotDoneResponse call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      return master.isSnapshotDone(controller,
        IsSnapshotDoneRequest.newBuilder().setSnapshot(snapshot).build());
    }
  }).getDone();
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:35,
代码来源:HBaseAdmin.java

示例13: isSnapshotFinished

点赞 1

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Check the current state of the passed snapshot.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the snapshot to fail</li>
 * </ol>
 * <p>
 * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
 * run/started since the snapshot your are checking, you will recieve an
 * {@link UnknownSnapshotException}.
 * @param snapshot description of the snapshot to check
 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
 *         running
 * @throws IOException if we have a network issue
 * @throws HBaseSnapshotException if the snapshot failed
 * @throws UnknownSnapshotException if the requested snapshot is unknown
 */
@Override
public boolean isSnapshotFinished(final SnapshotDescription snapshot)
    throws IOException, HBaseSnapshotException, UnknownSnapshotException {

  return executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection()) {
    @Override
    public IsSnapshotDoneResponse call(int callTimeout) throws ServiceException {
      return master.isSnapshotDone(null,
        IsSnapshotDoneRequest.newBuilder().setSnapshot(snapshot).build());
    }
  }).getDone();
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:33,
代码来源:HBaseAdmin.java

示例14: isSnapshotFinished

点赞 1

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Check the current state of the passed snapshot.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the snapshot to fail</li>
 * </ol>
 * <p>
 * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
 * run/started since the snapshot your are checking, you will recieve an
 * {@link UnknownSnapshotException}.
 * @param snapshot description of the snapshot to check
 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
 *         running
 * @throws IOException if we have a network issue
 * @throws HBaseSnapshotException if the snapshot failed
 * @throws UnknownSnapshotException if the requested snapshot is unknown
 */
public boolean isSnapshotFinished(final SnapshotDescription snapshot)
    throws IOException, HBaseSnapshotException, UnknownSnapshotException {

  return executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection()) {
    @Override
    public IsSnapshotDoneResponse call() throws ServiceException {
      return master.isSnapshotDone(null,
        IsSnapshotDoneRequest.newBuilder().setSnapshot(snapshot).build());
    }
  }).getDone();
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:32,
代码来源:HBaseAdmin.java

示例15: isSnapshotFinished

点赞 1

import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; //导入依赖的package包/类
/**
 * Check the current state of the passed snapshot.
 * <p>
 * There are three possible states:
 * <ol>
 * <li>running - returns <tt>false</tt></li>
 * <li>finished - returns <tt>true</tt></li>
 * <li>finished with error - throws the exception that caused the snapshot to fail</li>
 * </ol>
 * <p>
 * The cluster only knows about the most recent snapshot. Therefore, if another snapshot has been
 * run/started since the snapshot your are checking, you will recieve an
 * {@link UnknownSnapshotException}.
 * @param snapshot description of the snapshot to check
 * @return <tt>true</tt> if the snapshot is completed, <tt>false</tt> if the snapshot is still
 *         running
 * @throws IOException if we have a network issue
 * @throws HBaseSnapshotException if the snapshot failed
 * @throws UnknownSnapshotException if the requested snapshot is unknown
 */
public boolean isSnapshotFinished(final SnapshotDescription snapshot)
    throws IOException, HBaseSnapshotException, UnknownSnapshotException {

  return executeCallable(new MasterCallable<IsSnapshotDoneResponse>(getConnection()) {
    @Override
    public IsSnapshotDoneResponse call(int callTimeout) throws ServiceException {
      return master.isSnapshotDone(null,
        IsSnapshotDoneRequest.newBuilder().setSnapshot(snapshot).build());
    }
  }).getDone();
}
 

开发者ID:shenli-uiuc,
项目名称:PyroDB,
代码行数:32,
代码来源:HBaseAdmin.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)