001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.client.coprocessor; 019 020import java.io.IOException; 021import org.apache.yetus.audience.InterfaceAudience; 022 023/** 024 * A collection of interfaces and utilities used for interacting with custom RPC interfaces exposed 025 * by Coprocessors. 026 */ 027@InterfaceAudience.Public 028public abstract class Batch { 029 /** 030 * Defines a unit of work to be executed. 031 * <p> 032 * When used with 033 * {@link org.apache.hadoop.hbase.client.Table#coprocessorService(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call)} 034 * the implementations {@link Batch.Call#call(Object)} method will be invoked with a proxy to each 035 * region's coprocessor {@link com.google.protobuf.Service} implementation. 036 * </p> 037 * @see org.apache.hadoop.hbase.client.coprocessor.Batch 038 * @see org.apache.hadoop.hbase.client.Table#coprocessorService(byte[]) 039 * @see org.apache.hadoop.hbase.client.Table#coprocessorService(Class, byte[], byte[], 040 * org.apache.hadoop.hbase.client.coprocessor.Batch.Call) 041 * @param <T> the instance type to be passed to {@link Batch.Call#call(Object)} 042 * @param <R> the return type from {@link Batch.Call#call(Object)} 043 */ 044 @InterfaceAudience.Public 045 public interface Call<T, R> { 046 R call(T instance) throws IOException; 047 } 048 049 /** 050 * Defines a generic callback to be triggered for each {@link Batch.Call#call(Object)} result. 051 * <p> 052 * When used with 053 * {@link org.apache.hadoop.hbase.client.Table#coprocessorService(Class, byte[], byte[], org.apache.hadoop.hbase.client.coprocessor.Batch.Call)} 054 * the implementation's {@link Batch.Callback#update(byte[], byte[], Object)} method will be 055 * called with the {@link Batch.Call#call(Object)} return value from each region in the selected 056 * range. 057 * </p> 058 * @param <R> the return type from the associated {@link Batch.Call#call(Object)} 059 * @see org.apache.hadoop.hbase.client.Table#coprocessorService(Class, byte[], byte[], 060 * org.apache.hadoop.hbase.client.coprocessor.Batch.Call) 061 */ 062 @InterfaceAudience.Public 063 public interface Callback<R> { 064 void update(byte[] region, byte[] row, R result); 065 } 066}