Java 类org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SnapshotRequest 实例源码

项目:ditb    文件:HBaseAdmin.java   
/**
 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 * <p>
 * Only a single snapshot should be taken at a time, or results may be undefined.
 * @param snapshot snapshot to take
 * @return response from the server indicating the max time to wait for the snapshot
 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
 * @throws SnapshotCreationException if snapshot creation failed
 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
 */
@Override
public SnapshotResponse takeSnapshotAsync(SnapshotDescription snapshot) throws IOException,
    SnapshotCreationException {
  ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
  final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  // run the snapshot on the master
  return executeCallable(new MasterCallable<SnapshotResponse>(getConnection()) {
    @Override
    public SnapshotResponse call(int callTimeout) throws ServiceException {
      PayloadCarryingRpcController controller = rpcControllerFactory.newController();
      controller.setCallTimeout(callTimeout);
      return master.snapshot(controller, request);
    }
  });
}
项目:pbase    文件:HBaseAdmin.java   
/**
 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 * <p>
 * Only a single snapshot should be taken at a time, or results may be undefined.
 * @param snapshot snapshot to take
 * @return response from the server indicating the max time to wait for the snapshot
 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
 * @throws SnapshotCreationException if snapshot creation failed
 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
 */
@Override
public SnapshotResponse takeSnapshotAsync(SnapshotDescription snapshot) throws IOException,
    SnapshotCreationException {
  ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
  final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  // run the snapshot on the master
  return executeCallable(new MasterCallable<SnapshotResponse>(getConnection()) {
    @Override
    public SnapshotResponse call(int callTimeout) throws ServiceException {
      return master.snapshot(null, request);
    }
  });
}
项目:pbase    文件:TestSnapshotFromAdmin.java   
/**
 * 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());
}
项目:HIndex    文件:HBaseAdmin.java   
/**
 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 * <p>
 * Only a single snapshot should be taken at a time, or results may be undefined.
 * @param snapshot snapshot to take
 * @return response from the server indicating the max time to wait for the snapshot
 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
 * @throws SnapshotCreationException if snapshot creation failed
 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
 */
public SnapshotResponse takeSnapshotAsync(SnapshotDescription snapshot) throws IOException,
    SnapshotCreationException {
  ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
  final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  // run the snapshot on the master
  return executeCallable(new MasterCallable<SnapshotResponse>(getConnection()) {
    @Override
    public SnapshotResponse call() throws ServiceException {
      return master.snapshot(null, request);
    }
  });
}
项目:HIndex    文件:TestSnapshotFromAdmin.java   
/**
 * 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());
}
项目:PyroDB    文件:HBaseAdmin.java   
/**
 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 * <p>
 * Only a single snapshot should be taken at a time, or results may be undefined.
 * @param snapshot snapshot to take
 * @return response from the server indicating the max time to wait for the snapshot
 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
 * @throws SnapshotCreationException if snapshot creation failed
 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
 */
public SnapshotResponse takeSnapshotAsync(SnapshotDescription snapshot) throws IOException,
    SnapshotCreationException {
  ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
  final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  // run the snapshot on the master
  return executeCallable(new MasterCallable<SnapshotResponse>(getConnection()) {
    @Override
    public SnapshotResponse call(int callTimeout) throws ServiceException {
      return master.snapshot(null, request);
    }
  });
}
项目:PyroDB    文件:TestSnapshotFromAdmin.java   
/**
 * 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());
}
项目:c5    文件:HBaseAdmin.java   
/**
 * Take a snapshot without waiting for the server to complete that snapshot (asynchronous)
 * <p>
 * Only a single snapshot should be taken at a time, or results may be undefined.
 * @param snapshot snapshot to take
 * @return response from the server indicating the max time to wait for the snapshot
 * @throws IOException if the snapshot did not succeed or we lose contact with the master.
 * @throws SnapshotCreationException if snapshot creation failed
 * @throws IllegalArgumentException if the snapshot request is formatted incorrectly
 */
public SnapshotResponse takeSnapshotAsync(SnapshotDescription snapshot) throws IOException,
    SnapshotCreationException {
  ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot);
  final SnapshotRequest request = SnapshotRequest.newBuilder().setSnapshot(snapshot)
      .build();
  // run the snapshot on the master
  return executeCallable(new MasterCallable<SnapshotResponse>(getConnection()) {
    @Override
    public SnapshotResponse call() throws ServiceException {
      return master.snapshot(null, request);
    }
  });
}
项目:c5    文件:TestSnapshotFromAdmin.java   
/**
 * 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());
}
项目:ditb    文件:TestSnapshotFromAdmin.java   
/**
 * 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());
}