Hi,

I want to implement EndPoint Coprocessor. From the link 
(http://www.3pillarglobal.com/insights/hbase-coprocessors) I created my own 
files as specified in the link. In the link they worked on Sum but I want to 
have Average along with Filters so I did according to what they have specified 
in the link and loaded coprocessor in static way. But when I restart the HBase 
then in web status of master and regionserver  my coprocessor class cannot be 
seen.

When I ran client code then I got an error of null pointer exception

My client code is give below
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package coprocessor;

import java.io.IOException;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HConnection;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.ipc.BlockingRpcCallback;

import com.google.protobuf.ServiceException;

import coprocessor.generated.Avg.AvgRequest;
import coprocessor.generated.Avg.AvgResponse;
import coprocessor.generated.Avg.AvgService;

public class TagAggregate {
        public static void main(String args[]) throws IOException {
                Configuration conf = HBaseConfiguration.create();
                HConnection connection = 
HConnectionManager.createConnection(conf);
                HTableInterface table = connection.getTable("TLG_2");
                final AvgRequest request = AvgRequest.newBuilder()
                                
.setFamily("TagsOnDate").setColumn("ValueFloat").build();

                try {
                        Map<byte[], Long> results = table.coprocessorService(
                                        AvgService.class, null, null,
                                        new Batch.Call<AvgService, Long>() {
                                                @Override
                                                public Long call(AvgService 
aggregate)
                                                                throws 
IOException {

                                                        BlockingRpcCallback 
rpcCallback = new BlockingRpcCallback();

                                                        aggregate.getAvg(null, 
request, rpcCallback);

                                                        
System.out.println("rpcCallback.get() value is " +rpcCallback.get());
                                                        AvgResponse response 
=(AvgResponse) rpcCallback.get();
                                                        
System.out.println("response.hasAvg():" +response.hasAvg());
                                                        return (long) 
(response.hasAvg() ? response.getAvg() : 0L);
                                                }
                                        });

                        for (Long avg : results.values()) {
                                System.out.println("Avg = " + avg);
                        }
                } catch (ServiceException e) {
                        e.printStackTrace();
                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }
}

Error I got after running client code

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
rpcCallback.get() value is null
java.lang.NullPointerException
        at coprocessor.TagAggregate$1.call(TagAggregate.java:43)
        at coprocessor.TagAggregate$1.call(TagAggregate.java:1)
        at org.apache.hadoop.hbase.client.HTable$17.call(HTable.java:1629)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)


Reply via email to