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; - } -}