1

ご存知のように、必要なすべてのクラスを job-jar にパックしてサーバーにアップロードする必要があります。とても遅いので、サードパーティの jar を指定して map-red ジョブを実行する方法があるかどうかを知りたいので、依存関係のないクラスのみをパックできます。

PS(「-libjar」コマンドがあることがわかりましたが、その使用方法がわかりません。リンクは次のとおりですhttp://blog.cloudera.com/blog/2011/01/how-to-include -サードパーティのライブラリ-in-your-map-reduce-job/ )

4

2 に答える 2

3

これらは一般的なオプションと呼ばれます。したがって、それらをサポートするには、ジョブでツールを実装する必要があります。

次のようにジョブを実行します --

hadoop jar yourfile.jar [mainClass] args -libjars <comma seperated list of jars>

編集:

Toolを実装してConfiguredを拡張するには、MapReduce アプリケーションで次のようにします --

public class YourClass extends Configured implements Tool {

      public static void main(String[] args) throws Exception {
         int res = ToolRunner.run(new YourClass(), args);
         System.exit(res);
      }

      public int run(String[] args) throws Exception
      {
        //parse you normal arguments here.

        Configuration conf = getConf();
        Job job = new Job(conf, "Name of job");

        //set the class names etc

        //set the output data type classes etc

        //to accept the hdfs input and outpur dir at run time
        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        return job.waitForCompletion(true) ? 0 : 1;
    }
}
于 2013-09-26T16:10:58.363 に答える
0

私にとっては、引数の前に -libjar オプションを指定する必要がありました。それ以外の場合は、引数と見なされました。

于 2014-06-10T10:41:33.927 に答える