private void handleCallback(final Object result) { final Deferred<R> d = deferred; if (d == null) { LOG.debug("Handling a callback on RPC {} with no deferred attached!", this); return; } deferred = null; attempt = 0; // If the subclass is a "tracked RPC" unregister it, unless it never // got to the point of being registered. if (isRequestTracked() && sequenceId != RequestTracker.NO_SEQ_NO) { table.getAsyncClient().getRequestTracker().rpcCompleted(sequenceId); sequenceId = RequestTracker.NO_SEQ_NO; } deadlineTracker.reset(); traces.clear(); parentRpc = null; d.callback(result); }
@InterfaceAudience.LimitedPrivate("Test") List<Deferred<ConnectToMasterResponsePB>> connectToMasters( KuduTable masterTable, KuduRpc<?> parentRpc, long defaultTimeoutMs, Connection.CredentialsPolicy credentialsPolicy) { // Try to connect to each master. The ConnectToCluster instance // waits until it gets a good response before firing the returned // deferred. List<Deferred<ConnectToMasterResponsePB>> deferreds = new ArrayList<>(); for (HostAndPort hostAndPort : masterAddrs) { Deferred<ConnectToMasterResponsePB> d; RpcProxy proxy = masterTable.getAsyncClient().newMasterRpcProxy( hostAndPort, credentialsPolicy); if (proxy != null) { d = connectToMaster(masterTable, proxy, parentRpc, defaultTimeoutMs); } else { String message = "Couldn't resolve this master's address " + hostAndPort.toString(); LOG.warn(message); Status statusIOE = Status.IOError(message); d = Deferred.fromError(new NonRecoverableException(statusIOE)); } d.addCallbacks(callbackForNode(hostAndPort), errbackForNode(hostAndPort)); deferreds.add(d); } return deferreds; }
public static List<String> scanTableToStrings(KuduTable table, KuduPredicate... predicates) throws Exception { List<String> rowStrings = Lists.newArrayList(); KuduScanner.KuduScannerBuilder scanBuilder = table.getAsyncClient().syncClient().newScannerBuilder(table); for (KuduPredicate predicate : predicates) { scanBuilder.addPredicate(predicate); } KuduScanner scanner = scanBuilder.build(); while (scanner.hasMoreRows()) { RowResultIterator rows = scanner.nextRows(); for (RowResult r : rows) { rowStrings.add(r.rowToString()); } } Collections.sort(rowStrings); return rowStrings; }
/** * Scans the table and returns the number of rows. * @param table the table * @param predicates optional predicates to apply to the scan * @return the number of rows in the table matching the predicates */ public static long countRowsInTable(KuduTable table, KuduPredicate... predicates) throws KuduException { KuduScanner.KuduScannerBuilder scanBuilder = table.getAsyncClient().syncClient().newScannerBuilder(table); for (KuduPredicate predicate : predicates) { scanBuilder.addPredicate(predicate); } scanBuilder.setProjectedColumnIndexes(ImmutableList.<Integer>of()); return countRowsInScan(scanBuilder.build()); }
if (table.getAsyncClient().getLastPropagatedTimestamp() != AsyncKuduClient.NO_TIMESTAMP) { proto.setPropagatedTimestamp(client.getLastPropagatedTimestamp());
Preconditions.checkArgument(operation.getTable().getAsyncClient() == client, "Applied operations must be created from a KuduTable instance opened " + "from the same client that opened this KuduSession");
timestamp = lowerBoundPropagationTimestamp; } else { timestamp = table.getAsyncClient().getLastPropagatedTimestamp();