You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by Ruby Stevenson <ru...@gmail.com> on 2011/09/29 02:45:24 UTC

The configuration loading behavior

All -

Can someone please help me to understand this
(org.apache.hadoop.conf.Configuration, 20.204).

The following code reads like an exception will be thrown if debug is on, no
matter what, why?


 /** A new configuration where the behavior of reading from the default
  * resources can be turned off.
  *
  * If the parameter {@code loadDefaults} is false, the new instance
  * will not load resources from the default files.
  * @param loadDefaults specifies whether to load from the default files
  */
 public Configuration(boolean loadDefaults) {
   this.loadDefaults = loadDefaults;
*   if (LOG.isDebugEnabled()) {
     LOG.debug(StringUtils.stringifyException(new IOException("config()")));
   }*
   synchronized(Configuration.class) {
     REGISTRY.put(this, null);
   }
   this.storeResource = false;
 }

Thanks

Ruby

Re: The configuration loading behavior

Posted by Steve Loughran <st...@apache.org>.
On 29/09/11 16:25, Ruby Stevenson wrote:
> Uma, Harsh, and Steve,
>
> Thank you all for the explanation. I really appreciate it.
>
> I guess it is just ignorant of me of not knowing this as a mere debug
> printing technique. In my little world, every exception is a cause of
> alarm ... and I can't tell the difference in this case when I try to
> use the configuration and customize. I thought my core-site.xml was
> not found or read properly. If I had dump'ed  the whole thing - it
> should be behaving properly despite the *printed* exception.

if your core site isn't being found the behaviour would be much worse, 
believe me, as you'd be in pre-constructor initialiser failure time.

Re: The configuration loading behavior

Posted by Ruby Stevenson <ru...@gmail.com>.
Uma, Harsh, and Steve,

Thank you all for the explanation. I really appreciate it.

I guess it is just ignorant of me of not knowing this as a mere debug
printing technique. In my little world, every exception is a cause of
alarm ... and I can't tell the difference in this case when I try to
use the configuration and customize. I thought my core-site.xml was
not found or read properly. If I had dump'ed  the whole thing - it
should be behaving properly despite the *printed* exception.

Best Regard,


Ruby





On Thu, Sep 29, 2011 at 6:33 AM, Steve Loughran <st...@apache.org> wrote:
> On 29/09/11 02:40, Ruby Stevenson wrote:
>>
>> hmm ... I tried a small test program, if I put log4j configuration in the
>> classpath and turn on debug level, I am actually seeing the exception
>> thrown. The seemingly silly issue I had have been bugging me for a while.
>>
>>
>> DEBUG hadoop.conf.Configuration - java.io.IOException: config()
>>     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:226)
>>     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:213)
>>
>
> It's to help track down where things get configured
>

Re: The configuration loading behavior

Posted by Steve Loughran <st...@apache.org>.
On 29/09/11 02:40, Ruby Stevenson wrote:
> hmm ... I tried a small test program, if I put log4j configuration in the
> classpath and turn on debug level, I am actually seeing the exception
> thrown. The seemingly silly issue I had have been bugging me for a while.
>
>
> DEBUG hadoop.conf.Configuration - java.io.IOException: config()
>      at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:226)
>      at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:213)
>

It's to help track down where things get configured

Re: The configuration loading behavior

Posted by Harsh J <ha...@cloudera.com>.
FWIW, since this is the second time I saw this come up, I've opened
https://issues.apache.org/jira/browse/HADOOP-7696 as a trivial JIRA to
address it and avoid confusion :)

The usefulness of that statement is that it will tell you, during
debug logging, what piece of code instantiated Configuration objects,
and when / at what point.

On Thu, Sep 29, 2011 at 10:17 AM, Harsh J <ha...@cloudera.com> wrote:
> Ruby,
>
> Uma has already explained it isn't.
>
> Its just a 'technique' to print out a stack trace during DEBUG logging.
>
> It isn't an exception, and it isn't 'thrown' either - as you notice in
> the code. Creating an Exception instance doesn't 'throw' it.
>
> The line you see in logs is a proper, DEBUG-only statement. DEBUG log
> level _will_ be noisy in this way. Proper exceptions, that are to be
> worried about, are either thrown out explicitly, or are wrapped into
> WARN, ERROR or FATAL statements.
>
> So, coming to a question, what's your specific issue when using the
> Configuration class in Hadoop?
>
> On Thu, Sep 29, 2011 at 7:10 AM, Ruby Stevenson <ru...@gmail.com> wrote:
>> hmm ... I tried a small test program, if I put log4j configuration in the
>> classpath and turn on debug level, I am actually seeing the exception
>> thrown. The seemingly silly issue I had have been bugging me for a while.
>>
>>
>> DEBUG hadoop.conf.Configuration - java.io.IOException: config()
>>    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:226)
>>    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:213)
>>
>>
>> On Wed, Sep 28, 2011 at 8:50 PM, Uma Maheswara Rao G 72686 <
>> maheswara@huawei.com> wrote:
>>
>>> Hello Ruby,
>>>
>>> It is just logging the trace of configuration object invocations.
>>> It will not throw exception.
>>>
>>> Regards,
>>> Uma
>>>
>>>
>>> ----- Original Message -----
>>> From: Ruby Stevenson <ru...@gmail.com>
>>> Date: Thursday, September 29, 2011 6:15 am
>>> Subject: The configuration loading behavior
>>> To: common-dev@hadoop.apache.org
>>>
>>> > All -
>>> >
>>> > Can someone please help me to understand this
>>> > (org.apache.hadoop.conf.Configuration, 20.204).
>>> >
>>> > The following code reads like an exception will be thrown if debug
>>> > is on, no
>>> > matter what, why?
>>> >
>>> >
>>> > /** A new configuration where the behavior of reading from the
>>> > default  * resources can be turned off.
>>> >  *
>>> >  * If the parameter {@code loadDefaults} is false, the new instance
>>> >  * will not load resources from the default files.
>>> >  * @param loadDefaults specifies whether to load from the default
>>> > files  */
>>> > public Configuration(boolean loadDefaults) {
>>> >   this.loadDefaults = loadDefaults;
>>> > *   if (LOG.isDebugEnabled()) {
>>> >     LOG.debug(StringUtils.stringifyException(new
>>> > IOException("config()")));   }*
>>> >   synchronized(Configuration.class) {
>>> >     REGISTRY.put(this, null);
>>> >   }
>>> >   this.storeResource = false;
>>> > }
>>> >
>>> > Thanks
>>> >
>>> > Ruby
>>> >
>>>
>>
>
>
>
> --
> Harsh J
>



-- 
Harsh J

Re: The configuration loading behavior

Posted by Harsh J <ha...@cloudera.com>.
Ruby,

Uma has already explained it isn't.

Its just a 'technique' to print out a stack trace during DEBUG logging.

It isn't an exception, and it isn't 'thrown' either - as you notice in
the code. Creating an Exception instance doesn't 'throw' it.

The line you see in logs is a proper, DEBUG-only statement. DEBUG log
level _will_ be noisy in this way. Proper exceptions, that are to be
worried about, are either thrown out explicitly, or are wrapped into
WARN, ERROR or FATAL statements.

So, coming to a question, what's your specific issue when using the
Configuration class in Hadoop?

On Thu, Sep 29, 2011 at 7:10 AM, Ruby Stevenson <ru...@gmail.com> wrote:
> hmm ... I tried a small test program, if I put log4j configuration in the
> classpath and turn on debug level, I am actually seeing the exception
> thrown. The seemingly silly issue I had have been bugging me for a while.
>
>
> DEBUG hadoop.conf.Configuration - java.io.IOException: config()
>    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:226)
>    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:213)
>
>
> On Wed, Sep 28, 2011 at 8:50 PM, Uma Maheswara Rao G 72686 <
> maheswara@huawei.com> wrote:
>
>> Hello Ruby,
>>
>> It is just logging the trace of configuration object invocations.
>> It will not throw exception.
>>
>> Regards,
>> Uma
>>
>>
>> ----- Original Message -----
>> From: Ruby Stevenson <ru...@gmail.com>
>> Date: Thursday, September 29, 2011 6:15 am
>> Subject: The configuration loading behavior
>> To: common-dev@hadoop.apache.org
>>
>> > All -
>> >
>> > Can someone please help me to understand this
>> > (org.apache.hadoop.conf.Configuration, 20.204).
>> >
>> > The following code reads like an exception will be thrown if debug
>> > is on, no
>> > matter what, why?
>> >
>> >
>> > /** A new configuration where the behavior of reading from the
>> > default  * resources can be turned off.
>> >  *
>> >  * If the parameter {@code loadDefaults} is false, the new instance
>> >  * will not load resources from the default files.
>> >  * @param loadDefaults specifies whether to load from the default
>> > files  */
>> > public Configuration(boolean loadDefaults) {
>> >   this.loadDefaults = loadDefaults;
>> > *   if (LOG.isDebugEnabled()) {
>> >     LOG.debug(StringUtils.stringifyException(new
>> > IOException("config()")));   }*
>> >   synchronized(Configuration.class) {
>> >     REGISTRY.put(this, null);
>> >   }
>> >   this.storeResource = false;
>> > }
>> >
>> > Thanks
>> >
>> > Ruby
>> >
>>
>



-- 
Harsh J

Re: The configuration loading behavior

Posted by Ruby Stevenson <ru...@gmail.com>.
hmm ... I tried a small test program, if I put log4j configuration in the
classpath and turn on debug level, I am actually seeing the exception
thrown. The seemingly silly issue I had have been bugging me for a while.


DEBUG hadoop.conf.Configuration - java.io.IOException: config()
    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:226)
    at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:213)


On Wed, Sep 28, 2011 at 8:50 PM, Uma Maheswara Rao G 72686 <
maheswara@huawei.com> wrote:

> Hello Ruby,
>
> It is just logging the trace of configuration object invocations.
> It will not throw exception.
>
> Regards,
> Uma
>
>
> ----- Original Message -----
> From: Ruby Stevenson <ru...@gmail.com>
> Date: Thursday, September 29, 2011 6:15 am
> Subject: The configuration loading behavior
> To: common-dev@hadoop.apache.org
>
> > All -
> >
> > Can someone please help me to understand this
> > (org.apache.hadoop.conf.Configuration, 20.204).
> >
> > The following code reads like an exception will be thrown if debug
> > is on, no
> > matter what, why?
> >
> >
> > /** A new configuration where the behavior of reading from the
> > default  * resources can be turned off.
> >  *
> >  * If the parameter {@code loadDefaults} is false, the new instance
> >  * will not load resources from the default files.
> >  * @param loadDefaults specifies whether to load from the default
> > files  */
> > public Configuration(boolean loadDefaults) {
> >   this.loadDefaults = loadDefaults;
> > *   if (LOG.isDebugEnabled()) {
> >     LOG.debug(StringUtils.stringifyException(new
> > IOException("config()")));   }*
> >   synchronized(Configuration.class) {
> >     REGISTRY.put(this, null);
> >   }
> >   this.storeResource = false;
> > }
> >
> > Thanks
> >
> > Ruby
> >
>

Re: The configuration loading behavior

Posted by Uma Maheswara Rao G 72686 <ma...@huawei.com>.
Hello Ruby,

It is just logging the trace of configuration object invocations.
It will not throw exception.

Regards,
Uma


----- Original Message -----
From: Ruby Stevenson <ru...@gmail.com>
Date: Thursday, September 29, 2011 6:15 am
Subject: The configuration loading behavior
To: common-dev@hadoop.apache.org

> All -
> 
> Can someone please help me to understand this
> (org.apache.hadoop.conf.Configuration, 20.204).
> 
> The following code reads like an exception will be thrown if debug 
> is on, no
> matter what, why?
> 
> 
> /** A new configuration where the behavior of reading from the 
> default  * resources can be turned off.
>  *
>  * If the parameter {@code loadDefaults} is false, the new instance
>  * will not load resources from the default files.
>  * @param loadDefaults specifies whether to load from the default 
> files  */
> public Configuration(boolean loadDefaults) {
>   this.loadDefaults = loadDefaults;
> *   if (LOG.isDebugEnabled()) {
>     LOG.debug(StringUtils.stringifyException(new 
> IOException("config()")));   }*
>   synchronized(Configuration.class) {
>     REGISTRY.put(this, null);
>   }
>   this.storeResource = false;
> }
> 
> Thanks
> 
> Ruby
>