You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2017/11/23 15:47:26 UTC
[1/9] incubator-edgent git commit: remove samples (now in separate
repo)
Repository: incubator-edgent
Updated Branches:
refs/heads/develop 58b889560 -> 92672c050
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
deleted file mode 100644
index b1aba6b..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensorApplication.java
+++ /dev/null
@@ -1,44 +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.topology;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/*
- * A basic application used in the Edgent "Getting Started Guide":
- * https://edgent.apache.org/docs/edgent-getting-started.html
- */
-public class TempSensorApplication {
- public static void main(String[] args) throws Exception {
- TempSensor sensor = new TempSensor();
- DirectProvider dp = new DirectProvider();
- Topology topology = dp.newTopology();
-
- TStream<Double> tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS);
- TStream<Double> filteredReadings = tempReadings.filter(reading -> reading < 50 || reading > 80);
- filteredReadings.print();
-
- dp.submit(topology);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
deleted file mode 100644
index f15b3d0..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TerminateAfterNTuples.java
+++ /dev/null
@@ -1,67 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * This application simulates a crash and terminates the JVM after processing
- * a preset number of tuples. This application is used in conjunction with a
- * monitoring script to demonstrate the restart of a JVM which has terminated
- * because of an Edgent application crash.
- */
-public class TerminateAfterNTuples {
- /** The application will terminate the JVM after this tuple count */
- public final static int TERMINATE_COUNT = 15;
-
- public static void main(String[] args) throws Exception {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("PeriodicSource");
-
- // Since this is the Direct provider the graph can access
- // objects created while the topology is being defined
- // (in this case the Random object r).
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Program termination
- AtomicInteger count = new AtomicInteger(0);
- gaussian = gaussian.peek(g -> {
- if (count.incrementAndGet() >= TERMINATE_COUNT) {
- System.err.println("The JVM terminates after processing " +
- TERMINATE_COUNT + " tuples");
- System.exit(1);
- }
- });
-
- // Peek at the value on the Stream printing it to System.out
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- tp.submit(t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
deleted file mode 100644
index 000cb03..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/package-info.java
+++ /dev/null
@@ -1,24 +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 creating and executing basic topologies .
- */
-package org.apache.edgent.samples.topology;
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/resources/META-INF/NOTICE b/samples/topology/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index e02f844..0000000
--- a/samples/topology/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Topology
-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/utils/README.md
----------------------------------------------------------------------
diff --git a/samples/utils/README.md b/samples/utils/README.md
deleted file mode 100644
index 7381f2e..0000000
--- a/samples/utils/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-See the README.md in the samples root directory for information on building the samples.
-
-The build generated uber jar contains all of the dependent
-Edgent jars and their transitive dependencies.
-
-The desired sample can be run using the run-sample.sh script. e.g.,
-
-```sh
-cd utils
-./run-sample.sh PeriodicSourceWithMetrics
-```
-
-For usage information:
-
-```sh
-./run-sample.sh
-./run-sample.sh --list
-```
-
-If you want to run a sample from the standard jar there are two options:
-a) get a local copy of all of the Edgent jars and their dependencies.
- Form a CLASSPATH to the jars and run the sample's main class.
- The get-edgent-jars.sh script can be used to get the jars from
- a maven repository (local or remote).
-b) create an application package bundle. The bundle includes the
- sample(s) jar and a copy of all of the dependent Edgent jars
- and their dependencies. The package-app.sh script can be
- used to create this bundle.
- The package-app.sh script also creates a run-app.sh script.
- The run-app.sh script configures the CLASSPATH and runs the main class.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/pom.xml
----------------------------------------------------------------------
diff --git a/samples/utils/pom.xml b/samples/utils/pom.xml
deleted file mode 100644
index 9e9fecc..0000000
--- a/samples/utils/pom.xml
+++ /dev/null
@@ -1,60 +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-utils</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Utils</name>
-
- <dependencies>
- <!-- parent pom has Providers and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-utils-metrics</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-sensors</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-console-server</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math3</artifactId>
- <version>3.4.1</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/run-sample.sh
----------------------------------------------------------------------
diff --git a/samples/utils/run-sample.sh b/samples/utils/run-sample.sh
deleted file mode 100755
index 760c5bc..0000000
--- a/samples/utils/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=utils
-
-UBER_JAR=target/edgent-samples-${CATEGORY}-*-uber.jar
-
-SAMPLE_PACKAGE_BASE=org.apache.edgent.samples.${CATEGORY}
-SAMPLES_FQ=`cat <<EOF
-${SAMPLE_PACKAGE_BASE}.metrics.PeriodicSourceWithMetrics
-${SAMPLE_PACKAGE_BASE}.metrics.SplitWithMetrics
-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/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
deleted file mode 100644
index b883e3e..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/PeriodicSourceWithMetrics.java
+++ /dev/null
@@ -1,68 +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.utils.metrics;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.metrics.Metrics;
-import org.apache.edgent.metrics.MetricsSetup;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.codahale.metrics.MetricRegistry;
-
-public class PeriodicSourceWithMetrics {
- public static void main(String[] args) throws InterruptedException {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("PeriodicSource");
-
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Testing Peek
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- // Measure the tuple count for the gaussian TStream
- gaussian = Metrics.counter(gaussian);
-
- // A filter
- gaussian = gaussian.filter(g -> g > 0.5);
-
- // Measure tuple arrival rate after filtering
- gaussian = Metrics.rateMeter(gaussian);
-
- // A transformation
- TStream<String> gs = gaussian.map(g -> "G:" + g + ":");
- gs.print();
-
- // Initialize the metrics service
- MetricRegistry metrics = new MetricRegistry();
-
- // Start metrics JMX reporter
- MetricsSetup.withRegistry(tp.getServices(), metrics).startJMXReporter(
- PeriodicSourceWithMetrics.class.getName());
-
- // Submit the topology
- tp.submit(t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
deleted file mode 100644
index 43d4444..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/metrics/SplitWithMetrics.java
+++ /dev/null
@@ -1,71 +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.utils.metrics;
-
-import java.util.List;
-import java.util.Random;
-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.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Instruments a topology with a tuple counter on a specified stream.
- */
-public class SplitWithMetrics {
-
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology(SplitWithMetrics.class.getSimpleName());
-
- Random r = new Random();
-
- TStream<Integer> d = t.poll(() -> (int)(r.nextGaussian() * 3.0),
- 100, TimeUnit.MILLISECONDS);
-
- List<TStream<Integer>> splits = d.split(3, tuple -> {
- switch (tuple.intValue()) {
- case 0:
- return 0;
- case 1:
- return 1;
- default:
- return 2;
- }
- });
-
- /*
- * Insert a metric counter for the zeroes stream. Note that the
- * DevelopmentProvider submitter will insert metric counters at
- * submit time on the output of each oplet, including the counter
- * explicitly inserted below.
- */
- Metrics.counter(splits.get(0)).sink(tuple -> System.out.print("."));
-
- splits.get(1).sink(tuple -> System.out.print("#"));
- splits.get(2).sink(tuple -> System.out.print("@"));
-
- dtp.submit(t);
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
deleted file mode 100644
index d18313a..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/GpsSensor.java
+++ /dev/null
@@ -1,75 +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.utils.sensor;
-
-/**
- * A GPS Sensor Reading
- *
- * TODO rename to GpsSensorReading
- */
-public class GpsSensor {
-
- private double latitude;
- private double longitude;
- private double altitude;
- private double speedMetersPerSec; // meters per sec
- private long time;
- private double course;
-
- public GpsSensor(double latitude, double longitude, double altitude, double speedMetersPerSec, long time,
- double course) {
-
- this.latitude = latitude;
- this.longitude = longitude;
- this.altitude = altitude;
- this.speedMetersPerSec = speedMetersPerSec;
- this.time = time;
- this.course = course;
- }
-
- public double getLatitude() {
- return latitude;
- }
-
- public double getLongitude() {
- return longitude;
- }
-
- public double geAltitude() {
- return altitude;
- }
-
- public double getSpeedMetersPerSec() {
- return speedMetersPerSec;
- }
-
- public long getTime() {
- return time;
- }
-
- public double getCourse() {
- return course;
- }
-
- @Override
- public String toString() {
- return latitude + ", " + longitude + ", " + altitude + ", " + speedMetersPerSec + ", " + time + ", " + course;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
deleted file mode 100644
index 729b4ca..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/HeartMonitorSensor.java
+++ /dev/null
@@ -1,60 +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.utils.sensor;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.edgent.function.Supplier;
-
-/**
- * Streams of simulated heart monitor sensors.
- *
- */
-public class HeartMonitorSensor implements Supplier<Map<String,Integer>> {
- private static final long serialVersionUID = 1L;
- // Initial blood pressure
- public Integer currentSystolic = 115;
- public Integer currentDiastolic = 75;
- Random rand;
-
- public HeartMonitorSensor() {
- rand = new Random();
- }
-
- /**
- * Every call to this method returns a map containing a random systolic
- * pressure and a random diastolic pressure.
- */
- @Override
- public Map<String, Integer> get() {
- // Change the current pressure by some random amount between -2 and 2
- Integer newSystolic = rand.nextInt(2 + 1 + 2) - 2 + currentSystolic;
- currentSystolic = newSystolic;
-
- Integer newDiastolic = rand.nextInt(2 + 1 + 2) - 2 + currentDiastolic;
- currentDiastolic = newDiastolic;
-
- Map<String, Integer> pressures = new HashMap<String, Integer>();
- pressures.put("Systolic", currentSystolic);
- pressures.put("Diastolic", currentDiastolic);
- return pressures;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
deleted file mode 100644
index 93aa20f..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/PeriodicRandomSensor.java
+++ /dev/null
@@ -1,182 +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.utils.sensor;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.math3.util.Pair;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A factory of simple periodic random sensor reading streams.
- * <p>
- * The generated {@link TStream} has a {@code org.apache.commons.math3.utils.Pair}
- * tuple type where {@link Pair#getFirst()} the reading's msecTimestamp
- * and {@link Pair#getSecond()} is the sensor value reading.
- * <p>
- * The sensor reading values are randomly generated via {@link Random}
- * and have the value distributions, as defined by {@code Random}.
- * <p>
- * Each stream has its own {@code Random} object instance.
- */
-public class PeriodicRandomSensor {
- private Long seed;
-
- /**
- * Create a new random periodic sensor factory configured
- * to use {@link Random#Random()}.
- */
- public PeriodicRandomSensor() {
- }
-
- /**
- * Create a new random periodic sensor factory configured
- * to use {@link Random#Random(long)}.
- *
- * @param seed seed to use when creating new sensor streams.
- */
- public PeriodicRandomSensor(long seed) {
- this.seed = seed;
- }
-
- /**
- * Set the seed to be used by subsequently created sensor streams.
- * @param seed the seed value
- */
- public void setSeed(long seed) {
- this.seed = seed;
- }
-
- private Random newRandom() {
- if (seed != null)
- return new Random(seed);
- return new Random();
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextGaussian()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Double>> newGaussian(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Double>(System.currentTimeMillis(), r.nextGaussian()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextDouble()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Double>> newDouble(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Double>(System.currentTimeMillis(), r.nextDouble()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextFloat()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Float>> newFloat(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Float>(System.currentTimeMillis(), r.nextFloat()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextLong()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Long>> newLong(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Long>(System.currentTimeMillis(), r.nextLong()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextInt()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Integer>> newInteger(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Integer>(System.currentTimeMillis(), r.nextInt()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextInt(int)}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @param bound the upper bound (exclusive). Must be positive.
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Integer>> newInteger(Topology t, long periodMsec, int bound) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Integer>(System.currentTimeMillis(), r.nextInt(bound)),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextBoolean()}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @return the sensor value stream
- */
- public TStream<Pair<Long,Boolean>> newBoolean(Topology t, long periodMsec) {
- Random r = newRandom();
- return t.poll(() -> new Pair<Long,Boolean>(System.currentTimeMillis(), r.nextBoolean()),
- periodMsec, TimeUnit.MILLISECONDS);
-
- }
-
- /**
- * Create a periodic sensor stream with readings from {@link Random#nextBytes(byte[])}.
- * @param t the topology to add the sensor stream to
- * @param periodMsec how frequently to generate a reading
- * @param nBytes the number of bytes in each reading tuple
- * @return the sensor value stream
- */
- public TStream<Pair<Long,byte[]>> newBytes(Topology t, long periodMsec, int nBytes) {
- Random r = newRandom();
- return t.poll(() -> { byte[] bytes = new byte[nBytes];
- r.nextBytes(bytes);
- return new Pair<Long,byte[]>(System.currentTimeMillis(), bytes);
- },
- periodMsec, TimeUnit.MILLISECONDS);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
deleted file mode 100644
index 0e306ca..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimpleSimulatedSensor.java
+++ /dev/null
@@ -1,175 +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.utils.sensor;
-
-import java.text.DecimalFormat;
-import java.util.Random;
-
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.function.Supplier;
-
-/**
- * A simple simulated sensor.
- * <p>
- * The sensor starts off with an initial value.
- * Each call to {@link #get()} changes the current value by
- * a random amount between plus/minus {@code deltaFactor}.
- * The new current value is limited to a {@code range}
- * and then rounded to 1 fractional digit.
- * See {@link #setNumberFractionalDigits(int)}.
- * </p><p>
- * Sample use:
- * <pre>{@code
- * Topology t = ...;
- * // a miles-per-gallon sensor
- * SimpleSimulatedSensor avgMpgSensor = new SimpleSimulatedSensor(10.5, 0.4,
- * Ranges<Double>.closed(7.0,14.0));
- * TStream<Double> avgMpg = t.poll(avgMpgSensor, 1, TimeUnit.SECONDS);
- *
- * // an integer valued sensor
- * SimpleSimulatedSensor doubleSensor = new SimpleSimulatedSensor();
- * TStream<Integer> intSensor = t.poll(() -> doubleSensor.get().intValue(),
- * 1, TimeUnit.SECONDS);
- * }</pre>
- */
-public class SimpleSimulatedSensor implements Supplier<Double> {
- private static final long serialVersionUID = 1L;
- private int numFracDigits;
- private volatile DecimalFormat df;
- private Random r = new Random();
- private final Range<Double> range;
- private final double deltaFactor;
- private double currentValue;
-
- /**
- * Create a sensor.
- * <p>
- * Same as {@code SimpleSimulatedSensor(0.0, 1.0, null)};
- * </p>
- */
- public SimpleSimulatedSensor() {
- this(0.0, 1.0, null);
- }
-
- /**
- * Create a sensor.
- * <p>
- * Same as {@code SimpleSimulatedSensor(initialValue, 1.0, null)};
- * </p>
- * @param initialValue the initial value
- */
- public SimpleSimulatedSensor(double initialValue) {
- this(initialValue, 1.0, null);
- }
-
- /**
- * Create a sensor.
- *
- * <p>
- * Same as {@code SimpleSimulatedSensor(initialValue, deltaFactor, null)};
- * </p>
- * @param initialValue the initial value.
- * @param deltaFactor maximum plus/minus change on each {@code get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- */
- public SimpleSimulatedSensor(double initialValue, double deltaFactor) {
- this(initialValue, deltaFactor, null);
- }
-
- /**
- * Create a sensor.
- *
- * @param initialValue the initial value. Must be within range.
- * @param deltaFactor maximum plus/minus change on each {@link #get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- * @param range maximum sensor value range. Unlimited if null.
- */
- public SimpleSimulatedSensor(double initialValue,
- double deltaFactor, Range<Double> range) {
- if (range!=null && !range.contains(initialValue))
- throw new IllegalArgumentException("initialValue");
- if (deltaFactor <= 0.0)
- throw new IllegalArgumentException("deltaFactor");
- this.currentValue = initialValue;
- this.deltaFactor = deltaFactor;
- this.range = range;
- setNumberFractionalDigits(1);
- }
-
- /**
- * Set number of fractional digits to round sensor values to.
- * <p>
- * This class offers rounding as a convenience and because
- * ancestors of this implementation had such a scheme.
- * </p>
- * @param numFracDigits if <= 0, no rounding will be performed
- */
- public void setNumberFractionalDigits(int numFracDigits) {
- this.numFracDigits = numFracDigits;
- if (numFracDigits <= 0) {
- df = null;
- }
- else {
- String fracPattern = "";
- for (int i = 0; i < numFracDigits; i++)
- fracPattern += "#";
- df = new DecimalFormat("#."+fracPattern);
- }
- }
-
- /** Get the number of fractional digits setting
- * @return the value
- */
- public int getNumberFractionalDigits() {
- return numFracDigits;
- }
-
- /** Get the range setting
- * @return the value
- */
- public Range<Double> getRange() {
- return range;
- }
-
- /** Get the deltaFactor setting
- * @return the value
- */
- public double getDeltaFactor() {
- return deltaFactor;
- }
-
- /** Get the next sensor value as described in the class documentation. */
- @Override
- public Double get() {
- double delta = 2 * r.nextDouble() - 1.0; // between -1.0 and 1.0
- double nextValue = currentValue + delta * deltaFactor;
- if (range!=null && !range.contains(nextValue)) {
- nextValue = nextValue > currentValue
- ? range.upperEndpoint()
- : range.lowerEndpoint();
- }
- if (df != null)
- nextValue = Double.valueOf(df.format(nextValue));
- currentValue = nextValue;
- return currentValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
deleted file mode 100644
index 0d8145c..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedGpsSensor.java
+++ /dev/null
@@ -1,104 +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.utils.sensor;
-
-public class SimulatedGpsSensor {
- private int currentIndex;
- private int simulatedSec;
- private int requestedIterations = -1; // -1 means loop through gpsDataArray
- // forever
- private int currentIteration = 0;
-
- public SimulatedGpsSensor() {
- this.currentIndex = -1;
- this.simulatedSec = 1;
- }
-
- // TODO: Replace hard-coded data to reading in GPS data from file
- // GPS data from IBM Silicon Valley Lab to IBM Almaden Research and back to
- // IBM SVL
- private static double[][] gpsDataArray = { { 37.195647, -121.748087 }, // IBM
- // Silicon
- // Valley
- // Lab
- // 555
- // Bailey
- // Ave
- { 37.18110679999999, -121.7865003 }, // Calero Reservoir McKean
- { 37.19926299999999, -121.82234399999999 }, // Santa Clara Horsemen
- // Association 20350
- // McKean
- { 37.198632, -121.82234399999999 }, // Forestry & Fire Protection
- // 20255 McKean
- { 37.19875469999999, -121.82320830000003 }, // St. Anthony Church
- // 20101 McKean
- { 37.2004004, -121.82578030000002 }, // Challenger School 19950
- // McKean
- { 37.199576, -121.82468900000003 }, // Firehouse No.28 19911 McKean
- // Rd
- { 37.211053, -121.806949 }, // IBM Almaden Research Harry Road
- // then go back the reverse direction
- { 37.199576, -121.82468900000003 }, // Firehouse No.28 19911 McKean
- // Rd
- { 37.2004004, -121.82578030000002 }, // Challenger School 19950
- // McKean
- { 37.19875469999999, -121.82320830000003 }, // St. Anthony Church
- // 20101 McKean
- { 37.198632, -121.82234399999999 }, // Forestry & Fire Protection
- // 20255 McKean
- { 37.19926299999999, -121.82234399999999 }, // Santa Clara Horsemen
- // Association 20350
- // McKean
- { 37.18110679999999, -121.7865003 }, // Calero Reservoir McKean
- { 37.195647, -121.748087 }, // IBM Silicon Valley Lab 555 Bailey Ave
- };
-
- // TODO Re-write kluge code to read from a file
- // Returns a GpsSensor using the hard-coded list, then repeats through the
- // list
- // forever when requestedIterations = -1, or until iterations is reached.
- public GpsSensor nextGps() {
-
- GpsSensor result = null;
- if (requestedIterations == -1 || currentIteration < requestedIterations) {
- simulatedSec++;
-
- // Determine the index to use for generating the next GPS coordinate
- // If currentIndex is already at the end of the array, then set
- // currentIndex to start over at the array beginning at index 0
- // Otherwise, increment currentIndex
- if (currentIndex >= gpsDataArray.length - 1) {
- currentIndex = 0;
- currentIteration++;
- } else
- currentIndex++;
-
- // hardcode other data (altitude, course, time, speed, etc.) and at
- // index 5 for hard braking and acceleration speed
- if (currentIndex == 5)
- result = new GpsSensor(gpsDataArray[currentIndex][0], gpsDataArray[currentIndex][1], 32.1, 42.4,
- simulatedSec, 38.2);
- else
- result = new GpsSensor(gpsDataArray[currentIndex][0], gpsDataArray[currentIndex][1], 20.1, 29.0,
- simulatedSec, 28.2);
-
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
deleted file mode 100644
index b1856ff..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedSensors.java
+++ /dev/null
@@ -1,88 +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.utils.sensor;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * Streams of simulated sensors.
- *
- */
-public class SimulatedSensors {
-
- /**
- * Create a stream of simulated bursty sensor readings.
- *
- * Simulation of reading a sensor every 100ms with the readings
- * generally falling below 2.0 (absolute) but randomly have
- * prolonged bursts of higher values.
- *
- * Each tuple is a JSON object containing:
- * <UL>
- * <LI>{@code name} - Name of the sensor from {@code name}.</LI>
- * <LI>{@code reading} - Value.</LI>
- * </UL>
- *
- * @param topology Topology to be added to.
- * @param name Name of the sensor in the JSON output.
- * @return Stream containing bursty data.
- */
- public static TStream<JsonObject> burstySensor(Topology topology, String name) {
-
- Random r = new Random();
-
- TStream<Double> sensor = topology.poll(() -> r.nextGaussian(), 100, TimeUnit.MILLISECONDS);
-
- boolean[] abnormal = new boolean[1];
- int[] count = new int[1];
- double[] delta = new double[1];
- sensor = sensor.modify(t -> {
- if (abnormal[0] || r.nextInt(100) < 4) {
- if (!abnormal[0]) {
- delta[0] = 0.5 + 2 * r.nextGaussian();
- count[0] = 5 + r.nextInt(20);
- abnormal[0] = true;
- }
- count[0]--;
- if (count[0] <= 0)
- abnormal[0] = false;
- return t + delta[0];
- } else
- return t;
- });
-
- sensor = sensor.filter(t -> Math.abs(t) > 1.5);
-
- return sensor.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("name", name);
- j.addProperty("reading", t);
- return j;
- });
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java b/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
deleted file mode 100644
index e749ce8..0000000
--- a/samples/utils/src/main/java/org/apache/edgent/samples/utils/sensor/SimulatedTemperatureSensor.java
+++ /dev/null
@@ -1,107 +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.utils.sensor;
-
-import java.util.Objects;
-
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.analytics.sensors.Ranges;
-import org.apache.edgent.function.Supplier;
-
-/**
- * A Simulated temperature sensor.
- * <p>
- * The sensor starts off with an initial value.
- * Each call to {@link #get()} changes the current value by
- * a random amount between plus/minus a {@code deltaFactor}.
- * The new current value is limited to a {@code tempRange}
- * and then rounded to 1 fractional digit.
- * </p><p>
- * No temperature scale is implied (e.g., Fahrenheit, Kelvin, ...).
- * The {@code double} temperature values are simply generated as described.
- * The user of the class decides how to interpret them.
- * </p><p>
- * Sample use:
- * <pre>{@code
- * Topology t = ...;
- * SimulatedTemperatureSensor tempSensor = new SimulatedTemperatureSensor();
- * TStream<Double> temp = t.poll(tempSensor, 1, TimeUnit.SECONDS);
- * }</pre>
- * @see SimpleSimulatedSensor
- */
-public class SimulatedTemperatureSensor implements Supplier<Double> {
- private static final long serialVersionUID = 1L;
- private final SimpleSimulatedSensor sensor;
-
- /**
- * Create a temperature sensor.
- * <p>
- * Same as {@code SimulatedTemperatureSensor(80.0,
- * Ranges.closed(28.0, 112.0), 1.0)}
- * </p><p>
- * These default values roughly correspond to normal air temperature
- * in the Fahrenheit scale.
- * </p>
- */
- public SimulatedTemperatureSensor() {
- this(80.0, Ranges.closed(28.0, 112.0), 1.0);
- }
-
- /**
- * Create a temperature sensor.
- * <p>
- * No temperature scale is implied.
- * </p>
- * @param initialTemp the initial temperature. Must be within tempRange.
- * @param tempRange maximum sensor value range
- * @param deltaFactor maximum plus/minus change on each {@code get()}.
- * e.g., 1.0 to limit change to +/- 1.0.
- * Must be > 0.0
- */
- public SimulatedTemperatureSensor(double initialTemp,
- Range<Double> tempRange, double deltaFactor) {
- Objects.requireNonNull(tempRange, "tempRange");
- if (!tempRange.contains(initialTemp))
- throw new IllegalArgumentException("initialTemp");
- if (deltaFactor <= 0.0)
- throw new IllegalArgumentException("deltaFactor");
- sensor = new SimpleSimulatedSensor(initialTemp, deltaFactor, tempRange);
- }
-
- /** Get the tempRange setting
- * @return the value
- */
- public Range<Double> getTempRange() {
- return sensor.getRange();
- }
-
- /** Get the deltaFactor setting
- * @return the value
- */
- public double getDeltaFactor() {
- return sensor.getDeltaFactor();
- }
-
- /** Get the next sensor value. */
- @Override
- public Double get() {
- return sensor.get();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/utils/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/utils/src/main/resources/META-INF/NOTICE b/samples/utils/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index a581fd5..0000000
--- a/samples/utils/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Utils
-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
-
[7/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/JsonTuples.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/JsonTuples.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/JsonTuples.java
deleted file mode 100644
index 0c231c8..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/JsonTuples.java
+++ /dev/null
@@ -1,196 +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.apps;
-
-import static org.apache.edgent.analytics.math3.stat.Statistic.MAX;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MEAN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MIN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.STDDEV;
-
-import java.util.List;
-
-import org.apache.commons.math3.util.Pair;
-import org.apache.edgent.analytics.math3.json.JsonAnalytics;
-import org.apache.edgent.analytics.math3.stat.Statistic;
-import org.apache.edgent.function.BiFunction;
-import org.apache.edgent.function.Function;
-import org.apache.edgent.topology.TStream;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- * Utilties to ease working working with sensor "samples" by wrapping them
- * in JsonObjects.
- * <p>
- * The Json Tuple sensor "samples" have a standard collection of properties.
- */
-public class JsonTuples {
-
- /*
- * Common attributes in the JsonObject
- */
- public static final String KEY_ID = "id";
- public static final String KEY_TS = "msec";
- public static final String KEY_READING = "reading";
- public static final String KEY_AGG_BEGIN_TS = "agg.begin.msec";
- public static final String KEY_AGG_COUNT = "agg.count";
-
- /**
- * Create a JsonObject wrapping a raw {@code Pair<Long msec,T reading>>} sample.
- * @param <T> Tuple type
- * @param sample the raw sample
- * @param id the sensor's Id
- * @return the wrapped sample
- */
- public static <T> JsonObject wrap(Pair<Long,T> sample, String id) {
- JsonObject jo = new JsonObject();
- jo.addProperty(KEY_ID, id);
- jo.addProperty(KEY_TS, sample.getFirst());
- T value = sample.getSecond();
- if (value instanceof Number)
- jo.addProperty(KEY_READING, (Number)sample.getSecond());
- else if (value instanceof String)
- jo.addProperty(KEY_READING, (String)sample.getSecond());
- else if (value instanceof Boolean)
- jo.addProperty(KEY_READING, (Boolean)sample.getSecond());
-// else if (value instanceof array) {
-// // TODO cvt to JsonArray
-// }
-// else if (value instanceof Object) {
-// // TODO cvt to JsonObject
-// }
- else {
- Class<?> clazz = value != null ? value.getClass() : Object.class;
- throw new IllegalArgumentException("Unhandled value type: "+ clazz);
- }
- return jo;
- }
-
- /**
- * Create a stream of JsonObject wrapping a stream of
- * raw {@code Pair<Long msec,T reading>>} samples.
- *
- * @param <T> Tuple type
- * @param stream the raw input stream
- * @param id the sensor's Id
- * @return the wrapped stream
- */
- public static <T> TStream<JsonObject> wrap(TStream<Pair<Long,T>> stream, String id) {
- return stream.map(pair -> wrap(pair, id));
- }
-
- /**
- * The partition key function for wrapped sensor samples.
- * <p>
- * The {@code KEY_ID} property is returned for the key.
- * @return the function
- */
- public static Function<JsonObject,String> keyFn() {
- return sample -> sample.get(KEY_ID).getAsString();
- }
-
-
- /**
- * Get a statistic value from a sample.
- * <p>
- * Same as {@code getStatistic(jo, JsonTuples.KEY_READING, stat)}.
- *
- * @param jo the sample
- * @param stat the Statistic of interest
- * @return the JsonElement for the Statistic
- * @throws RuntimeException of the stat isn't present
- */
- public static JsonElement getStatistic(JsonObject jo, Statistic stat) {
- return getStatistic(jo, JsonTuples.KEY_READING, stat);
- }
-
- /**
- * Get a statistic value from a sample.
- * <p>
- * Convenience for working with samples containing a property
- * whose value is one or more {@link Statistic}
- * as created by
- * {@link JsonAnalytics#aggregate(org.apache.edgent.topology.TWindow, String, String, org.apache.edgent.analytics.math3.json.JsonUnivariateAggregate...) JsonAnalytics.aggregate()}
- *
- * @param jo the sample
- * @param valueKey the name of the property containing the JsonObject of Statistics
- * @param stat the Statistic of interest
- * @return the JsonElement for the Statistic
- * @throws RuntimeException of the stat isn't present
- */
- public static JsonElement getStatistic(JsonObject jo, String valueKey, Statistic stat) {
- JsonObject statsjo = jo.get(valueKey).getAsJsonObject();
- return statsjo.get(stat.name());
- }
-
- /**
- * Create a function that computes the specified statistics on the list of
- * samples and returns a new sample containing the result.
- * <p>
- * The single tuple contains the specified statistics computed over
- * all of the {@code JsonTuple.KEY_READING}
- * values from {@code List<JsonObject>}.
- * <p>
- * The resulting sample contains the properties:
- * <ul>
- * <li>JsonTuple.KEY_ID</li>
- * <li>JsonTuple.KEY_MSEC - msecTimestamp of the last sample in the window</li>
- * <li>JsonTuple.KEY_AGG_BEGIN_MSEC - msecTimestamp of the first sample in the window</li>
- * <li>JsonTuple.KEY_AGG_COUNT - number of samples in the window ({@code value=factor})</li>
- * <li>JsonTuple.KEY_READING - a JsonObject of the statistics
- * as defined by
- * {@link JsonAnalytics#aggregate(org.apache.edgent.topology.TWindow, String, String, org.apache.edgent.analytics.math3.json.JsonUnivariateAggregate...) JsonAnalytics.aggregate()}
- * </ul>
- * <p>
- * Sample use:
- * <pre>{@code
- * TStream<JsonObject> s = ...
- * // reduce s by a factor of 100 with stats MEAN and STDEV
- * TStream<JsonObject> reduced = s.batch(100, statistics(Statistic.MEAN, Statistic.STDDEV));
- * }</pre>
- *
- * @param statistics the statistics to calculate over the window
- * @return {@code TStream<JsonObject>} for the reduced {@code stream}
- */
- public static BiFunction<List<JsonObject>,String,JsonObject> statistics(Statistic... statistics) {
- BiFunction<List<JsonObject>,JsonElement,JsonObject> statsFn =
- JsonAnalytics.aggregateList(KEY_ID, KEY_READING,
- j -> j.get(KEY_READING).getAsDouble(),
- MIN, MAX, MEAN, STDDEV);
-
- return (samples, key) -> {
- JsonObject jo = statsFn.apply(samples, samples.get(0).get(KEY_ID));
- JsonTuples.addAggStdInfo(jo, samples);
- return jo;
- };
- }
-
- private static void addAggStdInfo(JsonObject jo, List<JsonObject> samples) {
- // beginMsec, endMsec, nSamples
- long msec = samples.get(0).get(KEY_TS).getAsLong();
- long msec2 = samples.get(samples.size()-1).get(KEY_TS).getAsLong();
- int nSamples = samples.size();
-
- jo.addProperty(KEY_TS, msec2);
- jo.addProperty(KEY_AGG_BEGIN_TS, msec);
- jo.addProperty(KEY_AGG_COUNT, nSamples);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/TopologyProviderFactory.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/TopologyProviderFactory.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/TopologyProviderFactory.java
deleted file mode 100644
index 1128fcb..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/TopologyProviderFactory.java
+++ /dev/null
@@ -1,63 +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.apps;
-
-import java.util.Properties;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-
-/**
- * A configuration driven factory for an Edgent topology provider.
- */
-public class TopologyProviderFactory {
- private final Properties props;
-
- /**
- * Construct a factory
- * @param props configuration information.
- */
- public TopologyProviderFactory(Properties props) {
- this.props = props;
- }
-
- /**
- * Get a new topology provider.
- * <p>
- * The default provider is {@code org.apache.edgent.providers.direct.DirectProvider}.
- * <p>
- * The {@code topology.provider} configuration property can specify
- * an alternative.
- *
- * @return the provider
- * @throws Exception if the provider couldn't be created
- */
- public DirectProvider newProvider() throws Exception {
- String name = props.getProperty("topology.provider", "org.apache.edgent.providers.direct.DirectProvider");
- Class<?> clazz = null;
- try {
- clazz = Class.forName(name);
- }
- catch (ClassNotFoundException e) {
- String msg = "Class not found: "+e.getLocalizedMessage();
- System.err.println(msg);
- throw new IllegalStateException(msg);
- }
- return (DirectProvider) clazz.newInstance();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/FleetManagementAnalyticsClientApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/FleetManagementAnalyticsClientApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/FleetManagementAnalyticsClientApplication.java
deleted file mode 100644
index 483ab09..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/FleetManagementAnalyticsClientApplication.java
+++ /dev/null
@@ -1,68 +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.apps.fleetManagement;
-
-import org.apache.edgent.samples.apps.AbstractIotpApplication;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A Global Positional System and On-Board Diagnostics application to perform
- * analytics defined in {@link GpsAnalyticsApplication} and
- * {@link ObdAnalyticsApplication}.
- * <p>
- * The Edgent console URL is written to the console and to file consoleUrl.txt.
- * <p>
- * The Watson IotF URL is written to the console and to file iotfUrl.txt
- *
- * <p>
- * Argument: specify pathname to application properties file. If running in
- * Eclipse, you can specify GpsObdAnalyticsApplication.properties.
- */
-public class FleetManagementAnalyticsClientApplication extends AbstractIotpApplication {
-
- public static void main(String[] args) throws Exception {
- if (args.length < 1)
- throw new Exception("missing pathname to application properties file");
-
- FleetManagementAnalyticsClientApplication application = new FleetManagementAnalyticsClientApplication(args[0]);
-
- application.run();
- }
-
- /**
- * Create an application instance.
- *
- * @param propsPath
- * pathname to an application configuration file
- * @throws Exception
- */
- FleetManagementAnalyticsClientApplication(String propsPath) throws Exception {
- super(propsPath);
- }
-
- @Override
- protected void buildTopology(Topology t) {
-
- // Add the GPS analytics to the topology
- new GpsAnalyticsApplication(t, this).addAnalytics();
-
- // TODO Add the OBD analytics to the topology
- // new ObdAnalyticsApplication(t, this).addAnalytics();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/GpsAnalyticsApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/GpsAnalyticsApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/GpsAnalyticsApplication.java
deleted file mode 100644
index c656300..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/GpsAnalyticsApplication.java
+++ /dev/null
@@ -1,214 +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.apps.fleetManagement;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.samples.utils.sensor.GpsSensor;
-import org.apache.edgent.samples.utils.sensor.SimulatedGpsSensor;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.TWindow;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * GPS analytics
- * <p>
- * Source is a stream of GPS sensor data {@link GpsSensor}
- * <p>
- * Here's an outline of the topology
- * <ul>
- * <li>Log GPS coordinates by publishing to IotF. The data may be used by a
- * server application to display the vehicle on a map.</li>
- * <li>Filter to detect speeds above a threshold and publish alert IotF</li>
- * <li>Filter for GPS coordinates that are outside of a defined Geofence
- * boundary</li>
- * <li>Windowing to detect hard driving: hard braking or hard acceleration and
- * publish alert to IotF</li>
- * </ul>
- */
-public class GpsAnalyticsApplication {
-
- private final FleetManagementAnalyticsClientApplication app;
- private final Topology topology;
-
- // TODO: make these configurable properties
- boolean trackGpsLocation = true;
- boolean trackSpeeding = true;
- boolean trackGeofence = true;
- boolean trackHardDriving = true;
- // Hard braking and acceleration thresholds may depend on the vehicle model
- double hardBrakingThreshold_MphPerSec = -8.25;
- double hardAccelerationThreshold_MphPerSec = 7.37;
- String driverId = "driver1";
- String VIN = "123456";
- double maxSpeed_Mph = 70;
-
- static double MILES_PER_HOUR_TO_METERS_PER_SEC = 0.44704;
- double METERS_PER_HOUR_TO_MILES_PER_SEC = 1 / MILES_PER_HOUR_TO_METERS_PER_SEC;
- // Convert 70 miles per hour to meters to sec
- double MAX_SPEED_METERS_PER_SEC = maxSpeed_Mph * MILES_PER_HOUR_TO_METERS_PER_SEC;
- static double MPS_TO_MPH = 3.6;
-
- public GpsAnalyticsApplication(Topology t, FleetManagementAnalyticsClientApplication app) {
- this.topology = t;
- this.app = app;
- }
-
- /**
- * Add the GPS sensor analytics to the topology.
- */
- public void addAnalytics() {
-
- // Generate source GPS data
- SimulatedGpsSensor g = new SimulatedGpsSensor();
- TStream<GpsSensor> gpsSensor = topology.poll(() -> g.nextGps(), 500, TimeUnit.MILLISECONDS);
-
- // Publish GPS data to IotF every 1 second
- if (trackGpsLocation) {
- TStream<GpsSensor> logGps = gpsSensor.peek(t -> System.out.println("log GPS: " + t.toString()));
- logGps.tag("logGps");
- // Publish GPS location to IotF
- app.iotDevice().events(JsonGps(logGps), "GPS: " + driverId, QoS.FIRE_AND_FORGET);
- }
-
- // Filter for actual speeding and publish to IoTF and local file
- if (trackSpeeding) {
- TStream<GpsSensor> speeding = gpsSensor.filter(t -> t.getSpeedMetersPerSec() > MAX_SPEED_METERS_PER_SEC);
-
- speeding.tag("speeding");
- // Count speeding tuples
- // TODO investigate why publish doesn't appear to work when a
- // counter is set
- // Metrics.counter(speeding);
-
- speeding.peek(t -> System.out.println("Alert: speeding - " + t.toString()));
- // Write speeding event to IotF
- app.iotDevice().events(JsonSpeed(speeding), "Speeding: " + driverId, QoS.FIRE_AND_FORGET);
- }
-
- // Filter for Geofence boundary exceptions and publish to IoTF
- if (trackGeofence) {
- TStream<GpsSensor> geofence = gpsSensor
- .filter(t -> SimulatedGeofence.outsideGeofence(t.getLatitude(), t.getLongitude()));
-
- geofence.tag("geofence");
- // Count Geofence exceptions
- // TODO investigate why publish doesn't appear to work when a
- // counter is set
- // Metrics.counter(geofence);
-
- geofence.peek(t -> System.out.println("Alert: geofence - " + t.toString()));
- // Write Geofence exceptions to IotF
- app.iotDevice().events(JsonGeofence(geofence), "Geofence: " + driverId, QoS.FIRE_AND_FORGET);
- }
-
- /*
- * Hard braking: (speed1 - speed0)/(time1 - time0) <
- * hardBrakingThreshold_KphPerSec Hard acceleration: (speed1 -
- * speed0)/(time1 - time0) > hardAccelerationThreshold_KphPerSec 1 mps =
- * 3.6 kph
- */
- if (trackHardDriving) {
- TStream<GpsSensor> hardDriving = gpsSensor;
- // TODO replace hardcoded "2" in "last(2," to force seeing
- // hardDriving alter
- TWindow<GpsSensor, Object> window = hardDriving.last(2, tuple -> 0);
- TStream<GpsSensor[]> logHardDriving = window.batch((tuples, key) -> {
- GpsSensor[] results = null;
- Object[] tuplesArray = tuples.toArray();
-
- GpsSensor gps1 = (GpsSensor) tuplesArray[1];
- GpsSensor gps0 = (GpsSensor) tuplesArray[0];
- double speed1 = gps1.getSpeedMetersPerSec();
- double speed0 = gps0.getSpeedMetersPerSec();
- long time1 = gps1.getTime();
- long time0 = gps0.getTime();
-
- // Check for hard braking or hard acceleration
- // Avoid division by 0
- if (time1 - time0 != 0) {
- double mphPerSec = (speed1 - speed0) / (time1 - time0) * MPS_TO_MPH;
- if (mphPerSec < hardBrakingThreshold_MphPerSec || mphPerSec > hardAccelerationThreshold_MphPerSec) {
- results = new GpsSensor[2];
- results[0] = gps0;
- results[1] = gps1;
- }
- }
- return results;
- }).peek(t -> System.out.println("hardDriving: t0=" + t[0].toString() + " t[1]=" + t[1].toString()))
- .tag("hardDriving");
-
- app.iotDevice().events(JsonHardDriving(logHardDriving), "hardDriving: " + driverId, QoS.FIRE_AND_FORGET);
- }
- }
-
- private TStream<JsonObject> JsonGps(TStream<GpsSensor> gpsSensor) {
- return gpsSensor.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("lat", t.getLatitude());
- j.addProperty("long", t.getLongitude());
- j.addProperty("alt", t.geAltitude());
- j.addProperty("mph", t.getSpeedMetersPerSec() * METERS_PER_HOUR_TO_MILES_PER_SEC);
- j.addProperty("course", t.getCourse());
- j.addProperty("time", t.getTime());
- return j;
- });
- }
-
- private TStream<JsonObject> JsonSpeed(TStream<GpsSensor> gpsSensor) {
- return gpsSensor.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("lat", t.getLatitude());
- j.addProperty("long", t.getLongitude());
- j.addProperty("mph", t.getSpeedMetersPerSec() * METERS_PER_HOUR_TO_MILES_PER_SEC);
- j.addProperty("time", t.getTime());
- return j;
- });
- }
-
- private TStream<JsonObject> JsonGeofence(TStream<GpsSensor> gpsSensor) {
- return gpsSensor.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("lat", t.getLatitude());
- j.addProperty("long", t.getLongitude());
- j.addProperty("time", t.getTime());
- return j;
- });
- }
-
- private TStream<JsonObject> JsonHardDriving(TStream<GpsSensor[]> gpsSensors) {
- return gpsSensors.map(t -> {
- JsonObject j = new JsonObject();
- j.addProperty("lat1", t[0].getLatitude());
- j.addProperty("long1", t[0].getLongitude());
- j.addProperty("time1", t[0].getTime());
- j.addProperty("speed1", t[0].getSpeedMetersPerSec());
- j.addProperty("lat2", t[1].getLatitude());
- j.addProperty("long2", t[1].getLongitude());
- j.addProperty("time2", t[1].getTime());
- j.addProperty("speed2", t[1].getSpeedMetersPerSec());
- j.addProperty("mphPerSec", (t[1].getSpeedMetersPerSec() - t[0].getSpeedMetersPerSec()) * MPS_TO_MPH
- / (t[1].getTime() - t[0].getTime()));
- return j;
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/ObdAnalyticsApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/ObdAnalyticsApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/ObdAnalyticsApplication.java
deleted file mode 100644
index 06e512f..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/ObdAnalyticsApplication.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.apps.fleetManagement;
-
-import org.apache.edgent.topology.Topology;
-public class ObdAnalyticsApplication{
-// TODO:
-// private final FleetManagementAnalyticsClientApplication app;
-// private final Topology t;
-// private final String sensorId = "obd";
-
- public ObdAnalyticsApplication(Topology t, FleetManagementAnalyticsClientApplication app) {
-// this.t = t;
-// this.app = app;
- }
-
- /**
- * Add the ODB sensor's analytics to the topology.
- */
- public void addAnalytics() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/SimulatedGeofence.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/SimulatedGeofence.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/SimulatedGeofence.java
deleted file mode 100644
index 546229c..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/fleetManagement/SimulatedGeofence.java
+++ /dev/null
@@ -1,36 +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.apps.fleetManagement;
-
-public class SimulatedGeofence {
- protected static double GEOFENCE_LATITUDE_MAX = 37.21;
- protected static double GEOFENCE_LATITUDE_MIN = 37.0;
- protected static double GEOFENCE_LONGITUDE_MAX = -121.75;
- protected static double GEOFENCE_LONGITUDE_MIN = -122.0;
-
- // Simple Geofence test
- public static boolean outsideGeofence(double latitude, double longitude) {
-
- if (latitude < GEOFENCE_LATITUDE_MIN || latitude > GEOFENCE_LATITUDE_MAX || longitude < GEOFENCE_LONGITUDE_MIN
- || longitude > GEOFENCE_LONGITUDE_MAX)
- return true;
- else
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/AbstractMqttApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/AbstractMqttApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/AbstractMqttApplication.java
deleted file mode 100644
index 6bd943a..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/AbstractMqttApplication.java
+++ /dev/null
@@ -1,121 +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.apps.mqtt;
-
-import static org.apache.edgent.connectors.iot.IotDevice.CMD_PAYLOAD;
-
-import java.util.Arrays;
-
-import org.apache.edgent.connectors.mqtt.iot.MqttDevice;
-import org.apache.edgent.samples.apps.AbstractApplication;
-import org.apache.edgent.samples.apps.ApplicationUtilities;
-import org.apache.edgent.samples.apps.TopologyProviderFactory;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * An MQTT Application base class.
- * <p>
- * Application instances need to:
- * <ul>
- * <li>define an implementation for {@link #buildTopology(Topology)}</li>
- * <li>call {@link #run()} to build and submit the topology for execution.</li>
- * </ul>
- * <p>
- * The class provides some common processing needs:
- * <ul>
- * <li>Support for an external configuration file</li>
- * <li>Provides a {@link TopologyProviderFactory}</li>
- * <li>Provides a {@link ApplicationUtilities}</li>
- * <li>Provides a {@link MqttDevice}</li>
- * </ul>
- */
-public abstract class AbstractMqttApplication extends AbstractApplication {
-
- private MqttDevice mqttDevice;
-
- public AbstractMqttApplication(String propsPath) throws Exception {
- super(propsPath);
- }
-
- @Override
- protected void preBuildTopology(Topology t) {
- // Add an MQTT device communication manager to the topology
- updateTopicPrefix();
- mqttDevice = new MqttDevice(t, props);
- System.out.println("MqttDevice serverURLs " + Arrays.toString(mqttDevice.getMqttConfig().getServerURLs()));
- System.out.println("MqttDevice clientId " + mqttDevice.getMqttConfig().getClientId());
- System.out.println("MqttDevice deviceId " + props.getProperty("mqttDevice.id"));
- System.out.println("MqttDevice event topic pattern " + mqttDevice.eventTopic(null));
- System.out.println("MqttDevice command topic pattern " + mqttDevice.commandTopic(null));
- }
-
- /**
- * Get the application's MqttDevice
- * @return the MqttDevice
- */
- public MqttDevice mqttDevice() {
- return mqttDevice;
- }
-
- private void updateTopicPrefix() {
- String val = props.getProperty("mqttDevice.topic.prefix");
- if (val != null) {
- val = val.replace("{user.name}", System.getProperty("user.name"));
- val = val.replace("{application.name}", props.getProperty("application.name"));
- props.setProperty("mqttDevice.topic.prefix", val);
- }
- }
-
- /**
- * Compose a MqttDevice eventId for the sensor.
- * @param sensorId the sensor id
- * @param eventId the sensor's eventId
- * @return the device eventId
- */
- public String sensorEventId(String sensorId, String eventId) {
- return sensorId + "." + eventId;
- }
-
- /**
- * Compose a MqttDevice commandId for the sensor
- * @param sensorId the sensor id
- * @param commandId the sensor's commandId
- * @return the device commandId
- */
- public String commandId(String sensorId, String commandId) {
- return sensorId + "." + commandId;
- }
-
- /**
- * Extract a simple string valued command arg
- * from a {@link MqttDevice#commands(String...)} returned
- * JsonObject tuple.
- * <p>
- * Interpret the JsonObject's embedded payload as a JsonObject with a single
- * "value" property.
- * @param jo the command tuple.
- * @return the command's argument value
- */
- public String getCommandValueString(JsonObject jo) {
- return jo.get(CMD_PAYLOAD).getAsJsonObject().get("value").getAsString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/DeviceCommsApp.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/DeviceCommsApp.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/DeviceCommsApp.java
deleted file mode 100644
index 70deaa4..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/DeviceCommsApp.java
+++ /dev/null
@@ -1,114 +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.apps.mqtt;
-
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.mqtt.MqttStreams;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.edgent.topology.json.JsonFunctions;
-
-import com.google.gson.JsonObject;
-
-/**
- * An MQTT Device Communications client for watching device events
- * and sending commands.
- * <p>
- * This is an "application properties" aware client that gets MQTT configuration
- * from an Edgent sample app application configuration properties file.
- * <p>
- * This client avoids the need for other MQTT clients (e.g., from a mosquitto
- * installation) to observe and control the applications.
- */
-public class DeviceCommsApp extends AbstractMqttApplication {
-
- private static final String usage = "Usage: watch | send <cmdLabel> <cmdArg>";
-
- private String mode;
- private String cmdLabel;
- private String cmdArg;
-
- public static void main(String[] args) throws Exception {
- if (args.length < 1)
- throw new Exception("missing pathname to application properties file");
-
- try {
- int i = 0;
- DeviceCommsApp application = new DeviceCommsApp(args[i++]);
- String mode = args[i++];
- if (!("watch".equals(mode) || "send".equals(mode))) {
- throw new IllegalArgumentException("Unsupport mode: "+application.mode);
- }
- application.mode = mode;
- if (application.mode.equals("send")) {
- application.cmdLabel = args[i++];
- application.cmdArg = args[i++];
- }
-
- application.run();
- }
- catch (IllegalArgumentException | IndexOutOfBoundsException e) {
- throw new IllegalArgumentException(e.getMessage()
- +"\n"+usage);
- }
- }
-
- /**
- * Create an application instance.
- * @param propsPath pathname to an application configuration file
- * @throws Exception
- */
- DeviceCommsApp(String propsPath) throws Exception {
- super(propsPath);
- }
-
- @Override
- protected void buildTopology(Topology t) {
- mqttDevice().getMqttConfig().setClientId(null);
- MqttStreams mqtt = new MqttStreams(t, () -> mqttDevice().getMqttConfig());
- if (mode.equals("send")) {
- String topic = mqttDevice().commandTopic(cmdLabel);
- JsonObject jo = new JsonObject();
- jo.addProperty("value", cmdArg);
- System.out.println("Publishing command: topic="+topic+" value="+jo);
- TStream<String> cmd = t.strings(JsonFunctions.asString().apply(jo));
- mqtt.publish(cmd, topic, QoS.FIRE_AND_FORGET, false/*retain*/);
- // Hmm... the paho MQTT *non-daemon* threads prevent the app
- // from exiting after returning from main() following job submit().
- // Lacking MqttStreams.shutdown() or such...
- // Delay a bit and then explicitly exit(). Ugh.
- cmd.sink(tuple -> {
- try {
- Thread.sleep(3*1000);
- } catch (Exception e) { }
- System.exit(0); });
- }
- else if (mode.equals("watch")) {
- String topicFilter = mqttDevice().eventTopic(null);
- System.out.println("Watching topic filter "+topicFilter);
- TStream<String> events = mqtt.subscribe(topicFilter, QoS.FIRE_AND_FORGET,
- (topic,payload) -> {
- String s = "\n# topic "+topic;
- s += "\n" + new String(payload);
- return s;
- });
- events.print();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/package-info.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/package-info.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/package-info.java
deleted file mode 100644
index 54598cb..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/mqtt/package-info.java
+++ /dev/null
@@ -1,25 +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.
-*/
-/**
- * Base support for Edgent MQTT based application samples.
- * <p>
- * This package builds on {@code org.apache.edgent.samples.apps} providing
- * additional common capabilities in the area of MQTT based device appliations.
- */
-package org.apache.edgent.samples.apps.mqtt;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/package-info.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/package-info.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/package-info.java
deleted file mode 100644
index cf62ba2..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/package-info.java
+++ /dev/null
@@ -1,42 +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.
-*/
-/**
- * Support for some more complex Edgent application samples.
- * <p>
- * This package provides some commonly needed capabilities particularly in
- * the area of an external configuration description influence on various
- * things.
- * <p>
- * Focal areas:
- * <ul>
- * <li>{@link org.apache.edgent.samples.apps.AbstractApplication} - a base class for
- * Edgent applications providing commonly needed features.
- * </li>
- * <li>{@link org.apache.edgent.samples.apps.TopologyProviderFactory} - a configuration
- * driven factory for an Edgent topology provider.
- * </li>
- * <li>{@link org.apache.edgent.samples.apps.ApplicationUtilities} - some
- * general configuration driven utilities.
- * </li>
- * <li>{@link org.apache.edgent.samples.apps.JsonTuples} - utilities for wrapping
- * sensor samples in a JsonObject and operating on it.
- * </li>
- * </ul>
- */
-package org.apache.edgent.samples.apps;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/Sensor1.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/Sensor1.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/Sensor1.java
deleted file mode 100644
index bdad9f4..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/Sensor1.java
+++ /dev/null
@@ -1,286 +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.apps.sensorAnalytics;
-
-import static org.apache.edgent.analytics.math3.stat.Statistic.MAX;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MEAN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MIN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.STDDEV;
-import static org.apache.edgent.samples.apps.JsonTuples.KEY_ID;
-import static org.apache.edgent.samples.apps.JsonTuples.KEY_READING;
-import static org.apache.edgent.samples.apps.JsonTuples.KEY_TS;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.commons.math3.util.Pair;
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.analytics.sensors.Ranges;
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.samples.apps.JsonTuples;
-import org.apache.edgent.samples.utils.sensor.PeriodicRandomSensor;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.edgent.topology.plumbing.PlumbingStreams;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonObject;
-
-/**
- * Analytics for "Sensor1".
- * <p>
- * This sample demonstrates some common continuous sensor analytic themes.
- * <p>
- * In this case we have a simulated sensor producing 1000 samples per second
- * of an integer type in the range of 0-255.
- * <p>
- * The processing pipeline created is roughly:
- * <ul>
- * <li>Batched Data Reduction - reduce the sensor's 1000 samples per second
- * down to 1 sample per second simple statistical aggregation of the readings.
- * </li>
- * <li>Compute historical information - each 1hz sample is augmented
- * with a 30 second trailing average of the 1hz readings.
- * </li>
- * <li>Threshold detection - each 1hz sample's value is compared
- * against a target range and outliers are identified.
- * </li>
- * <li>Local logging - outliers are logged to a local file
- * </li>
- * <li>Publishing results to a MQTT broker:
- * <ul>
- * <li>when enabled, invdividual outliers are published.</li>
- * <li>Every 30 seconds a list of the last 10 outliers is published.</li>
- * </ul>
- * </li>
- * </ul>
- * <p>
- * The sample also demonstrates:
- * <ul>
- * <li>Dynamic configuration control - subscribe to a MQTT broker
- * to receive commands to adjust the threshold detection range value.
- * </li>
- * <li>Generally, the configuration of the processing is driven via an
- * external configuration description.
- * </li>
- * <li>Conditional stream tracing - configuration controlled inclusion of tracing.
- * </li>
- * <li>Use of {@link TStream#tag(String...)} to improve information provided by
- * the Edgent DevelopmentProvider console.</li>
- * </ul>
- */
-public class Sensor1 {
- private final SensorAnalyticsApplication app;
- private final Topology t;
- private final String sensorId = "sensor1";
-
- public Sensor1(Topology t, SensorAnalyticsApplication app) {
- this.t = t;
- this.app = app;
- }
-
- /**
- * Add the sensor's analytics to the topology.
- */
- public void addAnalytics() {
-
- // Need synchronization for set/get of dynamically changeable values.
- AtomicReference<Range<Integer>> range = new AtomicReference<>();
- AtomicReference<Boolean> isPublish1hzOutsideRange = new AtomicReference<>();
-
- // Initialize the controls
- range.set(app.utils().getRangeInteger(sensorId, "outside1hzMeanRange"));
- isPublish1hzOutsideRange.set(false);
-
- // Handle the sensor's device commands
- app.mqttDevice().commands(commandId("set1hzMeanRangeThreshold"))
- .tag(commandId("set1hzMeanRangeThresholdCmd"))
- .sink(jo -> {
- Range<Integer> newRange = Ranges.valueOfInteger(getCommandValue(jo));
- System.out.println("===== Changing range to "+newRange+" ======");
- range.set(newRange);
- });
- app.mqttDevice().commands(commandId("setPublish1hzOutsideRange"))
- .tag(commandId("setPublish1hzOutsideRangeCmd"))
- .sink(jo -> {
- Boolean b = new Boolean(getCommandValue(jo));
- System.out.println("===== Changing isPublish1hzOutsideRange to "+b+" ======");
- isPublish1hzOutsideRange.set(b);
- });
-
- // Create a raw simulated sensor stream of 1000 tuples/sec.
- // Each tuple is Pair<Long timestampMsec, sensor-reading (0..255)>.
- PeriodicRandomSensor simulatedSensorFactory = new PeriodicRandomSensor();
- TStream<Pair<Long,Integer>> raw1khz =
- simulatedSensorFactory.newInteger(t, 1/*periodMsec*/, 255)
- .tag("raw1khz");
- traceStream(raw1khz, "raw1khz");
-
- // Wrap the raw sensor reading in a JsonObject for convenience.
- TStream<JsonObject> j1khz = JsonTuples.wrap(raw1khz, sensorId)
- .tag("j1khz");
- traceStream(j1khz, "j1khz");
-
- // Data-reduction: reduce 1khz samples down to
- // 1hz aggregate statistics samples.
- TStream<JsonObject> j1hzStats = j1khz.last(1000, JsonTuples.keyFn())
- .batch(JsonTuples.statistics(MIN, MAX, MEAN, STDDEV))
- .tag("1hzStats");
-
- // Create a 30 second sliding window of average trailing Mean values
- // and enrich samples with that information.
- j1hzStats = j1hzStats.last(30, JsonTuples.keyFn()).aggregate(
- (samples, key) -> {
- // enrich and return the most recently added tuple
- JsonObject jo = samples.get(samples.size()-1);
- double meanSum = 0;
- for (JsonObject js : samples) {
- meanSum += JsonTuples.getStatistic(js, MEAN).getAsDouble();
- }
- jo.addProperty("AvgTrailingMean", Math.round(meanSum / samples.size()));
- jo.addProperty("AvgTrailingMeanCnt", samples.size());
- return jo;
- })
- .tag("1hzStats.enriched");
- traceStream(j1hzStats, "j1hzStats");
-
- // Detect 1hz samples whose MEAN value are
- // outside the configuration specified range.
- TStream<JsonObject> outside1hzMeanRange = j1hzStats.filter(
- sample -> {
- int value = JsonTuples.getStatistic(sample, MEAN).getAsInt();
- return !range.get().contains(value);
- })
- .tag("outside1hzMeanRange");
- traceStream(outside1hzMeanRange, () -> "outside1hzMeanRange"+range.get());
-
- // Log every outside1hzMeanRange event
- app.utils().logStream(outside1hzMeanRange, "ALERT", "outside1hzMeanRange");
-
- // Conditionally publish every outside1hzMeanRange event.
- // Use a pressureReliever to prevent backpressure if the broker
- // can't be contacted.
- // TODO enhance MqttDevice with configurable reliever.
- app.mqttDevice().events(
- PlumbingStreams.pressureReliever(
- outside1hzMeanRange.filter(tuple -> isPublish1hzOutsideRange.get())
- .tag("outside1hzMeanRangeEvent.conditional"),
- tuple -> 0, 30).tag("outside1hzMeanRangeEvent.pressureRelieved"),
- app.sensorEventId(sensorId, "outside1hzMeanRangeEvent"), QoS.FIRE_AND_FORGET);
-
- // Demonstrate periodic publishing of a sliding window if
- // something changed since it was last published.
- periodicallyPublishLastNInfo(outside1hzMeanRange, 10, 30,
- "periodicLastOutsideRangeEvent");
-
- // TODO histogram: #alerts over the last 8hr
-
- }
-
- /**
- * Periodically publish the lastN on a stream.
- * @param stream tuples to
- * @param count sliding window size "lastN"
- * @param nSec publish frequency
- * @param event sensor's publish event label
- */
- private void periodicallyPublishLastNInfo(TStream<JsonObject> stream,
- int count, int nSec, String event) {
-
- // Demonstrate periodic publishing of a sliding window if
- // something changed since it was last published.
-
- // Maintain a sliding window of the last N tuples.
- // TODO today, windows don't provide "anytime" access to their collection
- // so maintain our own current copy of the collection that we can
- // access it when needed.
- //
- List<JsonObject> lastN = Collections.synchronizedList(new ArrayList<>());
- stream.last(count, JsonTuples.keyFn())
- .aggregate((samples, key) -> samples)
- .tag(event+".lastN")
- .sink(samples -> {
- // Capture the new list/window.
- synchronized(lastN) {
- lastN.clear();
- lastN.addAll(samples);
- }
- });
-
- // Publish the lastN (with trimmed down info) every nSec seconds
- // if anything changed since the last publish.
- TStream<JsonObject> periodicLastN =
- t.poll(() -> 1, nSec, TimeUnit.SECONDS).tag(event+".trigger")
- .filter(trigger -> !lastN.isEmpty()).tag(event+".changed")
- .map(trigger -> {
- synchronized(lastN) {
- // create a single JsonObject with the list
- // of reduced-content samples
- JsonObject jo = new JsonObject();
- jo.addProperty(KEY_ID, sensorId);
- jo.addProperty(KEY_TS, System.currentTimeMillis());
- jo.addProperty("window", count);
- jo.addProperty("pubFreqSec", nSec);
- JsonArray ja = new JsonArray();
- jo.add("lastN", ja);
- for (JsonObject j : lastN) {
- JsonObject jo2 = new JsonObject();
- ja.add(jo2);
- jo2.add(KEY_TS, j.get(KEY_TS));
- // reduce size: include only 2 significant digits
- jo2.addProperty(KEY_READING, String.format("%.2f",
- JsonTuples.getStatistic(j, MEAN).getAsDouble()));
- }
- lastN.clear();
- return jo;
- }
- })
- .tag(event);
-
- traceStream(periodicLastN, event);
-
- // Use a pressureReliever to prevent backpressure if the broker
- // can't be contacted.
- // TODO enhance MqttDevice with configurable reliever.
- app.mqttDevice().events(
- PlumbingStreams.pressureReliever(periodicLastN, tuple -> 0, 30)
- .tag(event+".pressureRelieved"),
- app.sensorEventId(sensorId, event), QoS.FIRE_AND_FORGET);
- }
-
- private String commandId(String commandId) {
- return app.commandId(sensorId, commandId);
- }
-
- private String getCommandValue(JsonObject jo) {
- return app.getCommandValueString(jo);
- }
-
- private <T> TStream<T> traceStream(TStream<T> stream, String label) {
- return traceStream(stream, () -> label);
- }
-
- private <T> TStream<T> traceStream(TStream<T> stream, Supplier<String> label) {
- return app.utils().traceStream(stream, sensorId, label);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/SensorAnalyticsApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/SensorAnalyticsApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/SensorAnalyticsApplication.java
deleted file mode 100644
index 061bf95..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/SensorAnalyticsApplication.java
+++ /dev/null
@@ -1,57 +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.apps.sensorAnalytics;
-
-import org.apache.edgent.samples.apps.mqtt.AbstractMqttApplication;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A sample application demonstrating some common sensor analytic processing
- * themes.
- */
-public class SensorAnalyticsApplication extends AbstractMqttApplication {
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to application properties file");
-
- SensorAnalyticsApplication application = new SensorAnalyticsApplication(args[0]);
-
- application.run();
- }
-
- /**
- * Create an application instance.
- * @param propsPath pathname to an application configuration file
- * @throws Exception
- */
- SensorAnalyticsApplication(String propsPath) throws Exception {
- super(propsPath);
- }
-
- @Override
- protected void buildTopology(Topology t) {
-
- // Add the "sensor1" analytics to the topology
- new Sensor1(t, this).addAnalytics();
-
- // TODO Add the "sensor2" analytics to the topology
- // TODO Add the "sensor3" analytics to the topology
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/package-info.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/package-info.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/package-info.java
deleted file mode 100644
index 6ce82b6..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/sensorAnalytics/package-info.java
+++ /dev/null
@@ -1,164 +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 Sensor Analytics sample application demonstrates some common
- * continuous sensor analytic application themes.
- * See {@link org.apache.edgent.samples.apps.sensorAnalytics.Sensor1 Sensor1} for the
- * core of the analytics processing and
- * {@link org.apache.edgent.samples.apps.sensorAnalytics.SensorAnalyticsApplication
- * SensorAnalyticsApplication}
- * for the main program.
- * <p>
- * The themes include:
- * <ul>
- * <li>Batched Data Reduction - reducing higher frequency sensor reading
- * samples down to a lower frequency using statistical aggregations
- * of the raw readings.
- * </li>
- * <li>Computing continuous historical statistics such as a
- * 30 second trailing average of sensor readings.
- * </li>
- * <li>Outlier / threshold detection against a configurable range</li>
- * <li>Local logging of stream tuples</li>
- * <li>Publishing analytic results to an MQTT broker</li>
- * <li>Dynamic configuration control - subscribing to a MQTT broker
- * to receive commands to adjust the threshold detection range value.
- * </li>
- * <li>Generally, the configuration of the processing is driven via an
- * external configuration description.
- * </li>
- * <li>Conditional stream tracing - configuration controlled inclusion of tracing.
- * </li>
- * </ul>
- *
- * <h2>Prerequisites:</h2>
- * <p>
- * The default configuration is for a local MQTT broker.
- * A good resource is <a href="http://mosquitto.org">mosquitto.org</a>
- * if you want to download and setup your own MQTT broker.
- * Or you can use some other broker available in your environment.
- * <p>
- * Alternatively, there are some public MQTT brokers available to experiment with.
- * Their availability status isn't guaranteed. If you're unable to connect
- * to the broker, it's likely that it isn't up or your firewalls don't
- * allow you to connect. DO NOT PUBLISH ANYTHING SENSITIVE - anyone
- * can be listing. A couple of public broker locations are noted
- * in the application's properties file.
- * <p>
- * The default {@code mqttDevice.topic.prefix} value, used by default in
- * generated MQTT topic values and MQTT clientId, contains the user's
- * local login id. The SensorAnalytics sample application does not have any
- * other sensitive information.
- * <p>
- * Edit {@code <edgent-release>/java8/scripts/apps/sensorAnalytics/sensoranalytics.properties}
- * to change the broker location or topic prefix.
- *
- * <h2>Application output:</h2>
- * <p>
- * The application periodically (every 30sec), publishes a list of
- * the last 10 outliers to MQTT. When enabled, it also publishes
- * full details of individual outliers as they occur.
- * It also subscribes to MQTT topics for commands to dynamically change the
- * threshold range and whether to publish individual outliers.
- * <p>
- * All MQTT configuration information, including topic patterns,
- * are in the application.properties file.
- * <p>
- * The application logs outlier events in local files. The actual location
- * is specified in the application.properties file.
- * <p>
- * The application generates some output on stdout and stderr.
- * The information includes:
- * <ul>
- * <li>MQTT device info. Lines 1 through 5 in the sample console output below.</li>
- * <li>URL for the Edgent development console. Line 6.</li>
- * <li>Trace of the outlier event stream. Line 7.
- * The output is a label, which includes the active threshold range,
- * followed by the event's JSON.
- * These are the events that will also be logged and conditionally published
- * as well as included in the periodic lastN info published every 30sec.
- * </li>
- * <li>Announcement when a "change threshold" or "enable publish of 1khz outliers"
- * command is received and processed.
- * Line 8 and 9.
- * </li>
- * <li>At this time some INFO trace output from the MQTT connector</li>
- * <li>At this time some INFO trace output from the File connector</li>
- * </ul>
- * Sample console output:
- * <pre>{@code
- * [1] MqttDevice serverURLs [tcp://localhost:1883]
- * [2] MqttDevice clientId id/012345
- * [3] MqttDevice deviceId 012345
- * [4] MqttDevice event topic pattern id/012345/evt/+/fmt/json
- * [5] MqttDevice command topic pattern id/012345/cmd/+/fmt/json
- * [6] Edgent Console URL for the job: http://localhost:57324/console
- * [7] sensor1.outside1hzMeanRange[124..129]: {"id":"sensor1","reading":{"N":1000,"MIN":0.0,"MAX":254.0,"MEAN":130.23200000000006,"STDDEV":75.5535473324351},"msec":1454623874408,"agg.begin.msec":1454623873410,"agg.count":1000,"AvgTrailingMean":128,"AvgTrailingMeanCnt":4}
- * ...
- * [8] ===== Changing range to [125..127] ======
- * sensor1.outside1hzMeanRange[125..127]: {"id":"sensor1","reading":{"N":1000,"MIN":0.0,"MAX":254.0,"MEAN":129.00099999999978,"STDDEV":74.3076080870567},"msec":1454624142419,"agg.begin.msec":1454624141420,"agg.count":1000,"AvgTrailingMean":127,"AvgTrailingMeanCnt":30}
- * [9] ===== Changing isPublish1hzOutsideRange to true ======
- * ...
- * }</pre>
- *
- * <h2>Running, observing and controlling the application:</h2>
- * <pre>{@code
- * $ ./runSensorAnalytics.sh
- * }</pre>
- * <p>
- * To observe the locally logged outlier events:
- * <pre>{@code
- * $ tail -f /tmp/SensorAnalytics/logs/.outside1hzMeanRange
- * }</pre>
- * <p>
- * To observe the events that are getting published to MQTT:
- * <pre>{@code
- * $ ./runDeviceComms.sh watch
- * }</pre>
- * <p>
- * To change the outlier threshold setting:
- * <br>The command value is the new range string: {@code [<lowerBound>..<upperBound>]}.
- * <pre>{@code
- * $ ./runDeviceComms.sh send sensor1.set1hzMeanRangeThreshold "[125..127]"
- * }</pre>
- * <p>
- * To change the "publish individual 1hz outliers" control:
- * <pre>{@code
- * $ ./runDeviceComms.sh send sensor1.setPublish1hzOutsideRange true
- * }</pre>
- *
- * <h3>Alternative MQTT clients</h3>
- * You can use any MQTT client but you will have to specify the
- * MQTT server, the event topics to watch / subscribe to, and the command topics
- * and JSON for publish commands. The MqttDevice output above provides most
- * of the necessary information.
- * <p>
- * For example, the {@code mosquitto_pub} and
- * {@code mosquitto_sub} commands equivalent to the above runDeviceComms.sh
- * commands are:
- * <pre>{@code
- * # Watch the device's event topics
- * $ /usr/local/bin/mosquitto_sub -t id/012345/evt/+/fmt/json
- * # change the outlier threshold setting
- * $ /usr/local/bin/mosquitto_pub -m '{"value":"[125..127]"}' -t id/012345/cmd/sensor1.set1hzMeanRangeThreshold/fmt/json
- * # change the "publish individual 1hz outliers" control
- * $ /usr/local/bin/mosquitto_pub -m '{"value":"true"}' -t id/012345/cmd/sensor1.setPublish1hzOutsideRange/fmt/json
- * }</pre>
- */
-package org.apache.edgent.samples.apps.sensorAnalytics;
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/resources/META-INF/NOTICE b/samples/apps/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 4b208a9..0000000
--- a/samples/apps/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,12 +0,0 @@
-
-Apache Edgent: Samples: Apps
-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/apps/src/main/resources/org/apache/edgent/samples/apps/applicationTemplate.properties
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/resources/org/apache/edgent/samples/apps/applicationTemplate.properties b/samples/apps/src/main/resources/org/apache/edgent/samples/apps/applicationTemplate.properties
deleted file mode 100644
index 4f23ff5..0000000
--- a/samples/apps/src/main/resources/org/apache/edgent/samples/apps/applicationTemplate.properties
+++ /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.
-#
-
-# A template file for Application Configuration properties
-#
-# The default Edgent topology provider is DirectProvider
-#topology.provider=org.apache.edgent.providers.development.DevelopmentProvider
-#
-application.name=MyAnalytics
-#
-
-# =========================================================================
-# Application stream logging configuration
-# Where the app puts its stream logs.
-# The directory will be created when the topology
-# runs if it doesn't already exist.
-application.log.dir=/tmp/MyAnalytics/logs
-
-# =========================================================================
-# Application "ranges" - e.g., for threshold detections
-# Specify values generated by Range.toString():
-# <lowerBoundType><lowerBound>..<upperBound><upperBoundType>
-# where
-# lowerBoundType is "[" inclusive or "(" exclusive
-# upperBoundType is "]" inclusive or ")" exclusive
-# lowerBound or upperBound is "*" for open ranges,
-# e.g., [*..50] for "atMost" 50
-#
-sensor1.range.outside1hzMeanRange=[124..129]
-
-# =========================================================================
-# MQTT Device and Connector configuration info.
-#
-# MQTT Device -- See org.apache.edgent.connectors.mqtt.device.MqttDevice for all
-# of the properties.
-#
-# An optional topic prefix. It can be used to isolate users or applications
-# in shared MQTT broker configurations. By default it is incorporated
-# into device topics and the MQTT clientId.
-# If you use a public MQTT broker you may want to change the topic
-# prefix so it is still unique for you but doesn't include the
-# user name or application name.
-mqttDevice.topic.prefix=ibm.xyzzy-streams.samples/user/{user.name}/{application.name}/
-#
-# The device id used for identifying the device's events and commands
-# in the MQTT topic namespace.
-# By default it also gets incorporated into the MQTT clientId value.
-mqttDevice.id=012345
-#
-# The MQTT clientId. Only one instance of a MqttDevice can connect
-# to the MQTT broker with a given clientId.
-#mqttDevice.mqtt.clientId={mqttDevice.topic.prefix}id/{mqttDevice.id}
-#
-# MQTT Connector See org.apache.edgent.connectors.mqtt.MqttConfig.fromProperties()
-#
-# The default configuration is for a local MQTT broker.
-# See mosquitto.org for instructions on downloading a MQTT broker.
-# Or use some other MQTT broker available in your environment.
-mqtt.serverURLs=tcp://localhost:1883
-#
-# Alternatively, there are some public MQTT brokers available to experiment with.
-# Their availability status isn't guaranteed. If you're unable to connect
-# to the broker, it's likely that it isn't up or your firewalls don't
-# allow you to connect. DO NOT PUBLISH ANYTHING SENSITIVE - anyone
-# can be listing.
-#mqtt.serverURLs=tcp://iot.eclipse.org:1883
-#mqtt.serverURLs=tcp://test.mosquitto.org:1883
-#
-#mqtt.userName=xyzzy
-#mqtt.password=myMosquittoPw
-
-# =========================================================================
-# Patterns for identifying which streams to trace to System.out
-# To enable use include.csv and/or includes.regex.
-# To exclude an otherwise included file, use excludes.csv and/or excludes.regex
-#
-# Some tracing labels
-# sensor1.raw1khz,sensor1.j1khz,sensor1.j1hzStats,sensor1.outside1hzMeanRange*,
-# sensor1.periodicLastN*
-#
-#stream.tracing.includes.csv=sensor1.j1hzStats
-stream.tracing.includes.regex=sensor1.outside1hzMeanRange.*
-#stream.tracing.excludes.regex=.*
-#stream.tracing.excludes.csv=sensor1.raw1khz
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/README.md
----------------------------------------------------------------------
diff --git a/samples/connectors/README.md b/samples/connectors/README.md
deleted file mode 100644
index 391cde3..0000000
--- a/samples/connectors/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-See the README.md in the samples root directory for information on building the samples.
-
-See the scripts directory for information on running these samples.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/pom.xml
----------------------------------------------------------------------
diff --git a/samples/connectors/pom.xml b/samples/connectors/pom.xml
deleted file mode 100644
index a918f59..0000000
--- a/samples/connectors/pom.xml
+++ /dev/null
@@ -1,80 +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-connectors</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Connectors</name>
-
- <dependencies>
- <!-- parent pom has Platforms and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-mqtt</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-kafka</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-jdbc</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-serial</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-file</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-iotp</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-math3</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples-topology</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/file/README
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/file/README b/samples/connectors/scripts/file/README
deleted file mode 100644
index 13629d0..0000000
--- a/samples/connectors/scripts/file/README
+++ /dev/null
@@ -1,21 +0,0 @@
-Sample File Streams connector topology applications.
-
-The file writer application writes a stream's tuples to files.
-
-The file reader application watches a directory for files and reads their
-contents into a stream of tuples.
-
-The source code for the samples is in the <edgent-release>/samples directory.
-
-Use:
-
-# create a new directory for the sample to use
-$ mkdir /tmp/fileSample
-
-# run the sample file watcher / reader
-# the reader runs forever printing out content from files read
-$ ./runfilesample.sh reader /tmp/fileSample
-
-# run the sample file writer
-# the writer runs forever printing out each generated tuple
-$ ./runfilesample.sh writer /tmp/fileSample
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/file/runfilesample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/file/runfilesample.sh b/samples/connectors/scripts/file/runfilesample.sh
deleted file mode 100755
index 1552d1b..0000000
--- a/samples/connectors/scripts/file/runfilesample.sh
+++ /dev/null
@@ -1,44 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the File connector sample
-#
-# ./runfilesample.sh writer
-# ./runfilesample.sh reader
-
-sampledir=/tmp/fileConnectorSample
-if [ ! -e $sampledir ]; then
- mkdir $sampledir
-fi
-
-export CLASSPATH=${UBER_JAR}
-
-app=$1; shift
-if [ "$app" == "writer" ]; then
- java org.apache.edgent.samples.connectors.file.FileWriterApp $sampledir
-elif [ "$app" == "reader" ]; then
- java org.apache.edgent.samples.connectors.file.FileReaderApp $sampledir
-else
- echo "unrecognized mode '$app'"
- echo "usage: $0 'writer|reader'"
- exit 1
-fi
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/README
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/README b/samples/connectors/scripts/iotp/README
deleted file mode 100644
index eccb2f8..0000000
--- a/samples/connectors/scripts/iotp/README
+++ /dev/null
@@ -1,36 +0,0 @@
-
-# ##########
-# The "Quickstart" samples connect to the IBM Watson IoT Platform
-# using the Quickstart feature that does not require device registration.
-# When the samples are run they print out a URL which allows a browser
-# to see the data being sent from this sample.
-#
-# IotpQuickstart2 demonstrates using the WIoTP API to initialize the IotpDevice
-# connector as well as the ability to publish events using the WIoTP HTTP protocol.
-
-IotpQuickstart - ./runquickstart.sh
-IotpQuickstart2 - ./runquickstart2.sh [useHttp]
-
-# ##########
-# IotpSensors connects to your IBM Watson IoT Platform service
-# as the device defined in your device config file.
-#
-# A prototype config file for your WIoTP registered device information
-# is provided in device.cfg.
-
-IotpSensors - ./runiotsensors.sh device-cfg-path
-
-# ##########
-# IotpDeviceSample and IotpGatewaySample
-# connect to your IBM Watson IoT Platform service.
-# They publish device events and print out received device commands.
-# Use IotpAppClient to print out the generated device events and
-# to generate the device commands.
-#
-# Prototype config files for your WIoTP registered device, gateway,
-# and application client information are provided in
-# iotp-device-sample.cfg, iotp-gwdevice-sample.cfg and iotp-app-client.cfg
-
-IotpDeviceSample - ./run-iotp-device-sample.sh [useDeviceClient|useManagedDevice] [useHttp] <device-cfg-path>
-IotpGatewaySample - ./run-iotp-gwdevice-sample.sh [useGatewayClient|useManagedGateway] [useHttp] <device-cfg-path>
-IotpAppClient - ./run-iotp-client-app.sh [useGW] <app-cfg-path>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/device.cfg
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/device.cfg b/samples/connectors/scripts/iotp/device.cfg
deleted file mode 100644
index 9c67292..0000000
--- a/samples/connectors/scripts/iotp/device.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-[device]
-org =
-type =
-id =
-auth-method = token
-auth-token =
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/iotp-app-client.cfg
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/iotp-app-client.cfg b/samples/connectors/scripts/iotp/iotp-app-client.cfg
deleted file mode 100644
index 177e6b5..0000000
--- a/samples/connectors/scripts/iotp/iotp-app-client.cfg
+++ /dev/null
@@ -1,25 +0,0 @@
-# configuration properties for the IotpAppSample app
-
-[application]
-# WIoTP defined application configuration properties
-
-Organization-ID =
-id =
-Authentication-Method = apikey
-API-Key =
-Authentication-Token =
-
-# --------------------------------------------------------
-# Input for the sample app, not WIoTP App props
-
-# Non-gateway mode target registered device
-# Corresponding values from the iotp-device-sample.cfg file
-deviceType =
-deviceId =
-
-# Gateway mode target registered gateway device and the connected device
-# Corresponding values from the iotp-gwdevice-sample.cfg file
-gwDeviceType =
-gwDeviceId =
-cn-dev1-type = myCnDev1Type
-cn-dev1-id = myCnDev1Id
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/iotp-device-sample.cfg
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/iotp-device-sample.cfg b/samples/connectors/scripts/iotp/iotp-device-sample.cfg
deleted file mode 100644
index 3a2aefb..0000000
--- a/samples/connectors/scripts/iotp/iotp-device-sample.cfg
+++ /dev/null
@@ -1,10 +0,0 @@
-# configuration properties for IotpDeviceSample
-
-[device]
-# WIoTP defined IoT device configuration properties
-
-Organization-ID =
-Device-Type =
-Device-ID =
-Authentication-Method = token
-Authentication-Token =
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/iotp-gwdevice-sample.cfg
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/iotp-gwdevice-sample.cfg b/samples/connectors/scripts/iotp/iotp-gwdevice-sample.cfg
deleted file mode 100644
index 1845fcc..0000000
--- a/samples/connectors/scripts/iotp/iotp-gwdevice-sample.cfg
+++ /dev/null
@@ -1,17 +0,0 @@
-# configuration properties for IotpGWDeviceSample
-
-[device]
-# WIoTP defined IoT Gateway device configuration properties
-
-Organization-ID =
-Gateway-Type =
-Gateway-ID =
-Authentication-Method = token
-Authentication-Token =
-
-# --------------------------------------------------------
-# Input for the sample app, not WIoTP device props
-
-# a type and id for a device connected to the gateway - pick anything
-cn-dev1-type = myCnDev1Type
-cn-dev1-id = myCnDev1Id
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/run-iotp-app-client.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/run-iotp-app-client.sh b/samples/connectors/scripts/iotp/run-iotp-app-client.sh
deleted file mode 100755
index 349aeb5..0000000
--- a/samples/connectors/scripts/iotp/run-iotp-app-client.sh
+++ /dev/null
@@ -1,47 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Platform IotpAppClient sample.
-#
-# run-iotp-app-client.sh [useGW] <app-cfg-path> # see iotp-app-client.cfg
-#
-# Connects to WIoTP and sends device commands to the
-# IotpDeviceSample or IotpGWDeviceSample device samples.
-#
-# This connects to your IBM Watson IoT Platform service
-# as the Application defined in a application config file.
-# The file format is the standard one for IBM Watson IoT Platform.
-#
-# Note, the config file also contains some additional information for this application.
-# A sample iot-app-client.cfg is in the scripts/connectors/iotp directory.
-
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpAppClient $*
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/run-iotp-device-sample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/run-iotp-device-sample.sh b/samples/connectors/scripts/iotp/run-iotp-device-sample.sh
deleted file mode 100755
index a8b3453..0000000
--- a/samples/connectors/scripts/iotp/run-iotp-device-sample.sh
+++ /dev/null
@@ -1,45 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Platform IotpDeviceSample sample.
-#
-# run-iotp-device-sample.sh [useDeviceClient|useManagedDevice] [useHttp] <device-cfg-path> # see iotp-device-sample.cfg
-#
-# Connects to WIoTP and sends device events and receives device commands.
-#
-# This connects to your IBM Watson IoT Platform service
-# as the Device defined in a device config file.
-# The file format is the standard one for IBM Watson IoT Platform.
-#
-# Note, the config file also contains some additional information for this application.
-# A sample iot-device-sample.cfg is in the scripts/connectors/iotp directory.
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpDeviceSample $*
[6/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/run-iotp-gwdevice-sample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/run-iotp-gwdevice-sample.sh b/samples/connectors/scripts/iotp/run-iotp-gwdevice-sample.sh
deleted file mode 100755
index 75b2dd6..0000000
--- a/samples/connectors/scripts/iotp/run-iotp-gwdevice-sample.sh
+++ /dev/null
@@ -1,46 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Platform IotpGWDeviceSample sample.
-#
-# run-iotp-gwdevice-sample.sh [useGatewayClient|useManagedGateway] [useHttp] <device-cfg-path> # see iotp-gwdevice-sample.cfg
-#
-# Connects to WIoTP and sends Gateway and connected device events and receives device commands.
-#
-# This connects to your IBM Watson IoT Platform service
-# as the Gateway defined in a gateway config file.
-# The file format is the standard one for IBM Watson IoT Platform.
-#
-# Note, the config file also contains some additional information for this application.
-# A sample iot-gwdevice-sample.cfg is in the scripts/connectors/iotp directory.
-
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpGWDeviceSample $*
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/runiotpquickstart.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/runiotpquickstart.sh b/samples/connectors/scripts/iotp/runiotpquickstart.sh
deleted file mode 100755
index 5970fae..0000000
--- a/samples/connectors/scripts/iotp/runiotpquickstart.sh
+++ /dev/null
@@ -1,43 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Plaform Quickstart sample.
-#
-# runiotpquickstart.sh
-#
-# This connectors to the Qucikstart IBM Watson IoT Platform service
-# which requires no registration at all.
-#
-# The application prints out a URL which allows a browser
-# to see the data being sent from this sample to
-# IBM Watson IoT Plaform Quickstart sample.
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpQuickstart
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/runiotpquickstart2.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/runiotpquickstart2.sh b/samples/connectors/scripts/iotp/runiotpquickstart2.sh
deleted file mode 100755
index f712f6e..0000000
--- a/samples/connectors/scripts/iotp/runiotpquickstart2.sh
+++ /dev/null
@@ -1,43 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Plaform Quickstart sample.
-#
-# runiotpquickstart2.sh
-#
-# This connects to the Quickstart IBM Watson IoT Platform service
-# which requires no registration at all.
-#
-# The application prints out a URL which allows a browser
-# to see the data being sent from this sample to
-# IBM Watson IoT Platform Quickstart sample.
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpQuickstart2 $*
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/iotp/runiotpsensors.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/iotp/runiotpsensors.sh b/samples/connectors/scripts/iotp/runiotpsensors.sh
deleted file mode 100755
index a1e840b..0000000
--- a/samples/connectors/scripts/iotp/runiotpsensors.sh
+++ /dev/null
@@ -1,44 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs IBM Watson IoT Plaform sample.
-#
-# runiotpsensors.sh path/device.cfg
-#
-# e.g. runiotpsensors.sh $HOME/device.cfg
-#
-# This connectors to your IBM Watson IoT Platform service
-# as the device defined in the device.cfg.
-# The format of device.cfg is the standard one for
-# IBM Watson IoT Platform and a sample is in this directory
-# (omitting values for the authorization tokens).
-
-export CLASSPATH=${UBER_JAR}
-
-# https://github.com/ibm-watson-iot/iot-java/tree/master#migration-from-release-015-to-021
-# Uncomment the following to use the pre-0.2.1 WIoTP client behavior.
-#
-#USE_OLD_EVENT_FORMAT=-Dcom.ibm.iotf.enableCustomFormat=false
-
-VM_OPTS=${USE_OLD_EVENT_FORMAT}
-
-java ${VM_OPTS} org.apache.edgent.samples.connectors.iotp.IotpSensors $1
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/jdbc/.gitignore
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/jdbc/.gitignore b/samples/connectors/scripts/jdbc/.gitignore
deleted file mode 100644
index 3292c9c..0000000
--- a/samples/connectors/scripts/jdbc/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# JDBC connector sample's outputs
-JdbcConnectorSampleDb/**
-derby.log
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/jdbc/README
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/jdbc/README b/samples/connectors/scripts/jdbc/README
deleted file mode 100644
index 112e02e..0000000
--- a/samples/connectors/scripts/jdbc/README
+++ /dev/null
@@ -1,35 +0,0 @@
-Sample JDBC connector dbms writer and reader topology applications.
-
-The following configuration is assumed:
-- Apache Derby is installed and the environment variable DERBY_HOME is set
-
-The writer is a simple JDBC connector sample demonstrating
-streaming write access of a dbms to add stream tuples to a table.
-
-The reader is a simple JDBC connector sample demonstrating
-streaming read access of a dbms table and creating stream
-tuples from the results.
-
-The source code for the samples is in the <edgent-release>/samples directory.
-
-Running the simple sample
--------------------------
-
-Modify the jdbc.properties file if required.
-
-# run the simple sample writer
-# the writer runs briefly and prints out additions to the table
-$ ./runjdbcsample.sh writer
-Inserting into persons table: person id=1 first=John last=Doe
-Inserting into persons table: person id=2 first=Jane last=Doe
-Inserting into persons table: person id=3 first=Billy last=McDoe
-$
-
-# run the simple sample reader
-# the reader runs briefly and prints out retrieved info
-$ ./runjdbcsample.sh reader
-retrieved person: id=1 first=John last=Doe
-retrieved person: id=2 first=Jane last=Doe
-retrieved person: id=3 first=Billy last=McDoe
-Unknown person id=99999
-$
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/jdbc/jdbc.properties
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/jdbc/jdbc.properties b/samples/connectors/scripts/jdbc/jdbc.properties
deleted file mode 100644
index 96a196a..0000000
--- a/samples/connectors/scripts/jdbc/jdbc.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-#db.name= # defaults to "JdbcConnectorSampleDb"
-#db.user= # defaults to System.getProperties("user.name")
-#db.password= # defaults to no password
-persondata.path=persondata.txt
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/jdbc/persondata.txt
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/jdbc/persondata.txt b/samples/connectors/scripts/jdbc/persondata.txt
deleted file mode 100644
index 9037c44..0000000
--- a/samples/connectors/scripts/jdbc/persondata.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# id,firstName,lastName
-1,John,Doe
-2,Jane,Doe
-3,Billy,McDoe
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/jdbc/runjdbcsample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/jdbc/runjdbcsample.sh b/samples/connectors/scripts/jdbc/runjdbcsample.sh
deleted file mode 100755
index 717abcf..0000000
--- a/samples/connectors/scripts/jdbc/runjdbcsample.sh
+++ /dev/null
@@ -1,48 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the Sample JDBC Writer or Reader
-#
-# ./runjdbcsample.sh writer
-# ./runjdbcsample.sh reader
-
-if [ -z "$DERBY_HOME" ]; then
- echo "\$DERBY_HOME not defined."
- exit 1;
-fi
-if [ ! -f $DERBY_HOME/lib/derby.jar ]; then
- echo "\$DERBY_HOME/lib/derby.jar: file not found"
- exit 1;
-fi
-
-export CLASSPATH=${UBER_JAR}:$DERBY_HOME/lib/derby.jar
-
-app=$1; shift
-if [ "$app" == "writer" ]; then
- java org.apache.edgent.samples.connectors.jdbc.SimpleWriterApp jdbc.properties
-elif [ "$app" == "reader" ]; then
- java org.apache.edgent.samples.connectors.jdbc.SimpleReaderApp jdbc.properties
-else
- echo "unrecognized mode '$app'"
- echo "usage: $0 writer|reader"
- exit 1
-fi
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/kafka/README
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/kafka/README b/samples/connectors/scripts/kafka/README
deleted file mode 100644
index b1c6bec..0000000
--- a/samples/connectors/scripts/kafka/README
+++ /dev/null
@@ -1,39 +0,0 @@
-Sample Kafka Publisher and Subscriber topology applications.
-
-By default the samples require the following kafka broker configuration:
-- bootstrap.servers="localhost:9092"
-- zookeeper.connect="localhost:2181"
-- kafka topic "kafkaSampleTopic" exists
-- no authentication
-
-See README-kafka for information about setting up a kafka server
-and creating the topic.
-
-The source code for the samples is in the <edgent-release>/samples directory.
-
-Running the simple sample
--------------------------
-
-Modify the kafka.properties file if required.
-
-# run the simple sample subscriber
-# the subscriber runs forever printing out each received message
-$ ./runkafkasample.sh sub
-
-# run the simple sample publisher
-# the publisher runs forever printing out each published message
-$ ./runkafkasample.sh pub
-
-Running the fully configurable clients
---------------------------------------
-
-# To see how to specify different values:
-$ ./runkafkaclient.sh -h
-
-# run the sample subscriber
-# the subscriber runs forever printing out each received message
-$ ./runkafkaclient.sh sub
-
-# run the sample producer
-# the producer runs forever printing out each published message
-$ ./runkafkaclient.sh pub
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/kafka/README-kafka
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/kafka/README-kafka b/samples/connectors/scripts/kafka/README-kafka
deleted file mode 100644
index e253963..0000000
--- a/samples/connectors/scripts/kafka/README-kafka
+++ /dev/null
@@ -1,25 +0,0 @@
-Setting up a Kafka/Zookeeper config on the default localhost ports is simple
-and well documented at https://kafka.apache.org/quickstart. This should do it:
-
-After downloading kafka:
-
-tar zxf ~/Downloads/kafka_2.11-0.10.1.0.tgz
-cd kafka_2.11-0.10.1.0/
-
-# start the servers (best in separate windows)
-bin/zookeeper-server-start.sh config/zookeeper.properties
-bin/kafka-server-start.sh config/server.properties
-
-The sample requires a topic. Create it:
-
-# create our kafka sample topic
-bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic kafkaSampleTopic
-bin/kafka-topics.sh --list --zookeeper localhost:2181
-
-# quick verify
-bin/kafka-console-producer.sh --broker-list localhost:9092 --topic kafkaSampleTopic
-hi
-there
-^D
-bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kafkaSampleTopic --from-beginning
-... you should see the "hi" and "there" messages.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/kafka/kafka.properties
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/kafka/kafka.properties b/samples/connectors/scripts/kafka/kafka.properties
deleted file mode 100644
index 2470078..0000000
--- a/samples/connectors/scripts/kafka/kafka.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# bootstrap.servers is for a kafka consumer
-bootstrap.servers=localhost:9092
-# zookeeper.connect is for a kafka producer
-zookeeper.connect=localhost:2181
-#group.id=
-topic=kafkaSampleTopic
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/kafka/runkafkaclient.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/kafka/runkafkaclient.sh b/samples/connectors/scripts/kafka/runkafkaclient.sh
deleted file mode 100755
index 74aae1a..0000000
--- a/samples/connectors/scripts/kafka/runkafkaclient.sh
+++ /dev/null
@@ -1,31 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the Kafka Publisher or Subscriber Client
-#
-# ./runkafkaclient.sh pub
-# ./runkafkaclient.sh sub
-# ./runkafkaclient.sh -h
-
-export CLASSPATH=${UBER_JAR}
-
-java org.apache.edgent.samples.connectors.kafka.KafkaClient $@
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/kafka/runkafkasample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/kafka/runkafkasample.sh b/samples/connectors/scripts/kafka/runkafkasample.sh
deleted file mode 100755
index 817da76..0000000
--- a/samples/connectors/scripts/kafka/runkafkasample.sh
+++ /dev/null
@@ -1,39 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the Sample Kafka Publisher or Subscriber
-#
-# ./runkafkasample.sh pub
-# ./runkafkasample.sh sub
-
-export CLASSPATH=${UBER_JAR}
-
-app=$1; shift
-if [ "$app" == "pub" ]; then
- java org.apache.edgent.samples.connectors.kafka.SimplePublisherApp kafka.properties
-elif [ "$app" == "sub" ]; then
- java org.apache.edgent.samples.connectors.kafka.SimpleSubscriberApp kafka.properties
-else
- echo "unrecognized mode '$app'"
- echo "usage: $0 pub|sub"
- exit 1
-fi
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/mqtt/README
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/mqtt/README b/samples/connectors/scripts/mqtt/README
deleted file mode 100644
index 922807c..0000000
--- a/samples/connectors/scripts/mqtt/README
+++ /dev/null
@@ -1,37 +0,0 @@
-Sample MQTT Publisher and Subscriber topology applications.
-
-By default, the following MQTT broker configuration is assumed:
-- the broker's connection URL is tcp://localhost:1883
-- the broker is configured for no authentication
-
-See http://mqtt.org for the code and setup information for
-a mqtt broker.
-
-The source code for the samples is in the <edgent-release>/samples directory.
-
-Running the simple sample
--------------------------
-
-Modify the mqtt.properties file if required.
-
-# run the simple sample subscriber
-# the subscriber runs forever printing out each received message
-$ ./runmqttsample.sh sub
-
-# run the simple sample publisher
-# the publisher runs forever printing out each published message
-$ ./runmqttsample.sh pub
-
-Running the fully configurable clients
---------------------------------------
-
-# To see how to specify different values:
-$ ./runmqttclient.sh -h
-
-# run the subscriber client
-# the subscriber runs forever printing out each received message
-$ ./runmqttclient.sh sub
-
-# run the publisher client
-# the publisher runs forever printing out each published message
-$ ./runmqttclient.sh pub
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/mqtt/mqtt.properties
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/mqtt/mqtt.properties b/samples/connectors/scripts/mqtt/mqtt.properties
deleted file mode 100644
index 9f28c7c..0000000
--- a/samples/connectors/scripts/mqtt/mqtt.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-mqtt.serverURLs=tcp://localhost:1883
-#mqtt.serverURLs=tcp://test.mosquitto.org:1883
-#mqtt.serverURLs=tcp://iot.eclipse.org:1883
-mqtt.topic=mqttSampleTopic
-#mqtt.userName=
-#mqtt.password=
-#mqtt.trustStore=
-#mqtt.trustStorePassword=
-#mqtt.keyStore=
-#mqtt.keyStorePassword=
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/mqtt/runmqttclient.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/mqtt/runmqttclient.sh b/samples/connectors/scripts/mqtt/runmqttclient.sh
deleted file mode 100755
index f755bc9..0000000
--- a/samples/connectors/scripts/mqtt/runmqttclient.sh
+++ /dev/null
@@ -1,31 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the MQTT Publisher or Subscriber client
-#
-# ./runmqttclient.sh pub
-# ./runmqttclient.sh sub
-# ./runmqttclient.sh -h
-
-export CLASSPATH=${UBER_JAR}
-
-java org.apache.edgent.samples.connectors.mqtt.MqttClient $@
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/scripts/mqtt/runmqttsample.sh
----------------------------------------------------------------------
diff --git a/samples/connectors/scripts/mqtt/runmqttsample.sh b/samples/connectors/scripts/mqtt/runmqttsample.sh
deleted file mode 100755
index 9d850dd..0000000
--- a/samples/connectors/scripts/mqtt/runmqttsample.sh
+++ /dev/null
@@ -1,39 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-connectors-*-uber.jar`
-
-# Runs the Sample MQTT Publisher or Subscriber
-#
-# ./runmqttsample.sh pub
-# ./runmqttsample.sh sub
-
-export CLASSPATH=${UBER_JAR}
-
-app=$1; shift
-if [ "$app" == "pub" ]; then
- java org.apache.edgent.samples.connectors.mqtt.SimplePublisherApp mqtt.properties
-elif [ "$app" == "sub" ]; then
- java org.apache.edgent.samples.connectors.mqtt.SimpleSubscriberApp mqtt.properties
-else
- echo "unrecognized mode '$app'"
- echo "usage: $0 pub|sub"
- exit 1
-fi
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/MsgSupplier.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/MsgSupplier.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/MsgSupplier.java
deleted file mode 100644
index 13f2b4e..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/MsgSupplier.java
+++ /dev/null
@@ -1,50 +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;
-
-import org.apache.edgent.function.Supplier;
-
-/**
- * A Supplier<String> for creating sample messages to publish.
- */
-public class MsgSupplier implements Supplier<String> {
- private static final long serialVersionUID = 1L;
- private final int maxCnt;
- private int cnt;
- private boolean done;
-
- public MsgSupplier(int maxCnt) {
- this.maxCnt = maxCnt;
- }
-
- @Override
- public synchronized String get() {
- ++cnt;
- if (maxCnt >= 0 && cnt >= maxCnt) {
- if (!done) {
- done = true;
- System.out.println("poll: no more messages to generate.");
- }
- return null;
- }
- String msg = String.format("Message-%d from %s", cnt, Util.simpleTS());
- System.out.println("poll generated msg to publish: " + msg);
- return msg;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Options.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Options.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Options.java
deleted file mode 100644
index fcab5c5..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Options.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;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.edgent.function.Function;
-
-/**
- * Simple command option processor.
- */
-public class Options {
- private static final Map<String,Function<String,?>> handlers = new HashMap<>();
- private static final Map<String,Object> options = new HashMap<>();
- private static final Map<String,Object> defaults = new HashMap<>();
-
- public <T> void addHandler(String opt, Function<String,T> cvtFn) {
- addHandler(opt, cvtFn, null);
- }
-
- public <T> void addHandler(String opt, Function<String,T> cvtFn, T dflt) {
- handlers.put(opt, cvtFn);
- if (dflt != null)
- defaults.put(opt, dflt);
- }
-
- public void processArgs(String[] args) {
- for (Map.Entry<String,Function<String,?>> e : handlers.entrySet()) {
- handleOpt(e.getKey(), e.getValue(), args);
- }
-
- for (String arg : args) {
- String[] item = arg.split("=");
- if (!handlers.containsKey(item[0]))
- throw new IllegalArgumentException("Unrecognized argument '"+arg+"'");
- }
- }
-
- private void handleOpt(String opt, Function<String,?> cvtFn, String[] args) {
- String v = getArg(cvtFn!=null ? opt : opt+"=true", args);
- if (v != null)
- options.put(opt, cvtFn==null ? true : cvtFn.apply(v));
- else if (defaults.get(opt) != null)
- options.put(opt, defaults.get(opt));
- }
-
- public <T> T get(String opt) {
- return get(opt, null);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T get(String opt, T dflt) {
- return options.get(opt) == null ? dflt : (T)options.get(opt);
- }
-
- public Set<Map.Entry<String,Object>> getAll() {
- return Collections.unmodifiableSet(options.entrySet());
- }
-
- public void put(String opt, Object value) {
- options.put(opt, value);
- }
-
- private String getArg(String item, String[] args) {
- String[] itemParts = item.split("=");
- if (itemParts.length>1)
- item = itemParts[0];
- for (String arg : args) {
- String[] parts = arg.split("=");
- if (item.equals(parts[0])) {
- if (parts.length > 1)
- return parts[1];
- else
- return itemParts.length > 1 ? itemParts[1] : parts[1];
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Util.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Util.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Util.java
deleted file mode 100644
index d9803ef..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/Util.java
+++ /dev/null
@@ -1,75 +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;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.execution.Job;
-
-/**
- * Utilities for connector samples.
- */
-public class Util {
-
- /**
- * Generate a simple timestamp with the form {@code HH:mm:ss.SSS}
- * @return the timestamp
- */
- public static String simpleTS() {
- return new SimpleDateFormat("HH:mm:ss.SSS").format(new Date());
- }
-
-
- /**
- * Wait for the job to reach the specified state.
- * <p>
- * A placeholder till GraphJob directly supports awaitState()?
- * @param job the job
- * @param state the state to wait for
- * @param timeout specify -1 to wait forever (until interrupted)
- * @param unit may be null if timeout is -1
- * @return true if the state was reached, false otherwise: the time limit
- * was reached of the thread was interrupted.
- */
- public static boolean awaitState(Job job, Job.State state, long timeout, TimeUnit unit) {
- long endWait = -1;
- if (timeout != -1) {
- endWait = System.currentTimeMillis()
- + unit.toMillis(timeout);
- }
- while (true) {
- Job.State curState = job.getCurrentState();
- if (curState == state)
- return true;
- if (endWait != -1) {
- long now = System.currentTimeMillis();
- if (now >= endWait)
- return false;
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- return false;
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Cmd.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Cmd.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Cmd.java
deleted file mode 100644
index f3ae61a..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Cmd.java
+++ /dev/null
@@ -1,76 +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.elm327;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import com.google.gson.JsonObject;
-
-/**
- * ELM327 and OBD-II command interface.
- *
- */
-public interface Cmd {
- /**
- * Key ({@value}) for PID identifier in JSON result.
- */
- String PID = "pid";
-
- /**
- * Key ({@value}) for timestamp in JSON result. Timestamp value is the
- * number of milliseconds since the 1907 epoch.
- */
- String TS = "ts";
-
- /**
- * Key ({@value}) for the returned value in JSON result.
- * May not be present.
- */
- String VALUE = "value";
-
- /**
- * How the command is written to the serial port.
- *
- * @param out
- * OutputStream to write bytes to.
- * @throws IOException
- * Exception writing bytes.
- */
- void writeCmd(OutputStream out) throws IOException;
-
- /**
- * Process the reply into a result.
- *
- * @param result
- * JSON object to populate with the result.
- * @param reply
- * Bytes that were returned from the command execution.
- *
- * @return {@code true} result is valid, {@code false} otherwise.
- */
- boolean result(JsonObject result, byte[] reply);
-
- /**
- * Unique identifier of the command.
- *
- * @return Unique identifier of the command.
- */
- String id();
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Cmds.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Cmds.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Cmds.java
deleted file mode 100644
index aed0c23..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Cmds.java
+++ /dev/null
@@ -1,75 +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.elm327;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.edgent.connectors.serial.SerialDevice;
-import org.apache.edgent.samples.connectors.elm327.runtime.CommandExecutor;
-
-import com.google.gson.JsonObject;
-
-/**
- * ELM327 commands.
- *
- *
- */
-public enum Elm327Cmds implements Cmd {
-
- INIT("ATZ"),
- ECHO_OFF("ATE0"),
- PROTOCOL_3("ATSP3"),
- PROTOCOL_5("ATSP5"),
- BYPASS_INIT("ATBI"),
- FAST_INIT("ATFI"),
- SLOW_INIT("ATSI"),;
-
- private byte[] cmd;
-
- Elm327Cmds(String code) {
- cmd = (code + "\r").getBytes(StandardCharsets.US_ASCII);
- }
-
- @Override
- public void writeCmd(OutputStream out) throws IOException {
- out.write(cmd);
- }
-
- @Override
- public boolean result(JsonObject result, byte[] data) {
- return true;
- }
-
- @Override
- public String id() {
- return name();
- }
-
- /**
- * Initialize the ELM327 to a specific protocol.
- * @param device Serial device the ELM327 is connected to.
- * @param protocol OBD-II protocol to initialize to.
- */
- public static void initializeProtocol(SerialDevice device, Elm327Cmds protocol) {
- device.setInitializer(port -> CommandExecutor.initialize(protocol, port.getOutput(), port.getInput()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Streams.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Streams.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Streams.java
deleted file mode 100644
index dbaf4db..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Elm327Streams.java
+++ /dev/null
@@ -1,70 +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.elm327;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.serial.SerialDevice;
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.samples.connectors.elm327.runtime.CommandExecutor;
-import org.apache.edgent.topology.TStream;
-
-import com.google.gson.JsonArray;
-
-/**
- * Streams fetching OBD-II data from an ELM327 through
- * a serial device.
- *
- * @see <a href="https://en.wikipedia.org/wiki/ELM327">ELM327</a>
- */
-public class Elm327Streams {
-
- /**
- * Periodically execute a number of ELM327 commands.
- * Each tuple on the returned stream is a JSON array containing
- * the result for each command.
- * <BR>
- * Each result is a JSON object containing the
- * {@link Cmd#id() command identifier} with key {@link Cmd#PID pid}
- * and any result set by the individual command, typically with
- * the key {@link Cmd#VALUE value}.
- *
- * @param device Serial device the ELM327 is connected to.
- * @param period Period to poll.
- * @param unit Unit of {@code period}.
- * @param cmds Commands to execute.
- * @return Stream containing the results of the command exections.
- */
- public static TStream<JsonArray> poll(SerialDevice device, long period, TimeUnit unit, Cmd ... cmds) {
-
- Supplier<JsonArray> data = device.getSource(
- port ->
- {
- JsonArray array = new JsonArray();
- for (Cmd cmd : cmds) {
- array.add(CommandExecutor.execute(cmd, port.getOutput(), port.getInput()));
- }
- return array;
-
- });
-
- return device.topology().poll(data, period, unit);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Pids01.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Pids01.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Pids01.java
deleted file mode 100644
index b42beb3..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/Pids01.java
+++ /dev/null
@@ -1,141 +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.elm327;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.edgent.samples.connectors.elm327.runtime.CommandExecutor;
-
-import com.google.gson.JsonObject;
-
-/**
- * OBD-II Standard Mode 01 Pids.
- *
- *
- * @see <a href="https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_01">OBD-II Mode 01 Pids</a>
- */
-public enum Pids01 implements Cmd {
-
- /**
- * Get the list of available PIDs.
- */
- AVAILABLE_PIDS("00"),
-
- /**
- * Engine coolant temperature in degrees C.
- */
- ENGINE_COOLANT_TEMP("05") {
- @Override
- protected boolean decode(JsonObject result, byte[] reply) {
-
- int[] binary = CommandExecutor.binary(reply, 4, 2);
-
- int c = binary[0] - 40;
- result.addProperty(VALUE, c);
-
- return true;
- }
- },
-
- /**
- * Engine speed in rpm.
- */
- RPM("0C") {
- @Override
- protected boolean decode(JsonObject result, byte[] reply) {
-
- int[] binary = CommandExecutor.binary(reply, 4, 4);
- int rpm = ((binary[0] * 256) + binary[1])/4;
- result.addProperty(VALUE, rpm);
-
- return true;
- }
- },
-
- /**
- * Vehicle speed in km/h.
- */
- SPEED("0D"){
- @Override
- protected boolean decode(JsonObject result, byte[] reply) {
-
- int[] binary = CommandExecutor.binary(reply, 4, 2);
-
- result.addProperty(VALUE, binary[0]);
-
- return true;
- }
- },
-
- /**
- * Engine air intake temperature in degrees C.
- */
- AIR_INTAKE_TEMP("0F"){
- @Override
- protected boolean decode(JsonObject result, byte[] reply) {
-
- int[] binary = CommandExecutor.binary(reply, 4, 2);
-
- int c = binary[0] - 40;
- result.addProperty(VALUE, c);
-
- return true;
- }
- },
- ;
-
- private final String pid;
- private final byte[] cmd;
-
- Pids01(String pid) {
- this.pid = pid;
- cmd = ("01" + pid + "1\r").getBytes(StandardCharsets.US_ASCII);
- }
-
- public String id() {
- return pid;
- }
-
- @Override
- public void writeCmd(OutputStream out) throws IOException {
- out.write(cmd);
- }
- @Override
- public final boolean result(JsonObject result, byte[] data) {
- return validateReply(data) && decode(result, data);
- }
- boolean decode(JsonObject result, byte[] data) {
- return true;
- }
-
- boolean validateReply(byte[] reply) {
- if (reply[0] != '4')
- return false;
- if (reply[1] != '1')
- return false;
- if (reply[2] != pid.charAt(0))
- return false;
- if (reply[3] != pid.charAt(1))
- return false;
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/package-info.java
deleted file mode 100644
index 9d3a9b9..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/package-info.java
+++ /dev/null
@@ -1,27 +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.
-*/
-/**
- * OBD-II protocol sample using ELM327.
- *
- * ELM327 devices allow connectivity to a vehicle's OBD-II information.
- *
- * @see <a href="https://en.wikipedia.org/wiki/OBD-II">OBD-II</a>
- * @see <a href="https://en.wikipedia.org/wiki/ELM327">ELM327</a>
- */
-package org.apache.edgent.samples.connectors.elm327;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/runtime/CommandExecutor.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/runtime/CommandExecutor.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/runtime/CommandExecutor.java
deleted file mode 100644
index b5a342f..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/elm327/runtime/CommandExecutor.java
+++ /dev/null
@@ -1,118 +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.elm327.runtime;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.edgent.samples.connectors.elm327.Cmd;
-import org.apache.edgent.samples.connectors.elm327.Elm327Cmds;
-
-import com.google.gson.JsonObject;
-
-/**
- * Runtime execution of ELM327 & OBD-II commands.
- *
- */
-public class CommandExecutor {
-
- public static int[] binary(byte[] reply, int offset, int length) {
- int[] binary = new int[length / 2];
- for (int i = 0; i < binary.length; i++) {
- int h = Character.digit(reply[offset++], 16);
- int l = Character.digit(reply[offset++], 16);
- binary[i] = ((h * 16) + l);
- }
- return binary;
- }
-
- public static void initialize(Cmd protocol, OutputStream out, InputStream in) {
- try {
-
- executeUntilOK(10, Elm327Cmds.INIT, out, in);
- Thread.sleep(1000);
-
- executeUntilOK(1, Elm327Cmds.ECHO_OFF, out, in);
-
- executeUntilOK(1, protocol, out, in);
- executeUntilOK(1, Elm327Cmds.SLOW_INIT, out, in);
- Thread.sleep(1000);
-
- } catch (Exception ioe) {
- throw new RuntimeException(ioe);
- }
- }
-
- private static boolean readUntilPrompt(InputStream in, ByteArrayOutputStream bytes) throws IOException {
- bytes.reset();
- for (;;) {
- int b = in.read();
- if (b == -1)
- return false;
- if (b == ' ')
- continue;
- if (b == '\r')
- continue;
- if (b == '>')
- return true;
-
- bytes.write(b);
- }
- }
-
- public static JsonObject executeUntilOK(int n, Cmd cmd, OutputStream out, InputStream in) throws IOException {
- try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(16)) {
- for (int i = 0; i < n; i++) {
- cmd.writeCmd(out);
- out.flush();
-
- if (!readUntilPrompt(in, bytes))
- continue;
-
- byte[] reply = bytes.toByteArray();
- JsonObject j = new JsonObject();
- if (cmd.result(j, reply))
- return j;
- break;
- }
- }
- throw new IllegalStateException("Could not execute command:" + cmd);
- }
-
- public static JsonObject execute(Cmd cmd, OutputStream out, InputStream in) {
- try (ByteArrayOutputStream bytes = new ByteArrayOutputStream(16)) {
- cmd.writeCmd(out);
- out.flush();
-
- JsonObject result = new JsonObject();
- result.addProperty(Cmd.PID, cmd.id());
- result.addProperty(Cmd.TS, System.currentTimeMillis());
-
- readUntilPrompt(in, bytes);
-
- cmd.result(result, bytes.toByteArray());
-
- return result;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileReaderApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileReaderApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileReaderApp.java
deleted file mode 100644
index 80086b7..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileReaderApp.java
+++ /dev/null
@@ -1,88 +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.file;
-
-import java.io.File;
-
-import org.apache.edgent.connectors.file.FileStreams;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Watch a directory for files and convert their contents into a stream.
- */
-public class FileReaderApp {
- private final String directory;
- private static final String baseLeafname = "FileSample";
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to an existing directory");
- FileReaderApp reader = new FileReaderApp(args[0]);
- reader.run();
- }
-
- /**
- *
- * @param directory an existing directory to watch for file
- */
- public FileReaderApp(String directory) {
- File dir = new File(directory);
- if (!dir.exists())
- throw new IllegalArgumentException("directory doesn't exist");
- this.directory = directory;
- }
-
- public void run() throws Exception {
- DevelopmentProvider tp = new DevelopmentProvider();
-
- // build the application / topology
-
- Topology t = tp.newTopology("FileSample consumer");
-
- // watch for files
- TStream<String> pathnames = FileStreams.directoryWatcher(t, () -> directory);
-
- // create a stream containing the files' contents.
- // use a preFn to include a separator in the results.
- // use a postFn to delete the file once its been processed.
- TStream<String> contents = FileStreams.textFileReader(pathnames,
- tuple -> "<PRE-FUNCTION> "+tuple,
- (tuple,exception) -> {
- // exercise a little caution in case the user pointed
- // us at a directory with other things in it
- if (tuple.contains("/"+baseLeafname+"_")) {
- new File(tuple).delete();
- }
- return null;
- });
-
- // print out what's being read
- contents.print();
-
- // run the application / topology
- System.out.println("starting the reader watching directory " + directory);
- 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/file/FileWriterApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileWriterApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileWriterApp.java
deleted file mode 100644
index c956cb6..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/FileWriterApp.java
+++ /dev/null
@@ -1,94 +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.file;
-
-import java.io.File;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.edgent.connectors.file.FileStreams;
-import org.apache.edgent.connectors.file.FileWriterCycleConfig;
-import org.apache.edgent.connectors.file.FileWriterFlushConfig;
-import org.apache.edgent.connectors.file.FileWriterPolicy;
-import org.apache.edgent.connectors.file.FileWriterRetentionConfig;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Write a TStream<String> to files.
- */
-public class FileWriterApp {
- private final String directory;
- private final String basePathname;
- private static final String baseLeafname = "FileSample";
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to an existing directory");
- FileWriterApp writer = new FileWriterApp(args[0]);
- writer.run();
- }
-
- /**
- *
- * @param directory an existing directory to create files in
- */
- public FileWriterApp(String directory) {
- File dir = new File(directory);
- if (!dir.exists())
- throw new IllegalArgumentException("directory doesn't exist");
- this.directory = directory;
- basePathname = directory+"/"+baseLeafname;
- }
-
- public void run() throws Exception {
- DevelopmentProvider tp = new DevelopmentProvider();
-
- // build the application / topology
-
- Topology t = tp.newTopology("FileSample producer");
-
- FileWriterPolicy<String> policy = new FileWriterPolicy<String>(
- FileWriterFlushConfig.newImplicitConfig(),
- FileWriterCycleConfig.newCountBasedConfig(5),
- FileWriterRetentionConfig.newFileCountBasedConfig(3));
-
- // create a tuple stream to write out
- AtomicInteger cnt = new AtomicInteger();
- TStream<String> stream = t.poll(() -> {
- String str = String.format("sample tuple %d %s",
- cnt.incrementAndGet(), new Date().toString());
- System.out.println("created tuple: "+str);
- return str;
- }, 1, TimeUnit.SECONDS);
-
- // write the stream
- FileStreams.textFileWriter(stream, () -> basePathname, () -> policy);
-
- // run the application / topology
- System.out.println("starting the producer writing to directory " + directory);
- 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/file/README
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/README b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/README
deleted file mode 100644
index 4477518..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/README
+++ /dev/null
@@ -1,11 +0,0 @@
-Sample File Streams connector topology applications.
-
-The file writer application writes a stream's tuples to files.
-
-The file reader application watches a directory for files and reads their
-contents into a stream of tuples.
-
-see scripts/connectors/file/README to run them
-
-FileWriterApp.java - the writer application topology
-FileReaderApp.java - the reader application topology
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/package-info.java
deleted file mode 100644
index a2cfe74..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/file/package-info.java
+++ /dev/null
@@ -1,32 +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/file/package-summary.html">
- * File stream connector</a>.
- * <p>
- * See <edgent-release>/scripts/connectors/file/README to run the samples.
- * <p>
- * The following samples are provided:
- * <ul>
- * <li>FileReaderApp.java - a simple directory watcher and file reader application topology</li>
- * <li>FileWriterApp.java - a simple file writer application topology</li>
- * </ul>
- */
-package org.apache.edgent.samples.connectors.file;
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
deleted file mode 100644
index 4f4e2dc..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
+++ /dev/null
@@ -1,147 +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.iotp;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-
-import com.google.gson.JsonObject;
-import com.ibm.iotf.client.app.ApplicationClient;
-import com.ibm.iotf.client.app.Command;
-import com.ibm.iotf.client.app.Event;
-import com.ibm.iotf.client.app.EventCallback;
-
-/**
- * An IBM Watson IoT Platform ApplicationClient that publishes device cmds
- * and subscribes to device events for
- * {@link IotpDeviceSample} and {@link IotpGWDeviceSample}.
- * <p>
- * Usage: {@code [useGW] <app-cfg-path> # see scripts/connectors/iotp/iotp-app-client.cfg}
- * <p>
- * This connects to your IBM Watson IoT Platform service
- * as the Application defined in a application config file.
- * The file format is the standard one for IBM Watson IoT Platform.
- * <p>
- * Note, the config file also contains some additional information for this application.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about a
- * prototype application configuration file and running the application.
- */
-public class IotpAppClient {
-
- private static final String usage = "[useGW] <app-cfg-path> # see scripts/connectors/iotp/iotp-app-client.cfg";
-
- public static void main(String[] args) throws Exception {
- if (args.length == 0)
- throw new Exception("Usage: " + usage);
- List<String> argList = Arrays.asList(args);
- boolean useGW = argList.contains("useGW");
- String deviceCfgPath = argList.get(argList.size() - 1);
-
- Properties cfgProps = new Properties();
- cfgProps.load(new FileReader(new File(deviceCfgPath)));
-
- String iotpOrg = getProperty(cfgProps, "Organization-ID", "org");
- String iotpAppId = getProperty(cfgProps, "id");
- String iotpApiKey = getProperty(cfgProps, "API-Key", "auth-key");
- System.out.println("org: " + iotpOrg);
- System.out.println("id: " + iotpAppId);
- System.out.println("ApiKey: " + iotpApiKey);
-
- String iotpDevType = cfgProps.getProperty("deviceType");
- String iotpDevId = cfgProps.getProperty("deviceId");
- if (useGW) {
- iotpDevType = cfgProps.getProperty("gwDeviceType");
- iotpDevId = cfgProps.getProperty("gwDeviceId");
- }
- System.out.println("deviceType: " + iotpDevType);
- System.out.println("deviceId: " + iotpDevId);
-
- ApplicationClient client = new ApplicationClient(cfgProps);
-
- client.connect();
-
- boolean sendCmd = true;
- if (sendCmd) {
- sendCmd(client, iotpDevType, iotpDevId);
- if (useGW) {
- sendCmd(client, cfgProps.getProperty("cn-dev1-type"), cfgProps.getProperty("cn-dev1-id"));
- }
- }
-
- boolean subscribeToEvents = true;
- if (subscribeToEvents) {
- System.out.println("Subscribing to events...");
- client.subscribeToDeviceEvents();
- client.setEventCallback(new EventCallback() {
-
- @Override
- public void processCommand(Command cmd) {
- // TODO Auto-generated method stub
-
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void processEvent(Event event) {
- System.out.println(
- String.format("Received event: %s %s:%s %s %s", event.getEvent(),
- event.getDeviceType(), event.getDeviceId(),
- event.getFormat(),
- event.getPayload()));
- }
-
- });
- Thread.sleep(Integer.MAX_VALUE);
- }
-
- client.disconnect();
- }
-
- private static int msgNum = 0;
- private static void sendCmd(ApplicationClient client, String iotpDevType, String iotpDevId) throws Exception {
- String command = "cmdId-1";
- JsonObject jo = new JsonObject();
- jo.addProperty("msgNum", ++msgNum);
- jo.addProperty("deviceTypeAndId", iotpDevType + "/" + iotpDevId);
- jo.addProperty("cmdId", command);
- jo.addProperty("str", "a-string");
- jo.addProperty("num", 12345);
- JsonObject data = jo;
-
- System.out.println("Sending "+iotpDevType+"/"+iotpDevId+" command: "+command+" data: "+data);
-
- boolean ok = client.publishCommand(iotpDevType, iotpDevId, command, data);
-
- System.out.println("Sent: " + (ok ? "OK" : "NOT-OK"));
- }
-
- private static String getProperty(Properties props, String... keys) {
- for (String key : keys) {
- String val = props.getProperty(key);
- if (val != null)
- return val;
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpDeviceSample.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpDeviceSample.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpDeviceSample.java
deleted file mode 100644
index 2880c99..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpDeviceSample.java
+++ /dev/null
@@ -1,148 +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.iotp;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-import com.ibm.iotf.client.device.DeviceClient;
-import com.ibm.iotf.devicemgmt.DeviceData;
-import com.ibm.iotf.devicemgmt.device.ManagedDevice;
-
-/**
- * Send device events and subscribe to device commands as a registered IoT device
- * using a standard IBM Watson IoT Platform service instance.
- * <P>
- * Use {@link IotpAppClient} to print published events and generate a command
- * (start this app before running IotpAppClient).
- * <P>
- * This sample demonstrates:
- * <UL>
- * <LI>Using the IotpDevice connector</LI>
- * <LI>Initializing the IotpDevice connector using the WIoTP API objects</LI>
- * <LI>Publishing and subscribing to device events and commands</LI>
- * </UL>
- * <p>
- * This connects to your IBM Watson IoT Platform service
- * as the Device defined in a device config file.
- * The file format is the standard one for IBM Watson IoT Platform.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about a
- * prototype device configuration file and running the sample.
- */
-public class IotpDeviceSample {
- private static final String usage = "[useDeviceClient|useManagedDevice] [useHttp] <device-cfg-path>";
-
- public static void main(String[] args) throws Exception {
- if (args.length == 0)
- throw new Exception("Usage: " + usage);
- List<String> argList = Arrays.asList(args);
- boolean useDeviceClient = argList.contains("useDeviceClient");
- boolean useManagedDevice = argList.contains("useManagedDevice");
- boolean useInternalDeviceClient = !(useDeviceClient || useManagedDevice);
- boolean useHttp = argList.contains("useHttp");
- String deviceCfgPath = argList.get(argList.size() - 1);
-
- DirectProvider tp = new DirectProvider();
- Topology topology = tp.newTopology("IotpDeviceSample");
-
- Properties cfgProps = new Properties();
- cfgProps.load(new FileReader(new File(deviceCfgPath)));
-
- String iotpOrg = getProperty(cfgProps, "Organization-ID", "org");
- String iotpDevType = getProperty(cfgProps, "Device-Type", "type");
- String iotpDevId = getProperty(cfgProps, "Device-ID", "id");
- System.out.println("org: " + iotpOrg);
- System.out.println("DeviceType: " + iotpDevType);
- System.out.println("DeviceId: " + iotpDevId);
-
- // System.out.println("mosquitto_pub -u <api-auth-key> -P <api-quth-token> -h "+iotpOrg+".messaging.internetofthings.ibmcloud.com -p 1883 -i a:"+iotpOrg+":appId1 -t iot-2/type/"+iotpDevType+"/id/"+iotpDevId+"/cmd/cmd-1/fmt/json -m '{}'");
- // System.out.println("mosquitto_sub -d -u <api-auth-key> -P <api-quth-token> -h "+iotpOrg+".messaging.internetofthings.ibmcloud.com -p 1883 -i a:"+iotpOrg+":appId2 -t iot-2/type/+/id/+/evt/+/fmt/+");
-
- IotpDevice device;
- if (useInternalDeviceClient) {
- System.out.println("Using internal DeviceClient");
- device = new IotpDevice(topology, cfgProps);
- }
- else if (useDeviceClient) {
- System.out.println("Using WIoTP DeviceClient");
- device = new IotpDevice(topology, new DeviceClient(cfgProps));
- }
- else if (useManagedDevice) {
- System.out.println("Using WIoTP ManagedDevice");
- DeviceData deviceData = new DeviceData.Builder().build();
- device = new IotpDevice(topology, new ManagedDevice(cfgProps, deviceData));
- }
- else
- throw new Exception("woops");
-
- Random r = new Random();
- TStream<double[]> raw = topology.poll(() -> {
- double[] v = new double[3];
-
- v[0] = r.nextGaussian() * 10.0 + 40.0;
- v[1] = r.nextGaussian() * 10.0 + 50.0;
- v[2] = r.nextGaussian() * 10.0 + 60.0;
-
- return v;
- }, 3, TimeUnit.SECONDS);
-
- TStream<JsonObject> json = raw.map(v -> {
- JsonObject j = new JsonObject();
- j.addProperty("temp", v[0]);
- j.addProperty("humidity", v[1]);
- j.addProperty("objectTemp", v[2]);
- return j;
- });
-
- if (!useHttp) {
- device.events(json, "sensors", QoS.FIRE_AND_FORGET);
- }
- else {
- System.out.println("Publishing events using HTTP");
- device.httpEvents(json, "sensors");
- }
-
- // subscribe to / report device cmds
- device.commands().sink(jo -> System.out.println("Received cmd: " + jo));
-
- tp.submit(topology);
- }
-
- private static String getProperty(Properties props, String... keys) {
- for (String key : keys) {
- String val = props.getProperty(key);
- if (val != null)
- return val;
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpGWDeviceSample.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpGWDeviceSample.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpGWDeviceSample.java
deleted file mode 100644
index 74ec4d9..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpGWDeviceSample.java
+++ /dev/null
@@ -1,193 +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.iotp;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.IotDevice;
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpGateway;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-import com.ibm.iotf.client.gateway.GatewayClient;
-import com.ibm.iotf.devicemgmt.DeviceData;
-import com.ibm.iotf.devicemgmt.gateway.ManagedGateway;
-
-/**
- * Similar to IotpDeviceSample but behaving as a registered IoT Gateway device.
- * <P>
- * Use {@link IotpAppClient} to print published events and generate a command
- * (start this app before running IotpAppClient with the "useGW" option).
- * <P>
- * This sample demonstrates:
- * <UL>
- * <LI>Using the IotpGateway connector</LI>
- * <LI>Initializing the IotpGateway connector using the WIoTP API objects</LI>
- * <LI>Publishing and subscribing to Gateway device events and commands</LI>
- * <LI>Publishing and subscribing to connected device events and commands</LI>
- * </UL>
- * <p>
- * This connects to your IBM Watson IoT Platform service
- * as the Gateway defined in a gateway config file.
- * The file format is the standard one for IBM Watson IoT Platform.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about a
- * prototype gateway device configuration file and running the sample.
- */
-public class IotpGWDeviceSample {
-
- private static final String usage = "[useGatewayClient|useManagedGateway] [useHttp] <device-cfg-path>";
-
- public static void main(String[] args) throws Exception {
- if (args.length == 0)
- throw new Exception("Usage: " + usage);
- List<String> argList = Arrays.asList(args);
- boolean useGatewayClient = argList.contains("useGatewayClient");
- boolean useManagedGateway = argList.contains("useManagedGateway");
- boolean useInternalGatewayClient = !(useGatewayClient || useManagedGateway);
- boolean useHttp = argList.contains("useHttp");
- String deviceCfgPath = argList.get(argList.size() - 1);
-
- DirectProvider tp = new DirectProvider();
- Topology topology = tp.newTopology("IotpGWDeviceSample");
-
- Properties cfgProps = new Properties();
- cfgProps.load(new FileReader(new File(deviceCfgPath)));
-
- String iotpOrg = getProperty(cfgProps, "Organization-ID", "org");
- String iotpGWDevType = getProperty(cfgProps, "Gateway-Type", "Device-Type", "type");
- String iotpGWDevId = getProperty(cfgProps, "Gateway-ID", "Device-ID", "id");
- String iotpCnDev1Type = cfgProps.getProperty("cn-dev1-type");
- String iotpCnDev1Id = cfgProps.getProperty("cn-dev1-id");
-
- System.out.println("orgId: " + iotpOrg);
- System.out.println("GWDeviceType: " + iotpGWDevType);
- System.out.println("GWDeviceId: " + iotpGWDevId);
- System.out.println("cn-dev1 DeviceType: " + iotpCnDev1Type);
- System.out.println("cn-dev1 DeviceId: " + iotpCnDev1Id);
-
- // System.out.println("GW mosquitto_pub -u <api-auth-key> -P <api-auth-token> -h "+iotpOrg+".messaging.internetofthings.ibmcloud.com -p 1883 -i a:"+iotpOrg+":appId1 -t iot-2/type/"+iotpGWDevType+"/id/"+iotpGWDevId+"/cmd/cmd-1/fmt/json -m '{}'");
- // System.out.println("GW mosquitto_sub -d -u <api-auth-key> -P <api-auth-token> -h "+iotpOrg+".messaging.internetofthings.ibmcloud.com -p 1883 -i a:"+iotpOrg+":appId2 -t iot-2/type/+/id/+/evt/+/fmt/+");
- // System.out.println("cn-dev1 mosquitto_pub -u <api-auth-key> -P <api-quth-token> -h "+iotpOrg+".messaging.internetofthings.ibmcloud.com -p 1883 -i a:"+iotpOrg+":appId1 -t iot-2/type/"+iotpCnDev1Type+"/id/"+iotpCnDev1Id+"/cmd/cmd-1/fmt/json -m '{}'");
-
- IotpGateway gwDevice;
- if (useInternalGatewayClient) {
- System.out.println("Using internal GatewayClient");
- gwDevice = new IotpGateway(topology, cfgProps);
- }
- else if (useGatewayClient) {
- System.out.println("Using WIoTP GatewayClient");
- gwDevice = new IotpGateway(topology, new GatewayClient(cfgProps));
- }
- else if (useManagedGateway) {
- System.out.println("Using WIoTP ManagedGateway");
- DeviceData deviceData = new DeviceData.Builder().build();
- gwDevice = new IotpGateway(topology, new ManagedGateway(cfgProps, deviceData));
- }
- else
- throw new IllegalStateException("woops");
-
- Map<String,String> devAttrMap = new HashMap<>();
- devAttrMap.put(IotpGateway.ATTR_DEVICE_TYPE, iotpCnDev1Type);
- devAttrMap.put(IotpGateway.ATTR_DEVICE_ID, iotpCnDev1Id);
-
- String cnDev1FqDeviceId = gwDevice.getIotDeviceId(devAttrMap);
- IotDevice cnDev1Device = gwDevice.getIotDevice(cnDev1FqDeviceId);
-
- System.out.println("GW fqDeviceId: " + gwDevice.getDeviceId());
- System.out.println("cn-dev1 fqDeviceId: " + cnDev1FqDeviceId);
- System.out.println("IotDevice cn-dev1 fqDeviceId: " + cnDev1Device.getDeviceId());
-
- Random r = new Random();
- TStream<double[]> raw = topology.poll(() -> {
- double[] v = new double[3];
-
- v[0] = r.nextGaussian() * 10.0 + 40.0;
- v[1] = r.nextGaussian() * 10.0 + 50.0;
- v[2] = r.nextGaussian() * 10.0 + 60.0;
-
- return v;
- }, 3, TimeUnit.SECONDS);
-
- // Create a stream of Gateway device events
- TStream<JsonObject> gwJson = raw.map(v -> {
- JsonObject jo2 = new JsonObject();
- jo2.addProperty("gw-fqDeviceId", gwDevice.getDeviceId());
- jo2.addProperty("temp", v[0]);
- return jo2;
- });
-
- // Create a stream of a connected device's events
- TStream<JsonObject> cnDev1Json = raw.map(v -> {
- JsonObject jo2 = new JsonObject();
- jo2.addProperty("cnDev1-fqDeviceId", cnDev1Device.getDeviceId());
- jo2.addProperty("humidity", v[1]);
- return jo2;
- });
-
- if (!useHttp) {
- gwDevice.events(gwJson, "gw-device", QoS.FIRE_AND_FORGET);
- gwDevice.eventsForDevice(cnDev1FqDeviceId, cnDev1Json, "gw-events-for-cnDev1", QoS.FIRE_AND_FORGET);
- cnDev1Device.events(cnDev1Json, "cnDev1-events", QoS.FIRE_AND_FORGET);
- }
- else {
- System.out.println("Publishing events using HTTP");
- throw new IllegalStateException("GW httpEvents is NYI");
- // gwDevice.httpEvents(json, "sensors");
- // gwDevice.httpEventsForDevice(cnDev1FqDeviceId, cnDev1Json, "gw-events-for-cnDev1");
- }
-
- // subscribe to / report cmds for the GW and all its connected devices
- gwDevice.commandsForDevice(Collections.emptySet()).sink(jo -> System.out.println("Received all-cmds cmd: " + jo));
-
- // subscribe to / report just GW device cmds
- gwDevice.commands().sink(jo -> System.out.println("Received gwDevice cmd: " + jo));
-
- // subscribe to / report just cnDev1 device cmds
- gwDevice.commandsForDevice(cnDev1FqDeviceId).sink(jo -> System.out.println("Received gwDevice-for-cnDev1 cmd: " + jo));
- cnDev1Device.commands().sink(jo -> System.out.println("Received cnDev1 cmd: " + jo));
-
- // subscribe to / report just cmds for a specific device type
- gwDevice.commandsForType(iotpGWDevType).sink(jo -> System.out.println("Received for-type-gwDeviceType cmd: " + jo));
- gwDevice.commandsForType(iotpCnDev1Type).sink(jo -> System.out.println("Received for-type-cnDev1DeviceType cmd: " + jo));
-
- tp.submit(topology);
- }
-
- private static String getProperty(Properties props, String... keys) {
- for (String key : keys) {
- String val = props.getProperty(key);
- if (val != null)
- return val;
- }
- return null;
- }
- }
[3/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/pom.xml.template
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/pom.xml.template b/samples/get-edgent-jars-project/pom.xml.template
deleted file mode 100644
index f8c9f1a..0000000
--- a/samples/get-edgent-jars-project/pom.xml.template
+++ /dev/null
@@ -1,148 +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>
-
- <!-- standalone project -->
- <!--parent>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-parent</artifactId>
- <version>1.2.0</version>
- </parent-->
-
- <groupId>org.apache.edgent</groupId>
- <artifactId>get-edgent-jars-project</artifactId>
- <version>1.3.0-SNAPSHOT</version>
-
- <name>Apache Edgent get-edgent-jars-project ${samples.projname.platform}</name>
-
- <properties>
- <samples.projname.platform> (Java 8)</samples.projname.platform> <!-- tweaked by -Pplatform-* -->
- <edgent.platform>java8</edgent.platform> <!-- tweaked by -Pplatform-* -->
- <edgent.groupId.platform/> <!-- tweaked by -Pplatform-* -->
- <edgent.base.groupId>org.apache.edgent${edgent.groupId.platform}</edgent.base.groupId>
- <!-- at least for now, the samples version is lockstep with the core
- so default to using the same core as the this project.
- get-edgent-jars.sh overrides via -Dedgent.runtime.version=...
- -->
- <edgent.runtime.version>${project.version}</edgent.runtime.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.5.3</version>
- <configuration>
- <finalName>edgent-${edgent.platform}-jars-${edgent.runtime.version}</finalName>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <version>1.5</version><!--$NO-MVN-MAN-VER$-->
- <executions>
- <execution>
- <id>process-resource-bundles</id>
- <goals>
- <goal>process</goal>
- </goals>
- <configuration>
- <resourceBundles>
- <!-- Will generate META-INF/{DEPENDENCIES,LICENSE,NOTICE} -->
- <resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
- <!-- Will generate META-INF/DISCLAIMER (incubator version) -->
- <resourceBundle>org.apache:apache-incubator-disclaimer-resource-bundle:1.1</resourceBundle>
- </resourceBundles>
- <!-- Content in this directory will be appended to generated resources -->
- <appendedResourcesDirectory>${remote-resources-maven-plugin.remote-resources.dir}</appendedResourcesDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptor>src/assembly/distribution.xml</descriptor>
- </configuration>
- <executions>
- <execution>
- <id>create-archive</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <!-- We don't need any jars as output in this module -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>platform-java7</id>
- <properties>
- <edgent.platform>java7</edgent.platform>
- <edgent.groupId.platform>.${edgent.platform}</edgent.groupId.platform>
- <platform.java7>true</platform.java7>
- <samples.projname.platform> (Java 7)</samples.projname.platform>
- </properties>
- </profile>
- <profile>
- <id>platform-android</id>
- <properties>
- <edgent.platform>android</edgent.platform>
- <edgent.groupId.platform>.${edgent.platform}</edgent.groupId.platform>
- <platform.android>true</platform.android>
- <samples.projname.platform> (Android)</samples.projname.platform>
- </properties>
- </profile>
- </profiles>
-
- <dependencies>
-<!-- INJECT_DEPENDENCIES_HERE -->
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/src/assembly/distribution.xml
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/src/assembly/distribution.xml b/samples/get-edgent-jars-project/src/assembly/distribution.xml
deleted file mode 100644
index 2f6da23..0000000
--- a/samples/get-edgent-jars-project/src/assembly/distribution.xml
+++ /dev/null
@@ -1,81 +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.
-
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-
- <!--
- NOTE: each platform (platforms/java7 and platforms/android) have their
- own distribution project and a copy of this configuration file that
- must be manually kept in sync.
- -->
-
- <id>bin</id>
-
- <formats>
- <format>tar.gz</format>
- <format>tar.bz2</format>
- <format>zip</format>
- </formats>
-
- <fileSets>
- <fileSet>
- <directory>${project.build.outputDirectory}/META-INF</directory>
- <includes>
- <include>DISCLAIMER</include>
- <include>DEPENDENCIES</include>
- </includes>
- <outputDirectory/>
- </fileSet>
-
- <fileSet>
- <directory>${project.build.outputDirectory}</directory>
- <includes>
- <include>README</include>
- </includes>
- <outputDirectory/>
- </fileSet>
-
- </fileSets>
-
- <dependencySets>
- <!-- Any edgent libs -->
- <dependencySet>
- <outputDirectory>libs</outputDirectory>
- <scope>runtime</scope>
- <includes>
- <include>org.apache.edgent*</include>
- </includes>
- <excludes>
- <exclude>org.apache.edgent*:get-edgent-jars-project</exclude>
- </excludes>
- </dependencySet>
-
- <!-- All other libs are treated as external libs -->
- <dependencySet>
- <outputDirectory>ext</outputDirectory>
- <scope>runtime</scope>
- <excludes>
- <exclude>org.apache.edgent*</exclude>
- </excludes>
- </dependencySet>
- </dependencySets>
-
-</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/get-edgent-jars-project/src/main/resources/README
----------------------------------------------------------------------
diff --git a/samples/get-edgent-jars-project/src/main/resources/README b/samples/get-edgent-jars-project/src/main/resources/README
deleted file mode 100644
index d91c7ff..0000000
--- a/samples/get-edgent-jars-project/src/main/resources/README
+++ /dev/null
@@ -1,12 +0,0 @@
-This bundle includes a number of artifacts with separate
-copyright notices and license terms. Your use of an artifact
-is subject to that artifact’s licensing terms and conditions.
-
-The Apache Edgent artifacts (everything in lib) all have the
-license “Apache License Version 2.0”.
-
-Edgent’s dependent artifacts in “ext” have all been evaluated
-to be compatible with Edgent’s license.
-
-A bundled artifact's advertised license information may be
-found in the DEPENDENCIES file in this bundle.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/mvnw
----------------------------------------------------------------------
diff --git a/samples/mvnw b/samples/mvnw
deleted file mode 100755
index 53d9860..0000000
--- a/samples/mvnw
+++ /dev/null
@@ -1,268 +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.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
- # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
- if [ -z "$JAVA_HOME" ]; then
- if [ -x "/usr/libexec/java_home" ]; then
- export JAVA_HOME="`/usr/libexec/java_home`"
- else
- export JAVA_HOME="/Library/Java/Home"
- fi
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Mingw, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
-
- if [ -z "$1" ]
- then
- echo "Path not specified to find_maven_basedir"
- return 1
- fi
-
- basedir="$1"
- wdir="$1"
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- # workaround for JBEAP-8937 (on Solaris 10/Sparc)
- if [ -d "${wdir}" ]; then
- wdir=`cd "$wdir/.."; pwd`
- fi
- # end of workaround
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-BASE_DIR=`find_maven_basedir "$(pwd)"`
-if [ -z "$BASE_DIR" ]; then
- exit 1;
-fi
-
-##########################################################################################
-# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-# This allows using the maven wrapper in projects that prohibit checking in binary data.
-##########################################################################################
-if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
- echo "Found .mvn/wrapper/maven-wrapper.jar"
-else
- echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
-
- jarUrl="https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar"
- while IFS="=" read key value; do
- case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
- esac
- done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
- echo "Downloading from: $jarUrl"
-
- if command -v wget > /dev/null; then
- echo "Found wget ... using wget"
- wget -O "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" "$jarUrl"
- elif command -v curl > /dev/null; then
- echo "Found curl ... using curl"
- curl -o "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" "$jarUrl"
- else
- echo "Falling back to using Java to download"
- javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
- if [ -e "$javaClass" ]; then
- if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- echo " - Compiling MavenWrapperDownloader.java ..."
- # Compiling the Java class
- ("$JAVA_HOME/bin/javac" "$javaClass")
- fi
- if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- # Running the downloader
- echo " - Running MavenWrapperDownloader.java ..."
- ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
- fi
- fi
- fi
-fi
-##########################################################################################
-# End of extension
-##########################################################################################
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-echo $MAVEN_PROJECTBASEDIR
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- [ -n "$MAVEN_PROJECTBASEDIR" ] &&
- MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
-fi
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/mvnw.cmd
----------------------------------------------------------------------
diff --git a/samples/mvnw.cmd b/samples/mvnw.cmd
deleted file mode 100644
index 898fb06..0000000
--- a/samples/mvnw.cmd
+++ /dev/null
@@ -1,159 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-set DOWNLOAD_URL="https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar"
-FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
- IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
-)
-
-@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
-if exist %WRAPPER_JAR% (
- echo Found %WRAPPER_JAR%
-) else (
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
- powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
- echo Finished downloading %WRAPPER_JAR%
-)
-@REM End of extension
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/package-app.sh
----------------------------------------------------------------------
diff --git a/samples/package-app.sh b/samples/package-app.sh
deleted file mode 100755
index c27edcc..0000000
--- a/samples/package-app.sh
+++ /dev/null
@@ -1,112 +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.
-#
-
-## Create a self contained application specific tar bundle that can be
-## brought to a system, unpacked and run.
-##
-## Run from the Application project's top level directory.
-
-USAGE="usage: `basename $0` [--platform {java8|java7|android}] [--mainClass classname] [--appjar jarname] [--add csv-paths] [--mvn mvn-cmd]"
-
-## --platform the platform the app was built for (default: java8. options: java7, android)
-## This controls which Edgent platform jars are collected.
-## E.g., use "--platform java7" when the app is built using
-## the profile "-Pplatform-java7".
-## --mainClass the main class name (default: com.mycompany.app.App)
-## --appjar the application jar name (default: my-app-1.0-SNAPSHOT.jar)
-## --add additional csv paths to include in the tarball (default: none)
-## Works best for paths in/under the App's project dir.
-## NOTE: anything in the App's src/main/resources dir generally
-## gets included in the App's jar.
-## --mvn mvn-cmd use mvn-cmd instead of "./mvnw"
-
-set -e
-
-SAMPLES_DIR=`(cd $(dirname $0); pwd)`
-MVN_CMD=${SAMPLES_DIR}/mvnw
-
-MAIN_CLASS=com.mycompany.app.App
-APP_JAR=my-app-1.0-SNAPSHOT.jar
-ADD_PATHS=
-PLATFORM=
-
-if [ "${1}" = "--platform" -a $# -gt 1 ] ; then
- PLATFORM=${2}; shift; shift
- if [ "${PLATFORM}" = "java8" ] ; then
- PLATFORM=
- fi
-fi
-if [ "${1}" = "--mainClass" -a $# -gt 1 ] ; then
- MAIN_CLASS=${2}; shift; shift
-fi
-if [ "${1}" = "--appjar" -a $# -gt 1 ] ; then
- APP_JAR=${2}; shift; shift
-fi
-if [ "${1}" = "--add" -a $# -gt 1 ] ; then
- ADD_PATHS=${2}; shift; shift
- ADD_PATHS=`echo ${ADD_PATHS} | sed -e 's/,/ /g'`
-fi
-if [ $# != 0 ]; then
- echo "$USAGE"
- exit 1
-fi
-
-TGT_REL_APP_JAR=`basename ${APP_JAR}` # support spec like target/my.jar
-
-echo
-echo "##### get the app specific dependencies..."
-PROFILES=
-if [ "${PLATFORM}" ] ; then
- PROFILES="-Pplatform-${PLATFORM}"
-fi
-rm -rf target/dependency
-# if someone screws up j7 or android deps, uncomment the following and
-# it will help identify wrong jars that are getting included / copied.
-#DEBUG_DEPS=-Dmdep.prependGroupId=true
-${MVN_CMD} dependency:copy-dependencies -DincludeScope=runtime ${PROFILES} ${DEBUG_DEPS}
-
-echo
-echo "##### create target/app-run.sh..."
-cat >target/app-run.sh <<EOF
-#!/bin/sh
-
-set -e
-
-USAGE="usage: \`basename \$0\` [ args ... ]"
-
-CP=${TGT_REL_APP_JAR}
-for i in dependency/\*; do
- CP=\${CP}:\${i}
-done
-
-export CLASSPATH=\${CP}
-java ${MAIN_CLASS} "\$@"
-EOF
-chmod +x target/app-run.sh
-
-echo
-echo "##### create target/app-pkg.tar..."
-D=`pwd`
-tar cf target/app-pkg.tar -C target app-run.sh ${TGT_REL_APP_JAR} dependency -C ${D} ${ADD_PATHS}
-
-echo
-echo "##### Copy target/app-pkg.tar to the destination system"
-echo "##### To run the app:"
-echo "##### mkdir app-pkg"
-echo "##### tar xf app-pkg.tar -C app-pkg"
-echo "##### (cd app-pkg; ./app-run.sh)"
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
deleted file mode 100644
index a10e91c..0000000
--- a/samples/pom.xml
+++ /dev/null
@@ -1,289 +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</groupId>
- <artifactId>apache</artifactId>
- <version>18</version>
- </parent>
-
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <name>Apache Edgent Samples ${samples.projname.platform}:</name>
-
- <properties>
- <samples.projname.platform>(Java 8)</samples.projname.platform> <!-- tweaked by -Pplatform-* -->
- <edgent.runtime.platform/> <!-- set by -Pplatform-* -->
- <edgent.runtime.groupId>org.apache.edgent${edgent.runtime.platform}</edgent.runtime.groupId>
- <!-- at least for now, the samples version is lockstep with the core -->
- <edgent.runtime.version>${project.version}</edgent.runtime.version>
-
- <java.version>1.8</java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputencoding>UTF-8</project.reporting.outputencoding>
- <maven.version>3.3.1</maven.version>
-
- <jetty.version>9.3.6.v20151106</jetty.version>
- <gson.version>2.2.4</gson.version>
- <slf4j.version>1.7.12</slf4j.version>
- <retrolambda.version>2.5.1</retrolambda.version>
- </properties>
-
- <modules>
- <module>apps</module>
- <module>connectors</module>
- <module>console</module>
- <!-- <module>get-edgent-jars-project</module> intentionally omitted -->
- <module>scenarios</module>
- <!-- <module>template</module> intentionally omitted -->
- <module>topology</module>
- <module>utils</module>
- </modules>
-
- <profiles>
- <profile>
- <id>platform-java7</id>
- <properties>
- <edgent.runtime.platform>.java7</edgent.runtime.platform>
- <platform.java7>true</platform.java7>
- <samples.projname.platform>(Java 7)</samples.projname.platform>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>net.orfjackal.retrolambda</groupId>
- <artifactId>retrolambda-maven-plugin</artifactId>
- <version>${retrolambda.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>process-main</goal>
- <goal>process-test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <!-- We don't currently support building samples for Android as many
- depend on the Development provider / Edgent Console
- -->
- </profiles>
-
- <dependencies>
- <!--
- In the examples we want this lib to be included,
- so we change the scope from 'provided' to 'compile'.
- -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- an SLF4J runtime implementation to use -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>${slf4j.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <!-- Other common sample dependencies -->
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-providers-direct</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-providers-development</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-providers-iot</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.6.1</version>
- <configuration>
- <source>${java.version}</source>
- <target>${java.version}</target>
- <testSource>${java.version}</testSource>
- <testTarget>${java.version}</testTarget>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>3.0.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <!-- Inject the "incubating" into the output filename -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <finalName>apache-edgent-${project.version}-incubating-samples</finalName>
- <formats>
- <format>zip</format>
- <format>tar.gz</format>
- </formats>
- </configuration>
- </plugin>
-
- <!--
- This is a fake plugin which is used to tell m2e (Eclipse) how
- to process this maven project.
- -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <versionRange>[1.0.0,)</versionRange>
- <goals>
- <goal>copy</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore/>
- </action>
- </pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <versionRange>[1.0.0,)</versionRange>
- <goals>
- <goal>process</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore/>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
-
- <!-- Make sure the DISCLAIMER contains the incubator version -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <version>1.5</version><!--$NO-MVN-MAN-VER$-->
- <executions>
- <execution>
- <id>process-resource-bundles</id>
- <goals>
- <goal>process</goal>
- </goals>
- <configuration>
- <resourceBundles>
- <resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
- <!-- Will generate META-INF/DISCLAIMER -->
- <resourceBundle>org.apache.apache.resources:apache-incubator-disclaimer-resource-bundle:1.2-SNAPSHOT</resourceBundle>
- </resourceBundles>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <!-- build an uber JAR -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>3.0.0</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <!-- avoid things like the following when running the uber:
- java.lang.NoClassDefFoundError: org.eclipse.paho.client.mqttv3.logging.JSR47Logger
- e.g., connectors.iotp uses watson-iot which uses
- paho.mqtt. Apparently watson-iot or paho.mqtt
- has some behind the scenes depedency that's not
- captured in the uber jar when minimize is true.
- -->
- <!-- <minimizeJar>true</minimizeJar> -->
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>uber</shadedClassifierName>
- <!-- avoid "Invalid signature file digest for Manifest
- main attributes" when running the uber jar.
- An included jar's signed manifest isn't valid in the uber.
- -->
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/README.md
----------------------------------------------------------------------
diff --git a/samples/scenarios/README.md b/samples/scenarios/README.md
deleted file mode 100644
index da1d9e3..0000000
--- a/samples/scenarios/README.md
+++ /dev/null
@@ -1,69 +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.
-
--->
-# edgent.IoTFRangeSensor
-
-See the Recipe this was created for [here](https://developer.ibm.com/recipes/tutorials/apache-quarks-on-pi-to-watson-iot-foundation/). If that link doesn't work, try [here](https://developer.ibm.com/recipes/tutorials/apache-edgent-on-pi-to-watson-iot-foundation/).
-
-See the README.md in the samples root directory for information on building the samples.
-
-The build generated uber jar contains all of the dependent
-Edgent jars and their transitive dependencies.
-
-The desired sample can be run using the run-sample.sh script. e.g.,
-
-```sh
-cd scenarios
-./run-sample.sh IotpRangeSensor quickstart true true # see below
-```
-
-For usage information:
-
-```sh
-./run-sample.sh
-./run-sample.sh --list
-```
-
-If you want to run a sample from the standard jar there are two options:
-a) get a local copy of all of the Edgent jars and their dependencies.
- Form a CLASSPATH to the jars and run the sample's main class.
- The get-edgent-jars.sh script can be used to get the jars from
- a maven repository (local or remote).
-b) create an application package bundle. The bundle includes the
- sample(s) jar and a copy of all of the dependent Edgent jars
- and their dependencies. The package-app.sh script can be
- used to create this bundle.
- The package-app.sh script also creates a run-app.sh script.
- The run-app.sh script configures the CLASSPATH and runs the main class.
-
-
-## Requirements:
-* You will need to have an HC-SR04 Range sensor hooked up with your EchoPin set to pin 18 and your TripPin at pin 16 (see these instructions on hardware setup: http://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi). To use a simulated sensor, pass in true as your second argument.
-* You will need to have an LED hooked up to pin 12 (See these instructions to set up an LED, however use pin 12 as your control pin: https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/). To use a simulated LED, pass in true as your third argument.
-* You will need to have your device registered with Watson IoTF and a device.cfg file, or you can use a quickstart version by passing in "quickstart" as your first argument.
-
-
-`./run-sample.sh IotpRangeSensor <device cfg file> <simulatedSensor?> <simulatedLED?>`
-
-To run with a device.cfg file, range sensor, and LED:
-
-`./run-sample.sh IotpRangeSensor device.cfg false false`
-
-To run in fully simulated mode (no sensors and using IoTF quickstart):
-
-`./run-sample.sh IotpRangeSensor quickstart true true`
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/pom.xml
----------------------------------------------------------------------
diff --git a/samples/scenarios/pom.xml b/samples/scenarios/pom.xml
deleted file mode 100644
index 1bfcbe5..0000000
--- a/samples/scenarios/pom.xml
+++ /dev/null
@@ -1,84 +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-scenarios</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Scenarios</name>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <executions>
- <execution>
- <id>license-check</id>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <excludes combine.children="append">
- <exclude>src/main/resources/**/*.cfg</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- parent pom has Providers and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-iotp</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-math3</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples-connectors</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>com.pi4j</groupId>
- <artifactId>pi4j-core</artifactId>
- <version>1.1</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/run-sample.sh
----------------------------------------------------------------------
diff --git a/samples/scenarios/run-sample.sh b/samples/scenarios/run-sample.sh
deleted file mode 100755
index 99536c1..0000000
--- a/samples/scenarios/run-sample.sh
+++ /dev/null
@@ -1,64 +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=scenarios
-
-UBER_JAR=target/edgent-samples-${CATEGORY}-*-uber.jar
-
-SAMPLE_PACKAGE_BASE=org.apache.edgent.samples.${CATEGORY}
-SAMPLES_FQ=`cat <<EOF
-${SAMPLE_PACKAGE_BASE}.iotp.IotpFullScenario
-${SAMPLE_PACKAGE_BASE}.iotp.range.sensor.IotpRangeSensor
-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
-
-set -x
-java -cp ${UBER_JAR} "${SAMPLE_FQ}" "$@"
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java
deleted file mode 100644
index 5fd37d9..0000000
--- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/IotpFullScenario.java
+++ /dev/null
@@ -1,92 +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.scenarios.iotp;
-
-
-import java.io.File;
-
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.providers.iot.IotProvider;
-import org.apache.edgent.samples.connectors.iotp.IotpSensors;
-
-/**
- * Sample IotProvider scenario using IBM Watson IoT Platform.
- * <BR>
- * IotProvider with three registered applications that
- * are not started but can be started by a a remote
- * application sending device commands through
- * IBM Watson IoT Platform.
- * <P>
- * This is equivalent to the {@link IotpSensors} application
- * but executing as three separate applications using
- * {@link IotProvider} rather than the lower level
- * {@link org.apache.edgent.providers.direct.DirectProvider}.
- *
- * </P>
- *
- * @see org.apache.edgent.topology.mbeans.ApplicationServiceMXBean
- * @see <a href="{@docRoot}/org/apache/edgent/topology/mbeans/package-summary.html">org.apache.edgent.topology.mbeans</a>
- */
-public class IotpFullScenario {
-
- /**
- * Run the IotpFullScenario application.
- *
- * Takes a single argument that is the path to the
- * device configuration file containing the connection
- * authentication information.
- *
- * @param args Must contain the path to the device configuration file.
- * @throws Exception on failure
- * @see IotpDevice#IotpDevice(org.apache.edgent.topology.Topology, File)
- */
- public static void main(String[] args) throws Exception {
- String deviceCfg = args[0];
-
- // Create an IotProvider that will use
- // an IotpDevice as the connectivity to
- // the IBM Watson IoT Platform message hub.
- IotProvider provider = new IotProvider(
- topology -> new IotpDevice(topology, new File(deviceCfg)));
-
- // Register three applications
- registerHeartbeat(provider);
- registerSensors(provider);
- registerDisplay(provider);
-
- // Start this provider
- // the three applications will not start
- provider.start();
- }
-
- public static void registerHeartbeat(IotProvider provider) {
- provider.registerTopology("Heartbeat",
- (iotDevice,config) -> IotpSensors.heartBeat(iotDevice, true));
- }
-
- public static void registerSensors(IotProvider provider) {
- provider.registerTopology("Sensors",
- (iotDevice,config) -> IotpSensors.simulatedSensors(iotDevice, true));
- }
- public static void registerDisplay(IotProvider provider) {
- provider.registerTopology("Display",
- (iotDevice,config) -> IotpSensors.displayMessages(iotDevice, true));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java
deleted file mode 100644
index b75be33..0000000
--- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/IotpRangeSensor.java
+++ /dev/null
@@ -1,219 +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.scenarios.iotp.range.sensor;
-
-import static org.apache.edgent.analytics.math3.stat.Statistic.MAX;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MEAN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MIN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.STDDEV;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.analytics.math3.json.JsonAnalytics;
-import org.apache.edgent.connectors.iot.IotDevice;
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.providers.direct.DirectTopology;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.TWindow;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.pi4j.io.gpio.Pin;
-import com.pi4j.io.gpio.RaspiPin;
-
-public class IotpRangeSensor {
- private static final Pin echoPin = RaspiPin.GPIO_05; // PI4J custom
- // numbering (pin 18 on
- // RPi2)
- private static final Pin trigPin = RaspiPin.GPIO_04; // PI4J custom
- // numbering (pin 16 on
- // RPi2)
- private static final Pin ledPin = RaspiPin.GPIO_01; // PI4J custom numbering
- // (pin 12 on RPi2)
-
- public static void main(String[] args) {
-
- if (args.length != 3) {
- System.out.println("Proper Usage is:\n " + " java program device.cfg sensorIsSimulated LEDIsSimulated\n"
- + "Example: \n"
- + " java -cp $EDGENT/build/distributions/java8/samples/lib/edgent.samples.scenarios.jar org.apache.edgent.samples.scenarios.iotp.range.sensor.IotpRangeSensor device.cfg false true");
- System.exit(0);
- }
-
- String deviceCfg = args[0];
- Boolean simulatedRange = Boolean.parseBoolean(args[1]);
- Boolean simulatedLED = Boolean.parseBoolean(args[2]);
-
- DirectProvider tp = new DirectProvider();
- DirectTopology topology = tp.newTopology("IotpRangeSensor");
-
- IotDevice device = getIotDevice(deviceCfg, topology);
-
- // HC-SR04 Range sensor for this device.
- rangeSensor(device, simulatedRange, true);
-
- // In addition create a heart beat event to
- // ensure there is some immediate output and
- // the connection to IoTF happens as soon as possible.
- TStream<Date> hb = topology.poll(() -> new Date(), 1, TimeUnit.MINUTES);
-
- // Convert to JSON
- TStream<JsonObject> hbj = hb.map(d -> {
- JsonObject j = new JsonObject();
- j.addProperty("when", d.toString());
- j.addProperty("hearbeat", d.getTime());
- return j;
- });
- hbj.print();
- device.events(hbj, "heartbeat", QoS.FIRE_AND_FORGET);
-
- // Subscribe to commands of id "display" for this
- // device and print them to standard out
- TStream<String> statusMsgs = displayMessages(device);
- statusMsgs.print();
-
- // Flash an LED for 1second when we receive commands from IoTF
- if (!simulatedLED) {
- LED led = new LED(ledPin);
- statusMsgs.sink(j -> led.flash(1000));
- } else {
- statusMsgs.sink(j -> System.out.println("*******Simulated LED Flash!*******"));
- }
-
- tp.submit(topology);
- }
-
- /*
- * Returns an IotDevice based on the device config parameter. If the type is
- * "quickstart" then we also output the URL to view the data.
- */
- private static IotDevice getIotDevice(String deviceCfg, DirectTopology topology) {
- IotDevice device;
-
- if (deviceCfg.equalsIgnoreCase("quickstart")) {
- // Declare a connection to IoTF Quickstart service
- String deviceId = "qs" + Long.toHexString(new Random().nextLong());
- device = IotpDevice.quickstart(topology, deviceId);
-
- System.out.println("Quickstart device type:" + IotpDevice.QUICKSTART_DEVICE_TYPE);
- System.out.println("Quickstart device id :" + deviceId);
- System.out.println("https://quickstart.internetofthings.ibmcloud.com/#/device/" + deviceId);
- } else {
- // Declare a connection to IoTF
- device = new IotpDevice(topology, new File(deviceCfg));
- }
-
- return device;
- }
-
- /**
- * Connect to an HC-SR04 Range Sensor
- *
- * @param device
- * IoTF device
- * @param print
- * True if the data submitted as events should also be printed to
- * standard out.
- * @param simulated
- * boolean flag
- */
- public static void rangeSensor(IotDevice device, boolean simulated, boolean print) {
-
- Supplier<Double> sensor;
-
- if (simulated) {
- sensor = new SimulatedRangeSensor();
- } else {
- sensor = new RangeSensor(echoPin, trigPin);
- }
-
- TStream<Double> distanceReadings = device.topology().poll(sensor, 1, TimeUnit.SECONDS);
- distanceReadings.print();
-
- // filter out bad readings that are out of the sensor's 4m range
- distanceReadings = distanceReadings.filter(j -> j < 400.0);
-
- TStream<JsonObject> sensorJSON = distanceReadings.map(v -> {
- JsonObject j = new JsonObject();
- j.addProperty("name", "rangeSensor");
- j.addProperty("reading", v);
- return j;
- });
-
- // Create a window on the stream of the last 10 readings partitioned
- // by sensor name. In this case we only have one range sensor so there
- // will be one partition.
- TWindow<JsonObject, JsonElement> sensorWindow = sensorJSON.last(10, j -> j.get("name"));
-
- // Aggregate the windows calculating the min, max, mean and standard
- // deviation
- // across each window independently.
- sensorJSON = JsonAnalytics.aggregate(sensorWindow, "name", "reading", MIN, MAX, MEAN, STDDEV);
-
- // Filter so that only when the mean sensor reading is that an object is
- // closer than 30cm send data.
- sensorJSON = sensorJSON
- .filter(j -> Math.abs(j.get("reading").getAsJsonObject().get("MEAN").getAsDouble()) < 30.0);
-
- if (print)
- sensorJSON.print();
-
- // Send the device streams as IoTF device events
- // with event identifier "sensors".
- device.events(sensorJSON, "sensors", QoS.FIRE_AND_FORGET);
- }
-
- /**
- * Subscribe to IoTF device commands with identifier {@code display}.
- * Subscribing to device commands returns a stream of JSON objects that
- * include a timestamp ({@code tsms}), command identifier ({@code command})
- * and payload ({@code payload}). Payload is the application specific
- * portion of the command. <BR>
- * In this case the payload is expected to be a JSON object containing a
- * {@code msg} key with a string display message. <BR>
- * The returned stream consists of the display message string extracted from
- * the JSON payload.
- * <P>
- * Note to receive commands a analytic application must exist that generates
- * them through IBM Watson IoT Platform.
- * </P>
- *
- * @param device IoTF device
- * @return JSON object includes tsms(timestamp) and payload.msg(status)
- *
- * @see IotDevice#commands(String...)
- */
- public static TStream<String> displayMessages(IotDevice device) {
- // Subscribe to commands of id "status" for this device
- TStream<JsonObject> statusMsgs = device.commands("display");
-
- // The returned JSON object includes several fields
- // tsms - Timestamp in milliseconds (this is generic to a command)
- // payload.msg - Status message (this is specific to this application)
-
- // Map to a String object containing the message
- return statusMsgs.map(j -> j.getAsJsonObject("payload").getAsJsonPrimitive("msg").getAsString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/LED.java
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/LED.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/LED.java
deleted file mode 100644
index 30507d9..0000000
--- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/LED.java
+++ /dev/null
@@ -1,52 +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.scenarios.iotp.range.sensor;
-
-import com.pi4j.io.gpio.GpioController;
-import com.pi4j.io.gpio.GpioFactory;
-import com.pi4j.io.gpio.GpioPinDigitalOutput;
-import com.pi4j.io.gpio.Pin;
-import com.pi4j.io.gpio.PinState;
-
-public class LED {
- private final GpioController gpio = GpioFactory.getInstance();
- private GpioPinDigitalOutput pin;
-
- public LED(Pin pin) {
- this.pin = gpio.provisionDigitalOutputPin(pin, "LED", PinState.HIGH);
- this.pin.setShutdownOptions(true, PinState.LOW);
- this.pin.low();
- }
-
- public void on() {
- this.pin.high();
- }
-
- public void off() {
- this.pin.low();
- }
-
- public void toggle() {
- this.pin.toggle();
- }
-
- public void flash(long ms) {
- this.pin.pulse(ms);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/RangeSensor.java
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/RangeSensor.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/RangeSensor.java
deleted file mode 100644
index da749bc..0000000
--- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/RangeSensor.java
+++ /dev/null
@@ -1,104 +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.scenarios.iotp.range.sensor;
-
-import org.apache.edgent.function.Supplier;
-
-import com.pi4j.io.gpio.GpioController;
-import com.pi4j.io.gpio.GpioFactory;
-import com.pi4j.io.gpio.GpioPinDigitalInput;
-import com.pi4j.io.gpio.GpioPinDigitalOutput;
-import com.pi4j.io.gpio.Pin;
-
-public class RangeSensor implements Supplier<Double> {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final static Double SPEED_OF_SOUND = 340.29; // speed of sound
- private final GpioPinDigitalInput echoPin;
- private final GpioPinDigitalOutput trigPin;
- private final int MAX_CYCLES = 3000;
-
- private final static GpioController gpio = GpioFactory.getInstance();
-
- public RangeSensor(Pin echoPin, Pin trigPin) {
- this.echoPin = gpio.provisionDigitalInputPin(echoPin);
- this.trigPin = gpio.provisionDigitalOutputPin(trigPin);
- this.trigPin.low();
- }
-
- /*
- * Get the distance in cm. Distance is (timeOfSignal * SpeedOfSound) / 2
- * (divide by 10000 is for units)
- */
- public Double getDistance() {
- triggerSensor();
-
- long reboundTimeMicroSeconds = getSignalDuration();
- Double distance = reboundTimeMicroSeconds * SPEED_OF_SOUND / (2 * 10000); // gives
- // distance
- // in
- // cm
- return distance;
- }
-
- /*
- * Send signal for 10 microseconds
- */
- private void triggerSensor() {
- this.trigPin.high();
- try {
- Thread.sleep(0, 10000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- this.trigPin.low();
- }
-
- /*
- * Measure signal duration
- */
- private long getSignalDuration() {
- int cycles = 0;
- long start = System.nanoTime();
-
- while (this.echoPin.isLow() && cycles < MAX_CYCLES) {
- // only iterate through MAX_CYCLES times before giving up
- start = System.nanoTime();
- cycles++;
- }
-
- cycles = 0;
-
- while (this.echoPin.isHigh() && cycles < MAX_CYCLES) {
- // only iterate through MAX_CYCLES times before giving up
- cycles++;
- }
- long end = System.nanoTime();
- long microSeconds = (long) Math.ceil((end - start) / 1000.0);
- return microSeconds;
- }
-
- @Override
- public Double get() {
- return getDistance();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/SimulatedRangeSensor.java
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/SimulatedRangeSensor.java b/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/SimulatedRangeSensor.java
deleted file mode 100644
index f7b8f22..0000000
--- a/samples/scenarios/src/main/java/org/apache/edgent/samples/scenarios/iotp/range/sensor/SimulatedRangeSensor.java
+++ /dev/null
@@ -1,42 +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.scenarios.iotp.range.sensor;
-
-import java.util.Random;
-
-import org.apache.edgent.function.Supplier;
-
-public class SimulatedRangeSensor implements Supplier<Double> {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- Random rand;
-
- public SimulatedRangeSensor() {
- rand = new Random();
- }
-
- @Override
- public Double get() {
- Double distance = 20 + rand.nextDouble() * 20;
- return distance;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/resources/META-INF/NOTICE b/samples/scenarios/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 2f9c926..0000000
--- a/samples/scenarios/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-
-Apache Edgent: Samples: Scenarios
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/scenarios/src/main/resources/org/apache/edgent/samples/scenarios/iotp/range/sensor/device.cfg
----------------------------------------------------------------------
diff --git a/samples/scenarios/src/main/resources/org/apache/edgent/samples/scenarios/iotp/range/sensor/device.cfg b/samples/scenarios/src/main/resources/org/apache/edgent/samples/scenarios/iotp/range/sensor/device.cfg
deleted file mode 100644
index 1d9bd6a..0000000
--- a/samples/scenarios/src/main/resources/org/apache/edgent/samples/scenarios/iotp/range/sensor/device.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-org = <org-name>
-type = <device-type>
-id = <device-id>
-auth-method = token
-auth-token = <auth-token>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/src/main/xslt/classpath.xsl
----------------------------------------------------------------------
diff --git a/samples/src/main/xslt/classpath.xsl b/samples/src/main/xslt/classpath.xsl
deleted file mode 100644
index bc601eb..0000000
--- a/samples/src/main/xslt/classpath.xsl
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.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.
-
--->
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:grphml="http://graphml.graphdrawing.org/xmlns"
- xmlns:yFiles="http://www.yworks.com/xml/graphml"
- exclude-result-prefixes="grphml yFiles"
- version="1.0">
-
- <xsl:param name="groupId"/>
- <xsl:param name="artifactId"/>
- <xsl:param name="version"/>
-
- <xsl:output media-type="text" omit-xml-declaration="yes"/>
- <!--xsl:output indent="yes"/-->
-
- <xsl:template match="/grphml:graphml">
- <!-- Calculate the name of the current module. This will help find the starting point -->
- <xsl:variable name="nodeName" select="concat($groupId,':', $artifactId, ':jar:', $version)"/>
- <!-- Start outputting the classpath starting with the current modules node -->
- <xsl:variable name="rootNode" select="grphml:graph/grphml:node[grphml:data/yFiles:ShapeNode/yFiles:NodeLabel = $nodeName]"/>
-
- <xsl:call-template name="processNode">
- <xsl:with-param name="currentNode" select="$rootNode"/>
- <xsl:with-param name="addedNodeIds"/>
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template name="processNode">
- <xsl:param name="currentNode"/>
- <xsl:param name="addedNodeIds"/>
- <xsl:variable name="currentNodeId" select="$currentNode/@id"/>
- <xsl:if test="not(contains($addedNodeIds, concat('|', $currentNodeId, '|')))">
- <xsl:variable name="newAddedNodeIds"><xsl:if test="string-length($addedNodeIds) = 0">|</xsl:if><xsl:value-of select="$addedNodeIds"/><xsl:value-of select="$currentNodeId"/>|</xsl:variable>
- <xsl:variable name="outgoingCompileDependencyIds" select="//grphml:edge[(@source = $currentNodeId) and ((grphml:data/yFiles:PolyLineEdge/yFiles:EdgeLabel = 'compile') or (grphml:data/yFiles:PolyLineEdge/yFiles:EdgeLabel = 'provided'))]/@target"/>
- <xsl:variable name="outgoingCompileDependencyName" select="$currentNode/grphml:data/yFiles:ShapeNode/yFiles:NodeLabel/text()"/>
- <xsl:variable name="outgoingCompileDependencyGroupId" select="substring-before($outgoingCompileDependencyName, ':')"/>
- <xsl:variable name="outgoingCompileDependencyArtifactId" select="substring-before(substring-after($outgoingCompileDependencyName, ':'), ':')"/>
- <xsl:variable name="outgoingCompileDependencyVersion" select="substring-before(substring-after(substring-after(substring-after($outgoingCompileDependencyName, ':'), ':'), ':'), ':')"/>
- <xsl:if test="not(starts-with($outgoingCompileDependencyGroupId, 'org.apache.edgent.'))">ext/</xsl:if><xsl:value-of select="concat($outgoingCompileDependencyArtifactId, '-', $outgoingCompileDependencyVersion, '.jar')"/>,<xsl:for-each select="$outgoingCompileDependencyIds">
- <xsl:variable name="currentDependentNodeId" select="."/>
- <xsl:variable name="currentDependentNode" select="//grphml:node[@id = $currentDependentNodeId]"/>
- <xsl:call-template name="processNode">
- <xsl:with-param name="currentNode" select="$currentDependentNode"/>
- <xsl:with-param name="addedNodeIds" select="$newAddedNodeIds"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:if>
- </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/.mvn/wrapper/MavenWrapperDownloader.java
----------------------------------------------------------------------
diff --git a/samples/template/.mvn/wrapper/MavenWrapperDownloader.java b/samples/template/.mvn/wrapper/MavenWrapperDownloader.java
deleted file mode 100644
index 44f8e00..0000000
--- a/samples/template/.mvn/wrapper/MavenWrapperDownloader.java
+++ /dev/null
@@ -1,110 +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.
-*/
-
-import java.net.*;
-import java.io.*;
-import java.nio.channels.*;
-import java.util.Properties;
-
-public class MavenWrapperDownloader {
-
- /**
- * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
- */
- private static final String DEFAULT_DOWNLOAD_URL =
- "https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar";
-
- /**
- * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
- * use instead of the default one.
- */
- private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
- ".mvn/wrapper/maven-wrapper.properties";
-
- /**
- * Path where the maven-wrapper.jar will be saved to.
- */
- private static final String MAVEN_WRAPPER_JAR_PATH =
- ".mvn/wrapper/maven-wrapper.jar";
-
- /**
- * Name of the property which should be used to override the default download url for the wrapper.
- */
- private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
-
- public static void main(String args[]) {
- System.out.println("- Downloader started");
- File baseDirectory = new File(args[0]);
- System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
-
- // If the maven-wrapper.properties exists, read it and check if it contains a custom
- // wrapperUrl parameter.
- File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
- String url = DEFAULT_DOWNLOAD_URL;
- if(mavenWrapperPropertyFile.exists()) {
- FileInputStream mavenWrapperPropertyFileInputStream = null;
- try {
- mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
- Properties mavenWrapperProperties = new Properties();
- mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
- url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
- } catch (IOException e) {
- System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
- } finally {
- try {
- if(mavenWrapperPropertyFileInputStream != null) {
- mavenWrapperPropertyFileInputStream.close();
- }
- } catch (IOException e) {
- // Ignore ...
- }
- }
- }
- System.out.println("- Downloading from: : " + url);
-
- File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
- if(!outputFile.getParentFile().exists()) {
- if(!outputFile.getParentFile().mkdirs()) {
- System.out.println(
- "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
- }
- }
- System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
- try {
- downloadFileFromURL(url, outputFile);
- System.out.println("Done");
- System.exit(0);
- } catch (Throwable e) {
- System.out.println("- Error downloading");
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- private static void downloadFileFromURL(String urlString, File destination) throws Exception {
- URL website = new URL(urlString);
- ReadableByteChannel rbc;
- rbc = Channels.newChannel(website.openStream());
- FileOutputStream fos = new FileOutputStream(destination);
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- fos.close();
- rbc.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/.mvn/wrapper/maven-wrapper.properties
----------------------------------------------------------------------
diff --git a/samples/template/.mvn/wrapper/maven-wrapper.properties b/samples/template/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index 7e8f382..0000000
--- a/samples/template/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1,20 +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.
-
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
-
-#wrapperUrl=https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/README.md
----------------------------------------------------------------------
diff --git a/samples/template/README.md b/samples/template/README.md
deleted file mode 100644
index 365dc46..0000000
--- a/samples/template/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-An Edgent Application template project.
-
-Clone this template project folder to create your Edgent application project.
-
-The project's pom supports
-
-- building for java8, java7 or android execution environments
-- building a standard jar and uber jar
-
-Edit the pom for your application. Adjust it for your application's maven coordinates.
-The pom has potential Edgent dependenacies present and commented out.
-Include the Edgent Providers, Analytics, Utils, and Connectors used by your application.
-
-Read `../README.md` for general information about Edgent Application development.
-
-The template includes a maven wrapper script to eliminate the need to
-manually download and install maven.
-
-# Building the project
-```sh
-./mvnw clean package # add -Pplatform-java7 or -Pplatform-android as needed
-```
-
-# Running the application
-
-You can copy `app-run.sh` and the generated `target/*-uber.jar` to the
-edge device and then run it
-```sh
-./app-run.sh
-```
-
-# Using package-app.sh with the project
-
-Adjust the main class name and application jar path below for your application.
-```sh
-PLATFORM= # add "--platform java7" or "--platform android" as appropriate
-../package-app.sh $PLATFORM --mainClass com.mycompany.app.TemplateApp --appjar target/my-app-1.0-SNAPSHOT.jar
-```
-
-# Using get-edgent-jars-project
-
-If you don't want to use the generated uber jar or `package-app.sh`
-approaches, you can copy the application's standard jar and a
-`get-edgent-jars-project` generated jar bundle to the edge device.
-See `samples/get-edgent-jars-project`.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/app-run.sh
----------------------------------------------------------------------
diff --git a/samples/template/app-run.sh b/samples/template/app-run.sh
deleted file mode 100755
index 8437275..0000000
--- a/samples/template/app-run.sh
+++ /dev/null
@@ -1,42 +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.
-#
-
-APP_DIR=.
-
-UBER_JAR=`echo ${APP_DIR}/target/*-uber.jar`
-
-FQ_MAIN_CLASS=com.mycompany.app.TemplateApp
-
-USAGE="usage: [--main <main-class>] [<args...>]"
-
-if [ "$1" = "--main" ]; then
- shift;
- if [ $# = 0 ]; then
- echo ${USAGE}
- exit 1;
- fi
- FQ_MAIN_CLASS=$1; shift
-fi
-
-# Runs the application
-#
-# ./app-run.sh
-
-export CLASSPATH=${UBER_JAR}
-
-java ${FQ_MAIN_CLASS} "$*"
[5/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart.java
deleted file mode 100644
index 3bd2414..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart.java
+++ /dev/null
@@ -1,88 +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.iotp;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.IotDevice;
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * IBM Watson IoT Platform Quickstart sample.
- * Submits a JSON device event every second using the
- * same format as the Quickstart device simulator,
- * with keys {@code temp}, {@code humidity} and {@code objectTemp}
- * and random values.
- * <P>
- * The device type is {@code iotsamples-edgent} and a random
- * device identifier is generated. Both are printed out when
- * the application starts.
- * </P>
- * A URL is also printed that allows viewing of the data
- * as it received by the Quickstart service.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about running the sample.
- */
-public class IotpQuickstart {
-
- public static void main(String[] args) {
-
- DirectProvider tp = new DirectProvider();
- Topology topology = tp.newTopology("IotpQuickstart");
-
- // Declare a connection to IoTF Quickstart service
- String deviceId = "qs" + Long.toHexString(new Random().nextLong());
- IotDevice device = IotpDevice.quickstart(topology, deviceId);
-
- System.out.println("Quickstart device type:" + IotpDevice.QUICKSTART_DEVICE_TYPE);
- System.out.println("Quickstart device id :" + deviceId);
- System.out.println("https://quickstart.internetofthings.ibmcloud.com/#/device/"
- + deviceId);
-
- Random r = new Random();
- TStream<double[]> raw = topology.poll(() -> {
- double[] v = new double[3];
-
- v[0] = r.nextGaussian() * 10.0 + 40.0;
- v[1] = r.nextGaussian() * 10.0 + 50.0;
- v[2] = r.nextGaussian() * 10.0 + 60.0;
-
- return v;
- }, 1, TimeUnit.SECONDS);
-
- TStream<JsonObject> json = raw.map(v -> {
- JsonObject j = new JsonObject();
- j.addProperty("temp", v[0]);
- j.addProperty("humidity", v[1]);
- j.addProperty("objectTemp", v[2]);
- return j;
- });
-
- device.events(json, "sensors", QoS.FIRE_AND_FORGET);
-
- tp.submit(topology);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart2.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart2.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart2.java
deleted file mode 100644
index ac4ee92..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpQuickstart2.java
+++ /dev/null
@@ -1,118 +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.iotp;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-import com.ibm.iotf.client.device.DeviceClient;
-import com.ibm.iotf.devicemgmt.DeviceData;
-import com.ibm.iotf.devicemgmt.device.ManagedDevice;
-
-/**
- * IBM Watson IoT Platform Quickstart sample.
- * Submits a JSON device event every second using the
- * same format as the Quickstart device simulator,
- * with keys {@code temp}, {@code humidity} and {@code objectTemp}
- * and random values.
- * <P>
- * The device type is {@code iotsamples-edgent} and a random
- * device identifier is generated. Both are printed out when
- * the application starts.
- * <P>
- * A URL is also printed that allows viewing of the data
- * as it received by the Quickstart service.
- * <P>
- * This sample demonstrates using the WIoTP API to initialize the IotpDevice
- * connector as well as the ability to publish events using the WIoTP HTTP protocol.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about running the sample.
- */
-public class IotpQuickstart2 {
-
- public static void main(String[] args) throws Exception {
- List<String> argList = Arrays.asList(args);
- boolean useDeviceClient = argList.contains("useDeviceClient");
- boolean useHttp = argList.contains("useHttp");
-
- DirectProvider tp = new DirectProvider();
- Topology topology = tp.newTopology("IotpQuickstart");
-
- // Declare a connector to IoTP Quickstart service, initializing with WIoTP API
- String deviceId = "qs" + Long.toHexString(new Random().nextLong());
- Properties options = new Properties();
- options.setProperty("org", "quickstart");
- options.setProperty("type", IotpDevice.QUICKSTART_DEVICE_TYPE);
- options.setProperty("id", deviceId);
- IotpDevice device;
- if (useDeviceClient) {
- System.out.println("Using WIoTP DeviceClient");
- device = new IotpDevice(topology, new DeviceClient(options));
- }
- else {
- System.out.println("Using WIoTP ManagedDevice");
- DeviceData deviceData = new DeviceData.Builder().build();
- device = new IotpDevice(topology, new ManagedDevice(options, deviceData));
- }
-
- System.out.println("Quickstart device type:" + IotpDevice.QUICKSTART_DEVICE_TYPE);
- System.out.println("Quickstart device id :" + deviceId);
- System.out.println("https://quickstart.internetofthings.ibmcloud.com/#/device/"
- + deviceId);
-
- Random r = new Random();
- TStream<double[]> raw = topology.poll(() -> {
- double[] v = new double[3];
-
- v[0] = r.nextGaussian() * 10.0 + 40.0;
- v[1] = r.nextGaussian() * 10.0 + 50.0;
- v[2] = r.nextGaussian() * 10.0 + 60.0;
-
- return v;
- }, 1, TimeUnit.SECONDS);
-
- TStream<JsonObject> json = raw.map(v -> {
- JsonObject j = new JsonObject();
- j.addProperty("temp", v[0]);
- j.addProperty("humidity", v[1]);
- j.addProperty("objectTemp", v[2]);
- return j;
- });
-
- if (!useHttp) {
- device.events(json, "sensors", QoS.FIRE_AND_FORGET);
- }
- else {
- System.out.println("Publishing events using HTTP");
- device.httpEvents(json, "sensors");
- }
-
- tp.submit(topology);
- }
- }
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpSensors.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpSensors.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpSensors.java
deleted file mode 100644
index e2f4b12..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpSensors.java
+++ /dev/null
@@ -1,164 +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.iotp;
-
-import java.io.File;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.iot.HeartBeat;
-import org.apache.edgent.connectors.iot.IotDevice;
-import org.apache.edgent.connectors.iot.QoS;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.providers.direct.DirectTopology;
-import org.apache.edgent.samples.topology.SensorsAggregates;
-import org.apache.edgent.topology.TStream;
-
-import com.google.gson.JsonObject;
-
-/**
- * Sample sending sensor device events to IBM Watson IoT Platform. <BR>
- * Simulates a couple of bursty sensors and sends the readings from the sensors
- * to IBM Watson IoT Platform as device events with id {@code sensors}. <BR>
- * Subscribes to device commands with identifier {@code display}.
- * <P>
- * In addition a device event with id {@code hearbeat} is sent
- * every minute. This ensure a connection attempt to IBM Watson IoT Platform
- * is made immediately rather than waiting for a bursty sensor to become
- * active.
- * <P>
- * This sample requires an IBM Watson IoT Platform service and a device configuration.<BR>
- * In order to see commands send from IBM Watson IoT Platform
- * there must be an analytic application
- * that sends commands with the identifier {@code display}.
- * </P>
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about a
- * prototype device configuration file and running the sample.
- */
-public class IotpSensors {
-
- /**
- * Run the IotpSensors application.
- *
- * Takes a single argument that is the path to the
- * device configuration file containing the connection
- * authentication information.
- *
- * @param args Must contain the path to the device configuration file.
- *
- * @see IotpDevice#IotpDevice(org.apache.edgent.topology.Topology, File)
- */
- public static void main(String[] args) {
-
- String deviceCfg = args[0];
-
- DirectProvider tp = new DirectProvider();
- DirectTopology topology = tp.newTopology("IotpSensors");
-
- // Declare a connection to IoTF
- IotDevice device = new IotpDevice(topology, new File(deviceCfg));
-
- // Simulated sensors for this device.
- simulatedSensors(device, true);
-
- // Heartbeat
- heartBeat(device, true);
-
- // Subscribe to commands of id "display" for this
- // device and print them to standard out
- displayMessages(device, true);
-
- tp.submit(topology);
- }
-
-
- /**
- * Simulate two bursty sensors and send the readings as IoTF device events
- * with an identifier of {@code sensors}.
- *
- * @param device
- * IoT device
- * @param print
- * True if the data submitted as events should also be printed to
- * standard out.
- */
- public static void simulatedSensors(IotDevice device, boolean print) {
-
- TStream<JsonObject> sensors = SensorsAggregates.sensorsAB(device.topology());
- if (print)
- sensors.print();
-
- // Send the device streams as IoTF device events
- // with event identifier "sensors".
- device.events(sensors, "sensors", QoS.FIRE_AND_FORGET);
- }
-
- /**
- * Create a heart beat device event with
- * identifier {@code heartbeat} to
- * ensure there is some immediate output and
- * the connection to IoTF happens as soon as possible.
- * @param device IoT device
- * @param print true to print generated heartbeat tuples to System.out.
- */
- public static void heartBeat(IotDevice device, boolean print) {
- TStream<JsonObject> hbs =
- HeartBeat.addHeartBeat(device, 1, TimeUnit.MINUTES, "heartbeat");
- if (print)
- hbs.print();
- }
-
-
- /**
- * Subscribe to IoTP device commands with identifier {@code display}.
- * Subscribing to device commands returns a stream of JSON objects that
- * include a timestamp ({@code tsms}), command identifier ({@code command})
- * and payload ({@code payload}). Payload is the application specific
- * portion of the command. <BR>
- * In this case the payload is expected to be a JSON object containing a
- * {@code msg} key with a string display message. <BR>
- * The returned stream consists of the display message string extracted from
- * the JSON payload.
- * <P>
- * Note to receive commands a analytic application must exist that generates
- * them through IBM Watson IoT Platform.
- * </P>
- *
- * @param device the device
- * @param print true to print the received command's payload to System.out.
- * @return the stream
- * @see IotDevice#commands(String...)
- */
- public static TStream<String> displayMessages(IotDevice device, boolean print) {
- // Subscribe to commands of id "display" for this device
- TStream<JsonObject> statusMsgs = device.commands("display");
-
- // The returned JSON object includes several fields
- // tsms - Timestamp in milliseconds (this is generic to a command)
- // payload.msg - Status message (this is specific to this application)
-
- // Map to a String object containing the message
- TStream<String> messages = statusMsgs.map(j -> j.getAsJsonObject("payload").getAsJsonPrimitive("msg").getAsString());
- if (print)
- messages.print();
- return messages;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/package-info.java
deleted file mode 100644
index 43dcfe9..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/package-info.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.
-*/
-
-/**
- * Samples showing use of the IBM Watson IoT Platform connector
- * to publish device events and subscribe to device
- * commands.
- *
- * <p>The "Quickstart" samples connect to the IBM Watson IoT Platform
- * using its Quickstart feature that does not require device registration.
- * When the samples are run they print out a URL which allows a browser
- * to see the data being sent from this sample.
- *
- * <p>The other samples connect to your IBM Watson IoT Platform service instance
- * using device and application registrations that you have created with your
- * service instance.
- *
- * <p>See each sample's Javadoc for more information.
- *
- * <p>See {@code scripts/connectors/iotp/README} for information about running the samples.
- */
-package org.apache.edgent.samples.connectors.iotp;
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/DbUtils.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/DbUtils.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/DbUtils.java
deleted file mode 100644
index a0264f1..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/DbUtils.java
+++ /dev/null
@@ -1,140 +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.jdbc;
-
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-/**
- * Utilities for the sample's non-streaming JDBC database related actions.
- */
-public class DbUtils {
-
- /**
- * Get the JDBC {@link DataSource} for the database.
- * <p>
- * The "db.name" property specifies the name of the database.
- * Defaults to "JdbcConnectorSampleDb".
- *
- * @param props configuration properties
- * @return the DataSource
- * @throws Exception on failure
- */
- public static DataSource getDataSource(Properties props) throws Exception {
- return createDerbyEmbeddedDataSource(props);
- }
-
- /**
- * Initialize the sample's database.
- * <p>
- * Tables are created as needed and purged.
- * @param ds the DataSource
- * @throws Exception on failure
- */
- public static void initDb(DataSource ds) throws Exception {
- createTables(ds);
- purgeTables(ds);
- }
-
- /**
- * Purge the sample's tables
- * @param ds the DataSource
- * @throws Exception on failure
- */
- public static void purgeTables(DataSource ds) throws Exception {
- try (Connection cn = ds.getConnection()) {
- Statement stmt = cn.createStatement();
- stmt.execute("DELETE FROM persons");
- }
- }
-
- private static void createTables(DataSource ds) throws Exception {
- try (Connection cn = ds.getConnection()) {
- Statement stmt = cn.createStatement();
- stmt.execute("CREATE TABLE persons "
- + "("
- + "id INTEGER NOT NULL,"
- + "firstname VARCHAR(40) NOT NULL,"
- + "lastname VARCHAR(40) NOT NULL,"
- + "PRIMARY KEY (id)"
- + ")"
- );
- }
- catch (SQLException e) {
- if (e.getLocalizedMessage().contains("already exists"))
- return;
- else
- throw e;
- }
- }
-
- private static DataSource createDerbyEmbeddedDataSource(Properties props) throws Exception
- {
- String dbName = props.getProperty("db.name", "JdbcConnectorSampleDb");
-
- // For our sample, avoid a compile-time dependency to the jdbc driver.
- // At runtime, require that the classpath can find it.
-
- String DERBY_DATA_SOURCE = "org.apache.derby.jdbc.EmbeddedDataSource";
-
- Class<?> nsDataSource = null;
- try {
- nsDataSource = Class.forName(DERBY_DATA_SOURCE);
- }
- catch (ClassNotFoundException e) {
- String msg = "Fix the test classpath. ";
- if (System.getenv("DERBY_HOME") == null) {
- msg += "DERBY_HOME not set. ";
- }
- msg += "Class not found: "+e.getLocalizedMessage();
- System.err.println(msg);
- throw new IllegalStateException(msg);
- }
- DataSource ds = (DataSource) nsDataSource.newInstance();
-
- @SuppressWarnings("rawtypes")
- Class[] methodParams = new Class[] {String.class};
- Method dbname = nsDataSource.getMethod("setDatabaseName", methodParams);
- Object[] args = new Object[] {dbName};
- dbname.invoke(ds, args);
-
- // create the db if necessary
- Method create = nsDataSource.getMethod("setCreateDatabase", methodParams);
- args = new Object[] {"create"};
- create.invoke(ds, args);
-
- // set the user
- Method setuser = nsDataSource.getMethod("setUser", methodParams);
- args = new Object[] { props.getProperty("db.user", System.getProperty("user.name")) };
- setuser.invoke(ds, args);
-
- // optionally set the pw
- Method setpw = nsDataSource.getMethod("setPassword", methodParams);
- args = new Object[] { props.getProperty("db.password") };
- if (args[0] != null)
- setpw.invoke(ds, args);
-
- return ds;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/Person.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/Person.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/Person.java
deleted file mode 100644
index bb57629..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/Person.java
+++ /dev/null
@@ -1,37 +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.jdbc;
-
-/**
- * A Person object for the sample.
- */
-public class Person {
- int id;
- String firstName;
- String lastName;
- Person(int id, String first, String last) {
- this.id = id;
- this.firstName = first;
- this.lastName = last;
- }
- public String toString() {
- return String.format("id=%d first=%s last=%s",
- id, firstName, lastName);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonData.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonData.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonData.java
deleted file mode 100644
index f7f1211..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonData.java
+++ /dev/null
@@ -1,96 +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.jdbc;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.stream.Collectors;
-
-/**
- * Utilities for loading the sample's person data.
- */
-public class PersonData {
-
- /**
- * Load the person data from the path specified by the "persondata.path"
- * property.
- * @param props configuration properties
- * @return the loaded person data
- * @throws Exception on failure
- */
- public static List<Person> loadPersonData(Properties props) throws Exception {
- String pathname = props.getProperty("persondata.path");
- List<Person> persons = new ArrayList<>();
- Path path = new File(pathname).toPath();
- try (BufferedReader br = Files.newBufferedReader(path)) {
- int lineno = 0;
- String line;
- while ((line = br.readLine()) != null) {
- lineno++;
- Object[] fields = parseLine(line, lineno, pathname);
- if (fields == null)
- continue;
- persons.add(new Person((Integer)fields[0], (String)fields[1], (String)fields[2]));
- }
- }
- return persons;
- }
-
- private static Object[] parseLine(String line, int lineno, String pathname) {
- line = line.trim();
- if (line.startsWith("#"))
- return null;
-
- // id,firstName,lastName
- String[] items = line.split(",");
- if (items.length < 3)
- throw new IllegalArgumentException("Invalid data on line "+lineno+" in "+pathname);
- int id;
- try {
- id = new Integer(items[0]);
- if (id < 1)
- throw new IllegalArgumentException("Invalid data on line "+lineno+" in "+pathname);
- }
- catch (NumberFormatException e) {
- throw new IllegalArgumentException("Invalid data on line "+lineno+" in "+pathname);
- }
-
- Object[] fields = new Object[3];
- fields[0] = id;
- fields[1] = items[1].trim();
- fields[2] = items[2].trim();
- return fields;
- }
-
- /**
- * Convert a {@code List<Person>} to a {@code List<PersonId>}
- * @param persons the person list
- * @return the person id list
- */
- public static List<PersonId> toPersonIds(List<Person> persons) {
- return persons.stream()
- .map(person -> new PersonId(person.id))
- .collect(Collectors.toList());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonId.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonId.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonId.java
deleted file mode 100644
index 218a027..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/PersonId.java
+++ /dev/null
@@ -1,32 +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.jdbc;
-
-/**
- * Another class containing a person id for the sample.
- */
-public class PersonId {
- int id;
- PersonId(int id) {
- this.id = id;
- }
- public String toString() {
- return String.format("id=%d", id);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleReaderApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleReaderApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleReaderApp.java
deleted file mode 100644
index 006b459..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleReaderApp.java
+++ /dev/null
@@ -1,102 +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.jdbc;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.edgent.connectors.jdbc.JdbcStreams;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A simple JDBC connector sample demonstrating streaming read access
- * of a dbms table and creating stream tuples from the results.
- */
-public class SimpleReaderApp {
- private final Properties props;
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to jdbc.properties file");
- SimpleReaderApp reader = new SimpleReaderApp(args[0]);
- reader.run();
- }
-
- /**
- * @param jdbcPropsPath pathname to properties file
- */
- SimpleReaderApp(String jdbcPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(jdbcPropsPath).toPath()));
- }
-
- /**
- * Create a topology for the writer application and run it.
- */
- private void run() throws Exception {
- DirectProvider tp = new DirectProvider();
-
- // build the application/topology
-
- Topology t = tp.newTopology("jdbcSampleWriter");
-
- // Create the JDBC connector
- JdbcStreams myDb = new JdbcStreams(t,
- () -> DbUtils.getDataSource(props),
- dataSource -> dataSource.getConnection());
-
- // Create a sample stream of tuples containing a person id
- List<PersonId> personIdList = PersonData.toPersonIds(PersonData.loadPersonData(props));
- personIdList.add(new PersonId(99999));
- TStream<PersonId> personIds = t.collection(personIdList);
-
- // For each tuple on the stream, read info from the db table
- // using the "id", and create a Person tuple on the result stream.
- TStream<Person> persons = myDb.executeStatement(personIds,
- () -> "SELECT id, firstname, lastname FROM persons WHERE id = ?",
- (personId,stmt) -> stmt.setInt(1, personId.id),
- (personId,rSet,exc,resultStream) -> {
- if (exc != null) {
- // some failure processing this tuple. an error was logged.
- System.err.println("Unable to process id="+personId+": "+exc);
- return;
- }
- if (rSet.next()) {
- resultStream.accept(
- new Person(rSet.getInt("id"),
- rSet.getString("firstname"),
- rSet.getString("lastname")));
- }
- else {
- System.err.println("Unknown person id="+personId.id);
- }
- }
- );
-
- // print out Person tuples as they are retrieved
- persons.sink(person -> System.out.println("retrieved person: "+person));
-
- // run the application / topology
- 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/jdbc/SimpleWriterApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleWriterApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleWriterApp.java
deleted file mode 100644
index 018c97b..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/SimpleWriterApp.java
+++ /dev/null
@@ -1,85 +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.jdbc;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.Properties;
-
-import org.apache.edgent.connectors.jdbc.JdbcStreams;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * A simple JDBC connector sample demonstrating streaming write access
- * of a dbms to add stream tuples to a table.
- */
-public class SimpleWriterApp {
- private final Properties props;
-
- public static void main(String[] args) throws Exception {
- if (args.length != 1)
- throw new Exception("missing pathname to jdbc.properties file");
- SimpleWriterApp writer = new SimpleWriterApp(args[0]);
- DbUtils.initDb(DbUtils.getDataSource(writer.props));
- writer.run();
- }
-
- /**
- * @param jdbcPropsPath pathname to properties file
- */
- SimpleWriterApp(String jdbcPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(jdbcPropsPath).toPath()));
- }
-
- /**
- * Create a topology for the writer application and run it.
- */
- private void run() throws Exception {
- DirectProvider tp = new DirectProvider();
-
- // build the application/topology
-
- Topology t = tp.newTopology("jdbcSampleWriter");
-
- // Create the JDBC connector
- JdbcStreams myDb = new JdbcStreams(t,
- () -> DbUtils.getDataSource(props),
- dataSource -> dataSource.getConnection());
-
- // Create a sample stream of Person tuples
- TStream<Person> persons = t.collection(PersonData.loadPersonData(props));
-
- // Write stream tuples to a table.
- myDb.executeStatement(persons,
- () -> "INSERT INTO persons VALUES(?,?,?)",
- (person,stmt) -> {
- System.out.println("Inserting into persons table: person "+person);
- stmt.setInt(1, person.id);
- stmt.setString(2, person.firstName);
- stmt.setString(3, person.lastName);
- }
- );
-
- // run the application / topology
- 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/jdbc/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/package-info.java
deleted file mode 100644
index 4e88b77..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/jdbc/package-info.java
+++ /dev/null
@@ -1,32 +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/jdbc/package-summary.html">
- * JDBC stream connector</a>.
- * <p>
- * See <edgent-release>/scripts/connectors/jdbc/README to run the samples.
- * <p>
- * The following samples are provided:
- * <ul>
- * <li>SimpleReaderApp.java - a simple dbms reader application topology</li>
- * <li>SimpleWriterApp.java - a simple dbms writer application topology</li>
- * </ul>
- */
-package org.apache.edgent.samples.connectors.jdbc;
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/KafkaClient.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/KafkaClient.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/KafkaClient.java
deleted file mode 100644
index 7d5a530..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/KafkaClient.java
+++ /dev/null
@@ -1,144 +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.kafka;
-
-import org.apache.edgent.samples.connectors.Options;
-
-/**
- * Demonstrate integrating with the Apache Kafka messaging system
- * <a href="http://kafka.apache.org">http://kafka.apache.org</a>.
- * <p>
- * {@link org.apache.edgent.connectors.kafka.KafkaProducer KafkaProducer} is
- * a connector used to create a bridge between topology streams
- * and publishing to Kafka topics.
- * <p>
- * {@link org.apache.edgent.connectors.kafka.KafkaConsumer KafkaConsumer} is
- * a connector used to create a bridge between topology streams
- * and subscribing to Kafka topics.
- * <p>
- * The client either publishes messages to a topic or
- * subscribes to the topic and reports the messages received.
- * <p>
- * By default, a running Kafka cluster with the following
- * characteristics is assumed:
- * <ul>
- * <li>{@code bootstrap.servers="localhost:9092"}</li>
- * <li>{@code zookeeper.connect="localhost:2181"}</li>
- * <li>kafka topic {@code "kafkaSampleTopic"} exists</li>
- * </ul>
- * <p>
- * See the Apache Kafka link above for information about setting up a Kafka
- * cluster as well as creating a topic.
- * <p>
- * This may be executed from as:
- * <UL>
- * <LI>
- * {@code java -cp samples/lib/org.apache.edgent.samples.connectors.kafka.jar
- * org.apache.edgent.samples.connectors.kafka.KafkaClient -h
- * } - Run directly from the command line.
- * </LI>
- * </UL>
- * <UL>
- * <LI>
- * An application execution within your IDE once you set the class path to include the correct jars.</LI>
- * </UL>
- */
-public class KafkaClient {
- private static final String usage = "usage: "
- + "\n" + "[-v] [-h]"
- + "\n" + "pub | sub"
- + "\n" + "[bootstrap.servers=<value>]"
- + "\n" + "[zookeeper.connect=<value>]"
- + "\n" + "[group.id=<value>]"
- + "\n" + "[pubcnt=<value>]"
- ;
-
- public static void main(String[] args) throws Exception {
- Options options = processArgs(args);
- if (options == null)
- return;
-
- Runner.run(options);
- }
-
- private static Options processArgs(String[] args) {
- Options options = new Options();
- initHandlers(options);
- try {
- options.processArgs(args);
- }
- catch (Exception e) {
- System.err.println(e);
- System.out.println(usage);
- return null;
- }
-
- if ((Boolean)options.get(OPT_HELP)) {
- System.out.println(usage);
- return null;
- }
-
- if (!(Boolean)options.get(OPT_PUB) && !(Boolean)options.get(OPT_SUB)) {
- System.err.println(String.format("Missing argument '%s' or '%s'.", OPT_PUB, OPT_SUB));
- System.out.println(usage);
- return null;
- }
-
- String[] announceOpts = new String[] {
- };
- if ((Boolean)options.get(OPT_VERBOSE))
- announceOpts = options.getAll().stream().map(e -> e.getKey()).toArray(String[]::new);
- for (String opt : announceOpts) {
- Object value = options.get(opt);
- if (value != null) {
- if (opt.toLowerCase().contains("password"))
- value = "*****";
- System.out.println("Using "+opt+"="+value);
- }
- }
-
- return options;
- }
-
- static final String OPT_VERBOSE = "-v";
- static final String OPT_HELP = "-h";
- static final String OPT_PUB = "pub";
- static final String OPT_SUB = "sub";
- static final String OPT_BOOTSTRAP_SERVERS = "bootstrap.servers";
- static final String OPT_ZOOKEEPER_CONNECT = "zookeeper.connect";
- static final String OPT_GROUP_ID = "group.id";
- static final String OPT_TOPIC = "topic";
- static final String OPT_PUB_CNT = "pubcnt";
-
- private static void initHandlers(Options opts) {
- // options for which we have a default
- opts.addHandler(OPT_HELP, null, false);
- opts.addHandler(OPT_VERBOSE, null, false);
- opts.addHandler(OPT_PUB, null, false);
- opts.addHandler(OPT_SUB, null, false);
- opts.addHandler(OPT_BOOTSTRAP_SERVERS, v -> v, "localhost:9092");
- opts.addHandler(OPT_ZOOKEEPER_CONNECT, v -> v, "localhost:2181");
- opts.addHandler(OPT_TOPIC, v -> v, "kafkaSampleTopic");
- opts.addHandler(OPT_PUB_CNT, v -> Integer.valueOf(v), -1);
-
- // optional options (no default value)
- opts.addHandler(OPT_GROUP_ID, v -> v);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/PublisherApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/PublisherApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/PublisherApp.java
deleted file mode 100644
index 6746a7d..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/PublisherApp.java
+++ /dev/null
@@ -1,81 +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.kafka;
-
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_BOOTSTRAP_SERVERS;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_PUB_CNT;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_TOPIC;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.samples.connectors.MsgSupplier;
-import org.apache.edgent.samples.connectors.Options;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.edgent.topology.TopologyProvider;
-
-import org.apache.edgent.connectors.kafka.KafkaProducer;
-
-/**
- * A Kafka producer/publisher topology application.
- */
-public class PublisherApp {
- private final TopologyProvider tp;
- private final Options options;
-
- /**
- * @param tp the TopologyProvider to use.
- * @param options
- */
- PublisherApp(TopologyProvider tp, Options options) {
- this.tp = tp;
- this.options = options;
- }
-
- /**
- * Create a topology for the publisher application.
- * @return the Topology
- */
- public Topology buildAppTopology() {
- Topology t = tp.newTopology("kafkaClientPublisher");
-
- // Create a sample stream of tuples to publish
- TStream<String> msgs = t.poll(new MsgSupplier(options.get(OPT_PUB_CNT)),
- 1L, TimeUnit.SECONDS);
-
- // Create the KafkaProducer broker connector
- Map<String,Object> config = newConfig();
- KafkaProducer kafka = new KafkaProducer(t, () -> config);
-
- // Publish the stream to the topic. The String tuple is the message value.
- kafka.publish(msgs, options.get(OPT_TOPIC));
-
- return t;
- }
-
- private Map<String,Object> newConfig() {
- Map<String,Object> config = new HashMap<>();
- // required kafka configuration items
- config.put("bootstrap.servers", options.get(OPT_BOOTSTRAP_SERVERS));
- return config;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/README
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/README b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/README
deleted file mode 100644
index 6554f8b..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/README
+++ /dev/null
@@ -1,26 +0,0 @@
-Sample Kafka Publisher and Subscriber topology applications.
-
-By default the samples assume the following kafka broker configuration:
-- bootstrap.servers="localhost:9092"
-- zookeeper.connect="localhost:2181"
-- kafka topic "kafkaSampleTopic" exists
-- no authentication
-
-See http://kafka.apache.org for the code and setup information for
-a Kafka broker.
-
-see scripts/connectors/kafka/README to run them
-
-The simple sample
------------------
-
-SimplePublisherApp.java - build and run the simple publisher application topology
-SimpleSubscriberApp.java - build and run the simple subscriber application topology
-
-The fully configurable client
------------------------------
-
-Runner.java - build and run the publisher or subscriber
-PublisherApp.java - build the publisher application topology
-SubscriberApp.java - build the subscriber application topology
-KafkaClient.java - the client's command line interface
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/Runner.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/Runner.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/Runner.java
deleted file mode 100644
index 2ffccfc..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/Runner.java
+++ /dev/null
@@ -1,68 +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.kafka;
-
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_BOOTSTRAP_SERVERS;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_PUB;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_TOPIC;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_ZOOKEEPER_CONNECT;
-
-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();
- }
-
- // Submit the app/topology; send or receive the messages.
- System.out.println(
- "Using Kafka cluster at bootstrap.servers="
- + options.get(OPT_BOOTSTRAP_SERVERS)
- + " zookeeper.connect=" + options.get(OPT_ZOOKEEPER_CONNECT)
- + "\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);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimplePublisherApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimplePublisherApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimplePublisherApp.java
deleted file mode 100644
index a8b9492..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimplePublisherApp.java
+++ /dev/null
@@ -1,99 +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.kafka;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-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;
-
-import org.apache.edgent.connectors.kafka.KafkaProducer;
-
-/**
- * A simple Kafka 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 kafka.properties file");
- SimplePublisherApp publisher = new SimplePublisherApp(args[0]);
- publisher.run();
- }
-
- /**
- * @param kafkaPropsPath pathname to properties file
- */
- SimplePublisherApp(String kafkaPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(kafkaPropsPath).toPath()));
- topic = props.getProperty("topic");
- }
-
- private Map<String,Object> createKafkaConfig() {
- Map<String,Object> kafkaConfig = new HashMap<>();
- kafkaConfig.put("bootstrap.servers", props.get("bootstrap.servers"));
- return kafkaConfig;
- }
-
- /**
- * 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("kafkaSamplePublisher");
-
- // Create the Kafka Producer broker connector
- Map<String,Object> kafkaConfig = createKafkaConfig();
- KafkaProducer kafka = new KafkaProducer(t, () -> kafkaConfig);
-
- // 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.
- kafka.publish(msgs, topic);
-
- // 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/kafka/SimpleSubscriberApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimpleSubscriberApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimpleSubscriberApp.java
deleted file mode 100644
index 7cef424..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SimpleSubscriberApp.java
+++ /dev/null
@@ -1,95 +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.kafka;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-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;
-
-import org.apache.edgent.connectors.kafka.KafkaConsumer;
-
-/**
- * A simple Kafka 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 kafka.properties file");
- SimpleSubscriberApp subscriber = new SimpleSubscriberApp(args[0]);
- subscriber.run();
- }
-
- /**
- * @param kafkaPropsPath pathname to properties file
- */
- SimpleSubscriberApp(String kafkaPropsPath) throws Exception {
- props = new Properties();
- props.load(Files.newBufferedReader(new File(kafkaPropsPath).toPath()));
- topic = props.getProperty("topic");
- }
-
- private Map<String,Object> createKafkaConfig() {
- Map<String,Object> kafkaConfig = new HashMap<>();
- kafkaConfig.put("zookeeper.connect", props.get("zookeeper.connect"));
- // for the sample, be insensitive to old/multiple consumers for
- // the topic/groupId hanging around
- kafkaConfig.put("group.id",
- "kafkaSampleConsumer_" + Util.simpleTS().replaceAll(":", ""));
- return kafkaConfig;
- }
-
- /**
- * 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("kafkaSampleSubscriber");
-
- // Create the Kafka Consumer broker connector
- Map<String,Object> kafkaConfig = createKafkaConfig();
- KafkaConsumer kafka = new KafkaConsumer(t, () -> kafkaConfig);
-
- // Subscribe to the topic and create a stream of messages
- TStream<String> msgs = kafka.subscribe(rec -> rec.value(), topic);
-
- // 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/kafka/SubscriberApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SubscriberApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SubscriberApp.java
deleted file mode 100644
index 7405f39..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/SubscriberApp.java
+++ /dev/null
@@ -1,91 +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.kafka;
-
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_GROUP_ID;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_TOPIC;
-import static org.apache.edgent.samples.connectors.kafka.KafkaClient.OPT_ZOOKEEPER_CONNECT;
-
-import java.util.HashMap;
-import java.util.Map;
-
-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;
-
-import org.apache.edgent.connectors.kafka.KafkaConsumer;
-
-/**
- * A Kafka consumer/subscriber topology application.
- */
-public class SubscriberApp {
- private final TopologyProvider tp;
- private final Options options;
- private final String uniq = Util.simpleTS();
-
- /**
- * @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("kafkaClientSubscriber");
-
- // Create the KafkaConsumer broker connector
- Map<String,Object> config = newConfig(t);
- KafkaConsumer kafka = new KafkaConsumer(t, () -> config);
-
- System.out.println("Using Kafka consumer group.id "
- + config.get(OPT_GROUP_ID));
-
- // Subscribe to the topic and create a stream of messages
- TStream<String> msgs = kafka.subscribe(rec -> rec.value(),
- (String)options.get(OPT_TOPIC));
-
- // Process the received msgs - just print them out
- msgs.sink(tuple -> System.out.println(
- String.format("[%s] received: %s", Util.simpleTS(), tuple)));
-
- return t;
- }
-
- private Map<String,Object> newConfig(Topology t) {
- Map<String,Object> config = new HashMap<>();
- // required kafka configuration items
- config.put("zookeeper.connect", options.get(OPT_ZOOKEEPER_CONNECT));
- config.put("group.id", options.get(OPT_GROUP_ID, newGroupId(t.getName())));
- return config;
- }
-
- private String newGroupId(String name) {
- // be insensitive to old consumers for the topic/groupId hanging around
- String groupId = name + "_" + uniq.replaceAll(":", "");
- return groupId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/package-info.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/package-info.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/package-info.java
deleted file mode 100644
index 761d053..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/kafka/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/kafka/package-summary.html">
- * Apache Kafka stream connector</a>.
- * <p>
- * See <edgent-release>/scripts/connectors/kafka/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.kafka;
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/MqttClient.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/MqttClient.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/MqttClient.java
deleted file mode 100644
index 9cf6c37..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/MqttClient.java
+++ /dev/null
@@ -1,183 +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 org.apache.edgent.samples.connectors.Options;
-
-/**
- * Demonstrate integrating with the MQTT messaging system
- * <a href="http://mqtt.org">http://mqtt.org</a>.
- * <p>
- * {@link org.apache.edgent.connectors.mqtt.MqttStreams MqttStreams} is
- * a connector used to create a bridge between topology streams
- * and an MQTT broker.
- * <p>
- * The client either publishes some messages to a MQTT topic
- * or subscribes to the topic and reports the messages received.
- * <p>
- * By default, a running MQTT broker with the following
- * characteristics is assumed:
- * <ul>
- * <li>the broker's connection is {@code tcp://localhost:1883}</li>
- * <li>the broker is configured for no authentication</li>
- * </ul>
- * <p>
- * See the MQTT link above for information about setting up a MQTT broker.
- * <p>
- * This may be executed as:
- * <UL>
- * <LI>
- * {@code java -cp samples/lib/org.apache.edgent.samples.connectors.mqtt.jar
- * org.apache.edgent.samples.connectors.mqtt.MqttClient -h
- * } - Run directly from the command line.
- * </LI>
- * <LI>
- * Specify absolute pathnames if using the {@code trustStore}
- * or {@code keyStore} arguments.
- * </LI>
- * <LI>
- * An application execution within your IDE once you set the class path to include the correct jars.
- * </LI>
- * </UL>
- */
-public class MqttClient {
- private static final String usage = "usage: "
- + "\n" + "[-v] [-h]"
- + "\n" + "pub | sub"
- + "\n" + "[serverURI=<value>]"
- + "\n" + "[clientId=<value>]"
- + "\n" + "[cleanSession=<true|false>]"
- + "\n" + "[topic=<value>] [qos=<value>]"
- + "\n" + "[retain]"
- + "\n" + "[pubcnt=<value>]"
- + "\n" + "[cnTimeout=<value>]"
- + "\n" + "[actionTimeoutMillis=<value>]"
- + "\n" + "[idleTimeout=<value>]"
- + "\n" + "[idleReconnectInterval=<value>]"
- + "\n" + "[userID=<value>] [password=<value>]"
- + "\n" + "[trustStore=<value>] [trustStorePassword=<value>]"
- + "\n" + "[keyStore=<value>] [keyStorePassword=<value>]"
- ;
-
- public static void main(String[] args) throws Exception {
- Options options = processArgs(args);
- if (options == null)
- return;
-
- Runner.run(options);
- }
-
- private static Options processArgs(String[] args) {
- Options options = new Options();
- initHandlers(options);
- try {
- options.processArgs(args);
- }
- catch (Exception e) {
- System.err.println(e);
- System.out.println(usage);
- return null;
- }
-
- if ((Boolean)options.get(OPT_HELP)) {
- System.out.println(usage);
- return null;
- }
-
- if (!(Boolean)options.get(OPT_PUB) && !(Boolean)options.get(OPT_SUB)) {
- System.err.println(String.format("Missing argument '%s' or '%s'.", OPT_PUB, OPT_SUB));
- System.out.println(usage);
- return null;
- }
-
- if (options.get(OPT_PASSWORD) != null)
- options.put(OPT_USER_ID, options.get(OPT_USER_ID, System.getProperty("user.name")));
-
- String[] announceOpts = new String[] {
- OPT_USER_ID,
- OPT_PASSWORD,
- OPT_TRUST_STORE,
- OPT_TRUST_STORE_PASSWORD,
- OPT_KEY_STORE,
- OPT_KEY_STORE_PASSWORD
- };
- if ((Boolean)options.get(OPT_VERBOSE))
- announceOpts = options.getAll().stream().map(e -> e.getKey()).toArray(String[]::new);
- for (String opt : announceOpts) {
- Object value = options.get(opt);
- if (value != null) {
- if (opt.toLowerCase().contains("password"))
- value = "*****";
- System.out.println("Using "+opt+"="+value);
- }
- }
-
- return options;
- }
-
- static final String OPT_VERBOSE = "-v";
- static final String OPT_HELP = "-h";
- static final String OPT_PUB = "pub";
- static final String OPT_SUB = "sub";
- static final String OPT_SERVER_URI = "serverURI";
- static final String OPT_CLIENT_ID = "clientId";
- static final String OPT_CN_TIMEOUT_SEC = "cnTimeout";
- static final String OPT_ACTION_TIMEOUT_MILLIS = "actionTimeoutMillis";
- static final String OPT_QOS = "qos";
- static final String OPT_TOPIC = "topic";
- static final String OPT_CLEAN_SESSION = "cleanSession";
- static final String OPT_RETAIN = "retain";
- static final String OPT_USER_ID = "userID";
- static final String OPT_PASSWORD = "password";
- static final String OPT_TRUST_STORE = "trustStore";
- static final String OPT_TRUST_STORE_PASSWORD = "trustStorePassword";
- static final String OPT_KEY_STORE = "keyStore";
- static final String OPT_KEY_STORE_PASSWORD = "keyStorePassword";
- static final String OPT_PUB_CNT = "pubcnt";
- static final String OPT_IDLE_TIMEOUT_SEC = "idleTimeout";
- static final String OPT_IDLE_RECONNECT_INTERVAL_SEC = "idleReconnectInterval";
-
- private static void initHandlers(Options opts) {
- // options for which we have a default
- opts.addHandler(OPT_HELP, null, false);
- opts.addHandler(OPT_VERBOSE, null, false);
- opts.addHandler(OPT_PUB, null, false);
- opts.addHandler(OPT_SUB, null, false);
- opts.addHandler(OPT_SERVER_URI, v -> v, "tcp://localhost:1883");
- opts.addHandler(OPT_TOPIC, v -> v, "mqttSampleTopic");
- opts.addHandler(OPT_RETAIN, null, false);
- opts.addHandler(OPT_PUB_CNT, v -> Integer.valueOf(v), -1);
- opts.addHandler(OPT_QOS, v -> Integer.valueOf(v), 0);
-
- // optional options (no default value)
- opts.addHandler(OPT_CLIENT_ID, v -> v);
- opts.addHandler(OPT_CN_TIMEOUT_SEC, v -> Integer.valueOf(v));
- opts.addHandler(OPT_ACTION_TIMEOUT_MILLIS, v -> Long.valueOf(v));
- opts.addHandler(OPT_CLEAN_SESSION, v -> Boolean.valueOf(v));
- opts.addHandler(OPT_USER_ID, v -> v);
- opts.addHandler(OPT_PASSWORD, v -> v);
- opts.addHandler(OPT_TRUST_STORE, v -> v);
- opts.addHandler(OPT_TRUST_STORE_PASSWORD, v -> v);
- opts.addHandler(OPT_KEY_STORE, v -> v);
- opts.addHandler(OPT_KEY_STORE_PASSWORD, v -> v);
- opts.addHandler(OPT_IDLE_TIMEOUT_SEC, v -> Integer.valueOf(v));
- opts.addHandler(OPT_IDLE_RECONNECT_INTERVAL_SEC, v -> Integer.valueOf(v));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/PublisherApp.java
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/PublisherApp.java b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/PublisherApp.java
deleted file mode 100644
index 4be6ce5..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/PublisherApp.java
+++ /dev/null
@@ -1,74 +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_PUB_CNT;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_QOS;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_RETAIN;
-import static org.apache.edgent.samples.connectors.mqtt.MqttClient.OPT_TOPIC;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.connectors.mqtt.MqttConfig;
-import org.apache.edgent.connectors.mqtt.MqttStreams;
-import org.apache.edgent.samples.connectors.MsgSupplier;
-import org.apache.edgent.samples.connectors.Options;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.edgent.topology.TopologyProvider;
-
-/**
- * A MQTT publisher topology application.
- */
-public class PublisherApp {
- private final TopologyProvider tp;
- private final Options options;
-
- /**
- * @param tp the TopologyProvider to use.
- * @param options
- */
- PublisherApp(TopologyProvider tp, Options options) {
- this.tp = tp;
- this.options = options;
- }
-
- /**
- * Create a topology for the publisher application.
- * @return the Topology
- */
- public Topology buildAppTopology() {
- Topology t = tp.newTopology("mqttClientPublisher");
-
- // Create a sample stream of tuples to publish
- TStream<String> msgs = t.poll(new MsgSupplier(options.get(OPT_PUB_CNT)),
- 1L, TimeUnit.SECONDS);
-
- // Create the MQTT broker connector
- MqttConfig config= Runner.newConfig(options);
- MqttStreams mqtt = new MqttStreams(t, () -> config);
-
- // Publish the stream to the topic. The String tuple is the message value.
- mqtt.publish(msgs, options.get(OPT_TOPIC),
- options.get(OPT_QOS), options.get(OPT_RETAIN));
-
- 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/README
----------------------------------------------------------------------
diff --git a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/README b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/README
deleted file mode 100644
index 7760f50..0000000
--- a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/mqtt/README
+++ /dev/null
@@ -1,24 +0,0 @@
-Sample MQTT Publisher and Subscriber topology applications.
-
-By default, the following MQTT broker configuration is assumed:
-- the broker's connection URL is tcp://localhost:1883
-- the broker is configured for no authentication
-
-See http://mqtt.org for the code and setup information for
-a mqtt broker.
-
-see scripts/connectors/mqtt/README to run them
-
-The simple sample
------------------
-
-SimplePublisherApp.java - build and run the simple publisher application topology
-SimpleSubscriberApp.java - build and run the simple subscriber application topology
-
-The fully configurable clients
-------------------------------
-
-Runner.java - build and run the publisher or subscriber
-PublisherApp.java - build the publisher application topology
-SubscriberApp.java - build the subscriber application topology
-MqttClient.java - the client's command line interface
[8/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
remove samples (now in separate repo)
Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/a7aeb2b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/a7aeb2b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/a7aeb2b4
Branch: refs/heads/develop
Commit: a7aeb2b4f972df6e6a74a0a7ded328391deab722
Parents: 58b8895
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Thu Nov 23 10:31:10 2017 -0500
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Thu Nov 23 10:31:10 2017 -0500
----------------------------------------------------------------------
samples/.gitignore | 34 --
.../.mvn/wrapper/MavenWrapperDownloader.java | 110 -----
samples/.mvn/wrapper/maven-wrapper.properties | 20 -
samples/APPLICATION_DEVELOPMENT.md | 179 --------
samples/LICENSE | 201 ---------
samples/NOTICE | 11 -
samples/README.md | 228 ----------
samples/apps/README.md | 3 -
samples/apps/pom.xml | 75 ----
samples/apps/scripts/sensorAnalytics/README | 27 --
.../scripts/sensorAnalytics/runDeviceComms.sh | 31 --
.../sensorAnalytics/runSensorAnalytics.sh | 29 --
.../sensorAnalytics/sensorAnalytics.properties | 82 ----
.../samples/apps/AbstractApplication.java | 130 ------
.../samples/apps/AbstractIotpApplication.java | 113 -----
.../samples/apps/ApplicationUtilities.java | 255 ------------
.../apache/edgent/samples/apps/JsonTuples.java | 196 ---------
.../samples/apps/TopologyProviderFactory.java | 63 ---
...eetManagementAnalyticsClientApplication.java | 68 ---
.../GpsAnalyticsApplication.java | 214 ----------
.../ObdAnalyticsApplication.java | 39 --
.../apps/fleetManagement/SimulatedGeofence.java | 36 --
.../apps/mqtt/AbstractMqttApplication.java | 121 ------
.../samples/apps/mqtt/DeviceCommsApp.java | 114 -----
.../edgent/samples/apps/mqtt/package-info.java | 25 --
.../edgent/samples/apps/package-info.java | 42 --
.../samples/apps/sensorAnalytics/Sensor1.java | 286 -------------
.../SensorAnalyticsApplication.java | 57 ---
.../apps/sensorAnalytics/package-info.java | 164 --------
samples/apps/src/main/resources/META-INF/NOTICE | 12 -
.../samples/apps/applicationTemplate.properties | 98 -----
samples/connectors/README.md | 3 -
samples/connectors/pom.xml | 80 ----
samples/connectors/scripts/file/README | 21 -
.../connectors/scripts/file/runfilesample.sh | 44 --
samples/connectors/scripts/iotp/README | 36 --
samples/connectors/scripts/iotp/device.cfg | 7 -
.../connectors/scripts/iotp/iotp-app-client.cfg | 25 --
.../scripts/iotp/iotp-device-sample.cfg | 10 -
.../scripts/iotp/iotp-gwdevice-sample.cfg | 17 -
.../scripts/iotp/run-iotp-app-client.sh | 47 ---
.../scripts/iotp/run-iotp-device-sample.sh | 45 --
.../scripts/iotp/run-iotp-gwdevice-sample.sh | 46 ---
.../scripts/iotp/runiotpquickstart.sh | 43 --
.../scripts/iotp/runiotpquickstart2.sh | 43 --
.../connectors/scripts/iotp/runiotpsensors.sh | 44 --
samples/connectors/scripts/jdbc/.gitignore | 3 -
samples/connectors/scripts/jdbc/README | 35 --
samples/connectors/scripts/jdbc/jdbc.properties | 4 -
samples/connectors/scripts/jdbc/persondata.txt | 4 -
.../connectors/scripts/jdbc/runjdbcsample.sh | 48 ---
samples/connectors/scripts/kafka/README | 39 --
samples/connectors/scripts/kafka/README-kafka | 25 --
.../connectors/scripts/kafka/kafka.properties | 6 -
.../connectors/scripts/kafka/runkafkaclient.sh | 31 --
.../connectors/scripts/kafka/runkafkasample.sh | 39 --
samples/connectors/scripts/mqtt/README | 37 --
samples/connectors/scripts/mqtt/mqtt.properties | 10 -
.../connectors/scripts/mqtt/runmqttclient.sh | 31 --
.../connectors/scripts/mqtt/runmqttsample.sh | 39 --
.../edgent/samples/connectors/MsgSupplier.java | 50 ---
.../edgent/samples/connectors/Options.java | 98 -----
.../apache/edgent/samples/connectors/Util.java | 75 ----
.../edgent/samples/connectors/elm327/Cmd.java | 76 ----
.../samples/connectors/elm327/Elm327Cmds.java | 75 ----
.../connectors/elm327/Elm327Streams.java | 70 ----
.../samples/connectors/elm327/Pids01.java | 141 -------
.../samples/connectors/elm327/package-info.java | 27 --
.../elm327/runtime/CommandExecutor.java | 118 ------
.../samples/connectors/file/FileReaderApp.java | 88 ----
.../samples/connectors/file/FileWriterApp.java | 94 -----
.../edgent/samples/connectors/file/README | 11 -
.../samples/connectors/file/package-info.java | 32 --
.../samples/connectors/iotp/IotpAppClient.java | 147 -------
.../connectors/iotp/IotpDeviceSample.java | 148 -------
.../connectors/iotp/IotpGWDeviceSample.java | 193 ---------
.../samples/connectors/iotp/IotpQuickstart.java | 88 ----
.../connectors/iotp/IotpQuickstart2.java | 118 ------
.../samples/connectors/iotp/IotpSensors.java | 164 --------
.../samples/connectors/iotp/package-info.java | 39 --
.../edgent/samples/connectors/jdbc/DbUtils.java | 140 -------
.../edgent/samples/connectors/jdbc/Person.java | 37 --
.../samples/connectors/jdbc/PersonData.java | 96 -----
.../samples/connectors/jdbc/PersonId.java | 32 --
.../connectors/jdbc/SimpleReaderApp.java | 102 -----
.../connectors/jdbc/SimpleWriterApp.java | 85 ----
.../samples/connectors/jdbc/package-info.java | 32 --
.../samples/connectors/kafka/KafkaClient.java | 144 -------
.../samples/connectors/kafka/PublisherApp.java | 81 ----
.../edgent/samples/connectors/kafka/README | 26 --
.../edgent/samples/connectors/kafka/Runner.java | 68 ---
.../connectors/kafka/SimplePublisherApp.java | 99 -----
.../connectors/kafka/SimpleSubscriberApp.java | 95 -----
.../samples/connectors/kafka/SubscriberApp.java | 91 ----
.../samples/connectors/kafka/package-info.java | 35 --
.../samples/connectors/mqtt/MqttClient.java | 183 --------
.../samples/connectors/mqtt/PublisherApp.java | 74 ----
.../edgent/samples/connectors/mqtt/README | 24 --
.../edgent/samples/connectors/mqtt/Runner.java | 116 ------
.../connectors/mqtt/SimplePublisherApp.java | 98 -----
.../connectors/mqtt/SimpleSubscriberApp.java | 90 ----
.../samples/connectors/mqtt/SubscriberApp.java | 72 ----
.../samples/connectors/mqtt/package-info.java | 35 --
.../samples/connectors/obd2/Obd2Streams.java | 145 -------
.../edgent/samples/connectors/package-info.java | 22 -
.../src/main/resources/META-INF/NOTICE | 12 -
samples/console/.gitignore | 2 -
samples/console/pom.xml | 49 ---
samples/console/run-sample.sh | 63 ---
.../samples/console/ConsoleWaterDetector.java | 412 -------------------
.../samples/console/HttpServerSample.java | 39 --
.../edgent/samples/console/package-info.java | 30 --
.../console/src/main/resources/META-INF/NOTICE | 12 -
samples/cron/.gitignore | 3 -
samples/cron/README.md | 35 --
samples/cron/mkcrontab.sh | 37 --
samples/cron/startapp.cron.template | 22 -
samples/cron/startapp.sh | 117 ------
samples/get-edgent-jars-project/.gitignore | 6 -
samples/get-edgent-jars-project/README.md | 54 ---
.../get-edgent-jars-project/get-edgent-jars.sh | 226 ----------
.../old-get-edgent-jars.sh | 254 ------------
.../get-edgent-jars-project/pom.xml.template | 148 -------
.../src/assembly/distribution.xml | 81 ----
.../src/main/resources/README | 12 -
samples/mvnw | 268 ------------
samples/mvnw.cmd | 159 -------
samples/package-app.sh | 112 -----
samples/pom.xml | 289 -------------
samples/scenarios/README.md | 69 ----
samples/scenarios/pom.xml | 84 ----
samples/scenarios/run-sample.sh | 64 ---
.../scenarios/iotp/IotpFullScenario.java | 92 -----
.../iotp/range/sensor/IotpRangeSensor.java | 219 ----------
.../scenarios/iotp/range/sensor/LED.java | 52 ---
.../iotp/range/sensor/RangeSensor.java | 104 -----
.../iotp/range/sensor/SimulatedRangeSensor.java | 42 --
.../src/main/resources/META-INF/NOTICE | 6 -
.../scenarios/iotp/range/sensor/device.cfg | 5 -
samples/src/main/xslt/classpath.xsl | 67 ---
.../.mvn/wrapper/MavenWrapperDownloader.java | 110 -----
.../.mvn/wrapper/maven-wrapper.properties | 20 -
samples/template/README.md | 45 --
samples/template/app-run.sh | 42 --
samples/template/mvnw | 268 ------------
samples/template/mvnw.cmd | 159 -------
samples/template/pom.xml | 296 -------------
.../java/com/mycompany/app/TemplateApp.java | 52 ---
.../java/com/mycompany/app/package-info.java | 24 --
.../template/src/main/resources/META-INF/NOTICE | 6 -
samples/topology/README.md | 30 --
samples/topology/pom.xml | 50 ---
samples/topology/run-sample.sh | 74 ----
.../CombiningStreamsProcessingResults.java | 168 --------
.../topology/DevelopmentMetricsSample.java | 64 ---
.../samples/topology/DevelopmentSample.java | 47 ---
.../topology/DevelopmentSampleJobMXBean.java | 85 ----
.../edgent/samples/topology/HelloEdgent.java | 48 ---
.../samples/topology/JobEventsSample.java | 165 --------
.../edgent/samples/topology/JobExecution.java | 124 ------
.../edgent/samples/topology/PeriodicSource.java | 65 ---
.../samples/topology/SensorsAggregates.java | 118 ------
.../samples/topology/SimpleFilterTransform.java | 57 ---
.../samples/topology/SplitWithEnumSample.java | 68 ---
.../edgent/samples/topology/StreamTags.java | 63 ---
.../edgent/samples/topology/TempSensor.java | 44 --
.../samples/topology/TempSensorApplication.java | 44 --
.../samples/topology/TerminateAfterNTuples.java | 67 ---
.../edgent/samples/topology/package-info.java | 24 --
.../topology/src/main/resources/META-INF/NOTICE | 12 -
samples/utils/README.md | 30 --
samples/utils/pom.xml | 60 ---
samples/utils/run-sample.sh | 63 ---
.../metrics/PeriodicSourceWithMetrics.java | 68 ---
.../samples/utils/metrics/SplitWithMetrics.java | 71 ----
.../edgent/samples/utils/sensor/GpsSensor.java | 75 ----
.../utils/sensor/HeartMonitorSensor.java | 60 ---
.../utils/sensor/PeriodicRandomSensor.java | 182 --------
.../utils/sensor/SimpleSimulatedSensor.java | 175 --------
.../utils/sensor/SimulatedGpsSensor.java | 104 -----
.../samples/utils/sensor/SimulatedSensors.java | 88 ----
.../sensor/SimulatedTemperatureSensor.java | 107 -----
.../utils/src/main/resources/META-INF/NOTICE | 12 -
183 files changed, 14579 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/.gitignore
----------------------------------------------------------------------
diff --git a/samples/.gitignore b/samples/.gitignore
deleted file mode 100644
index d555b80..0000000
--- a/samples/.gitignore
+++ /dev/null
@@ -1,34 +0,0 @@
-
-*.class
-
-# Local developers toolchain
-/toolchains-local.xml
-
-# Exclude the maven-wrapper.jar
-.mvn/wrapper/maven-wrapper.jar
-
-# More generated artifacts
-target/
-/reports
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.war
-*.ear
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-# IntelliJ Idea
-.idea/
-*.iml
-
-# Eclipse
-.classpath
-.project
-.settings/
-
-# Emacs
-*~
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/.mvn/wrapper/MavenWrapperDownloader.java
----------------------------------------------------------------------
diff --git a/samples/.mvn/wrapper/MavenWrapperDownloader.java b/samples/.mvn/wrapper/MavenWrapperDownloader.java
deleted file mode 100644
index 44f8e00..0000000
--- a/samples/.mvn/wrapper/MavenWrapperDownloader.java
+++ /dev/null
@@ -1,110 +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.
-*/
-
-import java.net.*;
-import java.io.*;
-import java.nio.channels.*;
-import java.util.Properties;
-
-public class MavenWrapperDownloader {
-
- /**
- * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
- */
- private static final String DEFAULT_DOWNLOAD_URL =
- "https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar";
-
- /**
- * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
- * use instead of the default one.
- */
- private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
- ".mvn/wrapper/maven-wrapper.properties";
-
- /**
- * Path where the maven-wrapper.jar will be saved to.
- */
- private static final String MAVEN_WRAPPER_JAR_PATH =
- ".mvn/wrapper/maven-wrapper.jar";
-
- /**
- * Name of the property which should be used to override the default download url for the wrapper.
- */
- private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
-
- public static void main(String args[]) {
- System.out.println("- Downloader started");
- File baseDirectory = new File(args[0]);
- System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
-
- // If the maven-wrapper.properties exists, read it and check if it contains a custom
- // wrapperUrl parameter.
- File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
- String url = DEFAULT_DOWNLOAD_URL;
- if(mavenWrapperPropertyFile.exists()) {
- FileInputStream mavenWrapperPropertyFileInputStream = null;
- try {
- mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
- Properties mavenWrapperProperties = new Properties();
- mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
- url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
- } catch (IOException e) {
- System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
- } finally {
- try {
- if(mavenWrapperPropertyFileInputStream != null) {
- mavenWrapperPropertyFileInputStream.close();
- }
- } catch (IOException e) {
- // Ignore ...
- }
- }
- }
- System.out.println("- Downloading from: : " + url);
-
- File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
- if(!outputFile.getParentFile().exists()) {
- if(!outputFile.getParentFile().mkdirs()) {
- System.out.println(
- "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
- }
- }
- System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
- try {
- downloadFileFromURL(url, outputFile);
- System.out.println("Done");
- System.exit(0);
- } catch (Throwable e) {
- System.out.println("- Error downloading");
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- private static void downloadFileFromURL(String urlString, File destination) throws Exception {
- URL website = new URL(urlString);
- ReadableByteChannel rbc;
- rbc = Channels.newChannel(website.openStream());
- FileOutputStream fos = new FileOutputStream(destination);
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- fos.close();
- rbc.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/.mvn/wrapper/maven-wrapper.properties
----------------------------------------------------------------------
diff --git a/samples/.mvn/wrapper/maven-wrapper.properties b/samples/.mvn/wrapper/maven-wrapper.properties
deleted file mode 100644
index 7e8f382..0000000
--- a/samples/.mvn/wrapper/maven-wrapper.properties
+++ /dev/null
@@ -1,20 +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.
-
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
-
-#wrapperUrl=https://repo1.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/APPLICATION_DEVELOPMENT.md
----------------------------------------------------------------------
diff --git a/samples/APPLICATION_DEVELOPMENT.md b/samples/APPLICATION_DEVELOPMENT.md
deleted file mode 100644
index 9e01074..0000000
--- a/samples/APPLICATION_DEVELOPMENT.md
+++ /dev/null
@@ -1,179 +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.
--->
-
-# Edgent Application Development, Packaging and Execution.
-
-To develop Edgent applications you will utilize the
-Edgent SDK/runtime jars and package your application
-artifacts for deploying to an edge device or gateway for execution.
-
-The Edgent SDK/runtime jars are published to the
-[ASF Nexus Repository](https://repository.apache.org/content/repositories/releases/)
-and the Maven Central Repository.
-Alternatively, you can build the Edgent SDK yourself from a source release
-and the resulting jars will be added to your local maven repository.
-
-There are a set of Edgent jars for each supported platform: java8, java7, and android.
-The maven artifact groupIds for the Edgent jars are:
-
-- `org.apache.edgent` - for java8,
-- `org.apache.edgent.java7`
-- `org.apache.edgent.android`
-
-Note, the Java package names for Edgent components do not incorporate
-the platform kind; the package names are the same regardless of the platform.
-
-See `JAVA_SUPPORT.md` for more information on artifact coordinates, etc.
-
-## Writing Your Application
-
-The Edgent API is most easily used by using Java8 lambda expressions.
-If you only want to deploy your Edgent application to a java8 environment
-then your application may use any java8 features it chooses. You compile
-and run against the Edgent java8 jars.
-
-If you want to deploy your Edgent application to a java7 or android
-environment, it's still easiest to write your application using the Edgent APIs
-with java8 lambda expressions. You compile with java8 but constrain
-your application to using java7 features plus java8 lambda expressions.
-The Retrolambda tool is used to convert your application's generated
-class files to java7.
-The Edgent java7 and android platform jars were created in that manner too.
-Your application would then be run against the appropriate
-Edgent platform jars.
-
-Alternatively you can forgo the use of lambda
-expressions and write your application in java7 and compile
-and run against the appropriate Edgent platform jars.
-
-For convenience it's easiest to build your Edgent application using
-maven-repository-enabled build tooling (e.g., maven, maven-enabled
-Eclipse or IntelliJ). The tooling transparently downloads the
-required Edgent jars from the maven repository if they aren't
-already present in your local maven repository.
-
-### Edgent Application Template
-
-You can clone the `template` project as a starting point for your
-Edgent application. See [samples/template/README.md](template/README.md).
-
-TODO: we would like to provide a maven Edgent Application archetype
-that users can use to create an application project template.
-
-### Using Non-maven-integrated Tooling
-
-If you can't or don't want to use maven-repository-enabled tooling
-you will need to get a local copy of the Edgent jars and their
-dependencies and add them to your compile classpath. This case
-is covered in subsequent sections.
-
-## Packaging and Execution
-
-Edgent doesn't provide any "deployment" mechanisms other than its primitive
-"register jar" feature (see the `IotProvider` javadoc). Generally, managing
-the deployment of application and Edgent jars to edge devices is left to
-others (as an example, the IBM Watson IoT Platform has device APIs to
-support "firmware" download/update).
-
-To run your Edgent application on an edge device, your application
-jar(s) need to be on the device. Additionally, the application's
-dependent Edgent jars (and their transitive dependencies) need to
-be on the device. It's unlikely the device will be able to retrieve
-the dependencies directly from a remote maven repository such as
-maven central.
-
-Here are three options for dealing with this.
-
-### Create an uber-jar for your application
-
-The uber jar is a standalone entity containing
-everything that's needed to run your application.
-
-The uber jar contains the application's classes and
-the application's dependent Edgent classes and their
-transitive dependencies.
-
-The template project's pom and
-the Edgent samples poms contain configuration information
-that generates an uber jar in addition to the standard
-application jar. Eclipse can also export an uber jar.
-
-### Separately manage the application and Edgent jars
-
-Copy the application's jars to the device.
-Get a copy of the Edgent jars and their dependencies
-onto the device. It's possible for multiple Edgent
-applications to share the Edgent jars.
-
-The Apache Edgent project does not release a
-binary bundle containing all of the Edgent jars
-and their dependencies. The binary artifacts
-are only released to maven central.
-
-See [samples/get-edgent-jars-project](get-edgent-jars-project/README.md)
-for a tool to get a copy of the Edgent jars.
-
-### Create an application package bundle
-
-The bundle is a standalone entity containing
-everything that's needed to run your application.
-
-The bundle is copied to the device and unpacked.
-A run script forms the appropriate `CLASSPATH`
-to the package's jars and starts the application.
-
-The supplied `package-app.sh` script creates an
-application bundle.
-
-The application bundle contains the application's jar,
-the application's dependent Edgent jars (as specified in
-the application's pom) and the Edgent jars' dependencies,
-and a run-app.sh script.
-
-The application's dependent Edgent runtime jars and
-their dependencies are retrieved from a local or remote
-maven repository.
-
-If the application's execution environment is
-java7 or android, use the appropriate script options
-to retrieve the appropriate Edgent platform jars for
-execution.
-
-The generated run-app.sh script configures the CLASSPATH
-and runs the application.
-
-E.g.,
-
-``` sh
-cd MyApp # the application's project directory
-package-app.sh --mainClass com.mycompany.app.MyApp --appjar target/my-app-1.0-SNAPSHOT.jar
-##### get the app specific dependencies...
-...
-##### create target/app-run.sh...
-##### create target/app-pkg.tar...
-##### Copy target/app-pkg.tar to the destination system"
-##### To run the app:"
-##### mkdir app-pkg"
-##### tar xf app-pkg.tar -C app-pkg"
-##### (cd app-pkg; ./app-run.sh)"
-```
-
-For more usage information:
-
-``` sh
-./package-app.sh -h
-```
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/LICENSE
----------------------------------------------------------------------
diff --git a/samples/LICENSE b/samples/LICENSE
deleted file mode 100644
index 8dada3e..0000000
--- a/samples/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed 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.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/NOTICE
----------------------------------------------------------------------
diff --git a/samples/NOTICE b/samples/NOTICE
deleted file mode 100644
index 9c9c1c3..0000000
--- a/samples/NOTICE
+++ /dev/null
@@ -1,11 +0,0 @@
-Apache Edgent
-Copyright 2016-2017 The Apache Software Foundation
-
-Apache Edgent is currently undergoing Incubation at the Apache Software Foundation.
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-===============================================================================
-
-Portions of this software were developed by IBM Corp.
-Copyright IBM Corp. 2015, 2016
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/README.md
----------------------------------------------------------------------
diff --git a/samples/README.md b/samples/README.md
deleted file mode 100644
index ba18312..0000000
--- a/samples/README.md
+++ /dev/null
@@ -1,228 +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.
--->
-
-# Quickstart
-
-You must have Java 8 installed on your system. Maven will be automatically
-downloaded and installed by the maven wrapper `mvnw`.
-
-Build the samples for Java 8
-```sh
-./mvnw clean package
-```
-
-Run the HelloEdgent sample
-```sh
-cd topology
-./run-sample.sh HelloEdgent # prints a hello message and terminates
- Hello
- Edgent!
- ...
-```
-
-# Overview
-
-The Edgent samples provide a starting point for jump starting your
-use of Edgent. See the _Samples Summary_ section for a list of the samples.
-
-The Edgent samples are organized into a few categories (subdirectories)
-and are a collection of maven projects. They can be built using maven
-or other maven-integrated tooling such as Eclipse.
-
-An Edgent application template maven project is supplied.
-It may be a useful starting point to clone for your application.
-The template has a standalone maven project pom, rather than a
-stylized one used by the rest of the samples.
-See [template/README.md](template/README.md).
-
-See [APPLICATION_DEVELOPMENT.md](APPLICATION_DEVELOPMENT.md) for general
-information on Edgent Application Development, Packaging and Execution.
-
-Additional information may also be found in
-Getting Started https://edgent.apache.org/docs/edgent-getting-started
-
-
-# Setup
-
-Once you have downloaded and unpacked the samples source bundle
-or cloned the the samples repository you need to download
-these additional development software tools.
-
-* Java 8 - The development setup assumes Java 8
-
-Maven is used as build tool and a maven-wrapper
-script (`mvwn` or `mvnw.bat`) is included.
-
-The maven-wrapper automatically downloads and installs the
-correct Maven version and use it. Besides this, there is no
-difference between using the `mvnw` command and the `mvn` command.
-
-You may also use a maven-integrated IDE with the samples.
-e.g., see the _Using Eclipse_ section below.
-
-The samples use Edgent SDK jars that have been released
-in a maven repository such as Maven Central.
-
-Alternatively, you can download the Edgent SDK sources and build them,
-populating your local maven repository. The samples
-will then use those Edgent SDK jars. Adjust the `edgent.version`
-property in the top level samples `pom.xml` accordingly.
-See [downloads](https://edgent.apache.org/docs/downloads)
-for downloading the Edgent SDK sources.
-
-# Building the Edgent samples
-
-By default Java8 class files are generated.
-Java7 platform class files are produced when the appropriate
-profile is specified.
-
-Currently, building and running the samples for the Android platform
-is not supported. Many samples happen to use the `DevelopmentProvider`,
-which is not supported on the Android platform.
-
-Build the samples
-```sh
-./mvnw clean package # -Pplatform-java7 as needed
-```
-
-A standard jar and uber jar are created for each sample category
-in the sample category's target directory: `<category>/target`.
-
-
-## Running the samples
-
-See the `README.md` in each sample category directory for information
-on running the samples.
-
-
-# Using Eclipse
-
-The Edgent Git repository and samples source release bundle contains
-Maven project definitions for the samples.
-
-Once you import the Maven projects into your workspace, builds
-in Eclipse use the same artifacts as the Maven command line tooling.
-Like the command line tooling, the jars for dependent projects
-are automatically downloaded to the local maven repository
-and used.
-
-If you want to use Eclipse to clone your fork, use the
-Eclipse Git Team Provider plugin
-
-1. From the Eclipse *File* menu, select *Import...*
-2. From the *Git* folder, select *Projects from Git* and click *Next*
-3. Select *Clone URI* to clone the remote repository. Click *Next*.
- + In the *Location* section, enter the URI of your fork in the *URI* field
- (e.g., `git@github.com:<username>/incubator-edgent.git`).
- The other fields will be populated automatically.
- Click *Next*. If required, enter your passphrase.
- + In the *Source Git Repository* window, select the branch
- (usually `master`) and click *Next*
- + Specify the directory where your local clone will be stored
- and click *Next*. The repository will be cloned.
- Note: You can build and run tests using Maven in this directory.
-4. In the *Select a wizard to use for importing projects* window, click *Cancel*.
- Then follow the steps below to import the Maven projects.
-
-
-Once you have cloned the Git repository to your machine or are working
-from an unpacked samples source release bundle, import the Maven projects
-into your workspace
-
-1. From the Eclipse *File* menu, select *Import...*
-2. From the *Maven* folder, select *Existing Maven Projects* and click *Next*
- + browse to the `samples` directory in the clone or source release directory
- and select it. A hierarchy of samples projects / pom.xml files will be
- listed and all selected.
- + Verify the *Add project(s) to working set* checkbox is checked
- + Click *Finish*. Eclipse starts the import process and builds the workspace.
-
-Top-level artifacts such as `README.md` are available under the
-`edgent-samples` project.
-
-Note: Specifics may change depending on your version of Eclipse or the
-Eclipse Maven or Git Team Provider.
-
-Once the samples projects have been imported you can run them from
-Eclipse in the usual manner. E.g.,
-
-1. From the Eclipse *Navigate* menu, select *Open Type*
- + enter type type name `HelloEdgent` and click *OK*
-2. right click on the `HelloEdgent` class name and from the context menu
- + click on *Run As*, then *Java application*.
- `HelloEdgent` runs and prints to the Console view.
-
-
-# Samples Summary
-
-<pre>
-HelloEdgent Basic mechanics of declaring a topology and executing
- it. Prints Hello Edgent! to standard output.
-
-TempSensorApplication A basic Edgent application used by the Edgent
- "Getting Started Guide":
- https://edgent.apache.org/docs/edgent-getting-started.html
-
-PeriodicSource Create a stream by polling a random number generator
- for a new value every second and then prints out the
- raw tuple value and a filtered and transformed stream.
-
-SensorAggregates Demonstrates partitioned window aggregation and
- filtering of simulated sensors that are bursty in
- nature, so that only intermittently is the data output
- to standard output.
-
-File Use the File stream connector to write a stream of
- tuples to files. Also watch a directory for new files
- and create a stream of tuples from the file contents.
-
-Iotp Use the IBM Watson IoT Platform connector to send
- simulated sensor readings to an IBM Watson IoT Platform
- instance as device events. Receive device commands.
-
-JDBC Use the JDBC stream connector to write a stream of
- tuples to an Apache Derby database table. Create a
- stream of tuples by reading a table.
-
-Kafka Use the Kafka stream connector to publish a stream of
- tuples to a Kafka topic. Create a stream of tuples by
- subscribing to a topic and receiving messages from it.
-
-MQTT Use the MQTT stream connector to publish a stream of
- tuples to a MQTT topic. Create a stream of tuples by
- subscribing to a topic and receiving messages from it.
-
-SensorAnalytics Demonstrates a more complex sample that includes
- configuration control, a device of one or more sensors
- and some typical analytics, use of MQTT for publishing
- results and receiving commands, local results logging,
- conditional stream tracing.
-</pre>
-
-Many other samples are provided but have not yet been noted above. Explore!
-
-# Licensing
-
-Apache Edgent samples are released under the Apache License Version 2.0.
-
-Apache Edgent is an effort undergoing incubation at The Apache Software Foundation (ASF),
-sponsored by the Incubator PMC. Incubation is required of all newly accepted
-projects until a further review indicates that the infrastructure, communications,
-and decision making process have stabilized in a manner consistent with other
-successful ASF projects. While incubation status is not necessarily a reflection
-of the completeness or stability of the code, it does indicate that the project
-has yet to be fully endorsed by the ASF.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/README.md
----------------------------------------------------------------------
diff --git a/samples/apps/README.md b/samples/apps/README.md
deleted file mode 100644
index 391cde3..0000000
--- a/samples/apps/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-See the README.md in the samples root directory for information on building the samples.
-
-See the scripts directory for information on running these samples.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/pom.xml
----------------------------------------------------------------------
diff --git a/samples/apps/pom.xml b/samples/apps/pom.xml
deleted file mode 100644
index 9695ad8..0000000
--- a/samples/apps/pom.xml
+++ /dev/null
@@ -1,75 +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-apps</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Apps</name>
-
- <dependencies>
- <!-- parent pom has Platforms and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-sensors</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-file</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-math3</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-iot</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-iotp</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-connectors-mqtt</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples-utils</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/scripts/sensorAnalytics/README
----------------------------------------------------------------------
diff --git a/samples/apps/scripts/sensorAnalytics/README b/samples/apps/scripts/sensorAnalytics/README
deleted file mode 100644
index 2e0b504..0000000
--- a/samples/apps/scripts/sensorAnalytics/README
+++ /dev/null
@@ -1,27 +0,0 @@
-Sensor Analytics sample application.
-
-The application demonstrates a more complete sample that includes
-some common themes.
-
-The source code for the application can be found under the
-<edgent-release>/<target>/samples/src directory.
-
-Use:
-
-See the SensorAnalytics sample link in <edgent-release>/docs/javadoc/overview-summary.html
-for full information on configuring and running the application
-and observing its behavior. In particular, the default configuration
-connects to MQTT server url "tcp://localhost:1883".
-
-# run the application
-# the application runs forever printing out and publishing information
-$ ./runSensorAnalytics.sh
-
-# Watch and report the device's MQTT event topics
-$ ./runDeviceComms.sh watch
-
-# Publish a command to change a sensor1 threshold
-$ ./runDeviceComms.sh send sensor1.set1hzMeanRangeThreshold "[125..127]"
-
-# Publish a command telling the device to publish each outlier event as they occur
-$ ./runDeviceComms.sh send sensor1.setPublish1hzOutsideRange true
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/scripts/sensorAnalytics/runDeviceComms.sh
----------------------------------------------------------------------
diff --git a/samples/apps/scripts/sensorAnalytics/runDeviceComms.sh b/samples/apps/scripts/sensorAnalytics/runDeviceComms.sh
deleted file mode 100755
index ac39ff6..0000000
--- a/samples/apps/scripts/sensorAnalytics/runDeviceComms.sh
+++ /dev/null
@@ -1,31 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-apps-*-uber.jar`
-
-# Runs the DeviceComms client
-#
-# ./runDeviceComms.sh watch | send <commandLabel> <commandArg>
-#
-# no checking is done for the validity of commandLabel or commandArg
-
-export CLASSPATH=${UBER_JAR}
-
-java org.apache.edgent.samples.apps.mqtt.DeviceCommsApp sensorAnalytics.properties $*
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/scripts/sensorAnalytics/runSensorAnalytics.sh
----------------------------------------------------------------------
diff --git a/samples/apps/scripts/sensorAnalytics/runSensorAnalytics.sh b/samples/apps/scripts/sensorAnalytics/runSensorAnalytics.sh
deleted file mode 100755
index eed2242..0000000
--- a/samples/apps/scripts/sensorAnalytics/runSensorAnalytics.sh
+++ /dev/null
@@ -1,29 +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.
-#
-
-CONNECTOR_SAMPLES_DIR=../..
-
-UBER_JAR=`echo ${CONNECTOR_SAMPLES_DIR}/target/edgent-samples-apps-*-uber.jar`
-
-# Runs the SensorAnalytics sample application
-#
-# ./runSensorAnalytics.sh
-
-export CLASSPATH=${UBER_JAR}
-
-java org.apache.edgent.samples.apps.sensorAnalytics.SensorAnalyticsApplication sensorAnalytics.properties
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/scripts/sensorAnalytics/sensorAnalytics.properties
----------------------------------------------------------------------
diff --git a/samples/apps/scripts/sensorAnalytics/sensorAnalytics.properties b/samples/apps/scripts/sensorAnalytics/sensorAnalytics.properties
deleted file mode 100644
index 9a1e812..0000000
--- a/samples/apps/scripts/sensorAnalytics/sensorAnalytics.properties
+++ /dev/null
@@ -1,82 +0,0 @@
-# Application Configuration properties
-#
-# The default topology provider is DirectProvider.
-topology.provider=org.apache.edgent.providers.development.DevelopmentProvider
-#
-application.name=SensorAnalytics
-#
-
-# =========================================================================
-# Application stream logging configuration
-# Where the app puts its stream logs.
-# The directory will be created when the topology
-# runs if it doesn't already exist.
-application.log.dir=/tmp/SensorAnalytics/logs
-
-# =========================================================================
-# Application "ranges" - e.g., for threshold detections
-# Specify values generated by Range.toString():
-# <lowerBoundType><lowerBound>..<upperBound><upperBoundType>
-# where
-# lowerBoundType is "[" inclusive or "(" exclusive
-# upperBoundType is "]" inclusive or ")" exclusive
-# lowerBound or upperBound is "*" for open ranges,
-# e.g., [*..50] for "atMost" 50
-#
-sensor1.range.outside1hzMeanRange=[124..129]
-
-# =========================================================================
-# MQTT Device and Connector configuration info.
-#
-# MQTT Device -- See org.apache.edgent.connectors.mqtt.device.MqttDevice for all
-# of the properties.
-#
-# An optional topic prefix. It can be used to isolate users or applications
-# in shared MQTT broker configurations. By default it is incorporated
-# into device topics and the MQTT clientId.
-# If you use a public MQTT broker you may want to change the topic
-# prefix so it is still unique for you but doesn't include the
-# user name or application name.
-mqttDevice.topic.prefix=ibm.xyzzy-streams.samples/user/{user.name}/{application.name}/
-#
-# The device id used for identifying the device's events and commands
-# in the MQTT topic namespace.
-# By default it also gets incorporated into the MQTT clientId value.
-mqttDevice.id=012345
-#
-# The MQTT clientId. Only one instance of a MqttDevice can connect
-# to the MQTT broker with a given clientId.
-#mqttDevice.mqtt.clientId={mqttDevice.topic.prefix}id/{mqttDevice.id}
-#
-# MQTT Connector See org.apache.edgent.connectors.mqtt.MqttConfig.fromProperties()
-#
-# The default configuration is for a local MQTT broker.
-# See mosquitto.org for instructions on downloading a MQTT broker.
-# Or use some other MQTT broker available in your environment.
-mqtt.serverURLs=tcp://localhost:1883
-#
-# Alternatively, there are some public MQTT brokers available to experiment with.
-# Their availability status isn't guaranteed. If you're unable to connect
-# to the broker, it's likely that it isn't up or your firewalls don't
-# allow you to connect. DO NOT PUBLISH ANYTHING SENSITIVE - anyone
-# can be listing.
-#mqtt.serverURLs=tcp://iot.eclipse.org:1883
-#mqtt.serverURLs=tcp://test.mosquitto.org:1883
-#
-# default username is System.getProperty("user.name") value
-#mqtt.userName=xyzzy
-#mqtt.password=myMosquittoPw
-
-# =========================================================================
-# Patterns for identifying which streams to trace to System.out
-# To enable use include.csv and/or includes.regex.
-# To exclude an otherwise included file, use excludes.csv and/or excludes.regex
-#
-# Some tracing labels
-# sensor1.raw1khz,sensor1.j1khz,sensor1.j1hzStats,sensor1.outside1hzMeanRange*,
-# sensor1.periodicLastN*
-#
-#stream.tracing.includes.csv=sensor1.j1hzStats
-stream.tracing.includes.regex=sensor1.outside1hzMeanRange.*
-#stream.tracing.excludes.regex=.*
-#stream.tracing.excludes.csv=sensor1.raw1khz
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractApplication.java
deleted file mode 100644
index 850e85e..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractApplication.java
+++ /dev/null
@@ -1,130 +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.apps;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.Properties;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.samples.apps.mqtt.AbstractMqttApplication;
-import org.apache.edgent.topology.Topology;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An Application base class.
- * <p>
- * Application instances need to:
- * <ul>
- * <li>define an implementation for {@link #buildTopology(Topology)}</li>
- * <li>call {@link #run()} to build and submit the topology for execution.</li>
- * </ul>
- * <p>
- * The class provides some common processing needs:
- * <ul>
- * <li>Support for an external configuration file</li>
- * <li>Provides a {@link TopologyProviderFactory}</li>
- * <li>Provides a {@link ApplicationUtilities}</li>
- * </ul>
- * @see AbstractMqttApplication
- */
-public abstract class AbstractApplication {
-
- protected final String propsPath;
- protected final Properties props;
- private final ApplicationUtilities applicationUtilities;
- private static final Logger logger = LoggerFactory.getLogger(AbstractApplication.class);
-
- protected Topology t;
-
- public AbstractApplication(String propsPath) throws Exception {
- this.propsPath = propsPath;
- props = new Properties();
- props.load(new FileReader(new File(propsPath)));
- applicationUtilities = new ApplicationUtilities(props);
- }
-
- /**
- * Construct and run the application's topology.
- * @throws Exception on failure
- */
- protected void run() throws Exception {
-// TODO need to setup logging to squelch stderr output from the runtime/connectors,
-// including paho output
-
- TopologyProviderFactory tpFactory = new TopologyProviderFactory(props);
-
- DirectProvider tp = tpFactory.newProvider();
-
- // Create a topology for the application
- t = tp.newTopology(config().getProperty("application.name"));
-
- preBuildTopology(t);
-
- buildTopology(t);
-
- // Run the topology
- HttpServer httpServer = tp.getServices().getService(HttpServer.class);
- if (httpServer != null) {
- System.out.println("Edgent Console URL for the job: "
- + httpServer.getConsoleUrl());
- }
- tp.submit(t);
- }
-
- /**
- * Get the application's raw configuration information.
- * @return the configuration
- */
- public Properties config() {
- return props;
- }
-
- /**
- * Get the application's
- * @return the helper
- */
- public ApplicationUtilities utils() {
- return applicationUtilities;
- }
-
- /**
- * A hook for a subclass to do things prior to the invocation
- * of {@link #buildTopology(Topology)}.
- * <p>
- * The default implementation is a no-op.
- * @param t the application's topology
- */
- protected void preBuildTopology(Topology t) {
- return;
- }
-
- /**
- * Build the application's topology.
- * @param t Topology to add to
- */
- abstract protected void buildTopology(Topology t);
-
- public void handleRuntimeError(String msg, Exception e) {
- logger.error("A runtime error occurred", e);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractIotpApplication.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractIotpApplication.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractIotpApplication.java
deleted file mode 100644
index 62cb416..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/AbstractIotpApplication.java
+++ /dev/null
@@ -1,113 +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.apps;
-
-import java.io.PrintWriter;
-import java.util.Random;
-
-import org.apache.edgent.connectors.iot.IotDevice;
-import org.apache.edgent.connectors.iotp.IotpDevice;
-import org.apache.edgent.topology.Topology;
-
-/**
- * An IotF Application base class.
- * <p>
- * Application instances need to:
- * <ul>
- * <li>define an implementation for {@link #buildTopology(Topology)}</li>
- * <li>call {@link #run()} to build and submit the topology for execution.</li>
- * </ul>
- * <p>
- * The class provides some common processing needs:
- * <ul>
- * <li>Support for an external configuration file</li>
- * <li>Provides a {@link TopologyProviderFactory}</li>
- * <li>Provides a {@link ApplicationUtilities}</li>
- * <li>Provides a {@link IotDevice}</li>
- * </ul>
- */
-public abstract class AbstractIotpApplication extends AbstractApplication {
-
- private IotDevice device;
-
- public AbstractIotpApplication(String propsPath) throws Exception {
- super(propsPath);
- }
-
- @Override
- protected void preBuildTopology(Topology topology) {
- // Add an Iotp device communication manager to the topology
- // Declare a connection to IoTF Quickstart service
- String deviceId = "qs" + Long.toHexString(new Random().nextLong());
- device = IotpDevice.quickstart(topology, deviceId);
-
- // TODO replace quickstart
- // iotfDevice = new IotpDevice(topology, new File("device.cfg"));
-
- System.out.println("Quickstart device type:" + IotpDevice.QUICKSTART_DEVICE_TYPE);
- System.out.println("Quickstart device id :" + deviceId);
- System.out.println("https://quickstart.internetofthings.ibmcloud.com/#/device/" + deviceId);
- // Also write this information to file quickstartUrl.txt in case the
- // console scrolls too fast
- try {
- PrintWriter writer = new PrintWriter("iotfUrl.txt", "UTF-8");
- writer.println("Quickstart device type:" + IotpDevice.QUICKSTART_DEVICE_TYPE);
- writer.println("Quickstart device id :" + deviceId);
- writer.println("https://quickstart.internetofthings.ibmcloud.com/#/device/" + deviceId);
- writer.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Get the application's IotDevice
- *
- * @return the IotDevice
- */
- public IotDevice iotDevice() {
- return device;
- }
-
- /**
- * Compose a IotDevice eventId for the sensor.
- *
- * @param sensorId
- * the sensor id
- * @param eventId
- * the sensor's eventId
- * @return the device eventId
- */
- public String sensorEventId(String sensorId, String eventId) {
- return sensorId + "." + eventId;
- }
-
- /**
- * Compose a IotpDevice commandId for the sensor
- *
- * @param sensorId
- * the sensor id
- * @param commandId
- * the sensor's commandId
- * @return the device commandId
- */
- public String commandId(String sensorId, String commandId) {
- return sensorId + "." + commandId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/apps/src/main/java/org/apache/edgent/samples/apps/ApplicationUtilities.java
----------------------------------------------------------------------
diff --git a/samples/apps/src/main/java/org/apache/edgent/samples/apps/ApplicationUtilities.java b/samples/apps/src/main/java/org/apache/edgent/samples/apps/ApplicationUtilities.java
deleted file mode 100644
index b8a0cee..0000000
--- a/samples/apps/src/main/java/org/apache/edgent/samples/apps/ApplicationUtilities.java
+++ /dev/null
@@ -1,255 +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.apps;
-
-import java.io.File;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.edgent.analytics.sensors.Range;
-import org.apache.edgent.analytics.sensors.Ranges;
-import org.apache.edgent.connectors.file.FileStreams;
-import org.apache.edgent.connectors.file.FileWriterCycleConfig;
-import org.apache.edgent.connectors.file.FileWriterFlushConfig;
-import org.apache.edgent.connectors.file.FileWriterPolicy;
-import org.apache.edgent.connectors.file.FileWriterRetentionConfig;
-import org.apache.edgent.function.Predicate;
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.topology.TStream;
-
-/**
- * Some general purpose application configuration driven utilities.
- * <p>
- * Utilities include:
- * <ul>
- * <li>Get a property name for a sensor configuration item</li>
- * <li>Get a Range value for a sensor range item</li>
- * <li>Log a stream</li>
- * <li>Conditionally trace a stream</li>
- * </ul>
- */
-public class ApplicationUtilities {
-
- private final Properties props;
-
- public ApplicationUtilities(Properties props) {
- this.props = props;
- }
-
- private Properties config() {
- return props;
- }
-
- /**
- * Trace a stream to System.out if the sensor id's "label" has been configured
- * to enable tracing.
- * <p>
- * If tracing has not been enabled in the config, the topology will not
- * be augmented to trace the stream.
- *
- * @param <T> Tuple type
- * @param stream the stream to trace
- * @param sensorId the sensor id
- * @param label some unique label
- * @return the input stream
- */
- public <T> TStream<T> traceStream(TStream<T> stream, String sensorId, Supplier<String> label) {
- return traceStream(stream, () -> sensorId+"."+label.get());
- }
-
- /**
- * Trace a stream to System.out if the "label" has been configured
- * to enable tracing.
- * <p>
- * If tracing has not been enabled in the config, the topology will not
- * be augmented to trace the stream.
- *
- * @param <T> Tuple type
- * @param stream the stream to trace
- * @param label some unique label
- * @return the input stream
- */
- public <T> TStream<T> traceStream(TStream<T> stream, Supplier<String> label) {
- if (includeTraceStreamOps(label.get())) {
- TStream<?> s = stream.filter(traceTuplesFn(label.get())).tag(label.get()+".trace");
- s.peek(sample -> System.out.println(String.format("%s: %s", label.get(), sample.toString())));
- }
- return stream;
- }
-
- private boolean includeTraceStreamOps(String label) {
- String includesCsv = config().getProperty("stream.tracing.includes.csv", "");
- String includesRegex = config().getProperty("stream.tracing.includes.regex", "");
- String excludesCsv = config().getProperty("stream.tracing.excludes.csv", "");
- String excludesRegex = config().getProperty("stream.tracing.excludes.regex", "");
-
- Set<String> includesSet = new HashSet<>();
- for (String s : includesCsv.split(","))
- includesSet.add(s.trim());
- Set<String> excludesSet = new HashSet<>();
- for (String s : excludesCsv.split(","))
- excludesSet.add(s.trim());
-
- boolean isIncluded = false;
- if (includesSet.contains(label) || label.matches(includesRegex))
- isIncluded = true;
- if (excludesSet.contains(label) || label.matches(excludesRegex))
- isIncluded = false;
-
- return isIncluded;
- }
-
- private <T> Predicate<T> traceTuplesFn(String label) {
- return tuple -> true; // TODO make dynamic config; affected by "label" value
- // check label for match against csv or regex from props
- }
-
- /**
- * Get the property name for a sensor's configuration item.
- * @param sensorId the sensor's id
- * @param label the label for an instance of "kind" (e.g., "tempThreshold")
- * @param kind the kind of configuration item (e.g., "range")
- * @return the configuration property name
- */
- public String getSensorPropertyName(String sensorId, String label, String kind) {
- String name = kind + "." + label; // kind.label
- if (sensorId!=null && !sensorId.isEmpty())
- name = sensorId + "." + name; // sensorId.kind.label
- return name;
- }
-
- private String getSensorConfigValue(String sensorId, String label, String kind) {
- String name = getSensorPropertyName(sensorId, label, kind);
- String val = config().getProperty(name);
- if (val==null)
- throw new IllegalArgumentException("Missing configuration property "+name);
- return val;
- }
-
- /**
- * Get the Range for a sensor range configuration item.
- * @param sensorId the sensor's id
- * @param label the range's label
- * @return the Range
- */
- public Range<Integer> getRangeInteger(String sensorId, String label) {
- String val = getSensorConfigValue(sensorId, label, "range");
- return Ranges.valueOfInteger(val);
- }
-
- /**
- * Get the Range for a sensor range configuration item.
- * @param sensorId the sensor's id
- * @param label the range's label
- * @return the Range
- */
- public Range<Byte> getRangeByte(String sensorId, String label) {
- String val = getSensorConfigValue(sensorId, label, "range");
- return Ranges.valueOfByte(val);
- }
-
- /**
- * Get the Range for a sensor range configuration item.
- * @param sensorId the sensor's id
- * @param label the range's label
- * @return the Range
- */
- public Range<Short> getRangeShort(String sensorId, String label) {
- String val = getSensorConfigValue(sensorId, label, "range");
- return Ranges.valueOfShort(val);
- }
-
- /**
- * Get the Range for a sensor range configuration item.
- * @param sensorId the sensor's id
- * @param label the range's label
- * @return the Range
- */
- public Range<Float> getRangeFloat(String sensorId, String label) {
- String val = getSensorConfigValue(sensorId, label, "range");
- return Ranges.valueOfFloat(val);
- }
-
- /**
- * Get the Range for a sensor range configuration item.
- * @param sensorId the sensor's id
- * @param label the range's label
- * @return the Range
- */
- public Range<Double> getRangeDouble(String sensorId, String label) {
- String val = getSensorConfigValue(sensorId, label, "range");
- return Ranges.valueOfDouble(val);
- }
-
- /**
- * Log every tuple on the stream using the {@code FileStreams} connector.
- * <p>
- * The logs are added to the directory as specified
- * by the "application.log.dir" property.
- * The directory will be created as needed.
- * <p>
- * The "active" (open / being written) log file name is {@code .<baseName>}.
- * <br>
- * Completed stable logs have a name of {@code <baseName>_YYYYMMDD_HHMMSS}.
- * <p>
- * The log entry format being used is:
- * {@code [<date>] [<eventTag>] <tuple>.toString()}
- * <p>
- * See {@link FileStreams#textFileWriter(TStream, org.apache.edgent.function.Supplier, org.apache.edgent.function.Supplier)}
- *
- * @param <T> Tuple type
- * @param stream the TStream
- * @param baseName the base log name
- * @param eventTag a tag that gets added to the log entry
- * @return the input stream
- */
- public <T> TStream<T> logStream(TStream<T> stream, String eventTag, String baseName) {
- // Define the writer policy.
- // TODO could make the policy configurable via config()
- FileWriterPolicy<String> policy = new FileWriterPolicy<String>(
- FileWriterFlushConfig.newTimeBasedConfig(2_000/*msec*/), // flush every 2sec
- FileWriterCycleConfig.newFileSizeBasedConfig(10_000), // new file every 10KB
- FileWriterRetentionConfig.newFileCountBasedConfig(1) // retain 1 file
- );
-
- // Compose the base file pathname
- File dir = new File(config().getProperty("application.log.dir"));
- String basePathname = new File(dir, baseName).toString();
-
- // Transform the stream to a TStream<String> of string log entry values
- TStream<String> stringEntries = stream.map(sample -> String.format("[%s] [%s] %s", new Date().toString(), eventTag, sample.toString()))
- .tag(baseName+".log");
-
- // Use the FileStreams connector to write the logs.
- //
- // A hack for getting the log directories created at runtime
- // TODO add another policy thing... or simply make textFileWriter do it?
- //
- FileStreams.textFileWriter(stringEntries,
- () -> { if (!dir.exists()) dir.mkdirs();
- return basePathname;
- },
- () -> policy);
-
- return stream;
- }
-
-}
[4/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
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`'
[9/9] incubator-edgent git commit: comment out samples stuff in
Jenkinsfile
Posted by dl...@apache.org.
comment out samples stuff in Jenkinsfile
Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/92672c05
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/92672c05
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/92672c05
Branch: refs/heads/develop
Commit: 92672c050331c56478f65ab754444d637e9adbab
Parents: a7aeb2b
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Thu Nov 23 10:36:26 2017 -0500
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Thu Nov 23 10:36:26 2017 -0500
----------------------------------------------------------------------
Jenkinsfile | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/92672c05/Jenkinsfile
----------------------------------------------------------------------
diff --git a/Jenkinsfile b/Jenkinsfile
index 3087a6e..52bc845 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -69,6 +69,7 @@ node('ubuntu') {
}
}
+/* ========================== TODO figure out what to do with samples now in a separate repo
stage ('Build Samples') {
echo 'Building samples'
sh "cd samples; ${mvnHome}/bin/mvn ${mavenFailureMode} ${mavenLocalRepo} clean package"
@@ -83,6 +84,7 @@ node('ubuntu') {
sh "cd samples/template; ${mvnHome}/bin/mvn ${mavenFailureMode} ${mavenLocalRepo} -Pplatform-java7 clean package; ./app-run.sh"
sh "cd samples/template; ${mvnHome}/bin/mvn ${mavenFailureMode} ${mavenLocalRepo} -Pplatform-android clean package; ./app-run.sh"
}
+========================== */
/* There seems to be a problem with this (Here the output of the build log):
[2/9] incubator-edgent git commit: remove samples (now in separate
repo)
Posted by dl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/mvnw
----------------------------------------------------------------------
diff --git a/samples/template/mvnw b/samples/template/mvnw
deleted file mode 100755
index 78d4420..0000000
--- a/samples/template/mvnw
+++ /dev/null
@@ -1,268 +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.
-# ----------------------------------------------------------------------------
-
-# ----------------------------------------------------------------------------
-# Maven2 Start Up Batch script
-#
-# Required ENV vars:
-# ------------------
-# JAVA_HOME - location of a JDK home dir
-#
-# Optional ENV vars
-# -----------------
-# M2_HOME - location of maven2's installed home dir
-# MAVEN_OPTS - parameters passed to the Java VM when running Maven
-# e.g. to debug Maven itself, use
-# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-# ----------------------------------------------------------------------------
-
-if [ -z "$MAVEN_SKIP_RC" ] ; then
-
- if [ -f /etc/mavenrc ] ; then
- . /etc/mavenrc
- fi
-
- if [ -f "$HOME/.mavenrc" ] ; then
- . "$HOME/.mavenrc"
- fi
-
-fi
-
-# OS specific support. $var _must_ be set to either true or false.
-cygwin=false;
-darwin=false;
-mingw=false
-case "`uname`" in
- CYGWIN*) cygwin=true ;;
- MINGW*) mingw=true;;
- Darwin*) darwin=true
- # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
- # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
- if [ -z "$JAVA_HOME" ]; then
- if [ -x "/usr/libexec/java_home" ]; then
- export JAVA_HOME="`/usr/libexec/java_home`"
- else
- export JAVA_HOME="/Library/Java/Home"
- fi
- fi
- ;;
-esac
-
-if [ -z "$JAVA_HOME" ] ; then
- if [ -r /etc/gentoo-release ] ; then
- JAVA_HOME=`java-config --jre-home`
- fi
-fi
-
-if [ -z "$M2_HOME" ] ; then
- ## resolve links - $0 may be a link to maven's home
- PRG="$0"
-
- # need this for relative symlinks
- while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG="`dirname "$PRG"`/$link"
- fi
- done
-
- saveddir=`pwd`
-
- M2_HOME=`dirname "$PRG"`/..
-
- # make it fully qualified
- M2_HOME=`cd "$M2_HOME" && pwd`
-
- cd "$saveddir"
- # echo Using m2 at $M2_HOME
-fi
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --unix "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-# For Mingw, ensure paths are in UNIX format before anything is touched
-if $mingw ; then
- [ -n "$M2_HOME" ] &&
- M2_HOME="`(cd "$M2_HOME"; pwd)`"
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
- # TODO classpath?
-fi
-
-if [ -z "$JAVA_HOME" ]; then
- javaExecutable="`which javac`"
- if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
- if $darwin ; then
- javaHome="`dirname \"$javaExecutable\"`"
- javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
- else
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- fi
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- JAVA_HOME="$javaHome"
- export JAVA_HOME
- fi
- fi
-fi
-
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- else
- JAVACMD="`which java`"
- fi
-fi
-
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly." >&2
- echo " We cannot execute $JAVACMD" >&2
- exit 1
-fi
-
-if [ -z "$JAVA_HOME" ] ; then
- echo "Warning: JAVA_HOME environment variable is not set."
-fi
-
-CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-
-# traverses directory structure from process work directory to filesystem root
-# first directory with .mvn subdirectory is considered project base directory
-find_maven_basedir() {
-
- if [ -z "$1" ]
- then
- echo "Path not specified to find_maven_basedir"
- return 1
- fi
-
- basedir="$1"
- wdir="$1"
- while [ "$wdir" != '/' ] ; do
- if [ -d "$wdir"/.mvn ] ; then
- basedir=$wdir
- break
- fi
- # workaround for JBEAP-8937 (on Solaris 10/Sparc)
- if [ -d "${wdir}" ]; then
- wdir=`cd "$wdir/.."; pwd`
- fi
- # end of workaround
- done
- echo "${basedir}"
-}
-
-# concatenates all lines of a file
-concat_lines() {
- if [ -f "$1" ]; then
- echo "$(tr -s '\n' ' ' < "$1")"
- fi
-}
-
-BASE_DIR=`find_maven_basedir "$(pwd)"`
-if [ -z "$BASE_DIR" ]; then
- exit 1;
-fi
-
-##########################################################################################
-# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-# This allows using the maven wrapper in projects that prohibit checking in binary data.
-##########################################################################################
-if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
- echo "Found .mvn/wrapper/maven-wrapper.jar"
-else
- echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
-
- jarUrl="http://central.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar"
- while IFS="=" read key value; do
- case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
- esac
- done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
- echo "Downloading from: $jarUrl"
-
- if command -v wget > /dev/null; then
- echo "Found wget ... using wget"
- wget -O "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" "$jarUrl"
- elif command -v curl > /dev/null; then
- echo "Found curl ... using curl"
- curl -o "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" "$jarUrl"
- else
- echo "Falling back to using Java to download"
- javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
- if [ -e "$javaClass" ]; then
- if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- echo " - Compiling MavenWrapperDownloader.java ..."
- # Compiling the Java class
- ("$JAVA_HOME/bin/javac" "$javaClass")
- fi
- if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
- # Running the downloader
- echo " - Running MavenWrapperDownloader.java ..."
- ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
- fi
- fi
- fi
-fi
-##########################################################################################
-# End of extension
-##########################################################################################
-
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
-echo $MAVEN_PROJECTBASEDIR
-MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
- [ -n "$MAVEN_PROJECTBASEDIR" ] &&
- MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
-fi
-
-WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-exec "$JAVACMD" \
- $MAVEN_OPTS \
- -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
- "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/mvnw.cmd
----------------------------------------------------------------------
diff --git a/samples/template/mvnw.cmd b/samples/template/mvnw.cmd
deleted file mode 100644
index cdcd27b..0000000
--- a/samples/template/mvnw.cmd
+++ /dev/null
@@ -1,159 +0,0 @@
-@REM ----------------------------------------------------------------------------
-@REM Licensed to the Apache Software Foundation (ASF) under one
-@REM or more contributor license agreements. See the NOTICE file
-@REM distributed with this work for additional information
-@REM regarding copyright ownership. The ASF licenses this file
-@REM to you under the Apache License, Version 2.0 (the
-@REM "License"); you may not use this file except in compliance
-@REM with the License. You may obtain a copy of the License at
-@REM
-@REM http://www.apache.org/licenses/LICENSE-2.0
-@REM
-@REM Unless required by applicable law or agreed to in writing,
-@REM software distributed under the License is distributed on an
-@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-@REM KIND, either express or implied. See the License for the
-@REM specific language governing permissions and limitations
-@REM under the License.
-@REM ----------------------------------------------------------------------------
-
-@REM ----------------------------------------------------------------------------
-@REM Maven2 Start Up Batch script
-@REM
-@REM Required ENV vars:
-@REM JAVA_HOME - location of a JDK home dir
-@REM
-@REM Optional ENV vars
-@REM M2_HOME - location of maven2's installed home dir
-@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
-@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
-@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
-@REM e.g. to debug Maven itself, use
-@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
-@REM ----------------------------------------------------------------------------
-
-@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
-@echo off
-@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
-@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
-
-@REM set %HOME% to equivalent of $HOME
-if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
-
-@REM Execute a user defined script before this one
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
-@REM check for pre script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
-if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
-:skipRcPre
-
-@setlocal
-
-set ERROR_CODE=0
-
-@REM To isolate internal variables from possible post scripts, we use another setlocal
-@setlocal
-
-@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJHome
-
-echo.
-echo Error: JAVA_HOME not found in your environment. >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-:OkJHome
-if exist "%JAVA_HOME%\bin\java.exe" goto init
-
-echo.
-echo Error: JAVA_HOME is set to an invalid directory. >&2
-echo JAVA_HOME = "%JAVA_HOME%" >&2
-echo Please set the JAVA_HOME variable in your environment to match the >&2
-echo location of your Java installation. >&2
-echo.
-goto error
-
-@REM ==== END VALIDATION ====
-
-:init
-
-@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
-@REM Fallback to current working directory if not found.
-
-set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
-IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
-
-set EXEC_DIR=%CD%
-set WDIR=%EXEC_DIR%
-:findBaseDir
-IF EXIST "%WDIR%"\.mvn goto baseDirFound
-cd ..
-IF "%WDIR%"=="%CD%" goto baseDirNotFound
-set WDIR=%CD%
-goto findBaseDir
-
-:baseDirFound
-set MAVEN_PROJECTBASEDIR=%WDIR%
-cd "%EXEC_DIR%"
-goto endDetectBaseDir
-
-:baseDirNotFound
-set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
-cd "%EXEC_DIR%"
-
-:endDetectBaseDir
-
-IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
-
-@setlocal EnableExtensions EnableDelayedExpansion
-for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
-@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
-
-:endReadAdditionalConfig
-
-SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
-set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-
-set DOWNLOAD_URL="http://central.maven.org/maven2/io/takari/maven-wrapper/0.2.1/maven-wrapper-0.2.1.jar"
-FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
- IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
-)
-
-@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
-@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
-if exist %WRAPPER_JAR% (
- echo Found %WRAPPER_JAR%
-) else (
- echo Couldn't find %WRAPPER_JAR%, downloading it ...
- echo Downloading from: %DOWNLOAD_URL%
- powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
- echo Finished downloading %WRAPPER_JAR%
-)
-@REM End of extension
-
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
-if ERRORLEVEL 1 goto error
-goto end
-
-:error
-set ERROR_CODE=1
-
-:end
-@endlocal & set ERROR_CODE=%ERROR_CODE%
-
-if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
-@REM check for post script, once with legacy .bat ending and once with .cmd ending
-if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
-if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
-:skipRcPost
-
-@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
-if "%MAVEN_BATCH_PAUSE%" == "on" pause
-
-if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
-
-exit /B %ERROR_CODE%
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/pom.xml
----------------------------------------------------------------------
diff --git a/samples/template/pom.xml b/samples/template/pom.xml
deleted file mode 100644
index 8d3f5cb..0000000
--- a/samples/template/pom.xml
+++ /dev/null
@@ -1,296 +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</groupId>
- <artifactId>apache</artifactId>
- <version>18</version>
- </parent-->
-
- <!-- your Edgent Application coordinates here -->
- <groupId>com.mycompany.app</groupId>
- <artifactId>my-app</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <name>My Edgent Application</name>
-
- <properties>
- <edgent.runtime.platform/> <!-- set by -Pplatform-* -->
- <edgent.runtime.groupId>org.apache.edgent${edgent.runtime.platform}</edgent.runtime.groupId>
- <edgent.runtime.version>1.3.0-SNAPSHOT</edgent.runtime.version>
-
- <java.version>1.8</java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputencoding>UTF-8</project.reporting.outputencoding>
- <maven.version>3.3.1</maven.version>
-
- <jetty.version>9.3.6.v20151106</jetty.version>
- <gson.version>2.2.4</gson.version>
- <slf4j.version>1.7.12</slf4j.version>
- <retrolambda.version>2.5.1</retrolambda.version>
- </properties>
-
- <dependencies>
- <!-- the SLF4J API -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- an SLF4J runtime implementation to use -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <version>${slf4j.version}</version>
- <scope>runtime</scope>
- </dependency>
-
- <!-- declare the Edgent provider(s) being used -->
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-providers-direct</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-providers-development</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-providers-iot</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
-
- <!-- declare Edgent Android dependencies
- -->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-android-hardware</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}.android</groupId>
- <artifactId>edgent-android-topology</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
-
- <!-- declare Edgent Analytics dependencies
- -->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-analytics-math3</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-analytics-sensors</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
-
- <!-- declare Edgent Utils dependencies
- -->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-utils-metrics</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
-
- <!-- declare Edgent Connector dependencies
- -->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-file</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-iot</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-iotp</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-jdbc</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-kafka</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-mqtt</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
- <!--dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>edgent-connectors-serial</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency-->
-
- </dependencies>
-
- <profiles>
- <profile>
- <!-- build app to run on Java7 platform -->
- <id>platform-java7</id>
- <properties>
- <platform.java7>true</platform.java7>
- <edgent.runtime.platform>.java7</edgent.runtime.platform>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>net.orfjackal.retrolambda</groupId>
- <artifactId>retrolambda-maven-plugin</artifactId>
- <version>${retrolambda.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>process-main</goal>
- <goal>process-test</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <!-- build app to run on Android platform -->
- <id>platform-android</id>
- <properties>
- <platform.android>true</platform.android>
- <edgent.runtime.platform>.android</edgent.runtime.platform>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>net.orfjackal.retrolambda</groupId>
- <artifactId>retrolambda-maven-plugin</artifactId>
- <version>${retrolambda.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>process-main</goal>
- <goal>process-test</goal>
- </goals>
- <configuration>
- <fork>true</fork>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.6.1</version>
- <configuration>
- <source>${java.version}</source>
- <target>${java.version}</target>
- <testSource>${java.version}</testSource>
- <testTarget>${java.version}</testTarget>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>3.0.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>verify</phase>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <!-- build an uber JAR -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>3.0.0</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <!-- avoid things like the following when running the uber:
- java.lang.NoClassDefFoundError: org.eclipse.paho.client.mqttv3.logging.JSR47Logger
- e.g., connectors.iotp uses watson-iot which uses
- paho.mqtt. Apparently watson-iot or paho.mqtt
- has some behind the scenes depedency that's not
- captured in the uber jar when minimize is true.
- -->
- <!-- <minimizeJar>true</minimizeJar> -->
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>uber</shadedClassifierName>
- <!-- avoid "Invalid signature file digest for Manifest
- main attributes" when running the uber jar.
- An included jar's signed manifest isn't valid in the uber.
- -->
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/src/main/java/com/mycompany/app/TemplateApp.java
----------------------------------------------------------------------
diff --git a/samples/template/src/main/java/com/mycompany/app/TemplateApp.java b/samples/template/src/main/java/com/mycompany/app/TemplateApp.java
deleted file mode 100644
index d95e939..0000000
--- a/samples/template/src/main/java/com/mycompany/app/TemplateApp.java
+++ /dev/null
@@ -1,52 +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 com.mycompany.app;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Edgent Application template.
- */
-public class TemplateApp {
-
- /**
- * Print "Hello Edgent Application Template!" as four tuples.
- * @param args command arguments
- * @throws Exception on failure
- */
- public static void main(String[] args) throws Exception {
-
- // create a provider
- DirectProvider dp = new DirectProvider();
-
- // create a topology
- Topology top = dp.newTopology();
-
- // build the topology
-
- TStream<String> helloStream = top.strings("Hello", "Edgent", "Application", "Template!");
-
- helloStream.print();
-
- // submit the topology
- dp.submit(top);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/src/main/java/com/mycompany/app/package-info.java
----------------------------------------------------------------------
diff --git a/samples/template/src/main/java/com/mycompany/app/package-info.java b/samples/template/src/main/java/com/mycompany/app/package-info.java
deleted file mode 100644
index dd00fdf..0000000
--- a/samples/template/src/main/java/com/mycompany/app/package-info.java
+++ /dev/null
@@ -1,24 +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.
-*/
-
-/**
- * A template for a simple Edgent Application project
- */
-package com.mycompany.app;
-
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/template/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/samples/template/src/main/resources/META-INF/NOTICE b/samples/template/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index d31fd13..0000000
--- a/samples/template/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-
-Apache Edgent: Samples: Template
-Copyright 2016-2017 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/README.md
----------------------------------------------------------------------
diff --git a/samples/topology/README.md b/samples/topology/README.md
deleted file mode 100644
index 5d8e6a1..0000000
--- a/samples/topology/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-See the README.md in the samples root directory for information on building the samples.
-
-The build generated uber jar contains all of the dependent
-Edgent jars and their transitive dependencies.
-
-The desired sample can be run using the run-sample.sh script. e.g.,
-
-```sh
-cd topology
-./run-sample.sh HelloEdgent
-```
-
-For usage information:
-
-```sh
-./run-sample.sh
-./run-sample.sh --list
-```
-
-If you want to run a sample from the standard jar there are two options:
-a) get a local copy of all of the Edgent jars and their dependencies.
- Form a CLASSPATH to the jars and run the sample's main class.
- The get-edgent-jars.sh script can be used to get the jars from
- a maven repository (local or remote).
-b) create an application package bundle. The bundle includes the
- sample(s) jar and a copy of all of the dependent Edgent jars
- and their dependencies. The package-app.sh script can be
- used to create this bundle.
- The package-app.sh script also creates a run-app.sh script.
- The run-app.sh script configures the CLASSPATH and runs the main class.
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/pom.xml
----------------------------------------------------------------------
diff --git a/samples/topology/pom.xml b/samples/topology/pom.xml
deleted file mode 100644
index 1e4e653..0000000
--- a/samples/topology/pom.xml
+++ /dev/null
@@ -1,50 +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-topology</artifactId>
-
- <name>Apache Edgent Samples ${samples.projname.platform}: Topology</name>
-
- <dependencies>
- <!-- parent pom has Providers and SLF4J dependencies -->
-
- <dependency>
- <groupId>${edgent.runtime.groupId}</groupId>
- <artifactId>edgent-analytics-math3</artifactId>
- <version>${edgent.runtime.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent.samples</groupId>
- <artifactId>edgent-samples-utils</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/run-sample.sh
----------------------------------------------------------------------
diff --git a/samples/topology/run-sample.sh b/samples/topology/run-sample.sh
deleted file mode 100755
index c7a6e05..0000000
--- a/samples/topology/run-sample.sh
+++ /dev/null
@@ -1,74 +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=topology
-
-UBER_JAR=target/edgent-samples-${CATEGORY}-*-uber.jar
-
-SAMPLE_PACKAGE_BASE=org.apache.edgent.samples.${CATEGORY}
-SAMPLES_FQ=`cat <<EOF
-${SAMPLE_PACKAGE_BASE}.CombiningStreamsProcessingResults
-${SAMPLE_PACKAGE_BASE}.DevelopmentMetricsSample
-${SAMPLE_PACKAGE_BASE}.DevelopmentSample
-${SAMPLE_PACKAGE_BASE}.DevelopmentSampleJobMXBean
-${SAMPLE_PACKAGE_BASE}.HelloEdgent
-${SAMPLE_PACKAGE_BASE}.JobEventsSample
-${SAMPLE_PACKAGE_BASE}.JobExecution
-${SAMPLE_PACKAGE_BASE}.PeriodicSource
-${SAMPLE_PACKAGE_BASE}.SensorsAggregates
-${SAMPLE_PACKAGE_BASE}.SimpleFilterTransform
-${SAMPLE_PACKAGE_BASE}.SplitWithEnumSample
-${SAMPLE_PACKAGE_BASE}.TempSensorApplication
-${SAMPLE_PACKAGE_BASE}.TerminateAfterNTuples
-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/topology/src/main/java/org/apache/edgent/samples/topology/CombiningStreamsProcessingResults.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/CombiningStreamsProcessingResults.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/CombiningStreamsProcessingResults.java
deleted file mode 100644
index b46e5d4..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/CombiningStreamsProcessingResults.java
+++ /dev/null
@@ -1,168 +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.topology;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.samples.utils.sensor.HeartMonitorSensor;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Applying different processing against a set of streams and combining the
- * resulting streams into a single stream.
- *
- * @see HeartMonitorSensor
- */
-public class CombiningStreamsProcessingResults {
- /**
- * Polls a simulated heart monitor to periodically obtain blood pressure readings.
- * Splits the readings by blood pressure category into separate streams.
- * Applies different processing on each stream to generate alert streams.
- * Combines the alert streams into a single stream and prints the alerts.
- *
- * @param args command arguments
- * @throws Exception on failure
- */
- public static void main(String[] args) throws Exception {
- HeartMonitorSensor monitor = new HeartMonitorSensor();
-
- DirectProvider dp = new DevelopmentProvider();
-
- System.out.println(dp.getServices().getService(HttpServer.class).getConsoleUrl());
-
- Topology top = dp.newTopology("heartMonitor");
-
- // Generate a stream of heart monitor readings
- TStream<Map<String, Integer>> readings = top
- .poll(monitor, 1, TimeUnit.MILLISECONDS)
- .filter(tuple -> tuple.get("Systolic") > 50 && tuple.get("Diastolic") > 30)
- .filter(tuple -> tuple.get("Systolic") < 200 && tuple.get("Diastolic") < 130);
-
- // Split the stream by blood pressure category
- List<TStream<Map<String, Integer>>> categories = readings.split(6, tuple -> {
- int s = tuple.get("Systolic");
- int d = tuple.get("Diastolic");
- if (s < 120 && d < 80) {
- // Normal
- return 0;
- } else if ((s >= 120 && s <= 139) || (d >= 80 && d <= 89)) {
- // Prehypertension
- return 1;
- } else if ((s >= 140 && s <= 159) || (d >= 90 && d <= 99)) {
- // High Blood Pressure (Hypertension) Stage 1
- return 2;
- } else if ((s >= 160 && s <= 179) || (d >= 100 && d <= 109)) {
- // High Blood Pressure (Hypertension) Stage 2
- return 3;
- } else if (s >= 180 && d >= 110) {
- // Hypertensive Crisis
- return 4;
- } else {
- // Invalid
- return -1;
- }
- });
-
- // Get each individual stream
- TStream<Map<String, Integer>> normal = categories.get(0).tag("normal");
- TStream<Map<String, Integer>> prehypertension = categories.get(1).tag("prehypertension");
- TStream<Map<String, Integer>> hypertension_stage1 = categories.get(2).tag("hypertension_stage1");
- TStream<Map<String, Integer>> hypertension_stage2 = categories.get(3).tag("hypertension_stage2");
- TStream<Map<String, Integer>> hypertensive = categories.get(4).tag("hypertensive");
-
- // Perform analytics on each stream and generate alerts for each blood pressure category
-
- // Category: Normal
- TStream<String> normalAlerts = normal
- .filter(tuple -> tuple.get("Systolic") > 80 && tuple.get("Diastolic") > 50)
- .tag("normal")
- .map(tuple -> {
- return "All is normal. BP is " + tuple.get("Systolic") + "/" +
- tuple.get("Diastolic") + ".\n"; })
- .tag("normal");
-
- // Category: Prehypertension category
- TStream<String> prehypertensionAlerts = prehypertension
- .map(tuple -> {
- return "At high risk for developing hypertension. BP is " +
- tuple.get("Systolic") + "/" + tuple.get("Diastolic") + ".\n"; })
- .tag("prehypertension");
-
- // Category: High Blood Pressure (Hypertension) Stage 1
- TStream<String> hypertension_stage1Alerts = hypertension_stage1
- .map(tuple -> {
- return "Monitor closely, patient has high blood pressure. " +
- "BP is " + tuple.get("Systolic") + "/" + tuple.get("Diastolic") + ".\n"; })
- .tag("hypertension_stage1")
- .modify(tuple -> "High Blood Pressure (Hypertension) Stage 1\n" + tuple)
- .tag("hypertension_stage1");
-
- // Category: High Blood Pressure (Hypertension) Stage 2
- TStream<String> hypertension_stage2Alerts = hypertension_stage2
- .filter(tuple -> tuple.get("Systolic") >= 170 && tuple.get("Diastolic") >= 105)
- .tag("hypertension_stage2")
- .peek(tuple ->
- System.out.println("BP: " + tuple.get("Systolic") + "/" + tuple.get("Diastolic")))
- .map(tuple -> {
- return "Warning! Monitor closely, patient is at risk of a hypertensive crisis!\n"; })
- .tag("hypertension_stage2")
- .modify(tuple -> "High Blood Pressure (Hypertension) Stage 2\n" + tuple)
- .tag("hypertension_stage2");
-
- // Category: Hypertensive Crisis
- TStream<String> hypertensiveAlerts = hypertensive
- .filter(tuple -> tuple.get("Systolic") >= 180)
- .tag("hypertensive")
- .peek(tuple ->
- System.out.println("BP: " + tuple.get("Systolic") + "/" + tuple.get("Diastolic")))
- .map(tuple -> { return "Emergency! See to patient immediately!\n"; })
- .tag("hypertensive")
- .modify(tuple -> tuple.toUpperCase())
- .tag("hypertensive")
- .modify(tuple -> "Hypertensive Crisis!!!\n" + tuple)
- .tag("hypertensive");
-
- // Additional processing for these streams could go here. In this case, union two streams
- // to obtain a single stream containing alerts from the normal and prehypertension alert streams.
- TStream<String> normalAndPrehypertensionAlerts = normalAlerts.union(prehypertensionAlerts);
-
- // Set of streams containing alerts from the other categories
- Set<TStream<String>> otherAlerts = new HashSet<>();
- otherAlerts.add(hypertension_stage1Alerts);
- otherAlerts.add(hypertension_stage2Alerts);
- otherAlerts.add(hypertensiveAlerts);
-
- // Union a stream with a set of streams to obtain a single stream containing alerts from
- // all alert streams
- TStream<String> allAlerts = normalAndPrehypertensionAlerts.union(otherAlerts);
-
- // Terminate the stream by printing out alerts from all categories
- allAlerts.sink(tuple -> System.out.println(tuple));
-
- dp.submit(top);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentMetricsSample.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentMetricsSample.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentMetricsSample.java
deleted file mode 100644
index b2f08dc..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentMetricsSample.java
+++ /dev/null
@@ -1,64 +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.topology;
-
-import java.util.Random;
-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.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-public class DevelopmentMetricsSample {
-
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
- DevelopmentProvider dtp2 = new DevelopmentProvider();
-
- Topology t = dtp.newTopology("DevelopmentMetricsSample");
- Topology t2 = dtp2.newTopology("another one");
-
- Random r = new Random();
- Random r2 = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- TStream<Double> gaussian2 = t2.poll(() -> r2.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // A filter
- gaussian = gaussian.filter(g -> g > 0.5);
-
- // Measure tuple arrival rate after filtering
- gaussian = Metrics.rateMeter(gaussian);
-
- // A transformation
- @SuppressWarnings("unused")
- TStream<String> gs = gaussian.map(g -> "G:" + g + ":");
- @SuppressWarnings("unused")
- TStream<String> gs2 = gaussian2.map(g -> "G:" + g + ":");
-
- dtp.submit(t);
- dtp2.submit(t2);
-
- System.out.println(dtp2.getServices().getService(HttpServer.class).getConsoleUrl());
-
- Thread.sleep(1000000);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSample.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSample.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSample.java
deleted file mode 100644
index 403e8da..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSample.java
+++ /dev/null
@@ -1,47 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-public class DevelopmentSample {
-
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology("DevelopmentSample");
-
- Random r = new Random();
-
- TStream<Double> d = t.poll(() -> r.nextGaussian(), 100, TimeUnit.MILLISECONDS);
-
- d.sink(tuple -> System.out.print("."));
-
- dtp.submit(t);
-
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSampleJobMXBean.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSampleJobMXBean.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSampleJobMXBean.java
deleted file mode 100644
index c694309..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/DevelopmentSampleJobMXBean.java
+++ /dev/null
@@ -1,85 +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.topology;
-
-import java.lang.management.ManagementFactory;
-import java.util.Iterator;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-public class DevelopmentSampleJobMXBean {
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology("DevelopmentSampleJobMXBean");
-
- Random r = new Random();
-
- TStream<Double> d = t.poll(() -> r.nextGaussian(), 100, TimeUnit.MILLISECONDS);
-
- d.sink(tuple -> System.out.print("."));
-
- dtp.submit(t);
-
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
-
- MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
-
- StringBuffer sbuf = new StringBuffer();
- sbuf.append(DevelopmentProvider.JMX_DOMAIN);
- sbuf.append(":interface=");
- sbuf.append(ObjectName.quote("org.apache.edgent.execution.mbeans.JobMXBean"));
- sbuf.append(",type=");
- sbuf.append(ObjectName.quote("job"));
- sbuf.append(",*");
-
- System.out.println("Looking for MBeans of type job: " + sbuf.toString());
-
- ObjectName jobObjName = new ObjectName(sbuf.toString());
- Set<ObjectInstance> jobInstances = mBeanServer.queryMBeans(jobObjName, null);
- Iterator<ObjectInstance> jobIterator = jobInstances.iterator();
-
- while (jobIterator.hasNext()) {
- ObjectInstance jobInstance = jobIterator.next();
- ObjectName objectName = jobInstance.getObjectName();
-
- String jobId = (String) mBeanServer.getAttribute(objectName, "Id");
- String jobName = (String) mBeanServer.getAttribute(objectName, "Name");
- String jobCurState = (String) mBeanServer.getAttribute(objectName, "CurrentState");
- String jobNextState = (String) mBeanServer.getAttribute(objectName, "NextState");
- String jobHealth = (String) mBeanServer.getAttribute(objectName, "Health");
- String jobLastError = (String) mBeanServer.getAttribute(objectName, "LastError");
-
- System.out.println("Found a job with JobId: " + jobId + " Name: " + jobName +
- " CurrentState: " + jobCurState + " NextState: " + jobNextState +
- " Health: " + jobHealth + " LastError: \"" + jobLastError + "\"");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/HelloEdgent.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/HelloEdgent.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/HelloEdgent.java
deleted file mode 100644
index c221179..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/HelloEdgent.java
+++ /dev/null
@@ -1,48 +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.topology;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Hello Edgent Topology sample.
- *
- */
-public class HelloEdgent {
-
- /**
- * Print "Hello Edgent!" as two tuples.
- * @param args command arguments
- * @throws Exception on failure
- */
- public static void main(String[] args) throws Exception {
-
- DirectProvider dp = new DirectProvider();
-
- Topology top = dp.newTopology();
-
- TStream<String> helloStream = top.strings("Hello", "Edgent!");
-
- helloStream.print();
-
- dp.submit(top);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobEventsSample.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobEventsSample.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobEventsSample.java
deleted file mode 100644
index b62ad54..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobEventsSample.java
+++ /dev/null
@@ -1,165 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.execution.Job;
-import org.apache.edgent.execution.services.JobRegistryService;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.runtime.jobregistry.JobEvents;
-import org.apache.edgent.runtime.jobregistry.JobRegistry;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonObject;
-
-/**
- * Demonstrates job monitoring using the {@link JobRegistryService} service.
- * <p>
- * The example starts a system monitoring application, then concurrently
- * submits two jobs.
- * The job monitoring application generates job event tuples when jobs
- * are added or removed from registry, or when a job gets updated.
- * Tuples are pushed to a sink, which prints them onto the system output.</p>
- * <p>
- * Note that the original job events stream processing is executed by the
- * JobRegistryService event {@linkplain
- * JobRegistryService#addListener(org.apache.edgent.function.BiConsumer) listeners}
- * invoker thread.
- * It is considered good practice to isolate the event source from the rest
- * of the graph, in order for the processing of tuples to be executed by a
- * different thread.</p>
- */
-public class JobEventsSample {
- private final DirectProvider dp;
-
- public static void main(String[] args) throws Exception {
-
- JobEventsSample sample = new JobEventsSample();
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
-
- // Monitoring app
- sample.startJobMonitorApp();
-
- // Asynchronously start two applications
- executor.schedule(sample.runMonitoredApp("MonitoredApp1"), 300, TimeUnit.MILLISECONDS);
- executor.schedule(sample.runMonitoredApp("MonitoredApp2"), 3000, TimeUnit.MILLISECONDS);
- }
-
- JobEventsSample() throws Exception {
- this.dp = new DirectProvider();
- JobRegistry.createAndRegister(dp.getServices());
- }
-
- /**
- * Declares and submits a monitored application.
- * <p>
- * Note that inline sleeps are introduced to simulate the timing
- * of a real-life application lifecycle.
- *
- * @param name application name
- */
- void monitored(String name) throws InterruptedException, ExecutionException {
- // Declare topology
- Topology t = dp.newTopology(name);
-
- Random r = new Random();
- TStream<Double> d = t.poll(() -> r.nextGaussian(), 100, TimeUnit.MILLISECONDS);
- d.sink(tuple -> System.out.print("."));
-
- // Submit job after 2 seconds
- Thread.sleep(2000);
- Future<Job> f = dp.submit(t);
- Job job = f.get();
-
- // Run for 5 seconds, then close job
- Thread.sleep(5000);
- job.stateChange(Job.Action.CLOSE);
-
- // Unregister job after 2 seconds
- Thread.sleep(2000);
- provider().getServices().getService(JobRegistryService.class).removeJob(job.getId());
- }
-
- /**
- * Monitoring application generates tuples on job registrations, removals,
- * and on registered job updates.
- */
- Job startJobMonitorApp() throws InterruptedException, ExecutionException {
- Topology topology = dp.newTopology("JobMonitorApp");
-
- TStream<JsonObject> jobEvents = JobEvents.source(
- topology,
- (evType, job) -> { return JobEventsSample.wrap(evType, job); });
-
- jobEvents.sink(tuple -> {
- System.err.println(tuple.toString());
- });
-
- Future<Job> f = dp.submit(topology);
- return f.get();
- }
-
- /**
- * Creates a JsonObject wrapping a JobRegistryService event type and
- * Job info.
- *
- * @param evType the event type
- * @param job the job
- * @return the wrapped data
- */
- static JsonObject wrap(JobRegistryService.EventType evType, Job job) {
- JsonObject value = new JsonObject();
- value.addProperty("time", (Number)System.currentTimeMillis());
- value.addProperty("event", evType.toString());
- JsonObject obj = new JsonObject();
- obj.addProperty("id", job.getId());
- obj.addProperty("name", job.getName());
- obj.addProperty("state", job.getCurrentState().toString());
- obj.addProperty("nextState", job.getNextState().toString());
- obj.addProperty("health", job.getHealth().toString());
- obj.addProperty("lastError", job.getLastError());
- value.add("job", obj);
- return value;
- }
-
- private DirectProvider provider() {
- return dp;
- }
-
- private Runnable runMonitoredApp(String name) {
- return new Runnable() {
-
- @Override
- public void run() {
- try {
- monitored(name);
- } catch (Throwable t) {
- throw new RuntimeException(t);
- }
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobExecution.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobExecution.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobExecution.java
deleted file mode 100644
index 9e53949..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/JobExecution.java
+++ /dev/null
@@ -1,124 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.edgent.execution.Job;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Using the Job API to get/set a job's state.
- */
-public class JobExecution {
- public final static long JOB_LIFE_MILLIS = 10000;
- public final static long WAIT_AFTER_CLOSE = 2000;
-
- public static void main(String[] args) throws ExecutionException {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("JobExecution");
-
- // Source
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Peek
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- // Transform to strings
- TStream<String> gsPeriodic = gaussian.map(g -> "G:" + g + ":");
- gsPeriodic.print();
-
- // Submit job and poll its status for a while
- Future<Job> futureJob = tp.submit(t);
- Reporter reporter = new Reporter();
- try {
- Job job = futureJob.get();
- reporter.start(job);
-
- // Wait for the job to complete
- try {
- job.complete(JOB_LIFE_MILLIS, TimeUnit.MILLISECONDS);
- System.out.println("The job completed successfully");
- } catch (ExecutionException e) {
- System.out.println("The job aborted by throwing exception: " + e);
- }
- catch (InterruptedException e) {
- System.out.println("Interrupted while waiting for the job to complete");
- }
- catch (TimeoutException e) {
- System.out.println("Timed out while waiting for the job to complete");
- }
- finally {
- System.out.println("Closing the job...");
- job.stateChange(Job.Action.CLOSE);
- }
- System.out.println("Sleep after job close for " + WAIT_AFTER_CLOSE + " ms");
- Thread.sleep(WAIT_AFTER_CLOSE);
- }
- catch (InterruptedException e) {
- System.err.println("Interrupted!");
- }
- finally {
- reporter.stop();
- }
- }
-
- static class Reporter implements Runnable {
- private volatile Job job;
- private volatile Thread runner;
-
- @Override
- public void run() {
- try {
- while (true) {
- if (job != null)
- System.out.println("Job state is: current=" + job.getCurrentState() +
- " next=" + job.getNextState());
- Thread.sleep(500);
- }
- } catch (InterruptedException e) {
- System.out.println("Reporter interrupted");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- void start(Job job) {
- this.job = job;
- runner = Executors.defaultThreadFactory().newThread(this);
- runner.setName("Reporter");
- runner.setDaemon(false);
- runner.start();
- }
-
- void stop() {
- runner.interrupt();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/PeriodicSource.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/PeriodicSource.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/PeriodicSource.java
deleted file mode 100644
index ad13b84..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/PeriodicSource.java
+++ /dev/null
@@ -1,65 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Periodic polling of source data.
- *
- */
-public class PeriodicSource {
- /**
- * Shows polling a data source to periodically obtain a value.
- * Polls a random number generator for a new value every second
- * and then prints out the raw value and a filtered and transformed stream.
- * @param args command arguments
- * @throws Exception on failure
- */
- public static void main(String[] args) throws Exception {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("PeriodicSource");
-
- // Since this is the Direct provider the graph can access
- // objects created while the topology is being defined
- // (in this case the Random object r).
- Random r = new Random();
- TStream<Double> gaussian = t.poll(() -> r.nextGaussian(), 1, TimeUnit.SECONDS);
-
- // Peek at the value on the Stream printing it to System.out
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- // A filter
- gaussian = gaussian.filter(g -> g > 0.5);
-
- // A transformation
- TStream<String> gs = gaussian.map(g -> "G:" + g + ":");
- gs.print();
-
- tp.submit(t);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/SensorsAggregates.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SensorsAggregates.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/SensorsAggregates.java
deleted file mode 100644
index c260ecf..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SensorsAggregates.java
+++ /dev/null
@@ -1,118 +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.topology;
-
-import static org.apache.edgent.analytics.math3.stat.Statistic.MAX;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MEAN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.MIN;
-import static org.apache.edgent.analytics.math3.stat.Statistic.STDDEV;
-
-import org.apache.edgent.analytics.math3.json.JsonAnalytics;
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.samples.utils.sensor.SimulatedSensors;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.TWindow;
-import org.apache.edgent.topology.Topology;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-/**
- * Aggregation of sensor readings.
- *
- * Demonstrates partitioned aggregation and filtering of simulated sensors
- * that are bursty in nature, so that only intermittently
- * is the data output to {@code System.out}.
- * <P>
- * The two sensors are read as independent streams but combined
- * into a single stream and then aggregated across the last 50 readings
- * using windows. The window is partitioned by the sensor name
- * so that each sensor will have its own independent window.
- * This partitioning is automatic so that the same code would
- * work if readings from one hundred different sensors were
- * on the same stream, is it just driven by a key function.
- * <BR>
- * The windows are then aggregated using Apache Common Math
- * provided statistics and the final stream filtered so
- * that it will only contain values when each sensor
- * is (independently) out of range.
- * </P>
- *
- * @see SimulatedSensors#burstySensor(Topology, String)
- */
-public class SensorsAggregates {
-
- /**
- * Run a topology with two bursty sensors printing them to standard out.
- * @param args command arguments
- * @throws Exception on failure
- */
- public static void main(String[] args) throws Exception {
-
- System.out.println("SensorsAggregates: Output will be randomly intermittent, be patient!");
-
- DirectProvider tp = new DevelopmentProvider();
-
- Topology topology = tp.newTopology("SensorsReadingAggregates");
-
- TStream<JsonObject> sensors = sensorsAB(topology);
-
- sensors.print();
-
- System.out.println("#### Console URL for the job: "
- + tp.getServices().getService(HttpServer.class).getConsoleUrl());
-
- tp.submit(topology);
- }
-
- /**
- * Create a stream containing two aggregates from two bursty
- * sensors A and B that only produces output when the sensors
- * (independently) are having a burst period out of their normal range.
- * @param topology Topology to add the sub-graph to.
- * @return Stream containing two aggregates from two bursty
- * sensors A and B
- */
- public static TStream<JsonObject> sensorsAB(Topology topology) {
-
- // Simulate two sensors, A and B, both randomly bursty
- TStream<JsonObject> sensorA = SimulatedSensors.burstySensor(topology, "A");
- TStream<JsonObject> sensorB = SimulatedSensors.burstySensor(topology, "B");
-
- // Combine the sensor readings into a single stream
- TStream<JsonObject> sensors = sensorA.union(sensorB);
-
- // Create a window on the stream of the last 50 readings partitioned
- // by sensor name. In this case two independent windows are created (for a and b)
- TWindow<JsonObject,JsonElement> sensorWindow = sensors.last(50, j -> j.get("name"));
-
- // Aggregate the windows calculating the min, max, mean and standard deviation
- // across each window independently.
- sensors = JsonAnalytics.aggregate(sensorWindow, "name", "reading", MIN, MAX, MEAN, STDDEV);
-
- // Filter so that only when the sensor is beyond 2.0 (absolute) is a reading sent.
- sensors = sensors.filter(j -> Math.abs(j.get("reading").getAsJsonObject().get("MEAN").getAsDouble()) > 2.0);
-
- return sensors;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/SimpleFilterTransform.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SimpleFilterTransform.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/SimpleFilterTransform.java
deleted file mode 100644
index 7cd38b9..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SimpleFilterTransform.java
+++ /dev/null
@@ -1,57 +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.topology;
-
-import java.util.Random;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.execution.Job;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-public class SimpleFilterTransform {
- public static void main(String[] args) throws Exception {
-
- DirectProvider tp = new DirectProvider();
-
- Topology t = tp.newTopology("SimpleFilterTransform");
-
- Random r = new Random();
- TStream<Double> gaussian = t.generate(() -> r.nextGaussian());
-
- // testing Peek!
- gaussian = gaussian.peek(g -> System.out.println("R:" + g));
-
- // A filter
- gaussian = gaussian.filter(g -> g > 0.5);
-
- // A transformation
- TStream<String> gs = gaussian.map(g -> "G:" + g + ":");
- gs.print();
-
- // Submit the job, then close it after a while
- Future<Job> futureJob = tp.submit(t);
- Job job = futureJob.get();
- Thread.sleep(TimeUnit.SECONDS.toMillis(5));
- job.stateChange(Job.Action.CLOSE);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/SplitWithEnumSample.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SplitWithEnumSample.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/SplitWithEnumSample.java
deleted file mode 100644
index 3e59074..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/SplitWithEnumSample.java
+++ /dev/null
@@ -1,68 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.topology;
-
-import java.util.EnumMap;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-public class SplitWithEnumSample {
-
- public enum LogSeverityEnum {
-
- ALERT(1), CRITICAL(2), ERROR(3), WARNING(4), NOTICE(5), INFO(6), DEBUG(7);
-
- @SuppressWarnings("unused")
- private final int code;
-
- LogSeverityEnum(final int code) {
- this.code = code;
- }
- }
-
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology("SplitWithEnumSample");
-
- Random r = new Random();
-
- LogSeverityEnum[] values = LogSeverityEnum.values();
- TStream<String> d = t.poll(() -> values[r.nextInt(values.length)].toString()+ "_Log", 500, TimeUnit.MILLISECONDS);
-
- EnumMap<LogSeverityEnum, TStream<String>> categories = d
- .split(LogSeverityEnum.class, e -> LogSeverityEnum.valueOf(e.split("_")[0]));
-
- TStream<String> warnStream = categories.get(LogSeverityEnum.WARNING).tag("WARN");
- TStream<String> errorStream = categories.get(LogSeverityEnum.ERROR).tag("ERROR");
- TStream<String> infoStream = categories.get(LogSeverityEnum.INFO).tag("INFO");
-
- warnStream.sink(data -> System.out.println("warnStream = " + data));
- errorStream.sink(data -> System.out.println("errorStream = " + data));
- infoStream.sink(data -> System.out.println("infoStream = " + data));
-
- dtp.submit(t);
-
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/StreamTags.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/StreamTags.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/StreamTags.java
deleted file mode 100644
index 3eb3fa9..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/StreamTags.java
+++ /dev/null
@@ -1,63 +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.topology;
-
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.edgent.console.server.HttpServer;
-import org.apache.edgent.providers.development.DevelopmentProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-
-/**
- * Illustrates tagging TStreams with string labels.
- */
-public class StreamTags {
- public static void main(String[] args) throws Exception {
- DevelopmentProvider dtp = new DevelopmentProvider();
-
- Topology t = dtp.newTopology("StreamTags");
-
- // Tag the source stream with
- Random r = new Random();
- TStream<Double> d = t.poll(() -> (r.nextDouble() * 3),
- 100, TimeUnit.MILLISECONDS).tag("dots", "hashes", "ats");
-
- List<TStream<Double>> splits = d.split(3, tuple -> {
- switch (tuple.intValue()) {
- case 0:
- return 0;
- case 1:
- return 1;
- default:
- return 2;
- }
- });
-
- splits.get(0).tag("dots").sink(tuple -> System.out.print("."));
- splits.get(1).tag("hashes").sink(tuple -> System.out.print("#"));
- splits.get(2).tag("ats").sink(tuple -> System.out.print("@"));
-
- dtp.submit(t);
-
- System.out.println(dtp.getServices().getService(HttpServer.class).getConsoleUrl());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a7aeb2b4/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensor.java
----------------------------------------------------------------------
diff --git a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensor.java b/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensor.java
deleted file mode 100644
index d9b8a40..0000000
--- a/samples/topology/src/main/java/org/apache/edgent/samples/topology/TempSensor.java
+++ /dev/null
@@ -1,44 +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.topology;
-
-import java.util.Random;
-
-import org.apache.edgent.function.Supplier;
-
-/**
- * Every time get() is called, TempSensor generates a temperature reading.
- */
-public class TempSensor implements Supplier<Double> {
- double currentTemp = 65.0;
- Random rand;
-
- TempSensor(){
- rand = new Random();
- }
-
- @Override
- public Double get() {
- // Change the current temperature some random amount
- double newTemp = rand.nextGaussian() + currentTemp;
- currentTemp = newTemp;
- return currentTemp;
- }
-}