Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.ClientProtocol


    // Thats ok because we make a new zk watcher for each test.
    this.watcher.registerListenerFirst(am);

    // Need to set up a fake scan of meta for the servershutdown handler
    // Make an RS Interface implementation.  Make it so a scanner can go against it.
    ClientProtocol implementation = Mockito.mock(ClientProtocol.class);
    // Get a meta row result that has region up on SERVERNAME_A

    Result r;
    if (splitRegion) {
      r = MetaMockingUtil.getMetaTableRowResultAsSplitRegion(REGIONINFO, SERVERNAME_A);
    } else {
      r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
    }

    ScanResponse.Builder builder = ScanResponse.newBuilder();
    builder.setMoreResults(true);
    builder.addResult(ProtobufUtil.toResult(r));
    Mockito.when(implementation.scan(
      (RpcController)Mockito.any(), (ScanRequest)Mockito.any())).
        thenReturn(builder.build());

    // Get a connection w/ mocked up common methods.
    HConnection connection =
View Full Code Here


    // Make an RS Interface implementation. Make it so a scanner can go against
    // it and a get to return the single region, REGIONINFO, this test is
    // messing with. Needed when "new master" joins cluster. AM will try and
    // rebuild its list of user regions and it will also get the HRI that goes
    // with an encoded name by doing a Get on .META.
    ClientProtocol ri = Mockito.mock(ClientProtocol.class);
    // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
    Result r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
    ScanResponse.Builder builder = ScanResponse.newBuilder();
    builder.setMoreResults(true);
    builder.addResult(ProtobufUtil.toResult(r));
    if (enabling) {
      Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any()))
          .thenReturn(builder.build()).thenReturn(builder.build()).thenReturn(builder.build())
          .thenReturn(builder.build()).thenReturn(builder.build())
          .thenReturn(ScanResponse.newBuilder().setMoreResults(false).build());
    } else {
      Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())).thenReturn(
          builder.build());
    }
    // If a get, return the above result too for REGIONINFO
    GetResponse.Builder getBuilder = GetResponse.newBuilder();
    getBuilder.setResult(ProtobufUtil.toResult(r));
    Mockito.when(ri.get((RpcController)Mockito.any(), (GetRequest) Mockito.any())).
      thenReturn(getBuilder.build());
    // Get a connection w/ mocked up common methods.
    HConnection connection = HConnectionTestingUtility.
      getMockedConnectionAndDecorate(HTU.getConfiguration(), null,
        ri, SERVERNAME_B, REGIONINFO);
View Full Code Here

    private final CatalogTracker ct;

    MockServer(final HBaseTestingUtility htu)
    throws NotAllMetaRegionsOnlineException, IOException, InterruptedException {
      this.c = htu.getConfiguration();
      ClientProtocol ri = Mockito.mock(ClientProtocol.class);
      MutateResponse.Builder builder = MutateResponse.newBuilder();
      builder.setProcessed(true);
      try {
        Mockito.when(ri.mutate(
          (RpcController)Mockito.any(), (MutateRequest)Mockito.any())).
            thenReturn(builder.build());
      } catch (ServiceException se) {
        throw ProtobufUtil.getRemoteException(se);
      }
View Full Code Here

    HConnection connection;
    CatalogTracker ct = null;
    try {
      // Mock an ClientProtocol. Our mock implementation will fail a few
      // times when we go to open a scanner.
      final ClientProtocol implementation = Mockito.mock(ClientProtocol.class);
      // When scan called throw IOE 'Server not running' a few times
      // before we return a scanner id.  Whats WEIRD is that these
      // exceptions do not show in the log because they are caught and only
      // printed if we FAIL.  We eventually succeed after retry so these don't
      // show.  We will know if they happened or not because we will ask
      // mockito at the end of this test to verify that scan was indeed
      // called the wanted number of times.
      List<KeyValue> kvs = new ArrayList<KeyValue>();
      final byte [] rowToVerify = Bytes.toBytes("rowToVerify");
      kvs.add(new KeyValue(rowToVerify,
        HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
        HRegionInfo.FIRST_META_REGIONINFO.toByteArray()));
      kvs.add(new KeyValue(rowToVerify,
        HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
        Bytes.toBytes(sn.getHostAndPort())));
      kvs.add(new KeyValue(rowToVerify,
        HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
        Bytes.toBytes(sn.getStartcode())));
      final Result [] results = new Result [] {new Result(kvs)};
      ScanResponse.Builder builder = ScanResponse.newBuilder();
      for (Result result: results) {
        builder.addResult(ProtobufUtil.toResult(result));
      }
      Mockito.when(implementation.scan(
        (RpcController)Mockito.any(), (ScanRequest)Mockito.any())).
          thenThrow(new ServiceException("Server not running (1 of 3)")).
          thenThrow(new ServiceException("Server not running (2 of 3)")).
          thenThrow(new ServiceException("Server not running (3 of 3)")).
          thenReturn(ScanResponse.newBuilder().setScannerId(1234567890L).build())
View Full Code Here

    Mockito.when(c.getRegionLocation((byte[]) Mockito.any(),
        (byte[]) Mockito.any(), Mockito.anyBoolean())).
      thenReturn(loc);
    Mockito.when(c.locateRegion((byte[]) Mockito.any(), (byte[]) Mockito.any())).
      thenReturn(loc);
    ClientProtocol hri = Mockito.mock(ClientProtocol.class);
    Mockito.when(hri.bulkLoadHFile((RpcController)Mockito.any(), (BulkLoadHFileRequest)Mockito.any())).
      thenThrow(new ServiceException(new IOException("injecting bulk load error")));
    Mockito.when(c.getClient(Mockito.any(ServerName.class))).
      thenReturn(hri);
    return c;
  }
View Full Code Here

   * @throws ServiceException
   * @throws InterruptedException
   */
  @Test public void testInterruptWaitOnMeta()
  throws IOException, InterruptedException, ServiceException {
    final ClientProtocol client = Mockito.mock(ClientProtocol.class);
    HConnection connection = mockConnection(null, client);
    try {
      Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())).
      thenReturn(GetResponse.newBuilder().build());
      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
      ServerName meta = ct.getMetaLocation();
      Assert.assertNull(meta);
      Thread t = new Thread() {
View Full Code Here

  }

  private void testVerifyMetaRegionLocationWithException(Exception ex)
  throws IOException, InterruptedException, KeeperException, ServiceException {
    // Mock an ClientProtocol.
    final ClientProtocol implementation = Mockito.mock(ClientProtocol.class);
    HConnection connection = mockConnection(null, implementation);
    try {
      // If a 'get' is called on mocked interface, throw connection refused.
      Mockito.when(implementation.get((RpcController) Mockito.any(), (GetRequest) Mockito.any())).
        thenThrow(new ServiceException(ex));
      // Now start up the catalogtracker with our doctored Connection.
      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
      try {
        MetaRegionTracker.setMetaLocation(this.watcher, SN);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.ClientProtocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.