本文整理汇总了Java中org.apache.hadoop.hbase.client.coprocessor.Batch.Callback方法的典型用法代码示例。如果您正苦于以下问题:Java Batch.Callback方法的具体用法?Java Batch.Callback怎么用?Java Batch.Callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.client.coprocessor.Batch
的用法示例。
在下文中一共展示了Batch.Callback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submitAll
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* Submit immediately the list of rows, whatever the server status. Kept for backward
* compatibility: it allows to be used with the batch interface that return an array of objects.
*
* @param pool ExecutorService to use.
* @param tableName name of the table for which the submission is made.
* @param rows the list of rows.
* @param callback the callback.
* @param results Optional array to return the results thru; backward compat.
*/
public <CResult> AsyncRequestFuture submitAll(ExecutorService pool, TableName tableName,
List<? extends Row> rows, Batch.Callback<CResult> callback, Object[] results) {
List<Action<Row>> actions = new ArrayList<Action<Row>>(rows.size());
// The position will be used by the processBatch to match the object array returned.
int posInList = -1;
NonceGenerator ng = this.connection.getNonceGenerator();
for (Row r : rows) {
posInList++;
if (r instanceof Put) {
Put put = (Put) r;
if (put.isEmpty()) {
throw new IllegalArgumentException("No columns to insert for #" + (posInList+1)+ " item");
}
}
Action<Row> action = new Action<Row>(r, posInList);
setNonce(ng, r, action);
actions.add(action);
}
AsyncRequestFutureImpl<CResult> ars = createAsyncRequestFuture(
tableName, actions, ng.getNonceGroup(), getPool(pool), callback, results, results != null);
ars.groupAndSendMultiAction(actions, 1);
return ars;
}
示例2: testSubmitWithCB
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Test
public void testSubmitWithCB() throws Exception {
ClusterConnection hc = createHConnection();
final AtomicInteger updateCalled = new AtomicInteger(0);
Batch.Callback<Object> cb = new Batch.Callback<Object>() {
@Override
public void update(byte[] region, byte[] row, Object result) {
updateCalled.incrementAndGet();
}
};
AsyncProcess ap = new MyAsyncProcess(hc, conf);
List<Put> puts = new ArrayList<Put>();
puts.add(createPut(1, true));
final AsyncRequestFuture ars = ap.submit(DUMMY_TABLE, puts, false, cb, false);
Assert.assertTrue(puts.isEmpty());
ars.waitUntilDone();
Assert.assertEquals(updateCalled.get(), 1);
}
示例3: submitMultiActions
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
<CResult> AsyncRequestFuture submitMultiActions(TableName tableName,
List<Action<Row>> retainedActions, long nonceGroup, Batch.Callback<CResult> callback,
Object[] results, boolean needResults, List<Exception> locationErrors,
List<Integer> locationErrorRows, Map<ServerName, MultiAction<Row>> actionsByServer,
ExecutorService pool) {
AsyncRequestFutureImpl<CResult> ars = createAsyncRequestFuture(
tableName, retainedActions, nonceGroup, pool, callback, results, needResults);
// Add location errors if any
if (locationErrors != null) {
for (int i = 0; i < locationErrors.size(); ++i) {
int originalIndex = locationErrorRows.get(i);
Row row = retainedActions.get(originalIndex).getAction();
ars.manageError(originalIndex, row,
Retry.NO_LOCATION_PROBLEM, locationErrors.get(i), null);
}
}
ars.sendMultiAction(actionsByServer, 1, null, false);
return ars;
}
示例4: processBatchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* Parameterized batch processing, allowing varying return types for different
* {@link Row} implementations.
* @deprecated since 0.96 - Use {@link HTableInterface#batchCallback} instead
*/
@Deprecated
public <R> void processBatchCallback(List<? extends Row> list,
final TableName tableName,
ExecutorService pool,
Object[] results,
Batch.Callback<R> callback) throws IOException, InterruptedException;
示例5: createAsyncRequestFuture
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@VisibleForTesting
/** Create AsyncRequestFuture. Isolated to be easily overridden in the tests. */
protected <CResult> AsyncRequestFutureImpl<CResult> createAsyncRequestFuture(
TableName tableName, List<Action<Row>> actions, long nonceGroup, ExecutorService pool,
Batch.Callback<CResult> callback, Object[] results, boolean needResults) {
return new AsyncRequestFutureImpl<CResult>(
tableName, actions, nonceGroup, getPool(pool), needResults, results, callback);
}
示例6: createAsyncRequestFuture
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
protected <Res> AsyncRequestFutureImpl<Res> createAsyncRequestFuture(TableName tableName,
List<Action<Row>> actions, long nonceGroup, ExecutorService pool,
Batch.Callback<Res> callback, Object[] results, boolean needResults) {
// Test HTable has tableName of null, so pass DUMMY_TABLE
AsyncRequestFutureImpl<Res> r = super.createAsyncRequestFuture(
DUMMY_TABLE, actions, nonceGroup, pool, callback, results, needResults);
allReqs.add(r);
callsCt.incrementAndGet();
return r;
}
示例7: processBatchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
@Deprecated
public <R> void processBatchCallback(
List<? extends Row> list,
byte[] tableName,
ExecutorService pool,
Object[] results,
Batch.Callback<R> callback)
throws IOException, InterruptedException {
processBatchCallback(list, TableName.valueOf(tableName), pool, results, callback);
}
示例8: batchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <R> void batchCallback(
final List<? extends Row> actions, final Object[] results, final Batch.Callback<R> callback)
throws IOException, InterruptedException {
connection.processBatchCallback(actions, tableName, pool, results, callback);
}
示例9: batchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <R> void batchCallback(List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws
IOException, InterruptedException {
if (tx == null) {
throw new IOException("Transaction not started");
}
hTable.batchCallback(transactionalizeActions(actions), results, callback);
}
示例10: batchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
@Override
public <R> Object[] batchCallback(List<? extends Row> actions, Batch.Callback<R> callback) throws IOException,
InterruptedException {
if (tx == null) {
throw new IOException("Transaction not started");
}
return hTable.batchCallback(transactionalizeActions(actions), callback);
}
示例11: batchCallback
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <R> void batchCallback(
final List<? extends Row> actions, final Object[] results, final Batch.Callback<R> callback)
throws IOException, InterruptedException {
throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
示例12: batchCoprocessorService
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <R extends Message> void batchCoprocessorService(Descriptors.MethodDescriptor methodDescriptor,
Message request, byte[] startKey, byte[] endKey, R responsePrototype,
Batch.Callback<R> callback) throws ServiceException {
throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
示例13: coprocessorService
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
<T extends Service, R> CompletableFuture<Void> coprocessorService(final String tableName, final Class<T> service, final Object startRowKey,
final Object endRowKey, final Batch.Call<T, R> callable, final Batch.Callback<R> callback) throws Exception {
return asyncExecutor.execute(new Callable<Void>() {
@Override
public Void call() throws Exception {
hbaseExecutor.coprocessorService(tableName, service, startRowKey, endRowKey, callable, callback);
return null;
}
});
}
示例14: batchCoprocessorService
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
<R extends Message> CompletableFuture<Void> batchCoprocessorService(final String tableName, final Descriptors.MethodDescriptor methodDescriptor,
final Message request, final Object startRowKey, final Object endRowKey, final R responsePrototype, final Batch.Callback<R> callback)
throws Exception {
return asyncExecutor.execute(new Callable<Void>() {
@Override
public Void call() throws Exception {
hbaseExecutor.batchCoprocessorService(tableName, methodDescriptor, request, startRowKey, endRowKey, responsePrototype, callback);
return null;
}
});
}
示例15: coprocessorExec
import org.apache.hadoop.hbase.client.coprocessor.Batch; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T extends CoprocessorProtocol, R> void coprocessorExec(Class<T> protocol,
byte[] startKey, byte[] endKey, Batch.Call<T, R> callable, Batch.Callback<R> callback)
throws IOException, Throwable {
// get regions covered by the row range
List<byte[]> keys = getStartKeysInRange(startKey, endKey);
connection.processExecs(protocol, keys, tableName, pool, callable, callback);
}