Repository: bahir-website Updated Branches: refs/heads/master f8d356989 -> b30d92b4a
[BAHIR-37] Publish Bahir 2.0.0 documentation Publish Bahir 2.0.0 documentation and update current documentation to use artifacts from master : 2.1.0-SNAPSHOT Project: http://git-wip-us.apache.org/repos/asf/bahir-website/repo Commit: http://git-wip-us.apache.org/repos/asf/bahir-website/commit/b30d92b4 Tree: http://git-wip-us.apache.org/repos/asf/bahir-website/tree/b30d92b4 Diff: http://git-wip-us.apache.org/repos/asf/bahir-website/diff/b30d92b4 Branch: refs/heads/master Commit: b30d92b4a543f4746aa42d12afa150621b183bc8 Parents: f8d3569 Author: Luciano Resende <[email protected]> Authored: Mon Aug 15 13:21:56 2016 -0700 Committer: Luciano Resende <[email protected]> Committed: Mon Aug 15 13:36:15 2016 -0700 ---------------------------------------------------------------------- site/_data/navigation.yml | 4 +- site/_data/project.yml | 4 +- site/docs/spark/2.0.0/documentation.md | 46 +++++++ .../spark/2.0.0/spark-sql-streaming-mqtt.md | 131 +++++++++++++++++++ site/docs/spark/2.0.0/spark-streaming-akka.md | 89 +++++++++++++ site/docs/spark/2.0.0/spark-streaming-mqtt.md | 71 ++++++++++ .../docs/spark/2.0.0/spark-streaming-twitter.md | 74 +++++++++++ site/docs/spark/2.0.0/spark-streaming-zeromq.md | 65 +++++++++ site/docs/spark/current/documentation.md | 10 +- 9 files changed, 486 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/_data/navigation.yml ---------------------------------------------------------------------- diff --git a/site/_data/navigation.yml b/site/_data/navigation.yml index 16ccd13..037c18c 100644 --- a/site/_data/navigation.yml +++ b/site/_data/navigation.yml @@ -47,8 +47,10 @@ topnav: - title: Documentation subcategories: - - title: Current + - title: Bahir Spark Extensions - Current url: /docs/spark/current/documentation + - title: Bahir Spark Extensions - 2.0.0 + url: /docs/spark/2.0.0/documentation - title: GitHub url: https://github.com/apache/bahir http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/_data/project.yml ---------------------------------------------------------------------- diff --git a/site/_data/project.yml b/site/_data/project.yml index 422f40d..1de896a 100644 --- a/site/_data/project.yml +++ b/site/_data/project.yml @@ -22,8 +22,8 @@ github_project_name: bahir description: Apache Bahir provides extensions to distributed analytic platforms such as Apache Spark. download: /download -latest_release: 2.0.0-preview -latest_release_date: 07/01/2016 +latest_release: 2.0.0 +latest_release_date: 08/11/2016 dev_list: [email protected] dev_list_subscribe: [email protected] http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/documentation.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/documentation.md b/site/docs/spark/2.0.0/documentation.md new file mode 100644 index 0000000..38148e9 --- /dev/null +++ b/site/docs/spark/2.0.0/documentation.md @@ -0,0 +1,46 @@ +--- +layout: page +title: Extensions for Apache Spark +description: Extensions for Apache Spark +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + +### Apache Bahir Extensions for Apache Spark + +<br/> + +#### Structured Streaming Data Sources + +[MQTT data source](../spark-sql-streaming-mqtt) + +<br/> + +#### Discretized Streams (DStreams) Connectors + +[Akka connector](../spark-streaming-akka) + +[MQTT connector](../spark-streaming-mqtt) + +[Twitter connector](../spark-streaming-twitter) + +[ZeroMQ connector](../spark-streaming-zeromq) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/spark-sql-streaming-mqtt.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/spark-sql-streaming-mqtt.md b/site/docs/spark/2.0.0/spark-sql-streaming-mqtt.md new file mode 100644 index 0000000..6f512a1 --- /dev/null +++ b/site/docs/spark/2.0.0/spark-sql-streaming-mqtt.md @@ -0,0 +1,131 @@ +--- +layout: page +title: Spark Structured Streaming MQTT +description: Spark Structured Streaming MQTT +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + +A library for reading data from MQTT Servers using Spark SQL Streaming ( or Structured streaming.). + +## Linking + +Using SBT: + + libraryDependencies += "org.apache.bahir" %% "spark-sql-streaming-mqtt" % "2.0.0" + +Using Maven: + + <dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-sql-streaming-mqtt_2.11</artifactId> + <version>2.0.0</version> + </dependency> + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + + $ bin/spark-shell --packages org.apache.bahir:spark-sql-streaming-mqtt_2.11:2.0.0 + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is compiled for Scala 2.11 only, and intends to support Spark 2.0 onwards. + +## Examples + +A SQL Stream can be created with data streams received through MQTT Server using, + + sqlContext.readStream + .format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSourceProvider") + .option("topic", "mytopic") + .load("tcp://localhost:1883") + +## Enable recovering from failures. + +Setting values for option `localStorage` and `clientId` helps in recovering in case of a restart, by restoring the state where it left off before the shutdown. + + sqlContext.readStream + .format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSourceProvider") + .option("topic", "mytopic") + .option("localStorage", "/path/to/localdir") + .option("clientId", "some-client-id") + .load("tcp://localhost:1883") + +### Scala API + +An example, for scala API to count words from incoming message stream. + + // Create DataFrame representing the stream of input lines from connection to mqtt server + val lines = spark.readStream + .format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSourceProvider") + .option("topic", topic) + .load(brokerUrl).as[(String, Timestamp)] + + // Split the lines into words + val words = lines.map(_._1).flatMap(_.split(" ")) + + // Generate running word count + val wordCounts = words.groupBy("value").count() + + // Start running the query that prints the running counts to the console + val query = wordCounts.writeStream + .outputMode("complete") + .format("console") + .start() + + query.awaitTermination() + +Please see `MQTTStreamWordCount.scala` for full example. + +### Java API + +An example, for Java API to count words from incoming message stream. + + // Create DataFrame representing the stream of input lines from connection to mqtt server. + Dataset<String> lines = spark + .readStream() + .format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSourceProvider") + .option("topic", topic) + .load(brokerUrl).select("value").as(Encoders.STRING()); + + // Split the lines into words + Dataset<String> words = lines.flatMap(new FlatMapFunction<String, String>() { + @Override + public Iterator<String> call(String x) { + return Arrays.asList(x.split(" ")).iterator(); + } + }, Encoders.STRING()); + + // Generate running word count + Dataset<Row> wordCounts = words.groupBy("value").count(); + + // Start running the query that prints the running counts to the console + StreamingQuery query = wordCounts.writeStream() + .outputMode("complete") + .format("console") + .start(); + + query.awaitTermination(); + +Please see `JavaMQTTStreamWordCount.java` for full example. + http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/spark-streaming-akka.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/spark-streaming-akka.md b/site/docs/spark/2.0.0/spark-streaming-akka.md new file mode 100644 index 0000000..9de0688 --- /dev/null +++ b/site/docs/spark/2.0.0/spark-streaming-akka.md @@ -0,0 +1,89 @@ +--- +layout: page +title: Spark Streaming Akka +description: Spark Streaming Akka +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + +A library for reading data from Akka Actors using Spark Streaming. + +## Linking + +Using SBT: + + libraryDependencies += "org.apache.bahir" %% "spark-streaming-akka" % "2.0.0" + +Using Maven: + + <dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-streaming-akka_2.11</artifactId> + <version>2.0.0</version> + </dependency> + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + + $ bin/spark-shell --packages org.apache.bahir:spark-streaming_akka_2.11:2.0.0 + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is cross-published for Scala 2.10 and Scala 2.11, so users should replace the proper Scala version (2.10 or 2.11) in the commands listed above. + +## Examples + +DStreams can be created with data streams received through Akka actors by using `AkkaUtils.createStream(ssc, actorProps, actor-name)`. + +### Scala API + +You need to extend `ActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + + class CustomActor extends ActorReceiver { + def receive = { + case data: String => store(data) + } + } + + // A new input stream can be created with this custom actor as + val ssc: StreamingContext = ... + val lines = AkkaUtils.createStream[String](ssc, Props[CustomActor](), "CustomReceiver") + +### Java API + +You need to extend `JavaActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + + class CustomActor extends JavaActorReceiver { + @Override + public void onReceive(Object msg) throws Exception { + store((String) msg); + } + } + + // A new input stream can be created with this custom actor as + JavaStreamingContext jssc = ...; + JavaDStream<String> lines = AkkaUtils.<String>createStream(jssc, Props.create(CustomActor.class), "CustomReceiver"); + +See end-to-end examples at [Akka Examples](https://github.com/apache/bahir/tree/master/streaming-akka/examples) http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/spark-streaming-mqtt.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/spark-streaming-mqtt.md b/site/docs/spark/2.0.0/spark-streaming-mqtt.md new file mode 100644 index 0000000..886bacb --- /dev/null +++ b/site/docs/spark/2.0.0/spark-streaming-mqtt.md @@ -0,0 +1,71 @@ +--- +layout: page +title: Spark Structured Streaming MQTT +description: Spark Structured Streaming MQTT +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + + +[MQTT](http://mqtt.org/) is MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. + +## Linking + +Using SBT: + + libraryDependencies += "org.apache.bahir" %% "spark-streaming-mqtt" % "2.0.0" + +Using Maven: + + <dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-streaming-mqtt_2.11</artifactId> + <version>2.0.0</version> + </dependency> + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + + $ bin/spark-shell --packages org.apache.bahir:spark-streaming_mqtt_2.11:2.0.0 + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is cross-published for Scala 2.10 and Scala 2.11, so users should replace the proper Scala version (2.10 or 2.11) in the commands listed above. + +## Examples + +### Scala API + +You need to extend `ActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + + val lines = MQTTUtils.createStream(ssc, brokerUrl, topic) + +### Java API + +You need to extend `JavaActorReceiver` so as to store received data into Spark using `store(...)` methods. The supervisor strategy of +this actor can be configured to handle failures, etc. + + JavaDStream<String> lines = MQTTUtils.createStream(jssc, brokerUrl, topic); + +See end-to-end examples at [MQTT Examples](https://github.com/apache/bahir/tree/master/streaming-mqtt/examples) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/spark-streaming-twitter.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/spark-streaming-twitter.md b/site/docs/spark/2.0.0/spark-streaming-twitter.md new file mode 100644 index 0000000..f04928a --- /dev/null +++ b/site/docs/spark/2.0.0/spark-streaming-twitter.md @@ -0,0 +1,74 @@ +--- +layout: page +title: Spark Streaming Twitter +description: Spark Streaming Twitter +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + +A library for reading social data from [twitter](http://twitter.com/) using Spark Streaming. + +## Linking + +Using SBT: + + libraryDependencies += "org.apache.bahir" %% "spark-streaming-twitter" % "2.0.0" + +Using Maven: + + <dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-streaming-twitter_2.11</artifactId> + <version>2.0.0</version> + </dependency> + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + + $ bin/spark-shell --packages org.apache.bahir:spark-streaming_twitter_2.11:2.0.0 + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is cross-published for Scala 2.10 and Scala 2.11, so users should replace the proper Scala version (2.10 or 2.11) in the commands listed above. + + +## Examples + +`TwitterUtils` uses Twitter4j to get the public stream of tweets using [Twitter's Streaming API](https://dev.twitter.com/docs/streaming-apis). Authentication information +can be provided by any of the [methods](http://twitter4j.org/en/configuration.html) supported by Twitter4J library. You can import the `TwitterUtils` class and create a DStream with `TwitterUtils.createStream` as shown below. + +### Scala API + + import org.apache.spark.streaming.twitter._ + + TwitterUtils.createStream(ssc, None) + +### Java API + + import org.apache.spark.streaming.twitter.*; + + TwitterUtils.createStream(jssc); + + +You can also either get the public stream, or get the filtered stream based on keywords. +See end-to-end examples at [Twitter Examples](https://github.com/apache/bahir/tree/master/streaming-twitter/examples) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/2.0.0/spark-streaming-zeromq.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/2.0.0/spark-streaming-zeromq.md b/site/docs/spark/2.0.0/spark-streaming-zeromq.md new file mode 100644 index 0000000..9c67a79 --- /dev/null +++ b/site/docs/spark/2.0.0/spark-streaming-zeromq.md @@ -0,0 +1,65 @@ +--- +layout: page +title: Spark Streaming ZeroMQ +description: Spark Streaming ZeroMQ +group: nav-right +--- +<!-- +{% comment %} +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to you under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +{% endcomment %} +--> + +{% include JB/setup %} + +A library for reading data from [ZeroMQ](http://zeromq.org/) using Spark Streaming. + +## Linking + +Using SBT: + + libraryDependencies += "org.apache.bahir" %% "spark-streaming-zeromq" % "2.0.0" + +Using Maven: + + <dependency> + <groupId>org.apache.bahir</groupId> + <artifactId>spark-streaming-zeromq_2.11</artifactId> + <version>2.0.0</version> + </dependency> + +This library can also be added to Spark jobs launched through `spark-shell` or `spark-submit` by using the `--packages` command line option. +For example, to include it when starting the spark shell: + + $ bin/spark-shell --packages org.apache.bahir:spark-streaming_zeromq_2.11:2.0.0 + +Unlike using `--jars`, using `--packages` ensures that this library and its dependencies will be added to the classpath. +The `--packages` argument can also be used with `bin/spark-submit`. + +This library is cross-published for Scala 2.10 and Scala 2.11, so users should replace the proper Scala version (2.10 or 2.11) in the commands listed above. + +## Examples + + +### Scala API + + val lines = ZeroMQUtils.createStream(ssc, ...) + +### Java API + + JavaDStream<String> lines = ZeroMQUtils.createStream(jssc, ...); + +See end-to-end examples at [ZeroMQ Examples](https://github.com/apache/bahir/tree/master/streaming-zeromq/examples) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/bahir-website/blob/b30d92b4/site/docs/spark/current/documentation.md ---------------------------------------------------------------------- diff --git a/site/docs/spark/current/documentation.md b/site/docs/spark/current/documentation.md index 16b6527..38148e9 100644 --- a/site/docs/spark/current/documentation.md +++ b/site/docs/spark/current/documentation.md @@ -31,16 +31,16 @@ limitations under the License. #### Structured Streaming Data Sources -[MQTT data source](/docs/spark/current/spark-sql-streaming-mqtt) +[MQTT data source](../spark-sql-streaming-mqtt) <br/> #### Discretized Streams (DStreams) Connectors -[Akka connector](/docs/spark/current/spark-streaming-akka) +[Akka connector](../spark-streaming-akka) -[MQTT connector](/docs/spark/current/spark-streaming-mqtt) +[MQTT connector](../spark-streaming-mqtt) -[Twitter connector](/docs/spark/current/spark-streaming-twitter) +[Twitter connector](../spark-streaming-twitter) -[ZeroMQ connector](/docs/spark/current/spark-streaming-zeromq) \ No newline at end of file +[ZeroMQ connector](../spark-streaming-zeromq) \ No newline at end of file
