Ok Anil.. Not a problem.. My intention was to just see if the api was
working during createtable so that it will help you.

Regards
Ram

> -----Original Message-----
> From: anil gupta [mailto:anilgupt...@gmail.com]
> Sent: Friday, October 19, 2012 11:22 AM
> To: user@hbase.apache.org
> Subject: Re: Unable to add co-processor to table through HBase api
> 
> Thanks a lot Guys. I really appreciate you help. I'll try this change
> in
> the morning and let you know the outcome.
> 
> @Ram: Actually, i was trying to add the coprocessor to a per-existing
> table. I think yesterday you assumed that I am trying to add the
> coprocessor while creating the table. That's why there was a confusion
> between us.
> 
> On Thu, Oct 18, 2012 at 10:40 PM, Ramkrishna.S.Vasudevan <
> ramkrishna.vasude...@huawei.com> wrote:
> 
> > 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.MockRegionOb
> serve
> > 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.MockRegionObse
> rver"
> > );
> >     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.Mo
> ckReg
> > 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:anilgupt...@gmail.com]
> > > Sent: Friday, October 19, 2012 11:02 AM
> > > To: user@hbase.apache.org
> > > 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 <
> > > ramkrishna.vasude...@huawei.com> 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:anilgupt...@gmail.com]
> > > > > Sent: Friday, October 19, 2012 10:29 AM
> > > > > To: user@hbase.apache.org
> > > > > 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
> > > <anoo...@huawei.com>
> > > > > 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-
> > > > > >
> > > > > > ________________________________________
> > > > > > From: anil gupta [anilgupt...@gmail.com]
> > > > > > Sent: Friday, October 19, 2012 2:46 AM
> > > > > > To: user@hbase.apache.org
> > > > > > Subject: Re: Unable to add co-processor to table through
> HBase
> > > api
> > > > > >
> > > > > > Hi Folks,
> > > > > >
> > > > > > Still, i am unable to add the co-processors through HBase
> client
> > > api.
> > > > > This
> > > > > > time i tried loading the coprocessor by providing the jar
> path
> > > along
> > > > > with
> > > > > > parameters. But, it failed.
> > > > > > I was able to add the same coprocessor to the table through
> HBase
> > > > > shell.
> > > > > > I also dont see any logs regarding adding coprocessors in
> > > > > regionservers
> > > > > > when i try to add the co-processor through api.I strongly
> feel
> > > that
> > > > > HBase
> > > > > > client api for adding coprocessor seems to be broken. Please
> let
> > > me
> > > > > know if
> > > > > > the code below seems to be problematic.
> > > > > >
> > > > > > Here is the code i used to add the coprocessor through HBase
> api:
> > > > > >     private static void modifyTable() throws IOException
> > > > > >     {
> > > > > >     Configuration conf = HBaseConfiguration.create();
> > > > > >     HBaseAdmin hAdmin = new HBaseAdmin(conf);
> > > > > >     String tableName = "txn";
> > > > > >     hAdmin.disableTable(tableName);
> > > > > >     if(!hAdmin.isTableEnabled(tableName))
> > > > > >     {
> > > > > >       System.out.println("Trying to add coproc to table"); //
> > > using
> > > > > err so
> > > > > > that it's easy to read this on eclipse console.
> > > > > >       HashMap<String, String> map = new
> HashMap<String,String>();
> > > > > >       map.put("arg1", "batchdate");
> > > > > >       String className =
> > > > > >
> > > > >
> > >
> "com.intuit.ihub.hbase.poc.coprocessor.observer.IhubTxnRegionObserver";
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > >
> hAdmin.getTableDescriptor(Bytes.toBytes(tableName)).addCoprocessor(clas
> > > > > sName,
> > > > > >               new
> Path("hdfs://hbasecluster/tmp/hbase_cdh4.jar"),
> > > > > > Coprocessor.PRIORITY_USER,map);
> > > > > >
> > > > > >       if(
> > > > > >
> > > > > >
> > > > >
> > >
> hAdmin.getTableDescriptor(Bytes.toBytes(tableName)).hasCoprocessor(clas
> > > > > sName)
> > > > > >               )
> > > > > >       {
> > > > > >         System.err.println("YIPPPPPPPPPIEEEEE!!!!!!!");
> > > > > >       }
> > > > > >       hAdmin.enableTable(tableName);
> > > > > >
> > > > > >     }
> > > > > >     hAdmin.close();
> > > > > >    }
> > > > > >
> > > > > > Thanks,
> > > > > > Anil Gupta
> > > > > >
> > > > > > On Wed, Oct 17, 2012 at 9:27 PM, Ramkrishna.S.Vasudevan <
> > > > > > ramkrishna.vasude...@huawei.com> wrote:
> > > > > >
> > > > > > > Do let me know if you are stuck up.  May be I did not get
> your
> > > > > actual
> > > > > > > problem.
> > > > > > >
> > > > > > > All the best.
> > > > > > >
> > > > > > > Regards
> > > > > > > Ram
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: anil gupta [mailto:anilgupt...@gmail.com]
> > > > > > > > Sent: Wednesday, October 17, 2012 11:34 PM
> > > > > > > > To: user@hbase.apache.org
> > > > > > > > Subject: Re: Unable to add co-processor to table through
> > > HBase
> > > > > api
> > > > > > > >
> > > > > > > > Hi Ram,
> > > > > > > >
> > > > > > > > The table exists and I don't get any error while running
> the
> > > > > program(i
> > > > > > > > would get an error if the table did not exist). I am
> running
> > > a
> > > > > > > > distributed
> > > > > > > > cluster.
> > > > > > > >
> > > > > > > > Tried following additional ways also:
> > > > > > > >
> > > > > > > >    1. I tried loading the AggregationImplementation
> coproc.
> > > > > > > >    2. I also tried adding the coprocs while the table is
> > > enabled.
> > > > > > > >
> > > > > > > >
> > > > > > > > Also had a look at the JUnit test cases and could not
> find
> > > any
> > > > > > > > difference.
> > > > > > > >
> > > > > > > > I am going to try adding the coproc along with jar in
> Hdfs
> > > and
> > > > > see what
> > > > > > > > happens.
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > > Anil Gupta
> > > > > > > >
> > > > > > > > On Tue, Oct 16, 2012 at 11:44 PM, Ramkrishna.S.Vasudevan
> <
> > > > > > > > ramkrishna.vasude...@huawei.com> wrote:
> > > > > > > >
> > > > > > > > > I tried out a sample test class.  It is working
> properly.
> > > I
> > > > > just
> > > > > > > > have a
> > > > > > > > > doubt whether you are doing the
> > > > > > > > > Htd.addCoprocessor() step before creating the table?
> Try
> > > that
> > > > > way
> > > > > > > > hope it
> > > > > > > > > should work.
> > > > > > > > >
> > > > > > > > > Regards
> > > > > > > > > Ram
> > > > > > > > >
> > > > > > > > > > -----Original Message-----
> > > > > > > > > > From: anil gupta [mailto:anilgupt...@gmail.com]
> > > > > > > > > > Sent: Wednesday, October 17, 2012 4:05 AM
> > > > > > > > > > To: user@hbase.apache.org
> > > > > > > > > > Subject: Unable to add co-processor to table through
> > > HBase
> > > > > api
> > > > > > > > > >
> > > > > > > > > > Hi All,
> > > > > > > > > >
> > > > > > > > > > I would like to add a RegionObserver to a HBase table
> > > through
> > > > > HBase
> > > > > > > > > > api. I
> > > > > > > > > > don't want to put this RegionObserver as a user or
> system
> > > co-
> > > > > > > > processor
> > > > > > > > > > in
> > > > > > > > > > hbase-site.xml since this is specific to a table. So,
> > > option
> > > > > of
> > > > > > > > using
> > > > > > > > > > hbase
> > > > > > > > > > properties is out. I have already copied the jar file
> in
> > > the
> > > > > > > > classpath
> > > > > > > > > > of
> > > > > > > > > > region server and restarted the cluster.
> > > > > > > > > >
> > > > > > > > > > Can any one point out the problem in following code
> for
> > > > > adding the
> > > > > > > > > > co-processor to the table:
> > > > > > > > > >     private void modifyTable(String name) throws
> > > IOException
> > > > > > > > > >     {
> > > > > > > > > >     Configuration conf = HBaseConfiguration.create();
> > > > > > > > > >     HBaseAdmin hAdmin = new HBaseAdmin(conf);
> > > > > > > > > >     hAdmin.disableTable("txn_subset");
> > > > > > > > > >     if(!hAdmin.isTableEnabled("txn_subset"))
> > > > > > > > > >     {
> > > > > > > > > >       System.err.println("Trying to add coproc to
> > > table"); //
> > > > > using
> > > > > > > > err
> > > > > > > > > > so
> > > > > > > > > > that it's easy to read this on eclipse console.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > >
> > >
> hAdmin.getTableDescriptor(Bytes.toBytes("txn_subset")).addCoprocessor("
> > > > > > > > > >
> > > > >
> com.intuit.hbase.poc.coprocessor.observer.IhubTxnRegionObserver");
> > > > > > > > > >       if(
> > > > > > > > > >
> > > > > > > >
> > > > >
> > >
> hAdmin.getTableDescriptor(Bytes.toBytes("txn_subset")).hasCoprocessor("
> > > > > > > > > >
> > > > >
> com.intuit.hbase.poc.coprocessor.observer.IhubTxnRegionObserver")
> > > > > > > > > > )
> > > > > > > > > >       {
> > > > > > > > > >
> System.err.println("YIPPPPPPPPPIEEEEE!!!!!!!");
> > > > > > > > > >       }
> > > > > > > > > >       hAdmin.enableTable("ihub_txn_subset");
> > > > > > > > > >     }
> > > > > > > > > >     hAdmin.close();
> > > > > > > > > >         }*
> > > > > > > > > > *
> > > > > > > > > > --
> > > > > > > > > > Thanks & Regards,
> > > > > > > > > > Anil Gupta
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks & Regards,
> > > > > > > > Anil Gupta
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks & Regards,
> > > > > > Anil Gupta
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks & Regards,
> > > > > Anil Gupta
> > > >
> > > >
> > >
> > >
> > > --
> > > Thanks & Regards,
> > > Anil Gupta
> >
> >
> 
> 
> --
> Thanks & Regards,
> Anil Gupta

Reply via email to