Java 类org.apache.hadoop.hbase.client.RpcRetryingCaller 实例源码

项目:hbase    文件:TestSpaceQuotas.java   
@Test(timeout=120000)
public void testNoBulkLoadsWithNoWrites() throws Exception {
  Put p = new Put(Bytes.toBytes("to_reject"));
  p.addColumn(
      Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
  TableName tableName = writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, p);

  // The table is now in violation. Try to do a bulk load
  ClientServiceCallable<Void> callable = generateFileToLoad(tableName, 1, 50);
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(TEST_UTIL.getConfiguration());
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  try {
    caller.callWithRetries(callable, Integer.MAX_VALUE);
    fail("Expected the bulk load call to fail!");
  } catch (SpaceLimitingException e) {
    // Pass
    LOG.trace("Caught expected exception", e);
  }
}
项目:ditb    文件:TestHRegionServerBulkLoad.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(
      NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final HConnection conn = UTIL.getHBaseAdmin().getConnection();
  RegionServerCallable<Void> callable =
      new RegionServerCallable<Void>(conn, tableName, Bytes.toBytes("aaa")) {
    @Override
    public Void call(int callTimeout) throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      BulkLoadHFileRequest request =
        RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true);
      getStub().bulkLoadHFile(null, request);
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 10 == 0) {
    // 10 * 50 = 500 open file handles!
    callable = new RegionServerCallable<Void>(conn, tableName, Bytes.toBytes("aaa")) {
      @Override
      public Void call(int callTimeout) throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:pbase    文件:TestHRegionServerBulkLoad.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(
      NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final HConnection conn = UTIL.getHBaseAdmin().getConnection();
  RegionServerCallable<Void> callable =
      new RegionServerCallable<Void>(conn, tableName, Bytes.toBytes("aaa")) {
    @Override
    public Void call(int callTimeout) throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      BulkLoadHFileRequest request =
        RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true);
      getStub().bulkLoadHFile(null, request);
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 10 == 0) {
    // 10 * 50 = 500 open file handles!
    callable = new RegionServerCallable<Void>(conn, tableName, Bytes.toBytes("aaa")) {
      @Override
      public Void call(int callTimeout) throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:HIndex    文件:TestHRegionServerBulkLoad.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(
      NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final HConnection conn = UTIL.getHBaseAdmin().getConnection();
  TableName tbl = TableName.valueOf(tableName);
  RegionServerCallable<Void> callable =
      new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
    @Override
    public Void call() throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      BulkLoadHFileRequest request =
        RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true);
      getStub().bulkLoadHFile(null, request);
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 10 == 0) {
    // 10 * 50 = 500 open file handles!
    callable = new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
      @Override
      public Void call() throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable);
  }
}
项目:hbase    文件:TestHRegionServerBulkLoadWithOldSecureEndpoint.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<>(NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final ClusterConnection conn = (ClusterConnection) UTIL.getAdmin().getConnection();
  Table table = conn.getTable(tableName);
  final String bulkToken = new SecureBulkLoadEndpointClient(table).prepareBulkLoad(tableName);
  RpcControllerFactory rpcControllerFactory = new RpcControllerFactory(UTIL.getConfiguration());
  ClientServiceCallable<Void> callable =
      new ClientServiceCallable<Void>(conn, tableName, Bytes.toBytes("aaa"),
          rpcControllerFactory.newController(), HConstants.PRIORITY_UNSET) {
        @Override
        protected Void rpcCall() throws Exception {
          LOG.debug("Going to connect to server " + getLocation() + " for row " +
              Bytes.toStringBinary(getRow()));
          try (Table table = conn.getTable(getTableName())) {
            boolean loaded = new SecureBulkLoadEndpointClient(table).bulkLoadHFiles(famPaths,
                null, bulkToken, getLocation().getRegionInfo().getStartKey());
          }
          return null;
        }
      };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 5 == 0) {
    // 5 * 50 = 250 open file handles!
    callable = new ClientServiceCallable<Void>(conn, tableName, Bytes.toBytes("aaa"),
        rpcControllerFactory.newController(), HConstants.PRIORITY_UNSET) {
      @Override
      protected Void rpcCall() throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:hbase    文件:TestHRegionServerBulkLoad.java   
@Override
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<>(NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final ClusterConnection conn = (ClusterConnection)UTIL.getConnection();
  Table table = conn.getTable(tableName);
  final String bulkToken = new SecureBulkLoadClient(UTIL.getConfiguration(), table).
      prepareBulkLoad(conn);
  ClientServiceCallable<Void> callable = new ClientServiceCallable<Void>(conn,
      tableName, Bytes.toBytes("aaa"),
      new RpcControllerFactory(UTIL.getConfiguration()).newController(), HConstants.PRIORITY_UNSET) {
    @Override
    public Void rpcCall() throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      SecureBulkLoadClient secureClient = null;
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      try (Table table = conn.getTable(getTableName())) {
        secureClient = new SecureBulkLoadClient(UTIL.getConfiguration(), table);
        secureClient.secureBulkLoadHFiles(getStub(), famPaths, regionName,
              true, null, bulkToken);
      }
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 5 == 0) {
    // 5 * 50 = 250 open file handles!
    callable = new ClientServiceCallable<Void>(conn,
        tableName, Bytes.toBytes("aaa"),
        new RpcControllerFactory(UTIL.getConfiguration()).newController(), HConstants.PRIORITY_UNSET) {
      @Override
      protected Void rpcCall() throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request = RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:hbase    文件:TestHRegionServerBulkLoadWithOldClient.java   
@Override
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<>(NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final ClusterConnection conn = (ClusterConnection) UTIL.getAdmin().getConnection();
  RpcControllerFactory rpcControllerFactory = new RpcControllerFactory(UTIL.getConfiguration());
  ClientServiceCallable<Void> callable =
      new ClientServiceCallable<Void>(conn, tableName,
          Bytes.toBytes("aaa"), rpcControllerFactory.newController(), HConstants.PRIORITY_UNSET) {
    @Override
    protected Void rpcCall() throws Exception {
      LOG.info("Non-secure old client");
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
          BulkLoadHFileRequest request =
              RequestConverter
                  .buildBulkLoadHFileRequest(famPaths, regionName, true, null, null);
          getStub().bulkLoadHFile(null, request);
          return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 5 == 0) {
    // 5 * 50 = 250 open file handles!
    callable = new ClientServiceCallable<Void>(conn, tableName,
        Bytes.toBytes("aaa"), rpcControllerFactory.newController(), HConstants.PRIORITY_UNSET) {
      @Override
      protected Void rpcCall() throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:PyroDB    文件:TestHRegionServerBulkLoad.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(
      NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final HConnection conn = UTIL.getHBaseAdmin().getConnection();
  TableName tbl = TableName.valueOf(tableName);
  RegionServerCallable<Void> callable =
      new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
    @Override
    public Void call(int callTimeout) throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      BulkLoadHFileRequest request =
        RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true);
      getStub().bulkLoadHFile(null, request);
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable, Integer.MAX_VALUE);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 10 == 0) {
    // 10 * 50 = 500 open file handles!
    callable = new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
      @Override
      public Void call(int callTimeout) throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable, Integer.MAX_VALUE);
  }
}
项目:c5    文件:TestHRegionServerBulkLoad.java   
public void doAnAction() throws Exception {
  long iteration = numBulkLoads.getAndIncrement();
  Path dir =  UTIL.getDataTestDirOnTestFS(String.format("bulkLoad_%08d",
      iteration));

  // create HFiles for different column families
  FileSystem fs = UTIL.getTestFileSystem();
  byte[] val = Bytes.toBytes(String.format("%010d", iteration));
  final List<Pair<byte[], String>> famPaths = new ArrayList<Pair<byte[], String>>(
      NUM_CFS);
  for (int i = 0; i < NUM_CFS; i++) {
    Path hfile = new Path(dir, family(i));
    byte[] fam = Bytes.toBytes(family(i));
    createHFile(fs, hfile, fam, QUAL, val, 1000);
    famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
  }

  // bulk load HFiles
  final HConnection conn = UTIL.getHBaseAdmin().getConnection();
  TableName tbl = TableName.valueOf(tableName);
  RegionServerCallable<Void> callable =
      new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
    @Override
    public Void call() throws Exception {
      LOG.debug("Going to connect to server " + getLocation() + " for row "
          + Bytes.toStringBinary(getRow()));
      byte[] regionName = getLocation().getRegionInfo().getRegionName();
      BulkLoadHFileRequest request =
        RequestConverter.buildBulkLoadHFileRequest(famPaths, regionName, true);
      getStub().bulkLoadHFile(null, request);
      return null;
    }
  };
  RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(conf);
  RpcRetryingCaller<Void> caller = factory.<Void> newCaller();
  caller.callWithRetries(callable);

  // Periodically do compaction to reduce the number of open file handles.
  if (numBulkLoads.get() % 10 == 0) {
    // 10 * 50 = 500 open file handles!
    callable = new RegionServerCallable<Void>(conn, tbl, Bytes.toBytes("aaa")) {
      @Override
      public Void call() throws Exception {
        LOG.debug("compacting " + getLocation() + " for row "
            + Bytes.toStringBinary(getRow()));
        AdminProtos.AdminService.BlockingInterface server =
          conn.getAdmin(getLocation().getServerName());
        CompactRegionRequest request =
          RequestConverter.buildCompactRegionRequest(
            getLocation().getRegionInfo().getRegionName(), true, null);
        server.compactRegion(null, request);
        numCompactions.incrementAndGet();
        return null;
      }
    };
    caller.callWithRetries(callable);
  }
}