/** * Little helper to set the table byte array. If it's different than the last * table we reset the byte array. Otherwise we just use the existing array. * @param table The table we're operating against */ private void setTable(final String table) { if (!lastTable.equals(table)) { lastTable = table; BigtableTableName tableName = options .getInstanceName() .toTableName(table); lastTableBytes = tableName .toString() .getBytes(); synchronized(this) { if (bulkMutation != null) { try { bulkMutation.flush(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } bulkMutation = session.createBulkMutation(tableName); } } }
/** * Constructor for BulkRead. * @param client a {@link BigtableDataClient} object. * @param tableName a {@link BigtableTableName} object. * @param batchSizes The number of keys to lookup per RPC. * @param threadPool the {@link ExecutorService} to execute the batched reads on */ public BulkRead(BigtableDataClient client, BigtableTableName tableName, int batchSizes, ExecutorService threadPool) { this.client = client; this.tableName = tableName.toString(); this.batchSizes = batchSizes; this.threadPool = threadPool; this.batches = new HashMap<>(); }
/** * <p>getTableNameString.</p> * * @return a {@link java.lang.String} object. */ protected String getTableNameString() { return getBigtableTableName().toString(); }
/** * <p>getTableNameString.</p> * * @return a {@link java.lang.String} object. */ protected String getTableNameString() { return getBigtableTableName().toString(); }
@VisibleForTesting void waitForReplication(BigtableTableName tableName, BackOff backOff) throws InterruptedException, TimeoutException { String token = generateConsistencyToken(tableName); while (!checkConsistency(tableName, token)) { long backOffMillis; try { backOffMillis = backOff.nextBackOffMillis(); } catch (IOException e) { // Should never happen, we only use ExponentialBackOff which doesn't throw. throw new RuntimeException("Problem getting backoff: " + e); } if (backOffMillis == BackOff.STOP) { throw new TimeoutException( "Table " + tableName.toString() + " is not consistent after timeout."); } else { // sleep for backOffMillis milliseconds and retry operation. Thread.sleep(backOffMillis); } } }
BulkMutation( BigtableTableName tableName, BigtableDataClient client, OperationAccountant operationAccountant, ScheduledExecutorService retryExecutorService, BulkOptions bulkOptions) { this.tableName = tableName.toString(); this.client = client; this.retryExecutorService = retryExecutorService; this.operationAccountant = operationAccountant; this.maxRowKeyCount = bulkOptions.getBulkMaxRowKeyCount(); this.maxRequestSize = bulkOptions.getBulkMaxRequestSize(); this.autoflushMs = bulkOptions.getAutoflushMs(); }
request.setTableName(bigtableTableName.toString()); LOG.debug("Sampling rowkeys for table %s", request.getTableName());
request.setTableName(bigtableTableName.toString()); LOG.debug("Sampling rowkeys for table %s", request.getTableName());
private String generateConsistencyToken(BigtableTableName tableName) { GenerateConsistencyTokenRequest request = GenerateConsistencyTokenRequest.newBuilder().setName(tableName.toString()).build(); return createUnaryListener(request, generateConsistencyTokenRpc, request.getName()) .getBlockingResult() .getConsistencyToken(); }
private boolean checkConsistency(BigtableTableName tableName, String token) { CheckConsistencyRequest request = CheckConsistencyRequest.newBuilder() .setName(tableName.toString()) .setConsistencyToken(token) .build(); return createUnaryListener(request, checkConsistencyRpc, request.getName()) .getBlockingResult() .getConsistent(); }