2012-05-22 11 views
5

giraphインキュベータ(https://cwiki.apache.org/confluence/display/GIRAPH/Shortest+Paths+Example)から最短パスの例を実行しようとしています。しかし、giraph - * - dependencies.jarからこの例を実行する代わりに、自分のジョブjarを作成しました。例に提示されるよう、私は一つのジョブファイルを作成したとき、私はGiraph最短パスの例ClassNotFoundException

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.test.giraph.Test$SimpleShortestPathsVertexInputFormat 

を得ていたそれから私は、ファイルを分離するために内部クラス(SimpleShortestPathsVertexInputFormatとSimpleShortestPathsVertexOutputFormat)に移動し、ちょうど(SimpleShortestPathsVertexInputFormat_v2、SimpleShortestPathsVertexOutputFormat_v2)のケースでそれらの名前を変更しました。 のクラスは、これ以上静的ではありません。これは、SimpleShortestPathsVertexInputFormat_v2で見つからないクラスの問題を解決しましたが、SimpleShortestPathsVertexOutputFormat_v2で同じエラーが発生しています。以下は私のスタックトレースです。

INFO mapred.JobClient: Running job: job_201205221101_0003 
INFO mapred.JobClient: map 0% reduce 0% 
INFO mapred.JobClient: Task Id : attempt_201205221101_0003_m_000005_0, Status : FAILED 
    java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.test.giraph.utils.SimpleShortestPathsVertexOutputFormat_v2 
      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:898) 
      at org.apache.giraph.graph.BspUtils.getVertexOutputFormatClass(BspUtils.java:134) 
      at org.apache.giraph.bsp.BspOutputFormat.getOutputCommitter(BspOutputFormat.java:56) 
      at org.apache.hadoop.mapred.Task.initialize(Task.java:490) 
      at org.apache.hadoop.mapred.MapTask.run(MapTask.java:352) 
      at org.apache.hadoop.mapred.Child$4.run(Child.java:259) 
      at java.security.AccessController.doPrivileged(Native Method) 
      at javax.security.auth.Subject.doAs(Subject.java:415) 
      at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059) 
      at org.apache.hadoop.mapred.Child.main(Child.java:253) 
    Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.test.giraph.utils.SimpleShortestPathsVertexOutputFormat_v2 
      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:866) 
      at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:890) 
      ... 9 more 

私は自分の仕事の瓶を検査し、すべての授業があります。さらに、私はhadoop 0.20.203を疑似分散モードで使用しています。私が自分の仕事を開始する方法を以下に示します。

hadoop jar giraphJobs.jar org.test.giraph.Test -libjars /path/to/giraph-0.2-SNAPSHOT-jar-with-dependencies.jar /path/to/input /path/to/output 0 3 

また、giraph - * - dependencies.jarのHADOOP_CLASSPATHを定義しました。私はPageRankBenchmarkの例を(giraph - * - dependencies.jarから直接)問題なく実行することができ、shortesのパスの例も同様に(giraph - * - dependencies.jarから直接)動作します。他のhadoopジョブは問題なく動作します(私の "クラスタ"が正しく動作するかどうかテストするために読んだところです)。誰も似たような問題に遭遇しましたかどんな助けもありがとう。


ソリューション(申し訳ありませんが、このようにそれを投稿することが、私はより多くの時間のカップルのための私自身の質問に答えることはできません)私は私の仕事のjarファイルを追加する必要がありました。この問題を解決するために

-libjars(作成されたHADOOP_CLASSPATHへの変更はありません)。今すぐジョブを起動するコマンドは次のようになります。

jarのリストはコンマで区切る必要があります。これは私の問題を解決しましたが。なぜ私は自分のジョブjarを "classpath"パラメータとして渡す必要があるのか​​不思議です。誰かがこれの背後にある合理的なものを私に説明することはできますか?私が気づいたように、私の仕事の瓶を呼び出すためにそれは不思議であった。私は本当に説明が不思議です。

答えて

3

私はこの問題に対する代替のプログラム的な解決策を発見しました。 は、我々は次のようにrun()メソッドを変更する必要があります -

... 
@Override 
public int run(String[] argArray) throws Exception { 
    Preconditions.checkArgument(argArray.length == 4, 
     "run: Must have 4 arguments <input path> <output path> " + 
     "<source vertex id> <# of workers>"); 

    GiraphJob job = new GiraphJob(getConf(), getClass().getName()); 
    // This is the addition - it will make hadoop look for other classes in the same  jar that contains this class 
    job.getInternalJob().setJarByClass(getClass()); 
    job.setVertexClass(getClass()); 
    ... 
} 

setJarByClass()のgetClass()によって返されたクラスを含む同じ瓶で不足しているクラスのためのHadoopの外観を作り、そして私たちがするだろうジョブjar名を-libjarsオプションに個別に追加する必要はありません。

関連する問題