You used createTable() API but the log said: Table already exists
On Jul 12, 2013, at 2:22 AM, ch huang <[email protected]> wrote: > hi,all: > i spend all day for the problem ,and now totally exhausted,hope > anyone can help me > > i code myself endpoint ,the logic is sample run the scan in some region > with a filter and count the found records, > i do not want my endpoint work for each region,i just need it work for my > test table region.i compile and pack the MyTestProtocol and MyTestEndpoint > into jar > and put the jar into HDFS,and write the info into HTableDescriptor ,and use > it create the test table. > > my testing code > > import java.io.IOException; > import java.util.Map; > > import org.apache.commons.net.bsd.RExecClient; > import org.apache.hadoop.conf.Configuration; > import org.apache.hadoop.fs.Path; > import org.apache.hadoop.hbase.Coprocessor.*; > import org.apache.hadoop.hbase.Coprocessor; > import org.apache.hadoop.hbase.HBaseConfiguration; > import org.apache.hadoop.hbase.HColumnDescriptor; > import org.apache.hadoop.hbase.HTableDescriptor; > import org.apache.hadoop.hbase.client.HBaseAdmin; > import org.apache.hadoop.hbase.client.HTable; > import org.apache.hadoop.hbase.client.Put; > import org.apache.hadoop.hbase.client.Scan; > import org.apache.hadoop.hbase.client.coprocessor.Batch; > import org.apache.hadoop.hbase.filter.CompareFilter; > import org.apache.hadoop.hbase.filter.Filter; > import org.apache.hadoop.hbase.filter.RegexStringComparator; > import org.apache.hadoop.hbase.filter.ValueFilter; > import org.apache.hadoop.hbase.util.Bytes; > > public class TestMyCo { > /** > * @param args > */ > public static void main(String[] args) throws IOException { > // TODO Auto-generated method stub > Configuration conf = HBaseConfiguration.create(); > conf.addResource( "hbase-site.xml"); > String tableName = "mytest"; > > HBaseAdmin admin = new HBaseAdmin(conf); > if (admin.tableExists(tableName)) { > System. out.println("table already exists!drop it\n" ); > admin.disableTable(tableName); > admin.deleteTable(tableName); > } > > final Scan scan = new Scan(); > scan.addColumn("myfl".getBytes(), "myqf".getBytes()); > final Filter filter = new ValueFilter(CompareFilter.CompareOp.EQUAL,new > RegexStringComparator(".*\\.5")); > HTableDescriptor htd = new HTableDescriptor(); > HColumnDescriptor hcd = new HColumnDescriptor("myfl".getBytes()); > htd.addFamily(hcd); > htd.setName(tableName.getBytes()); > Path path = new Path("hdfs:///192.168.10.22:9000/alex/test.jar"); > System.out.println(": > "+path.toString()+"|"+TestMyCo.class.getCanonicalName()+"|"+Coprocessor.PRIORITY_USER); > > htd.setValue("COPROCESSOR$1", path.toString()+"|" > + TestMyCo.class.getCanonicalName()+"|"+Coprocessor.PRIORITY_USER); > > admin.createTable(htd); > HTable table = new HTable(conf,tableName); > Put put = new Put(Bytes.toBytes("row1")); > put.add("myfl".getBytes(), "myqf".getBytes(), "myv.5".getBytes()); > table.put(put); > try{ > Map<byte[],Long> results = > table.coprocessorExec(MyTestProtocol.class, null, null, > new Batch.Call<MyTestProtocol, Long>() { > public Long call(MyTestProtocol mycheck) throws > IOException { > return mycheck.myFilter(scan, filter); > } > }); > for(Map.Entry<byte[], Long> entry : results.entrySet()){ > System.out.println("find : " +entry.getKey() + " : " + > entry.getValue() ); > } > > }catch(Throwable throwable){ > throwable.printStackTrace(); > } > } > } > > hbase error info > > log4j:WARN No appenders could be found for logger > (org.apache.hadoop.metrics2.lib.MutableMetricsFactory). > log4j:WARN Please initialize the log4j system properly. > log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for > more info. > SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". > SLF4J: Defaulting to no-operation (NOP) logger implementation > SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further > details. > table already exists!drop it > : hdfs:/192.168.10.22:9000/alex/test.jar|TestMyCo|1073741823 > org.apache.hadoop.hbase.ipc.HBaseRPC$UnknownProtocolException: > org.apache.hadoop.hbase.ipc.HBaseRPC$UnknownProtocolException: No matching > handler for protocol MyTestProtocol in region > mytest,,1373620889656.eb4e9026641447abad7d825feb35a8d9. > at org.apache.hadoop.hbase.regionserver.HRegion.exec(HRegion.java:5463) > at > org.apache.hadoop.hbase.regionserver.HRegionServer.execCoprocessor(HRegionServer.java:3720) > at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.hadoop.hbase.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:320) > at > org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1426) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) > at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown > Source) > at java.lang.reflect.Constructor.newInstance(Unknown Source) > at > org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.java:90) > at > org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.java:79) > at > org.apache.hadoop.hbase.client.ServerCallable.translateException(ServerCallable.java:228) > at > org.apache.hadoop.hbase.client.ServerCallable.withRetries(ServerCallable.java:166) > at > org.apache.hadoop.hbase.ipc.ExecRPCInvoker.invoke(ExecRPCInvoker.java:79) > at com.sun.proxy.$Proxy9.myFilter(Unknown Source) > at TestMyCo$1.call(TestMyCo.java:66) > at TestMyCo$1.call(TestMyCo.java:1) > at > org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation$4.call(HConnectionManager.java:1466) > at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) > at java.util.concurrent.FutureTask.run(Unknown Source) > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) > at java.lang.Thread.run(Unknown Source) > Caused by: > org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hbase.ipc.HBaseRPC$UnknownProtocolException): > org.apache.hadoop.hbase.ipc.HBaseRPC$UnknownProtocolException: No matching > handler for protocol MyTestProtocol in region > mytest,,1373620889656.eb4e9026641447abad7d825feb35a8d9. > at org.apache.hadoop.hbase.regionserver.HRegion.exec(HRegion.java:5463) > at > org.apache.hadoop.hbase.regionserver.HRegionServer.execCoprocessor(HRegionServer.java:3720) > at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.apache.hadoop.hbase.ipc.WritableRpcEngine$Server.call(WritableRpcEngine.java:320) > at > org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:1426) > at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:995) > at > org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:86) > at com.sun.proxy.$Proxy8.execCoprocessor(Unknown Source) > at > org.apache.hadoop.hbase.ipc.ExecRPCInvoker$1.call(ExecRPCInvoker.java:75) > at > org.apache.hadoop.hbase.ipc.ExecRPCInvoker$1.call(ExecRPCInvoker.java:73) > at > org.apache.hadoop.hbase.client.ServerCallable.withRetries(ServerCallable.java:163) > ... 10 more
