SnappyData v.0-5
我的目标是运行 snappydata 驱动程序以连接到远程服务器中的 SnappyData。我写了一个 Junit 来做到这一点。但是,当我运行它时,我得到一个 SparkContext 被实例化的错误:
**java.lang.NoClassDefFoundError: org/eclipse/jetty/server/handler/GzipHandler**
at org.apache.spark.ui.JettyUtils$$anonfun$4.apply(JettyUtils.scala:235)
at org.apache.spark.ui.JettyUtils$$anonfun$4.apply(JettyUtils.scala:234)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at org.apache.spark.ui.JettyUtils$.startJettyServer(JettyUtils.scala:234)
at org.apache.spark.ui.WebUI.bind(WebUI.scala:136)
at org.apache.spark.SparkContext$$anonfun$13.apply(SparkContext.scala:499)
at org.apache.spark.SparkContext$$anonfun$13.apply(SparkContext.scala:499)
at scala.Option.foreach(Option.scala:236)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:499)
我的 pom.xml 依赖项是:
<dependency>
<groupId>io.snappydata</groupId>
<artifactId>snappy-core_2.10</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>io.snappydata</groupId>
<artifactId>snappy-cluster_2.10</artifactId>
<version>0.5</version>
<dependency>
@Test
public void testInsertDataFromCsv() throws Exception {
SparkConf conf = new SparkConf();
conf.setMaster("spark://snappy-lead-host:8090");
conf.setAppName("MySparkApp");
SparkContext sc = new SparkContext(conf);
SnappyContext snappyContext = new SnappyContext(sc);
String fileResource = "data.csv";
DataFrame dataFrame = snappyContext.read()
.format("com.databricks.spark.csv").option("header", "true")
.option("inferSchema", "true").load(fileResource);
JavaRDD<Row> row = dataFrame.javaRDD();
System.out.println(row.toDebugString());
dataFrame.write().insertInto("example_table_col");
}