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