Spark Streaming を使用して kafka から binlog データを読み取りたいのですが、binlog データはcanal (protobuf-2.4.1 を使用) を使用して収集されます。Spark Streaming 環境で protobuf-2.5.0 を使用する必要があります。今、私は次の例外を得ました
16/07/11 15:13:01 ERROR yarn.ApplicationMaster: User class threw exception: org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 4 times, most recent failure: Lost task 0.3 in stage 0.0 : java.lang.RuntimeException: Unable to find proto buffer class
at com.google.protobuf.GeneratedMessageLite$SerializedForm.readResolve(GeneratedMessageLite.java:775)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1807)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at com.data.binlog.BinlogEntryUtil.deserializeFromProtoBuf(BinlogEntryUtil.java:30)
at main.com.data.scala.Utils$.binlogDecode(Utils.scala:30)
at main.com.data.scala.IntegrateKafka$$anonfun$main$4.apply(IntegrateKafka.scala:37)
at main.com.data.scala.IntegrateKafka$$anonfun$main$4.apply(IntegrateKafka.scala:37)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
at main.com.data.scala.IntegrateKafka$$anonfun$main$5$$anonfun$apply$2$$anonfun$apply$3.apply(IntegrateKafka.scala:42)
at main.com.data.scala.IntegrateKafka$$anonfun$main$5$$anonfun$apply$2$$anonfun$apply$3.apply(IntegrateKafka.scala:42)
at org.apache.spark.Logging$class.logInfo(Logging.scala:59)
at main.com.data.scala.IntegrateKafka$.logInfo(IntegrateKafka.scala:16)
at main.com.data.scala.IntegrateKafka$$anonfun$main$5$$anonfun$apply$2.apply(IntegrateKafka.scala:42)
at main.com.data.scala.IntegrateKafka$$anonfun$main$5$$anonfun$apply$2.apply(IntegrateKafka.scala:39)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:898)
at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$29.apply(RDD.scala:898)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1850)
at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1850)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:66)
at org.apache.spark.scheduler.Task.run(Task.scala:88)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:214)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.alibaba.otter.canal.protocol.CanalEntry$Entry
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.google.protobuf.GeneratedMessageLite$SerializedForm.readResolve(GeneratedMessageLite.java:768)
... 29 more
コード com.data.binlog.BinlogEntryUtil.deserializeFromProtoBuf はこちら
public static Entry deserializeFromProtoBuf(byte[] input) {
Entry entry = null;
try {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(input));
entry = (Entry)ois.readObject();
} catch (ClassNotFoundException e) {
logger.error("Exception:" + e);
} catch (IOException e) {
logger.error("IOException " + e);
}
return entry;
}
しかし、私は自分の瓶に CanalEntry$Entry.class を見つけました
-rw---- 2.0 脂肪 14431 bl defN 16-Jul-11 15:11 com/alibaba/otter/canal/protocol/CanalEntry$Entry.class
CanalEntry.java
とCanalPacket.java
を使用して生成しようとしprotoc-2.5.0
ましたが、同じ例外が発生しました。java.lang.ClassNotFoundException: com.alibaba.otter.canal.protocol.CanalEntry$Entry
protobuf-2.4.1
を使用して binlog データ (によってシリアル化された) を読み取るための提案を誰かに教えてもらえますprotobuf-2.5.0
か? ありがとう