You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by cd...@apache.org on 2017/12/14 14:32:56 UTC
[39/50] [abbrv] incubator-edgent git commit: remove samples (now in
separate repo)
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/Runner.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/Runner.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/Runner.java
deleted file mode 100644
index 5e9ee4a..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/Runner.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.connectors.mqtt;
-
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_ACTION_TIMEOUT_MILLIS;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_CLEAN_SESSION;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_CLIENT_ID;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_CN_TIMEOUT_SEC;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_IDLE_RECONNECT_INTERVAL_SEC;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_IDLE_TIMEOUT_SEC;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_KEY_STORE;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_KEY_STORE_PASSWORD;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_PASSWORD;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_PUB;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_SERVER_URI;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_TOPIC;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_TRUST_STORE;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_TRUST_STORE_PASSWORD;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_USER_ID;
-
-import org.apache.edgent.connectors.mqtt.MqttConfig;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.samples.connectors.Options;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Build and run the publisher or subscriber application.
- */
-public class Runner {
-
- /**
- * Build and run the publisher or subscriber application.
- * @param options command line options
- * @throws Exception on failure
- */
- public static void run(Options options) throws Exception {
- boolean isPub = options.get(OPT_PUB);
-
- // Get a topology runtime provider
- DevelopmentProvider tp = new DevelopmentProvider();
-
- Topology top;
- if (isPub) {
- PublisherApp publisher = new PublisherApp(tp, options);
- top = publisher.buildAppTopology();
- }
- else {
- SubscriberApp subscriber = new SubscriberApp(tp, options);
- top = subscriber.buildAppTopology();
- }
-
- // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
-
- // Submit the app/topology; send or receive the messages.
- System.out.println(
- "Using MQTT broker at " + options.get(OPT_SERVER_URI)
- + "\n" + (isPub ? "Publishing" : "Subscribing")
- + " to topic "+options.get(OPT_TOPIC));
- System.out.println("Console URL for the job: "
- + tp.getServices().getService(HttpServer.class).getConsoleUrl());
- tp.submit(top);
- }
-
- /**
- * Build a MqttConfig broker connector configuration.
- * @param options command line options
- * @return the connector configuration
- */
- static MqttConfig newConfig(Options options) {
- // Only the serverURI is required. Everything else is optional.
- MqttConfig config = new MqttConfig(options.get(OPT_SERVER_URI),
- options.get(OPT_CLIENT_ID));
-
- if (options.get(OPT_CLEAN_SESSION) != null)
- config.setCleanSession(options.get(OPT_CLEAN_SESSION));
- if (options.get(OPT_CN_TIMEOUT_SEC) != null)
- config.setConnectionTimeout(options.get(OPT_CN_TIMEOUT_SEC));
- if (options.get(OPT_ACTION_TIMEOUT_MILLIS) != null)
- config.setActionTimeToWaitMillis(options.get(OPT_ACTION_TIMEOUT_MILLIS));
- if (options.get(OPT_IDLE_TIMEOUT_SEC) != null)
- config.setIdleTimeout(options.get(OPT_IDLE_TIMEOUT_SEC));
- if (options.get(OPT_IDLE_RECONNECT_INTERVAL_SEC) != null)
- config.setSubscriberIdleReconnectInterval(options.get(OPT_IDLE_RECONNECT_INTERVAL_SEC));
- if (options.get(OPT_USER_ID) != null)
- config.setUserName(options.get(OPT_USER_ID));
- if (options.get(OPT_PASSWORD) != null)
- config.setPassword(((String)options.get(OPT_PASSWORD)).toCharArray());
- if (options.get(OPT_TRUST_STORE) != null)
- config.setTrustStore(options.get(OPT_TRUST_STORE));
- if (options.get(OPT_TRUST_STORE_PASSWORD) != null)
- config.setTrustStore(options.get(OPT_TRUST_STORE_PASSWORD));
- if (options.get(OPT_KEY_STORE) != null)
- config.setKeyStore(options.get(OPT_KEY_STORE));
- if (options.get(OPT_KEY_STORE_PASSWORD) != null)
- config.setTrustStore(options.get(OPT_KEY_STORE_PASSWORD));
- return config;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimplePublisherApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimplePublisherApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimplePublisherApp.java
deleted file mode 100644
index bc6395a..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimplePublisherApp.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.connectors.mqtt;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.edgent.connectors.mqtt.MqttConfig;
-import org.apache.edgent.connectors.mqtt.MqttStreams;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.samples.connectors.Util;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A simple MQTT publisher topology application.
- */
-public class SimplePublisherApp {
- private final Properties props;
- private final String topic;
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to mqtt.properties file");
- SimplePublisherApp publisher = new SimplePublisherApp(args[0]);
- publisher.run();
- }
-
- /**
- * @param mqttPropsPath pathname to properties file
- */
- SimplePublisherApp(String mqttPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(mqttPropsPath).toPath()));
- topic = props.getProperty("mqtt.topic");
- }
-
- private MqttConfig createMqttConfig() {
- MqttConfig mqttConfig = MqttConfig.fromProperties(props);
- return mqttConfig;
- }
-
- /**
- * Create a topology for the publisher application and run it.
- */
- private void run() throws Exception {
- DevelopmentProvider tp = new DevelopmentProvider();
-
- // build the application/topology
-
- Topology t = tp.newTopology("mqttSamplePublisher");
-
- // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
-
- // Create the MQTT broker connector
- MqttConfig mqttConfig = createMqttConfig();
- MqttStreams mqtt = new MqttStreams(t, () -> mqttConfig);
-
- // Create a sample stream of tuples to publish
- AtomicInteger cnt = new AtomicInteger();
- TStream<String> msgs = t.poll(
- () -> {
- String msg = String.format("Message-%d from %s",
- cnt.incrementAndGet(), Util.simpleTS());
- System.out.println("poll generated msg to publish: " + msg);
- return msg;
- }, 1L, TimeUnit.SECONDS);
-
- // Publish the stream to the topic. The String tuple is the message value.
- mqtt.publish(msgs, topic, 0/*qos*/, false/*retain*/);
-
- // run the application / topology
- System.out.println("Console URL for the job: "
- + tp.getServices().getService(HttpServer.class).getConsoleUrl());
- tp.submit(t);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimpleSubscriberApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimpleSubscriberApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimpleSubscriberApp.java
deleted file mode 100644
index efa1d95..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SimpleSubscriberApp.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.connectors.mqtt;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.Properties;
-
-import org.apache.edgent.connectors.mqtt.MqttConfig;
-import org.apache.edgent.connectors.mqtt.MqttStreams;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.samples.connectors.Util;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A simple MQTT subscriber topology application.
- */
-public class SimpleSubscriberApp {
- private final Properties props;
- private final String topic;
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to mqtt.properties file");
- SimpleSubscriberApp subscriber = new SimpleSubscriberApp(args[0]);
- subscriber.run();
- }
-
- /**
- * @param mqttPropsPath pathname to properties file
- */
- SimpleSubscriberApp(String mqttPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(mqttPropsPath).toPath()));
- topic = props.getProperty("mqtt.topic");
- }
-
- private MqttConfig createMqttConfig() {
- MqttConfig mqttConfig = MqttConfig.fromProperties(props);
- return mqttConfig;
- }
-
- /**
- * Create a topology for the subscriber application and run it.
- */
- private void run() throws Exception {
- DevelopmentProvider tp = new DevelopmentProvider();
-
- // build the application/topology
-
- Topology t = tp.newTopology("mqttSampleSubscriber");
-
- // System.setProperty("javax.net.debug", "ssl"); // or "all"; "help" for full list
-
- // Create the MQTT broker connector
- MqttConfig mqttConfig = createMqttConfig();
- MqttStreams mqtt = new MqttStreams(t, () -> mqttConfig);
-
- // Subscribe to the topic and create a stream of messages
- TStream<String> msgs = mqtt.subscribe(topic, 0/*qos*/);
-
- // Process the received msgs - just print them out
- msgs.sink(tuple -> System.out.println(
- String.format("[%s] received: %s", Util.simpleTS(), tuple)));
-
- // run the application / topology
- System.out.println("Console URL for the job: "
- + tp.getServices().getService(HttpServer.class).getConsoleUrl());
- tp.submit(t);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SubscriberApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SubscriberApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SubscriberApp.java
deleted file mode 100644
index e30f767..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/SubscriberApp.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.connectors.mqtt;
-
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_QOS;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_TOPIC;
-
-import org.apache.edgent.connectors.mqtt.MqttConfig;
-import org.apache.edgent.connectors.mqtt.MqttStreams;
-import org.apache.edgent.samples.connectors.Options;
-import org.apache.edgent.samples.connectors.Util;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.edgent.topology.TopologyProvider;
-
-/**
- * A MQTT subscriber topology application.
- */
-public class SubscriberApp {
- private final TopologyProvider tp;
- private final Options options;
-
- /**
- * @param top the TopologyProvider to use.
- * @param options
- */
- SubscriberApp(TopologyProvider tp, Options options) {
- this.tp = tp;
- this.options = options;
- }
-
- /**
- * Create a topology for the subscriber application.
- * @return the Topology
- */
- public Topology buildAppTopology() {
- Topology t = tp.newTopology("mqttClientSubscriber");
-
- // Create the MQTT broker connector
- MqttConfig config = Runner.newConfig(options);
- MqttStreams mqtt = new MqttStreams(t, () -> config);
-
- System.out.println("Using MQTT clientId " + config.getClientId());
-
- // Subscribe to the topic and create a stream of messages
- TStream<String> msgs = mqtt.subscribe(options.get(OPT_TOPIC),
- options.get(OPT_QOS));
-
- // Process the received msgs - just print them out
- msgs.sink(tuple -> System.out.println(
- String.format("[%s] received: %s", Util.simpleTS(), tuple)));
-
- return t;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/package-info.java
deleted file mode 100644
index 85602ef..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/package-info.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-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.
-*/
-
-/**
- * Samples showing use of the
- * <a href="{@docRoot}/org/apache/edgent/connectors/mqtt/package-summary.html">
- * MQTT stream connector</a>.
- * <p>
- * See <edgent-release>/scripts/connectors/mqtt/README to run the samples.
- * <p>
- * The following simple samples are provided:
- * <ul>
- * <li>SimplePublisherApp.java - a simple publisher application topology</li>
- * <li>SimpleSubscriberApp.java - a simple subscriber application topology</li>
- * </ul>
- * The remaining classes are part of a sample that more fully exposes
- * controlling various configuration options.
- */
-package org.apache.edgent.samples.connectors.mqtt;
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/obd2/Obd2Streams.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/obd2/Obd2Streams.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/obd2/Obd2Streams.java
deleted file mode 100644
index 13ab20a..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/obd2/Obd2Streams.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.connectors.obd2;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.apache.edgent.analytics.math3.stat.Regression.SLOPE;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MAX;
-import static org.apache.edgent.samples.connectors.elm327.Cmd.PID;
-import static org.apache.edgent.samples.connectors.elm327.Cmd.VALUE;
-import static org.apache.edgent.samples.connectors.elm327.Pids01.AIR_INTAKE_TEMP;
-import static org.apache.edgent.samples.connectors.elm327.Pids01.ENGINE_COOLANT_TEMP;
-import static org.apache.edgent.samples.connectors.elm327.Pids01.RPM;
-import static org.apache.edgent.samples.connectors.elm327.Pids01.SPEED;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.analytics.math3.json.JsonAnalytics;
-import org.apache.edgent.connectors.serial.SerialDevice;
-import org.apache.edgent.samples.connectors.elm327.Elm327Streams;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.TWindow;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- * Sample OBD-II streams.
- *
- */
-public class Obd2Streams {
-
- /**
- * Get a stream of temperature readings which
- * are increasing over the last minute.
- *
- * Poll temperatures every five seconds and
- * calculate the maximum reading and rate of change
- * (slope) over the last minute, partitioned by parameter
- * {@link org.apache.edgent.samples.connectors.elm327.Cmd#PID pid}. Filter so that only
- * those with a rate of increase greater than
- * or equal to 1 degree C/minute is present on the returned stream.
- *
- * Temperatures included are
- * {@link org.apache.edgent.samples.connectors.elm327.Pids01#AIR_INTAKE_TEMP AIR_INTAKE_TEMP} and
- * {@link org.apache.edgent.samples.connectors.elm327.Pids01#ENGINE_COOLANT_TEMP ENGINE_COOLANT_TEMP}.
- *
- * @param device Serial device the ELM327 is connected to.
- * @return Stream that will contain parameters with increasing temperatures.
- */
- public static TStream<JsonObject> increasingTemps(SerialDevice device) {
-
- TStream<JsonArray> tempsA = Elm327Streams.poll(device, 5, SECONDS,
- AIR_INTAKE_TEMP,
- ENGINE_COOLANT_TEMP);
-
- TStream<JsonObject> temps = tempsA.flatMap(je -> je).map(je -> je.getAsJsonObject());
-
- TWindow<JsonObject, JsonElement> window = temps.last(1, MINUTES, j -> j.get(PID));
-
- TStream<JsonObject> temperatureRate = JsonAnalytics.aggregate(window, PID, VALUE, MAX, SLOPE);
-
- // Have the stream contain only tuples where
- // the rise in temperatures >= 1 degree C/minute
- temperatureRate = temperatureRate.filter(j -> {
- JsonObject v = getObject(j, "value");
- return v.has("SLOPE") && getDouble(v, "SLOPE") >= 1.0;
- });
-
- return temperatureRate;
- }
-
- /**
- * Get a stream containing vehicle speed (km/h)
- * and engine revs (rpm).
- *
- * {@link org.apache.edgent.samples.connectors.elm327.Pids01#SPEED Speed}
- * and {@link org.apache.edgent.samples.connectors.elm327.Pids01#RPM engine revs}
- * are polled every 200ms and returned as a stream
- * containing JSON objects with keys {@code speed}
- * and {@code rpm}.
- *
- * The two readings may not be exactly consistent with
- * each other as there are fetched sequentially from
- * the ELM327.
- *
- * @param device Serial device the ELM327 is connected to.
- * @return Stream that will contain speed and engine revolutions.
- */
- public static TStream<JsonObject> tach(SerialDevice device) {
-
- TStream<JsonArray> rpmSpeed = Elm327Streams.poll(device, 200, TimeUnit.MILLISECONDS,
- SPEED, RPM);
-
- TStream<JsonObject> tach = rpmSpeed.map(ja -> {
- JsonObject j = new JsonObject();
-
- double speed = getDouble(ja.get(0), VALUE);
- double rpm = getDouble(ja.get(1), VALUE);
- j.addProperty("speed", speed);
- j.addProperty("rpm", rpm);
-
- return j;
- });
-
- return tach;
- }
-
- /**
- * Utility method to simplify accessing a JSON object.
- * @param json JSON object containing the object to be got.
- * @param key Key of the object to be got.
- * @return JSON object with key {@code key} from {@code json}.
- */
- public static JsonObject getObject(JsonObject json, String key) {
- return json.getAsJsonObject(key);
- }
-
- /**
- * Utility method to simplify accessing a number as a double.
- * @param json JSON object containing the number to be got.
- * @param key Key of the number to be got.
- * @return Number with key {@code key} from {@code json}.
- */
- public static double getDouble(JsonElement json, String key) {
- return json.getAsJsonObject().get(key).getAsDouble();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/package-info.java
deleted file mode 100644
index 4936d92..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-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.
-*/
-/**
- * General support for connector samples.
- */
-package org.apache.edgent.samples.connectors;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/resources/META-INF/NOTICE b/samples/connectors/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index cce431c..0000000
--- a/samples/connectors/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Connectors
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-===============================================================================
-
-Portions of this bundle were developed by IBM Corp.
-Copyright IBM Corp. 2015, 2016
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/.gitignore
----------------------------------------------------------------------
diff --git a/samples/console/.gitignore b/samples/console/.gitignore
deleted file mode 100644
index d3cd401..0000000
--- a/samples/console/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# sample's output file
-consoleUrl.txt
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/pom.xml
----------------------------------------------------------------------
diff --git a/samples/console/pom.xml b/samples/console/pom.xml
deleted file mode 100644
index ba9d3e2..0000000
--- a/samples/console/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>edgent-samples-console</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Console</name>
-
- <dependencies>
- <!-- parent pom has Platforms and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-console-server</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-utils-metrics</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/run-sample.sh
----------------------------------------------------------------------
diff --git a/samples/console/run-sample.sh b/samples/console/run-sample.sh
deleted file mode 100755
index f97b058..0000000
--- a/samples/console/run-sample.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-#
-# 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.
-#
-
-USAGE="usage: `basename $0` [--list] simple-main-class-name [sample-args]"
-
-CATEGORY=console
-
-UBER_JAR=target/edgent-samples-${CATEGORY}-*-uber.jar
-
-SAMPLE_PACKAGE_BASE=org.apache.edgent.samples.${CATEGORY}
-SAMPLES_FQ=`cat <<EOF
-${SAMPLE_PACKAGE_BASE}.ConsoleWaterDetector
-${SAMPLE_PACKAGE_BASE}.HttpServerSample
-EOF
-`
-
-if [ "$1" = "--list" ] ; then
- SAMPLES=
- for i in ${SAMPLES_FQ}; do
- SAMPLE=`echo ${i} | sed -e 's/.*\.//'`
- SAMPLES="${SAMPLES} ${SAMPLE}"
- done
- echo ${SAMPLES}
- exit 0
-fi
-if [ "$1" = "" ] ; then
- echo $USAGE
- exit 1
-fi
-
-SAMPLE_NAME=$1
-shift
-
-SAMPLE_FQ=
-for i in ${SAMPLES_FQ}; do
- SAMPLE_FQ=`echo $i | grep -- "\.${SAMPLE_NAME}\$"`
- if [ "${SAMPLE_FQ}" != "" ]; then
- break
- fi
-done
-if [ "${SAMPLE_FQ}" = "" ]; then
- echo unrecognized sample name \"${SAMPLE_NAME}\"
- echo ${USAGE}
- exit 1
-fi
-
-java -cp ${UBER_JAR} "${SAMPLE_FQ}" "$@"
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/src/main/java/org/apache/edgent/samples/console/ConsoleWaterDetector.java
----------------------------------------------------------------------
diff --git a/samples/console/src/main/java/org/apache/edgent/samples/console/ConsoleWaterDetector.java b/samples/console/src/main/java/org/apache/edgent/samples/console/ConsoleWaterDetector.java
deleted file mode 100644
index 9f6675c..0000000
--- a/samples/console/src/main/java/org/apache/edgent/samples/console/ConsoleWaterDetector.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
-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.
-*/
-package org.apache.edgent.samples.console;
-
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.metrics.Metrics;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.MetricRegistry;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- *
- * Demonstrates some of the features of the console.
- * <P>
- * The topology graph in the console currently allows for 3 distinct "views" of the topology:
- * <ul>
- * <li>Static flow</li>
- * <li>Tuple count</li>
- * <li>Oplet kind</li>
- * </ul>
- * <P>
- * Selecting any of these, with the exception of "Static flow", adds a legend to the topology which
- * allows the user to identify elements of the view.
- * </P>
- * <P> The "Static flow" view shows the toology in an unchanging state - that is if tuple counts are available the
- * lines (connections) representing the edges of the topology are not updated, nor are the circles (representing the vertices) dimensions updated.
- * The purpose of this view is to give the user an indication of the topology map of the application.
- * </P>
- * <P>
- * The "Oplet kind" view colors the oplets or vertices displayed in the topology graph (the circles) by their
- * corresponding Oplet kind.
- * </P>
- * <P>
- * If "Tuple count" is selected the legend reflects ranges of tuple counts measured since the application was started.
- * </P>
- * <P>
- * Note: The DevelopmentProvider class overrides the submit method of the DirectProvider class
- * and adds a Metrics counter to the submitted topology.
- * If a counter is not added to the topology (or to an individual oplet), the "Tuple count" view selection is not enabled.
- * </P>
- *
- * <P>
- * In the lower half of the edgent console is a chart displaying metrics, if available. In this example metrics
- * are available since the DevelopmentProvider class is being used. Note that the DevelopmentProvider class adds a Metrics counter
- * to all oplets in the topology, with the exception of certain oplet types. For further information
- * about how metrics are added to a topology, see the details in the org.apache.edgent.metrics.Metrics class and the counter method.
- * <br>
- * A counter can be added to an individual oplet, and not the entire topology. For an example of this
- * see the org.apache.edgent.samples.utils.metrics.DevelopmentMetricsSample.
- * </P>
- * <P>
- * The org.apache.edgent.metric.Metrics class also provides a rate meter. Rate meters must be added to individual oplets and are not currently
- * available for the entire topology.
- * </P>
-
- * <P>
- * The metrics chart displayed is a bar chart by default. If a rate meter is added to an oplet it will be displayed
- * as a line chart over the last 20 measures (the interval to refresh the line chart is every 2 1/2 seconds).
- * If a counter is added to a single oplet, the tuple count can also be displayed as a line chart.
- * </P>
- *
- * <P>
- * ConsoleWaterDetector scenario:
- * A county agency is responsible for ensuring the safety of residents well water. Each well they monitor has four different
- * sensor types:
- * <ul>
- * <li>Temperature</li>
- * <li>Acidity</li>
- * <li>Ecoli</li>
- * <li>Lead</li>
- * </ul>
- * <P>
- * This application topology monitors 3 wells:
- * <ul>
- * <li>
- * Each well that is to be measured is added to the topology. The topology polls each sensor for each well as a unit.
- * All the sensor readings for a single well are 'unioned' into a single TStream<JsonObject>.
- * </li>
- * <li>
- * Now, each well has a single stream with each of the sensors readings as a property with a name and value in the JsonObject.
- * Each well's sensors are then checked to see if their values are in an acceptable range. The filter oplet is used to check each sensor's range.
- * If any of the sensor's readings are out of the acceptable range the tuple is passed along. Those that are within an acceptable range
- * are discarded.
- * </li>
- * <li>
- * If the tuples in the stream for the well are out of range they are then passed to the split oplet. The split oplet breaks the single
- * TStream<JsonObject> into individual streams for each sensor type for the well.
- * </li>
- * <li>
- * Well1 and Well3's temperature sensor streams have rate meters placed on them. This will be used to compare the rate of tuples flowing through these
- * streams that are a result of out of range readings for Well1 and Well3 respectively.
- * </li>
- * <li>
- * Each stream that is produced from the split prints out the value for the sensor reading that it is monitoring along with the wellId.
- * </li>
- * </ul>
- *
- */
-
-public class ConsoleWaterDetector {
-
- /**
- * Hypothetical values for all the sensor types: temp, acidity, ecoli and Lead
- */
- static int TEMP_ALERT_MIN = 49;
- static int TEMP_ALERT_MAX = 81;
- static int TEMP_RANDOM_LOW = 40;
- static int TEMP_RANDOM_HIGH = 90;
- static String TEMP_ALERT_TAG = "TEMP out of range";
-
- static int ACIDITY_ALERT_MIN = 4;
- static int ACIDITY_ALERT_MAX = 9;
- static int ACIDITY_RANDOM_LOW = 1;
- static int ACIDITY_RANDOM_HIGH = 11;
- static String ACIDITY_ALERT_TAG = "ACIDITY out of range";
-
- static int ECOLI_ALERT = 1;
- static int ECOLI_RANDOM_LOW = 0;
- static int ECOLI_RANDOM_HIGH = 3;
- static String ECOLI_ALERT_TAG = "ECOLI out of range";
-
- static int LEAD_ALERT_MAX = 10;
- static int LEAD_RANDOM_LOW = 0;
- static int LEAD_RANDOM_HIGH = 15;
- static String LEAD_ALERT_TAG = "LEAD out of range";
-
- private static final Logger logger = LoggerFactory.getLogger(ConsoleWaterDetector.class);
-
- public static void main(String[] args) throws Exception {
- DirectProvider dp = new DevelopmentProvider();
-
- System.out.println(dp.getServices().getService(HttpServer.class).getConsoleUrl());
-
- try {
- PrintWriter writer = new PrintWriter("consoleUrl.txt", "UTF-8");
- writer.println(dp.getServices().getService(HttpServer.class).getConsoleUrl());
- writer.close();
- } catch ( Exception e) {
- logger.error("Exception caught", e);
- }
-
- Topology wellTopology = dp.newTopology("ConsoleWaterDetector");
-
- TStream<JsonObject> well1 = waterDetector(wellTopology, 1);
- TStream<JsonObject> well2 = waterDetector(wellTopology, 2);
- TStream<JsonObject> well3 = waterDetector(wellTopology, 3);
-
- TStream<JsonObject> filteredReadings1 = alertFilter(well1, 1, false);
- TStream<JsonObject> filteredReadings2 = alertFilter(well2, 2, true);
- TStream<JsonObject> filteredReadings3 = alertFilter(well3, 3, false);
-
- List<TStream<JsonObject>> individualAlerts1 = splitAlert(filteredReadings1, 1);
-
- // Put a rate meter on well1's temperature sensor output
- Metrics.rateMeter(individualAlerts1.get(0));
- individualAlerts1.get(0).tag(TEMP_ALERT_TAG, "well1").sink(tuple -> System.out.println("\n" + formatAlertOutput(tuple, "1", "temp")));
- individualAlerts1.get(1).tag(ACIDITY_ALERT_TAG, "well1").sink(tuple -> System.out.println(formatAlertOutput(tuple, "1", "acidity")));
- individualAlerts1.get(2).tag(ECOLI_ALERT_TAG, "well1").sink(tuple -> System.out.println(formatAlertOutput(tuple, "1", "ecoli")));
- individualAlerts1.get(3).tag(LEAD_ALERT_TAG, "well1").sink(tuple -> System.out.println(formatAlertOutput(tuple, "1", "lead")));
-
- List<TStream<JsonObject>> individualAlerts2 = splitAlert(filteredReadings2, 2);
-
- TStream<JsonObject> alert0Well2 = individualAlerts2.get(0);
- alert0Well2 = Metrics.counter(alert0Well2);
- alert0Well2.tag("well2", "temp");
-
- TStream<JsonObject> alert1Well2 = individualAlerts2.get(1);
- alert1Well2 = Metrics.counter(alert1Well2);
- alert1Well2.tag("well2", "acidity");
-
- TStream<JsonObject> alert2Well2 = individualAlerts2.get(2);
- alert2Well2 = Metrics.counter(alert2Well2);
- alert2Well2.tag("well2", "ecoli");
-
- TStream<JsonObject> alert3Well2 = individualAlerts2.get(3);
- alert3Well2 = Metrics.counter(alert3Well2);
- alert3Well2.tag("well2", "lead");
-
- List<TStream<JsonObject>> individualAlerts3 = splitAlert(filteredReadings3, 3);
-
- // Put a rate meter on well3's temperature sensor output
- Metrics.rateMeter(individualAlerts3.get(0));
- individualAlerts3.get(0).tag(TEMP_ALERT_TAG, "well3").sink(tuple -> System.out.println(formatAlertOutput(tuple, "3", "temp")));
- individualAlerts3.get(1).tag(ACIDITY_ALERT_TAG, "well3").sink(tuple -> System.out.println(formatAlertOutput(tuple, "3", "acidity")));
- individualAlerts3.get(2).tag(ECOLI_ALERT_TAG, "well3").sink(tuple -> System.out.println(formatAlertOutput(tuple, "3", "ecoli")));
- individualAlerts3.get(3).tag(LEAD_ALERT_TAG, "well3").sink(tuple -> System.out.println(formatAlertOutput(tuple, "3", "lead")));
-
- dp.submit(wellTopology);
-
- while (true) {
- MetricRegistry metricRegistry = dp.getServices().getService(MetricRegistry.class);
- SortedMap<String, Counter> counters = metricRegistry.getCounters();
-
- Set<Entry<String, Counter>> values = counters.entrySet();
- for (Entry<String, Counter> e : values) {
- if (e.getValue().getCount() == 0) {
- System.out.println("Counter Op:" + e.getKey() + " has a tuple count of zero!");
- }
- }
- Thread.sleep(2000);
- }
- }
-
- /**
- * Creates a TStream<JsonObject> for each sensor reading for each well. Unions all the TStream<JsonObject> into a
- * single one representing all readings on the well.
- * @param topology Topology providing the tuples for the sensors
- * @param wellId Id of the well sending the measurements
- * @return TStream<JsonObject> containing a measurement from each sensor type.
- * Creates a single TStream<JsonObject> from polling the four sensor types as TStream<Integer>
- */
- public static TStream<JsonObject> waterDetector(Topology topology, int wellId) {
- Random rNum = new Random();
- TStream<Integer> temp = topology.poll(() -> rNum.nextInt(TEMP_RANDOM_HIGH - TEMP_RANDOM_LOW) + TEMP_RANDOM_LOW, 1, TimeUnit.SECONDS);
- TStream<Integer> acidity = topology.poll(() -> rNum.nextInt(ACIDITY_RANDOM_HIGH - ACIDITY_RANDOM_LOW) + ACIDITY_RANDOM_LOW, 1, TimeUnit.SECONDS);
- TStream<Integer> ecoli = topology.poll(() -> rNum.nextInt(ECOLI_RANDOM_HIGH - ECOLI_RANDOM_LOW) + ECOLI_RANDOM_LOW, 1, TimeUnit.SECONDS);
- TStream<Integer> lead = topology.poll(() -> rNum.nextInt(LEAD_RANDOM_HIGH - LEAD_RANDOM_LOW) + LEAD_RANDOM_LOW, 1, TimeUnit.SECONDS);
- TStream<Integer> id = topology.poll(() -> wellId, 1, TimeUnit.SECONDS);
-
- // add tags to each sensor
- temp.tag("temperature", "well" + wellId);
- acidity.tag("acidity", "well" + wellId);
- ecoli.tag("ecoli", "well" + wellId);
- lead.tag("lead", "well" + wellId);
- id.tag("well" + wellId);
-
- TStream<JsonObject> tempObj = temp.map(t -> {
- JsonObject jObj = new JsonObject();
- jObj.addProperty("temp", t);
- return jObj;
- });
-
- TStream<JsonObject> acidityObj = acidity.map(a -> {
- JsonObject jObj = new JsonObject();
- jObj.addProperty("acidity", a);
- return jObj;
- });
-
- TStream<JsonObject> ecoliObj = ecoli.map(e -> {
- JsonObject jObj = new JsonObject();
- jObj.addProperty("ecoli", e);
- return jObj;
- });
-
- TStream<JsonObject> leadObj = lead.map(l -> {
- JsonObject jObj = new JsonObject();
- jObj.addProperty("lead", l);
- return jObj;
- });
-
- TStream<JsonObject> idObj = id.map(i -> {
- JsonObject jObj = new JsonObject();
- jObj.addProperty("id", i);
- return jObj;
- });
-
- // ArrayAsList
- HashSet<TStream<JsonObject>> set = new HashSet <TStream<JsonObject>>();
- set.add(acidityObj);
- set.add(acidityObj);
- set.add(ecoliObj);
- set.add(leadObj);
- set.add(idObj);
-
- TStream<JsonObject> allReadings = tempObj.union(set);
-
- return allReadings;
- }
-
- /**
- * Look through the stream and check to see if any of the measurements cause concern.
- * Only a TStream that has one or more of the readings at "alert" level are passed through
- * @param readingsDetector The TStream<JsonObject> that represents all of the different sensor readings for the well
- * @param wellId The id of the well
- * @param simulateNormal Make this stream simulate all readings within the normal range, and therefore will not pass through the filter
- * @return TStream<JsonObject> that contain readings that could cause concern. Note: if any reading is out of range the tuple
- * will be returned
- */
-
- public static TStream<JsonObject> alertFilter(TStream<JsonObject> readingsDetector, int wellId, boolean simulateNormal) {
- readingsDetector = readingsDetector.filter(r -> {
- if (simulateNormal == true) {
- return false;
- }
-
- JsonElement tempElement = r.get("temp");
- if (tempElement != null) {
- int temp = tempElement.getAsInt();
- return (temp <= TEMP_ALERT_MIN || temp >= TEMP_ALERT_MAX);
- }
-
- JsonElement acidElement = r.get("acidity");
- if (acidElement != null) {
- int acid = acidElement.getAsInt();
- return (acid <= ACIDITY_ALERT_MIN || acid >= ACIDITY_ALERT_MAX);
- }
-
- JsonElement ecoliElement = r.get("ecoli");
- if (ecoliElement != null) {
- int ecoli = ecoliElement.getAsInt();
- return ecoli >= ECOLI_ALERT;
- }
-
- JsonElement leadElement = r.get("lead");
- if (leadElement != null) {
- int lead = leadElement.getAsInt();
- return lead >= LEAD_ALERT_MAX;
- }
-
- return false;
- });
-
- return readingsDetector;
- }
- /**
- * Splits the incoming TStream<JsonObject> into individual TStreams based on the sensor type
- * @param alertStream The TStream<JsonObject> that we know has some out of range condition - it could be temp, acidity, ecoli or lead
- * - or all of them
- * @param wellId The id of the well that has the out of range readings
- * @return List<TStream<JsonObject>> - one for each sensor.
- */
- public static List<TStream<JsonObject>> splitAlert(TStream<JsonObject> alertStream, int wellId) {
-
- List<TStream<JsonObject>> allStreams = alertStream.split(5, tuple -> {
- if (tuple.get("temp") != null) {
- JsonObject tempObj = new JsonObject();
- int temp = tuple.get("temp").getAsInt();
- if (temp <= TEMP_ALERT_MIN || temp >= TEMP_ALERT_MAX) {
- tempObj.addProperty("temp", temp);
- return 0;
- } else {
- return -1;
- }
- } else if (tuple.get("acidity") != null){
- JsonObject acidObj = new JsonObject();
- int acid = tuple.get("acidity").getAsInt();
- if (acid <= ACIDITY_ALERT_MIN || acid >= ACIDITY_ALERT_MAX) {
- acidObj.addProperty("acidity", acid);
- return 1;
- } else {
- return -1;
- }
- } else if (tuple.get("ecoli") != null) {
- JsonObject ecoliObj = new JsonObject();
- int ecoli = tuple.get("ecoli").getAsInt();
- if (ecoli >= ECOLI_ALERT) {
- ecoliObj.addProperty("ecoli", ecoli);
- return 2;
- } else {
- return -1;
- }
- } else if (tuple.get("lead") != null) {
- JsonObject leadObj = new JsonObject();
- int lead = tuple.get("lead").getAsInt();
- if (lead >= LEAD_ALERT_MAX) {
- leadObj.addProperty("lead", lead);
- return 3;
- } else {
- return -1;
- }
- } else {
- return -1;
- }
- });
-
- return allStreams;
- }
-
- /**
- * Formats the output of the alert, containing the well id, sensor type and value of the sensor
- * @param alertObj The tuple that contains out of range readings
- * @param wellId The id of the well
- * @param alertType The type of sensor that has the possible alert on it
- * @return String containing the wellId, sensor type and sensor value
- */
- public static String formatAlertOutput(JsonObject alertObj, String wellId, String alertType) {
- return "Well" + wellId + " alert, " + alertType + " value is " + alertObj.get(alertType).getAsInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/src/main/java/org/apache/edgent/samples/console/HttpServerSample.java
----------------------------------------------------------------------
diff --git a/samples/console/src/main/java/org/apache/edgent/samples/console/HttpServerSample.java b/samples/console/src/main/java/org/apache/edgent/samples/console/HttpServerSample.java
deleted file mode 100644
index 1885e57..0000000
--- a/samples/console/src/main/java/org/apache/edgent/samples/console/HttpServerSample.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-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.
-*/
-
-package org.apache.edgent.samples.console;
-
-import org.apache.edgent.console.server.HttpServer;
-
-public class HttpServerSample {
-
- public static void main(String[] args) {
-
- try {
- HttpServer server = HttpServer.getInstance();
- server.startServer();
- String consolePath = server.getConsoleUrl();
- System.out.println("Point your browser to :");
- System.out.println(consolePath);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/src/main/java/org/apache/edgent/samples/console/package-info.java
----------------------------------------------------------------------
diff --git a/samples/console/src/main/java/org/apache/edgent/samples/console/package-info.java b/samples/console/src/main/java/org/apache/edgent/samples/console/package-info.java
deleted file mode 100644
index 3beac82..0000000
--- a/samples/console/src/main/java/org/apache/edgent/samples/console/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-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.
-*/
-
-/**
- * Samples showing use of the Console web application.
- * The following simple samples are provided:
- * <ul>
- * <li>ConsoleWaterDetector.java - a simple application topology demonstrating features of the console like viewing the topology by
- * Stream tags, Oplet kind and Tuple count. A DevelopmentProvider is used which automatically adds a Metrics counter to the topology.
- * </li>
- * <li>HttpServerSample.java - a <i>very</i> simple application that just brings up the Edgent console - with no jobs.</li>
- * </ul>
- */
-package org.apache.edgent.samples.console;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/console/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/console/src/main/resources/META-INF/NOTICE b/samples/console/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 0b5f6e3..0000000
--- a/samples/console/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Console
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-===============================================================================
-
-Portions of this bundle were developed by IBM Corp.
-Copyright IBM Corp. 2015, 2016
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/cron/.gitignore
----------------------------------------------------------------------
diff --git a/samples/cron/.gitignore b/samples/cron/.gitignore
deleted file mode 100644
index 127f7ab..0000000
--- a/samples/cron/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-
-# mkcrontab generated output
-startapp.cron
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/cron/README.md
----------------------------------------------------------------------
diff --git a/samples/cron/README.md b/samples/cron/README.md
deleted file mode 100644
index 0c641e1..0000000
--- a/samples/cron/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-Restarting Edgent if the JVM crashes
-
-The startapp.sh script can be setup to run as a cron job every minute in order
-to monitor a JVM running an Edgent application and restart Edgent if the
-JVM crashes. The script checks whether the pid of the JVM indicates
-a process which is still running. If the pid is not there, it executes the
-command to start the application in the first place.
-
-A crontab entry file contains information which cron uses to schedule the job.
-The sample startapp.cron file is configured to execute the
-org.apache.edgent.samples.topology.TerminateAfterNTuples sample application,
-which terminates the JVM after processing a preset number of tuples.
-
-See README.md in the samples root directory for information on building the samples.
-
-To setup cron to restart the sample application every minute:
-
-1. Create the startapp.cron file from the startapp.cron.template file:
-
- $ ./mkcrontab
-
-2. Install startapp.cron:
-
- $ crontab ./startapp.cron
-
- Note: if you wish to have your ~/.profile executed you must explicitly
- do so in the crontab entry or in a script called by the entry.
-
-3. To see the set crontab entries:
-
- $ crontab -l
-
-3. To remove the current crontab entries:
-
- $ crontab -r
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/cron/mkcrontab.sh
----------------------------------------------------------------------
diff --git a/samples/cron/mkcrontab.sh b/samples/cron/mkcrontab.sh
deleted file mode 100755
index 61afc3b..0000000
--- a/samples/cron/mkcrontab.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env bash
-#
-# 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.
-#
-
-USAGE="usage: `basename $0`"
-
-set -e
-
-if [ "${JAVA_HOME}" = "" ]; then
- echo JAVA_HOME not set
- exit 1
-fi
-
-EDGENT_SAMPLES_DIR=`pwd`/..
-
-TOPOLOGY_SAMPLES_JAR=`echo ${EDGENT_SAMPLES_DIR}/topology/target/edgent-samples-topology-*-uber.jar`
-
-sed -e "s,{EDGENT_SAMPLES_DIR},${EDGENT_SAMPLES_DIR},g" \
- -e "s,{TOPOLOGY_SAMPLES_JAR},${TOPOLOGY_SAMPLES_JAR},g" \
- -e "s,{JAVA_HOME},${JAVA_HOME},g" \
- <startapp.cron.template >startapp.cron
-
-echo created startapp.cron
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/cron/startapp.cron.template
----------------------------------------------------------------------
diff --git a/samples/cron/startapp.cron.template b/samples/cron/startapp.cron.template
deleted file mode 100644
index 9eed367..0000000
--- a/samples/cron/startapp.cron.template
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# 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.
-#
-# Crontab file which contains settings for scheduling the execution of a
-# monitoring script every minute using cron.
-
-JAVA_HOME={JAVA_HOME}
-
-* * * * * {EDGENT_SAMPLES_DIR}/cron/startapp.sh {TOPOLOGY_SAMPLES_JAR} org.apache.edgent.samples.topology.TerminateAfterNTuples /tmp >> /tmp/edgent-cron.log
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/cron/startapp.sh
----------------------------------------------------------------------
diff --git a/samples/cron/startapp.sh b/samples/cron/startapp.sh
deleted file mode 100755
index 6954f23..0000000
--- a/samples/cron/startapp.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-_usage() {
- echo -e "Usage: ${0} {classpath} {mainclass} [dir]\n\n\
-Runs a Java application while saving its stdout to dir/mainclass.out, its stderr to dir/mainclass.err, and its process id to dir/mainclass.pid.\n\
-\n\
-This script starts a Java application only if it cannot find its pid. If the process id specified by dir/mainclass.pid exists, then the script will not start the application.\n\
-\n\
- classpath The application's class path.\n\
- classname The name of the class to be launched.\n\
- dir The directory where the process stdout, stderr and pid files are\n\
- written. If dir is not specified, then the files are saved into\n\
- the current directory.\n\
-"
-}
-
-# _get_pid program [pidfile]
-# Set $pid to pids from /tmp* for {program}.
-# $pid should be declared local in the caller.
-_get_pid() {
- local base=${1##*/}
- local pid_file=${2:-/tmp/$base.pid}
-
- pid=
- if [ -f "$pid_file" ] ; then
- local p
-
- [ ! -r "$pid_file" ] && return 1 # "Cannot access pid file"
-
- p=$(cat "$pid_file")
- [ -z "${p//[0-9]/}" ] && [ -d "/proc/$p" ] && pid="$p"
- if [ -n "$pid" ]; then
- return 0
- fi
- return 2 # "Program is not running but pid file exists"
- fi
- return 3 # "Program pid file does not exist"
-}
-
-# _readlink path
-# Output the full path, replacement for readlink -f
-_readlink() {
- (
- pushd ${1%/*} > /dev/null 2>&1
- echo $PWD/${1##*/}
- popd > /dev/null 2>&1
- )
-}
-
-# _dirname path
-# Get the directory name, replacement for dirname.
-_dirname() {
- echo ${1%/*}
-}
-
-_error() {
- echo $1; exit 1
-}
-
-
-## Main script
-#[ ! -n "${EDGENT:-}" ] && EDGENT=../..
-[ ! -n "${JAVA_HOME:-}" ] && _error "JAVA_HOME must be set"
-
-if [ $# -lt 2 ]; then
- _usage
- exit 1
-fi
-
-classpath=${1}
-main_class=${2}
-out_dir=${3:-.}
-
-# Command to start the application.
-command="${JAVA_HOME}/bin/java -cp ${classpath} ${main_class}"
-
-if [[ ! -d ${out_dir} || ${out_dir:0:1} != '/' ]]; then
- ## out_dir as absolute path
- out_dir=$(_readlink ${out_dir})
- out_dir=$(_dirname ${out_dir})
-fi
-
-pid_file=${out_dir}/${main_class}.pid
-out_file=${out_dir}/${main_class}.out
-err_file=${out_dir}/${main_class}.err
-pid=
-
-_get_pid $main_class $pid_file
-RC="$?"
-[ $RC == "1" ] && _error "Cannot access pid file $pid_file"
-
-if [ -z "$pid" ]; then
- $command >> $out_file 2>> $err_file &
- pid="$!"
- echo $pid >| $pid_file
- echo -e "The program was restarted with command:\n\
-${command}\n\
-Process id: $pid"
-else
- echo "The program's process id is $pid"
-fi
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/.gitignore
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/.gitignore b/samples/get-edgent-jars-project/.gitignore
deleted file mode 100644
index 574159f..0000000
--- a/samples/get-edgent-jars-project/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-
-# generated from pom.xml.template
-pom.xml
-
-# old-get-edgent-jars.sh generated outout
-tmp-get-edgent-jars-project
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/README.md
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/README.md b/samples/get-edgent-jars-project/README.md
deleted file mode 100644
index 174980c..0000000
--- a/samples/get-edgent-jars-project/README.md
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
- 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.
--->
-
-The `get-edgent-jars-project` can be used to copy Apache Edgent jars
-and their transitive dependencies from a local or remote maven
-repository into bundles under `target`.
-
-Use `get-edgent-jars.sh` to create bundles containing the jars.
-The script also creates `target/classpath.sh` for composing a classpath
-to use the Edgent jars.
-
-By default the script retrieves the Edgent java8 platform jars for the
-project's default Edgent version.
-
-``` sh
-cd get-edgent-jars-project
-./get-edgent-jars.sh --version 1.3.0-SNAPSHOT # retrieve the Edgent 1.3.0-SNAPSHOT java8 jars
-##### Generating dependency decls...
-##### Generating pom.xml...
-...
-##### Generating the bundles...
-...
-##### Generating classpath.sh...
-##### Bundle LICENSING information:
-...
-##### Using a bundle:
-
- copy a bundle from target and unpack it
- copy target/classpath.sh and use it to compose a classpath:
-
- export CLASSPATH=`./classpath.sh --add-slf4j-jdk <path-to-unpacked-bundle>`
-
- Omit "--add-slf4j-jdk" to omit an slf4j-jdk* implementation jar from the classpath.
-```
-
-
-For more usage information:
-``` sh
-get-edgent-jars.sh -h
-```
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/get-edgent-jars.sh
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/get-edgent-jars.sh b/samples/get-edgent-jars-project/get-edgent-jars.sh
deleted file mode 100755
index 3bdacd6..0000000
--- a/samples/get-edgent-jars-project/get-edgent-jars.sh
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-## Get the Apache Edgent jars and their transitive external dependencies.
-##
-## By default get the Edgent java8 platform jars for the script's default Edgent version.
-##
-## --platform {java8|java7|android} get the specified target platform jars
-## --version edgent-version get the specified version's jars (e.g., 1.2.0)
-## --artifacts csv-gav-list get only the specified artifacts. Not restricted to Edgent jars.
-## The Edgent version is substituted for all instances of '{EV}'
-## --file gav-file get only the specified artifacts. Not restricted to Edgent jars.
-## The Edgent version is substituted for all instances of '{EV}'
-## Lines that begin with '#' are ignored.
-## --mvn mvn-cmd use mvn-cmd instead of "../mvnw"
-##
-## Creates bundles and classpath.sh in the target dir.
-
-USAGE="usage: [--platform {java8|java7|android}] [--version edgent-version] [--artifacts csv-gav-list] [--file gav-file] [--mvn mvn-cmd]"
-
-set -e
-
-# project dir is where this script resides
-PROJ_DIR=`(cd $(dirname $0); pwd)`
-
-SAMPLES_DIR=`(cd $(dirname $0); pwd)`/..
-MVN_CMD=${SAMPLES_DIR}/mvnw
-
-EDGENT_PLATFORM=java8
-EDGENT_VERSION=
-SLF4J_VERSION=1.7.12
-
-if [ "$1" = "--platform" -a $# -gt 1 ]; then
- EDGENT_PLATFORM=$2; shift; shift
-fi
-if [ "$1" = "--version" -a $# -gt 1 ]; then
- EDGENT_VERSION=$2; shift; shift
-fi
-OPT_GAVS=
-if [ "$1" = "--artifacts" -a $# -gt 1 ]; then
- OPT_CSV_GAVS=$2; shift; shift
- OPT_GAVS=`echo "${OPT_CSV_GAVS}" | sed -e 's/,/ /g'`
-fi
-if [ "$1" = "--file" -a $# -gt 1 ]; then
- OPT_GAVS_FILE=$2; shift; shift
- OPT_GAVS=`sed -e '/^#/d' < ${OPT_GAVS_FILE}`
-fi
-if [ "$1" = "--mvn" -a $# -gt 1 ]; then
- MVN_CMD=$2; shift; shift
-fi
-if [ $# != 0 ]; then
- echo "$USAGE"
- exit 1
-fi
-
-# only declare "top level" Edgent components that a user
-# would directly declare/use and let these components
-# (most typically the provider) pull in the rest of the
-# Edgent jars (and their dependencies)
-#
-# Explicitly add edgent-connectors-websocket-jetty
-# as there's not a direct dependency on it from connectors-websocket.
-#
-# Hmm... consider adding org.apache.edgent.console:edgent-console-servlets:{EV}:war
-# It's bundled in edgent-console-server.jar. Having it separately available
-# would enable having the "console" in a Servler engine of the user's choosing.
-# If added, may want to put it in a directory other than edgent-jars.
-#
-DEFAULT_GAVS=`cat << EOF
-org.slf4j:slf4j-jdk14:${SLF4J_VERSION}
-org.apache.edgent:edgent-analytics-math3:{EV}
-org.apache.edgent:edgent-analytics-sensors:{EV}
-org.apache.edgent:edgent-connectors-command:{EV}
-org.apache.edgent:edgent-connectors-csv:{EV}
-org.apache.edgent:edgent-connectors-file:{EV}
-org.apache.edgent:edgent-connectors-http:{EV}
-org.apache.edgent:edgent-connectors-iot:{EV}
-org.apache.edgent:edgent-connectors-iotp:{EV}
-org.apache.edgent:edgent-connectors-jdbc:{EV}
-org.apache.edgent:edgent-connectors-kafka:{EV}
-org.apache.edgent:edgent-connectors-mqtt:{EV}
-org.apache.edgent:edgent-connectors-pubsub:{EV}
-org.apache.edgent:edgent-connectors-serial:{EV}
-org.apache.edgent:edgent-connectors-websocket:{EV}
-org.apache.edgent:edgent-connectors-websocket-jetty:{EV}
-org.apache.edgent:edgent-providers-development:{EV}
-org.apache.edgent:edgent-providers-direct:{EV}
-org.apache.edgent:edgent-providers-iot:{EV}
-org.apache.edgent:edgent-utils-metrics:{EV}
-org.apache.edgent:edgent-utils-streamscope:{EV}
-EOF
-`
-if [ "${EDGENT_PLATFORM}" != "java8" ]; then
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}" | sed -e "s/apache.edgent/apache.edgent.${EDGENT_PLATFORM}/"`
-fi
-if [ "${EDGENT_PLATFORM}" == "android" ]; then
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}" | sed -e "/edgent-providers-development/d"`
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}"; echo "org.apache.edgent.android:edgent-android-hardware:{EV}"`
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}"; echo "org.apache.edgent.android:edgent-android-topology:{EV}"`
-fi
-
-
-function confirm () { # [$1: question]
- while true; do
- # call with a prompt string or use a default
- /bin/echo -n "${1:-Are you sure?}"
- read -r -p " [y/n] " response
- case ${response} in
- [yY]) return `true` ;;
- [nN]) return `false` ;;
- *) echo "illegal response '$response'" ;;
- esac
- done
-}
-
-###########################
-echo
-echo "##### Generating dependency decls..."
-ARTIFACT_GAVS="${OPT_GAVS:-${DEFAULT_GAVS}}"
-mkdir -p target
-DEP_DECLS_FILE=target/tmp-dep-decls
-rm -f ${DEP_DECLS_FILE}
-for i in ${ARTIFACT_GAVS}; do
- echo ${i} | awk -F : '{ type=""; if ($3 == "{EV}") $3="${edgent.runtime.version}"; if ($4 != "") type=" <type>" $4 "</type>\n"; printf "<dependency>\n <groupId>%s</groupId>\n <artifactId>%s</artifactId>\n <version>%s</version>\n%s</dependency>\n", $1, $2, $3, type }' >> ${DEP_DECLS_FILE}
-done
-DEP_DECLS=`cat ${DEP_DECLS_FILE}`
-
-###########################
-echo
-echo "##### Generating pom.xml..."
-cd ${PROJ_DIR}
-cp pom.xml.template pom.xml
-ed -s pom.xml <<EOF
-/INJECT_DEPENDENCIES_HERE
-a
-${DEP_DECLS}
-.
-wq
-EOF
-
-###########################
-echo
-echo "##### Generating the bundles..."
-EDGENT_VERSION_PROPERTY=
-if [ "${EDGENT_VERSION}" ]; then
- EDGENT_VERSION_PROPERTY=-Dedgent.runtime.version=${EDGENT_VERSION}
-fi
-PLATFORM_PROFILE=
-if [ ${EDGENT_PLATFORM} != "java8" ]; then
- PLATFORM_PROFILE="-Pplatform-${EDGENT_PLATFORM}"
-fi
-${MVN_CMD} clean package ${EDGENT_VERSION_PROPERTY} ${PLATFORM_PROFILE}
-
-
-###########################
-echo
-echo "##### Generating classpath.sh..."
-cat << 'EOF' > ${PROJ_DIR}/target/classpath.sh
-#!/bin/sh
-USAGE="usage: classpath.sh [--add-slf4j-jdk] <path-to-unpacked-bundle>"
-set -e
-if [ "${1}" == "--add-slf4j-jdk" ]; then
- ADD_SLF4J_IMPL=slf4j-jdk
- shift
-fi
-if [ $# != 1 ] || [[ ${1} == -* ]] ; then
- echo "${USAGE}"
- exit 1
-fi
-BASEDIR=${1}
-cd ${BASEDIR}
-SEP=
-CP=
-if [ "`ls libs 2>/dev/null`" != "" ]; then
- for i in libs/*; do
- CP="${CP}${SEP}${BASEDIR}/${i}"
- SEP=":"
- done
-fi
-if [ "`ls ext 2>/dev/null`" != "" ]; then
- for i in ext/*; do
- if [[ ${i} == */slf4j-* ]] && [[ ${i} != */slf4j-api-* ]] ; then
- # it's an slf4j impl
- if [[ "${ADD_SLF4J_IMPL}" == "" ]] || [[ ${i} != */${ADD_SLF4J_IMPL}* ]] ; then
- continue
- fi
- fi
- CP="${CP}${SEP}${BASEDIR}/${i}"
- SEP=":"
- done
-fi
-echo "${CP}"
-EOF
-chmod +x target/classpath.sh
-
-###########################
-echo
-echo "##### Bundle LICENSING information:"
-echo
-cat ${PROJ_DIR}/src/main/resources/README
-echo
-cat <<'EOF'
-##### Using a bundle:
-
- copy a bundle from target and unpack it
- copy target/classpath.sh and use it to compose a classpath:
-
- export CLASSPATH=`./classpath.sh --add-slf4j-jdk <path-to-unpacked-bundle>`
-
- Omit "--add-slf4j-jdk" to omit an slf4j-jdk* implementation jar from the classpath.
-EOF
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/old-get-edgent-jars.sh
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/old-get-edgent-jars.sh b/samples/get-edgent-jars-project/old-get-edgent-jars.sh
deleted file mode 100755
index 102467e..0000000
--- a/samples/get-edgent-jars-project/old-get-edgent-jars.sh
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/bin/sh
-#
-# 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.
-#
-
-## Get the Apache Edgent jars and their transitive external dependencies.
-##
-## By default get the Edgent java8 platform jars for the script's default Edgent version.
-##
-## --platform {java8|java7|android} get the specified target platform jars
-## --version edgent-version get the specified version's jars (e.g., 1.2.0)
-## --artifacts csv-gav-list get only the specified artifacts. Not restricted to Edgent jars.
-## The Edgent version is substituted for all instances of '{EV}'
-## --file gav-file get only the specified artifacts. Not restricted to Edgent jars.
-## The Edgent version is substituted for all instances of '{EV}'
-## Lines that begin with '#' are ignored.
-## --mvn mvn-cmd use mvn-cmd instead of "./mvnw"
-##
-## Creates the directory get-edgent-jars-project and a maven project in it
-
-USAGE="usage: [--platform {java8|java7|android}] [--version edgent-version] [--artifacts csv-gav-list] [--file gav-file] [--mvn mvn-cmd]"
-
-set -e
-
-SAMPLES_DIR=`(cd $(dirname $0); pwd)`/..
-MVN_CMD=${SAMPLES_DIR}/mvnw
-
-EDGENT_PLATFORM=java8
-EDGENT_VERSION=1.2.0
-SLF4J_VERSION=1.7.12
-
-PROJ_DIR=tmp-get-edgent-jars-project
-
-if [ "$1" = "--platform" -a $# -gt 1 ]; then
- EDGENT_PLATFORM=$2; shift; shift
-fi
-if [ "$1" = "--version" -a $# -gt 1 ]; then
- EDGENT_VERSION=$2; shift; shift
-fi
-OPT_GAVS=
-if [ "$1" = "--artifacts" -a $# -gt 1 ]; then
- OPT_CSV_GAVS=$2; shift; shift
- OPT_GAVS=`echo "${OPT_CSV_GAVS}" | sed -e 's/,/ /g'`
-fi
-if [ "$1" = "--file" -a $# -gt 1 ]; then
- OPT_GAVS_FILE=$2; shift; shift
- OPT_GAVS=`sed -e '/^#/d' < ${OPT_GAVS_FILE}`
-fi
-if [ "$1" = "--mvn" -a $# -gt 1 ]; then
- MVN_CMD=$2; shift; shift
-fi
-if [ $# != 0 ]; then
- echo "$USAGE"
- exit 1
-fi
-
-# only declare "top level" Edgent components that a user
-# would directly declare/use and let these components
-# (most typically the provider) pull in the rest of the
-# Edgent jars (and their dependencies)
-#
-# Explicitly add edgent-connectors-websocket-jetty
-# as there's not a direct dependency on it from connectors-websocket.
-#
-# Hmm... consider adding org.apache.edgent.console:edgent-console-servlets:{EV}:war
-# It's bundled in edgent-console-server.jar. Having it separately available
-# would enable having the "console" in a Servler engine of the user's choosing.
-# If added, may want to put it in a directory other than edgent-jars.
-#
-DEFAULT_GAVS=`cat << EOF
-org.slf4j:slf4j-jdk14:${SLF4J_VERSION}
-org.apache.edgent:edgent-analytics-math3:{EV}
-org.apache.edgent:edgent-analytics-sensors:{EV}
-org.apache.edgent:edgent-connectors-command:{EV}
-org.apache.edgent:edgent-connectors-csv:{EV}
-org.apache.edgent:edgent-connectors-file:{EV}
-org.apache.edgent:edgent-connectors-http:{EV}
-org.apache.edgent:edgent-connectors-iot:{EV}
-org.apache.edgent:edgent-connectors-iotp:{EV}
-org.apache.edgent:edgent-connectors-jdbc:{EV}
-org.apache.edgent:edgent-connectors-kafka:{EV}
-org.apache.edgent:edgent-connectors-mqtt:{EV}
-org.apache.edgent:edgent-connectors-pubsub:{EV}
-org.apache.edgent:edgent-connectors-serial:{EV}
-org.apache.edgent:edgent-connectors-websocket:{EV}
-org.apache.edgent:edgent-connectors-websocket-jetty:{EV}
-org.apache.edgent:edgent-providers-development:{EV}
-org.apache.edgent:edgent-providers-direct:{EV}
-org.apache.edgent:edgent-providers-iot:{EV}
-org.apache.edgent:edgent-utils-metrics:{EV}
-org.apache.edgent:edgent-utils-streamscope:{EV}
-EOF
-`
-if [ "${EDGENT_PLATFORM}" != "java8" ]; then
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}" | sed -e "s/apache.edgent/apache.edgent.${EDGENT_PLATFORM}/"`
-fi
-if [ "${EDGENT_PLATFORM}" == "android" ]; then
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}" | sed -e "/edgent-providers-development/d"`
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}"; echo "org.apache.edgent.android:edgent-android-hardware:{EV}"`
- DEFAULT_GAVS=`echo "${DEFAULT_GAVS}"; echo "org.apache.edgent.android:edgent-android-topology:{EV}"`
-fi
-
-
-function confirm () { # [$1: question]
- while true; do
- # call with a prompt string or use a default
- /bin/echo -n "${1:-Are you sure?}"
- read -r -p " [y/n] " response
- case $response in
- [yY]) return `true` ;;
- [nN]) return `false` ;;
- *) echo "illegal response '$response'" ;;
- esac
- done
-}
-
-###########################
-cat <<EOF
-This command downloads the Apache Edgent jars and their transitive external dependencies.
-The external dependencies have their own licensing term that you should review.
-A summary of the external dependencies can be found here <TODO URL>.
-EOF
-confirm "Continue?" || exit
-
-###########################
-if [ ! -d ${PROJ_DIR} ]; then
- echo "##### Generating maven project ${PROJ_DIR}..."
- # ensure a standalone pom (no parent) to avoid unwanted inherited deps
- TMP_PROJ=${PROJ_DIR}-tmp
- mkdir ${TMP_PROJ}
- cd ${TMP_PROJ}
- ${MVN_CMD} -B archetype:generate \
- -DarchetypeGroupId=org.apache.maven.archeTypes \
- -DarchetypeArtifactId=maven-archetype-quickstart \
- -DgroupId=org.apache.edgent.tools \
- -DartifactId=${PROJ_DIR} \
- -Dversion=1.0
- cd ..
- mv ${TMP_PROJ}/${PROJ_DIR} ${PROJ_DIR}
- rmdir ${TMP_PROJ}
- cp ${PROJ_DIR}/pom.xml ${PROJ_DIR}/pom.xml.orig
-else
- cp ${PROJ_DIR}/pom.xml.orig ${PROJ_DIR}/pom.xml
-fi
-
-###########################
-
-cd ${PROJ_DIR}
-
-###########################
-
-###########################
-echo
-echo "##### Generating dependency decls..."
-ARTIFACT_GAVS="${OPT_GAVS:-${DEFAULT_GAVS}}"
-ARTIFACT_GAVS=`echo "${ARTIFACT_GAVS}" | sed -e "s/{EV}/${EDGENT_VERSION}/g"`
-mkdir -p target
-DEP_DECLS_FILE=target/tmp-dep-decls
-rm -f ${DEP_DECLS_FILE}
-for i in ${ARTIFACT_GAVS}; do
- echo $i | awk -F : '{ type=""; if ($4 != "") type=" <type>" $4 "</type>\n"; printf "<dependency>\n <groupId>%s</groupId>\n <artifactId>%s</artifactId>\n <version>%s</version>\n%s</dependency>\n", $1, $2, $3, type }' >> ${DEP_DECLS_FILE}
-done
-DEP_DECLS=`cat ${DEP_DECLS_FILE}`
-
-###########################
-echo
-echo "##### Adding dependency decls to pom..."
-ed pom.xml <<EOF
-/<dependencies>
-a
-${DEP_DECLS}
-.
-wq
-EOF
-
-###########################
-echo
-echo "##### Retrieving jars into local maven repo..."
-${MVN_CMD} clean compile
-
-###########################
-echo
-echo "##### Copying jars..."
-# if someone screws up j7 or android deps, uncomment the following and
-# it will help identify wrong jars that are getting included / copied
-# (and otherwise overwriting each other).
-#DEBUG_DEPS=-Dmdep.prependGroupId=true
-${MVN_CMD} dependency:copy-dependencies -DincludeScope=runtime ${DEBUG_DEPS}
-
-DEPS_SRC_DIR=target/dependency
-EDGENT_DEPS_DIR=${EDGENT_PLATFORM}/edgent-jars
-EXT_DEPS_DIR=${EDGENT_PLATFORM}/ext-jars
-
-rm -rf "${EDGENT_DEPS_DIR}"; mkdir -p ${EDGENT_DEPS_DIR}
-rm -rf "${EXT_DEPS_DIR}"; mkdir -p ${EXT_DEPS_DIR}
-
-cp ${DEPS_SRC_DIR}/* ${EXT_DEPS_DIR}
-
-for i in `find ${EXT_DEPS_DIR} -name '*edgent-*.*ar'`; do
- mv $i ${EDGENT_DEPS_DIR}
-done
-
-###########################
-echo
-echo "##### Generating classpath.sh..."
-cat << 'EOF' > ${EDGENT_PLATFORM}/classpath.sh
-#!/bin/sh
-set -e
-if [ "${1}" = "" -o "${1}" = "-?" -o "${1}" = "-help" ]; then
- echo "usage: classpath.sh <path-to-parent-of-edgent-jars-dir>"
- exit 1
-fi
-BASEDIR=${1}
-cd ${BASEDIR}
-SEP=
-CP=
-if [ "`ls edgent-jars 2>/dev/null`" != "" ]; then
- for i in edgent-jars/*; do
- CP="${CP}${SEP}${BASEDIR}/${i}"
- SEP=":"
- done
-fi
-if [ "`ls ext-jars 2>/dev/null`" != "" ]; then
- for i in ext-jars/*; do
- if [[ ${i} == */slf4j-* ]] && [[ ${i} != */slf4j-api-* ]] ; then
- continue
- fi
- CP="${CP}${SEP}${BASEDIR}/${i}"
- SEP=":"
- done
-fi
-echo "${CP}"
-EOF
-chmod +x ${EDGENT_PLATFORM}/classpath.sh
-
-###########################
-echo
-echo "##### The Edgent jars are in ${PROJ_DIR}/${EDGENT_DEPS_DIR}"
-echo "##### The external jars are in ${PROJ_DIR}/${EXT_DEPS_DIR}"
-echo "##### CLASSPATH may be set by copying ${PROJ_DIR}/${EDGENT_PLATFORM}/classpath.sh and using it like:"
-echo '##### export CLASSPATH=`classpath.sh path-to-parent-of-edgent-jars-dir`'