You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by pranjal shrivastava <br...@gmail.com> on 2011/09/21 15:37:42 UTC

Can JobConf object be declared global and used in mapper and reducer class

pranjal shrivastava to mapreduce-user.
show details 9:12 AM (24 minutes ago)

Hi
I declared JobConf object static and globally in the main class and
initialized it in the main function.Since it is global and static to inner
mapper and reducer classes ,I tried to JobConf object in the mapper and
reducer function.But on doing this I find JobConf object to be null.Why is
this happening .

Code is like
class wordcount{
private static JobConf conf;

//public static mapperclass{
    //I try to access conf object here which comes to be null

}
//public static reducerclass{
}
public static void main(String args[]){
conf=new JobConf(wordcount.class)
//set mapper class
//setreducer class
//set job client
//launch the mappers,reducers
}
}

Whats going wrong?Why I am not able to access conf object in mapper.I need
this for using distributed cache files.

Thank you
Pranjal

Re: Can JobConf object be declared global and used in mapper and reducer class

Posted by Mostafa Gaber <mo...@gmail.com>.
Your initialization of JobConf is accomplished in the main method, which
runs at the JobTracker node only. You need to override the configure()
method in the old API or the setup() method in the new API, so as to
initialize this conf object at every TaskTracker's JVM.

On Wed, Sep 21, 2011 at 9:37 AM, pranjal shrivastava
<br...@gmail.com>wrote:

> pranjal shrivastava to mapreduce-user.
> show details 9:12 AM (24 minutes ago)
>
> Hi
> I declared JobConf object static and globally in the main class and
> initialized it in the main function.Since it is global and static to inner
> mapper and reducer classes ,I tried to JobConf object in the mapper and
> reducer function.But on doing this I find JobConf object to be null.Why is
> this happening .
>
> Code is like
> class wordcount{
> private static JobConf conf;
>
> //public static mapperclass{
>     //I try to access conf object here which comes to be null
>
> }
> //public static reducerclass{
> }
> public static void main(String args[]){
> conf=new JobConf(wordcount.class)
> //set mapper class
> //setreducer class
> //set job client
> //launch the mappers,reducers
> }
> }
>
> Whats going wrong?Why I am not able to access conf object in mapper.I need
> this for using distributed cache files.
>
> Thank you
> Pranjal
>



-- 
Best Regards,
Mostafa Ead