Skip to content

Instantly share code, notes, and snippets.

@vicenteg
Last active September 21, 2016 19:12
Show Gist options
  • Save vicenteg/c3ff4dfec0c0fe7e79cff89bc896b2a7 to your computer and use it in GitHub Desktop.
Save vicenteg/c3ff4dfec0c0fe7e79cff89bc896b2a7 to your computer and use it in GitHub Desktop.
{
"paragraphs": [
{
"text": "%md\n\nFirst thing you need to do to run this notebook is to make sure Zeppelin knows how to pull in MapR Streams maven dependencies.\n\nAdd this artifact to the Spark interpreter (update the version as needed):\n\n`org.apache.kafka:kafka-clients:0.9.0.0-mapr-1607`\n\nAlso make sure that the MapR repository is set up:\n\nhttp://repository.mapr.com/maven/\n\nFollow the [Zeppelin documentation for dependency management](http://zeppelin.apache.org/docs/0.6.1/manual/dependencymanagement.html) for instructions on to do this.\n",
"dateUpdated": "2016-09-20T20:53:52-0700",
"config": {
"colWidth": 12,
"graph": {
"mode": "table",
"height": 300,
"optionOpen": false,
"keys": [],
"values": [],
"groups": [],
"scatter": {}
},
"enabled": true,
"editorMode": "ace/mode/markdown",
"editorHide": true
},
"settings": {
"params": {},
"forms": {}
},
"jobName": "paragraph_1474427228572_1074230698",
"id": "20160920-200708_547700634",
"dateCreated": "2016-09-20T20:07:08-0700",
"status": "FINISHED",
"progressUpdateIntervalMs": 500,
"$$hashKey": "object:6061",
"user": "mapr:2000",
"dateFinished": "2016-09-20T20:53:44-0700",
"dateStarted": "2016-09-20T20:53:44-0700",
"result": {
"code": "SUCCESS",
"type": "HTML",
"msg": "<p>First thing you need to do to run this notebook is to make sure Zeppelin knows how to pull in MapR Streams maven dependencies.</p>\n<p>Add this artifact to the Spark interpreter (update the version as needed):</p>\n<p><code>org.apache.kafka:kafka-clients:0.9.0.0-mapr-1607</code></p>\n<p>Also make sure that the MapR repository is set up:</p>\n<p>http://repository.mapr.com/maven/</p>\n<p>Follow the <a href=\"http://zeppelin.apache.org/docs/0.6.1/manual/dependencymanagement.html\">Zeppelin documentation for dependency management</a> for instructions on to do this.</p>\n"
},
"focus": true
},
{
"text": "%sh\nmaprcli stream info -path /tmp/stream || maprcli stream create -path /tmp/stream ",
"user": "mapr:2000",
"dateUpdated": "2016-09-20T18:30:58-0700",
"config": {
"colWidth": 12,
"graph": {
"mode": "table",
"height": 300,
"optionOpen": false,
"keys": [],
"values": [],
"groups": [],
"scatter": {}
},
"enabled": true,
"editorMode": "ace/mode/sh"
},
"settings": {
"params": {},
"forms": {}
},
"jobName": "paragraph_1474407605876_1116084523",
"id": "20160920-144005_742848173",
"result": {
"code": "SUCCESS",
"type": "TEXT",
"msg": "produceperm defaultpartitions topicperm consumeperm autocreate clientcompression logicalsize path copyperm compression ttl numtopics physicalsize adminperm \nu:mapr 1 u:mapr u:mapr true true 57344 /tmp/stream u:mapr lz4 604800 1 106496 u:mapr \n"
},
"dateCreated": "2016-09-20T14:40:05-0700",
"dateStarted": "2016-09-20T18:30:58-0700",
"dateFinished": "2016-09-20T18:31:04-0700",
"status": "FINISHED",
"progressUpdateIntervalMs": 500,
"$$hashKey": "object:6062"
},
{
"text": " import java.util.Properties\n import org.apache.kafka.clients.producer.KafkaProducer\n import org.apache.kafka.clients.producer.RecordMetadata\n import org.apache.kafka.clients.producer.Callback\n\n class PrintAckCallback extends Callback {\n def onCompletion(metadata: RecordMetadata, exception: Exception) {\n if (exception != null) {\n println(\"Send callback returns the following exception\", exception)\n } else {\n println(\"The offset of the record we just sent is: \", metadata.offset())\n }\n }\n }\n \n val callback = new PrintAckCallback\n val props = new Properties()\n //props.put(\"bootstrap.servers\", \"localhost:9092\")\n\n props.put(\"key.serializer\", \"org.apache.kafka.common.serialization.StringSerializer\")\n props.put(\"value.serializer\", \"org.apache.kafka.common.serialization.StringSerializer\")\n props.put(\"acks\", \"all\")\n\n val TOPIC = \"/tmp/stream:test\"\n val producer = new KafkaProducer[String, String](props)\n\n for (i <- 1 to 50) {\n val record = new ProducerRecord(TOPIC, \"key\", s\"hello $i\")\n producer.send(record, callback)\n }\n producer.close()",
"user": "mapr:2000",
"dateUpdated": "2016-09-20T18:32:05-0700",
"config": {
"colWidth": 12,
"graph": {
"mode": "table",
"height": 264,
"optionOpen": false,
"keys": [],
"values": [],
"groups": [],
"scatter": {}
},
"enabled": true,
"editorMode": "ace/mode/scala"
},
"settings": {
"params": {},
"forms": {}
},
"jobName": "paragraph_1474406377046_-224514152",
"id": "20160920-141937_2037316043",
"result": {
"code": "SUCCESS",
"type": "TEXT",
"msg": "\nimport java.util.Properties\n\nimport org.apache.kafka.clients.producer.KafkaProducer\n\nimport org.apache.kafka.clients.producer.RecordMetadata\n\nimport org.apache.kafka.clients.producer.Callback\n\ndefined class PrintAckCallback\n\ncallback: PrintAckCallback = $iwC$$iwC$PrintAckCallback@3cdc6479\n\nprops: java.util.Properties = {}\n\nres104: Object = null\n\nres105: Object = null\n\nres106: Object = null\n\nTOPIC: String = /tmp/stream:test\n\nproducer: org.apache.kafka.clients.producer.KafkaProducer[String,String] = org.apache.kafka.clients.producer.KafkaProducer@6eaa49fe\n"
},
"dateCreated": "2016-09-20T02:19:37-0700",
"dateStarted": "2016-09-20T18:32:05-0700",
"dateFinished": "2016-09-20T18:32:11-0700",
"status": "FINISHED",
"progressUpdateIntervalMs": 500,
"$$hashKey": "object:6063"
},
{
"text": "%sh\nmaprcli stream info -path /tmp/stream\nmaprcli stream delete -path /tmp/stream",
"user": "mapr:2000",
"dateUpdated": "2016-09-20T16:21:28-0700",
"config": {
"colWidth": 12,
"graph": {
"mode": "table",
"height": 300,
"optionOpen": false,
"keys": [],
"values": [],
"groups": [],
"scatter": {}
},
"enabled": true,
"editorMode": "ace/mode/sh"
},
"settings": {
"params": {},
"forms": {}
},
"jobName": "paragraph_1474407200089_-398116937",
"id": "20160920-143320_209056447",
"result": {
"code": "SUCCESS",
"type": "TEXT",
"msg": "produceperm defaultpartitions topicperm consumeperm autocreate clientcompression logicalsize path copyperm compression ttl numtopics physicalsize adminperm \nu:mapr 1 u:mapr u:mapr true true 57344 /tmp/stream u:mapr lz4 604800 1 106496 u:mapr \n"
},
"dateCreated": "2016-09-20T14:33:20-0700",
"dateStarted": "2016-09-20T16:21:28-0700",
"dateFinished": "2016-09-20T16:21:38-0700",
"status": "FINISHED",
"progressUpdateIntervalMs": 500,
"$$hashKey": "object:6064"
},
{
"text": "",
"user": "mapr:2000",
"dateUpdated": "2016-09-20T15:12:33-0700",
"config": {
"colWidth": 12,
"graph": {
"mode": "table",
"height": 300,
"optionOpen": false,
"keys": [],
"values": [],
"groups": [],
"scatter": {}
},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"jobName": "paragraph_1474407742008_-1363485865",
"id": "20160920-144222_1134603347",
"result": {
"code": "SUCCESS",
"type": "TEXT",
"msg": ""
},
"dateCreated": "2016-09-20T14:42:22-0700",
"dateStarted": "2016-09-20T15:12:34-0700",
"dateFinished": "2016-09-20T15:13:06-0700",
"status": "FINISHED",
"progressUpdateIntervalMs": 500,
"$$hashKey": "object:6065"
}
],
"name": "mapr_streams",
"id": "2BYVVS5MZ",
"angularObjects": {
"2BV1MWFQW:shared_process": [],
"2BYRMM9JT:shared_process": [],
"2BV1FZZN9:shared_process": [],
"2BYG8GSMA:shared_process": [],
"2BXXMJ371:shared_process": [],
"2BXUHMRQM:shared_process": [],
"2BY3DA8AH:shared_process": [],
"2BXCE3ESX:shared_process": [],
"2BY5ZFAVK:shared_process": [],
"2BWN6EP5J:shared_process": [],
"2BX839NWY:shared_process": [],
"2BY5CTNKW:shared_process": [],
"2BY899X46:shared_process": [],
"2BVURR6YB:shared_process": [],
"2BWDX4A6V:shared_process": [],
"2BW8HN9RU:shared_process": [],
"2BYDAREH6:shared_process": [],
"2BX8JU7F8:shared_process": []
},
"config": {
"looknfeel": "default"
},
"info": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment