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/master Commit: a7aeb2b4f972df6e6a74a0a7ded328391deab722 Parents: 58b8895 Author: Dale LaBossiere <dlab...@us.ibm.com> Authored: Thu Nov 23 10:31:10 2017 -0500 Committer: Dale LaBossiere <dlab...@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., `g...@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; - } - -}