Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Unable to add co-processor to table through HBase api


Copy link to this message
-
RE: Unable to add co-processor to table through HBase api
Yes you are right. modifyTable has to be called.

public class TestClass {
  private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
  @BeforeClass
  public static void setupBeforeClass() throws Exception {
    Configuration conf = UTIL.getConfiguration();  
    
  }
  
  @Before
  public void setUp() throws Exception{
    UTIL.startMiniCluster(1);
  }
  
  @Test
  public void testSampe() throws Exception{
    HBaseAdmin admin = UTIL.getHBaseAdmin();
    Configuration conf = UTIL.getConfiguration();
    ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
    String userTableName = "testSampe";
    HTableDescriptor htd = new HTableDescriptor(userTableName);
 
//htd.addCoprocessor("org.apache.hadoop.hbase.regionserver.MockRegionObserve
r");
    HColumnDescriptor hcd = new HColumnDescriptor("col");
    htd.addFamily(hcd);
    admin.createTable(htd);
    ZKAssign.blockUntilNoRIT(zkw);
    
    admin.disableTable(userTableName);
 
htd.addCoprocessor("org.apache.hadoop.hbase.regionserver.MockRegionObserver"
);
    admin.modifyTable(Bytes.toBytes(userTableName), htd);
    admin.enableTable(userTableName);
    HTable table = new HTable(conf, userTableName);
    
    HTableDescriptor tableDescriptor admin.getTableDescriptor(Bytes.toBytes(userTableName));
    boolean hasCoprocessor tableDescriptor.hasCoprocessor("org.apache.hadoop.hbase.regionserver.MockReg
ionObserver");
    System.out.println(hasCoprocessor);
    
    
    
  }
}

If you comment the modifyTable() you will not be able to see the coprocessor
added.
That's what I told in my previous reply itself like try doing this while
createTable itself.  If you want to add it later then its thro modify table
you can do because it involves changes the HTD.

Regards
Ram

> -----Original Message-----
> From: anil gupta [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 19, 2012 11:02 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Unable to add co-processor to table through HBase api
>
> Hi Guys,
>
> Do you mean to say that i need to call the following method after the
> call
> to addCoprocessor method:
>
> public void *modifyTable*(byte[] tableName,
>                         HTableDescriptor
> <http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescript
> or.html>
> htd)
>                  throws IOException
> <http://download.oracle.com/javase/6/docs/api/java/io/IOException.html?
> is-external=true>
>
>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdm
> in.html#modifyTable%28byte[],%20org.apache.hadoop.hbase.HTableDescripto
> r%29
>
> Thanks,
> Anil Gupta
>
> On Thu, Oct 18, 2012 at 10:23 PM, Ramkrishna.S.Vasudevan <
> [EMAIL PROTECTED]> wrote:
>
> > I can attach the code that I tried.  Here as the HTD is getting
> modified we
> > may need to call modifyTable().
> > My testclass did try this while doing creation of table itself.
> >
> > I will attach shortly.
> >
> > Regards
> > Ram
> >
> > > -----Original Message-----
> > > From: anil gupta [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, October 19, 2012 10:29 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Unable to add co-processor to table through HBase api
> > >
> > > Hi Anoop,
> > >
> > > Sorry, i am unable to understand what you mean by "have to modify
> the
> > > table
> > > calling Admin API??". Am i missing some other calls in my code?
> > >
> > > Thanks,
> > > Anil Gupta
> > >
> > > On Thu, Oct 18, 2012 at 9:43 PM, Anoop Sam John
> <[EMAIL PROTECTED]>
> > > wrote:
> > >
> > > >
> > > >
> > > >
> > >
> >hAdmin.getTableDescriptor(Bytes.toBytes(tableName)).addCoprocessor(cla
> > > ssName,
> > > >               new Path("hdfs://hbasecluster/tmp/hbase_cdh4.jar"),
> > > > Coprocessor.PRIORITY_USER,map);
> > > >
> > > > Anil,
> > > >
> > > > Don't you have to modify the table calling Admin API??  !!!!!
> Not
> > > seeing
> > > > that code here...
> > > >
> > > > -Anoop-
> > > >
> > > > ________________________________________
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB