Skip to content

Commit

Permalink
Issue 187: Cleanup
Browse files Browse the repository at this point in the history
- build.gradle file now uses versions defined in gradle.properties
- Removed unneeded wrapper task from build.gradle
- Changed package name to io.pravega.example.mqtt
- `gradle run` now provides the required command-line argument
- Updated documentation

Signed-off-by: Claudio Fahey <[email protected]>
  • Loading branch information
Claudio Fahey committed May 1, 2019
1 parent 306d00b commit 1a0aea4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
pravegaVersion=0.4.0
flinkConnectorVersion=0.4.0

#3rd party Versions
guavaVersion=20.0
junitVersion=4.12
qosLogbackVersion=1.2.3
pahoClientMqttv3Version=1.2.0
slf4jApiVersion=1.7.25

### Pravega-samples output library
samplesVersion=0.5.0-SNAPSHOT

Expand Down
20 changes: 15 additions & 5 deletions scenarios/mqtt-pravega-bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ This sample application reads events from MQTT and writes them to a Pravega stre

See <http://pravega.io> for more information.

- Pravega Video Demo: This is a simple command-line application that demonstrates how to write video files to Pravega.
It also demonstrates how to read the video files from Pravega and decode them.
- MQTT Pravega Bridge: This sample application reads events from MQTT and writes them to a Pravega stream.

- Docker: This demo uses Docker and Docker Compose to greatly simplify the deployment of the various
components on Linux and/or Windows servers, desktops, or even laptops.
Expand Down Expand Up @@ -42,11 +41,15 @@ and <https://docs.docker.com/compose/install/>.

This will run a development instance of Pravega locally.
In the command below, replace x.x.x.x with the IP address of a local network interface such as eth0.
You may need to checkout the specific version of Pravega that pravega-samples was built with.
Refer to gradle.properties for the correct version.

```
cd
git clone https://github.com/pravega/pravega
cd pravega/docker/compose
cd pravega
git checkout r0.4
cd docker/compose
export HOST_IP=x.x.x.x
docker-compose up -d
```
Expand All @@ -70,17 +73,24 @@ You can view the stream files stored on HDFS with `docker-compose exec hdfs hdfs
to specify your Pravega controller URI (controllerUri) as
`tcp://HOST_IP:9090`.

- In IntelliJ, run the class com.dell.mqtt.pravega.ApplicationMain with the following parameters:
- Run the application:
```
../../gradlew run
```

- Alternatively, you may run in IntelliJ.
Run the class ApplicationMain with the following parameters:
```
scenarios/mqtt-pravega-bridge/src/main/dist/conf
```

- Publish a sample MQTT message.
Note that the topic must be formatted as "topic/car_id" as shown below.
```
mosquitto_pub -t center/0001 -m "12,34,56.78"
```

- You should see the following application output:
```
[MQTT Call: CanDataReader] com.dell.mqtt.pravega.MqttListener: Writing Data Packet: CarID: 0001 Timestamp: 1551671403118 Payload: [B@2813d92f annotation: null
[MQTT Call: CanDataReader] io.pravega.example.mqtt.MqttListener: Writing Data Packet: CarID: 0001 Timestamp: 1551671403118 Payload: [B@2813d92f annotation: null
```
25 changes: 11 additions & 14 deletions scenarios/mqtt-pravega-bridge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
}

group 'com.dell.mqtt'
version = samplesVersion

task wrapper(type: Wrapper) {
gradleVersion = '3.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}

apply plugin: 'java'
apply plugin: "distribution"
apply plugin: 'application'

version = samplesVersion
sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = 'com.dell.mqtt.pravega.ApplicationMain'
mainClassName = 'io.pravega.example.mqtt.ApplicationMain'
applicationDefaultJvmArgs = ["-Dlog4j.configuration=file:conf/log4j.properties"]
archivesBaseName = 'pravega-mqtt-bridge'

Expand All @@ -31,12 +24,12 @@ repositories {
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0"
compile "org.slf4j:slf4j-api:1.6.6"
compile "ch.qos.logback:logback-classic:1.0.9"
compile "com.google.guava:guava:20.0"
compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${pahoClientMqttv3Version}"
compile "org.slf4j:slf4j-api:${slf4jApiVersion}"
compile "ch.qos.logback:logback-classic:${qosLogbackVersion}"
compile "com.google.guava:guava:${guavaVersion}"
compile "io.pravega:pravega-client:${pravegaVersion}"
testCompile "junit:junit:${junitVersion}"
}

shadowJar {
Expand All @@ -56,3 +49,7 @@ distributions {
}
}
}

run {
args = ["src/main/dist/conf"]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import com.google.common.base.Preconditions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttException;
Expand All @@ -14,7 +14,7 @@ public class ApplicationMain {
public static void main(String ... args) {

if (args.length != 1) {
log.error("Missing required arguments. Usage: java com.dell.mqtt.pravega.ApplicationMain <CONF_DIR_PATH>");
log.error("Missing required arguments. Usage: java io.pravega.example.mqtt.ApplicationMain <CONF_DIR_PATH>");
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import java.io.Serializable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import com.google.common.base.Preconditions;
import org.eclipse.paho.client.mqttv3.MqttCallback;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import io.pravega.client.stream.EventStreamWriter;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.dell.mqtt.pravega;
package io.pravega.example.mqtt;

import io.pravega.client.ClientFactory;
import io.pravega.client.admin.StreamManager;
Expand Down

0 comments on commit 1a0aea4

Please sign in to comment.