You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Yossi Ittach <yo...@gmail.com> on 2008/11/10 09:06:54 UTC

How to start a Configuration (Java API) with a specific file?

Hi all

I want to specify in the code which hbase-site.xml file will be used as a
source for configuration. I tried to use addResources() but it doesn't work
- the path is added , but nothing happends - it's automatically goes for the
defaults (127.0.0.1:6000) . Can you please advise?

This is the code:


       conf = new HBaseConfiguration();
        Path sitePath = new Path("util/hbase-site.xml");
        Path defualtPath = new Path("util/hbase-default.xml");

        conf.addResource(sitePath);
        conf.addResource(defualtPath);

        try {
            admin = new HBaseAdmin(conf);
        } catch (MasterNotRunningException e) {
            e.printStackTrace();
        }


Thanks

Vale et me ama
Yossi

Re: How to start a Configuration (Java API) with a specific file?

Posted by stack <st...@duboce.net>.
You know about the HBASE_CONF_DIR environment variable?  You could set 
it to point to different locations when you launch your job.

Doing it in code, it depends on the context.  Be sure to read the 
addResource code and see how it works (there are configurations that 
cannot be overridden).  Then, make sure that there are not other 
hbase-*.xml files ahead of yours in the CLASSPATH (Check job jars for 
bundled hbase-*.xmls).  Using names other than hbase-*.xml might also 
help IIRC.

St.Ack


Yossi Ittach wrote:
> Hi all
>
> I want to specify in the code which hbase-site.xml file will be used as a
> source for configuration. I tried to use addResources() but it doesn't work
> - the path is added , but nothing happends - it's automatically goes for the
> defaults (127.0.0.1:6000) . Can you please advise?
>
> This is the code:
>
>
>        conf = new HBaseConfiguration();
>         Path sitePath = new Path("util/hbase-site.xml");
>         Path defualtPath = new Path("util/hbase-default.xml");
>
>         conf.addResource(sitePath);
>         conf.addResource(defualtPath);
>
>         try {
>             admin = new HBaseAdmin(conf);
>         } catch (MasterNotRunningException e) {
>             e.printStackTrace();
>         }
>
>
> Thanks
>
> Vale et me ama
> Yossi
>
>   


Re: How to start a Configuration (Java API) with a specific file?

Posted by Billy Pearson <sa...@pearsonwholesale.com>.
on MR jobs I do this
conf = new HBaseConfiguration();
conf.set("hbase.master","123.123.123.123:6000");
but I do this in a JobConf

I thank the HBaseConfiguration() site-hbase.xml file for you

Billy

"Yossi Ittach" <yo...@gmail.com> wrote in 
message news:d8c3ded50811100006tac7d584gc5f40fa7869c5e9e@mail.gmail.com...
> Hi all
>
> I want to specify in the code which hbase-site.xml file will be used as a
> source for configuration. I tried to use addResources() but it doesn't 
> work
> - the path is added , but nothing happends - it's automatically goes for 
> the
> defaults (127.0.0.1:6000) . Can you please advise?
>
> This is the code:
>
>
>       conf = new HBaseConfiguration();
>        Path sitePath = new Path("util/hbase-site.xml");
>        Path defualtPath = new Path("util/hbase-default.xml");
>
>        conf.addResource(sitePath);
>        conf.addResource(defualtPath);
>
>        try {
>            admin = new HBaseAdmin(conf);
>        } catch (MasterNotRunningException e) {
>            e.printStackTrace();
>        }
>
>
> Thanks
>
> Vale et me ama
> Yossi
>