http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/highlevelapi/src/test/java/org/apache/apex/malhar/stream/sample/cookbook/MaxPerKeyExamplesTest.java ---------------------------------------------------------------------- diff --git a/demos/highlevelapi/src/test/java/org/apache/apex/malhar/stream/sample/cookbook/MaxPerKeyExamplesTest.java b/demos/highlevelapi/src/test/java/org/apache/apex/malhar/stream/sample/cookbook/MaxPerKeyExamplesTest.java deleted file mode 100644 index ec28b40..0000000 --- a/demos/highlevelapi/src/test/java/org/apache/apex/malhar/stream/sample/cookbook/MaxPerKeyExamplesTest.java +++ /dev/null @@ -1,210 +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.apex.malhar.stream.sample.cookbook; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Callable; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import org.apache.hadoop.conf.Configuration; - -import com.google.common.base.Throwables; - -import com.datatorrent.api.LocalMode; -import com.datatorrent.lib.db.jdbc.JdbcTransactionalStore; -import com.datatorrent.stram.StramLocalCluster; - -/** - * Test for MaxPerKeyExamples Application. - */ -public class MaxPerKeyExamplesTest -{ - - private static final String INPUT_TUPLE_CLASS = "org.apache.apex.malhar.stream.sample.cookbook.InputPojo"; - private static final String OUTPUT_TUPLE_CLASS = "org.apache.apex.malhar.stream.sample.cookbook.OutputPojo"; - private static final String DB_DRIVER = "org.h2.Driver"; - private static final String DB_URL = "jdbc:h2:~/test"; - private static final String INPUT_TABLE = "InputTable"; - private static final String OUTPUT_TABLE = "OutputTable"; - private static final String USER_NAME = "root"; - private static final String PSW = "password"; - private static final String QUERY = "SELECT * FROM " + INPUT_TABLE + ";"; - - private static final double[] MEANTEMPS = {85.3, 75.4}; - - @BeforeClass - public static void setup() - { - try { - Class.forName(DB_DRIVER).newInstance(); - - Connection con = DriverManager.getConnection(DB_URL,USER_NAME,PSW); - Statement stmt = con.createStatement(); - - String createMetaTable = "CREATE TABLE IF NOT EXISTS " + JdbcTransactionalStore.DEFAULT_META_TABLE + " ( " - + JdbcTransactionalStore.DEFAULT_APP_ID_COL + " VARCHAR(100) NOT NULL, " - + JdbcTransactionalStore.DEFAULT_OPERATOR_ID_COL + " INT NOT NULL, " - + JdbcTransactionalStore.DEFAULT_WINDOW_COL + " BIGINT NOT NULL, " - + "UNIQUE (" + JdbcTransactionalStore.DEFAULT_APP_ID_COL + ", " - + JdbcTransactionalStore.DEFAULT_OPERATOR_ID_COL + ", " + JdbcTransactionalStore.DEFAULT_WINDOW_COL + ") " - + ")"; - stmt.executeUpdate(createMetaTable); - - String createInputTable = "CREATE TABLE IF NOT EXISTS " + INPUT_TABLE - + "(MONTH INT(2) not NULL, DAY INT(2), YEAR INT(4), MEANTEMP DOUBLE(10) )"; - stmt.executeUpdate(createInputTable); - - String createOutputTable = "CREATE TABLE IF NOT EXISTS " + OUTPUT_TABLE - + "(MONTH INT(2) not NULL, MEANTEMP DOUBLE(10) )"; - stmt.executeUpdate(createOutputTable); - - String cleanTable = "truncate table " + INPUT_TABLE; - stmt.executeUpdate(cleanTable); - - stmt = con.createStatement(); - - String sql = "INSERT INTO " + INPUT_TABLE + " VALUES (6, 21, 2014, 85.3)"; - stmt.executeUpdate(sql); - sql = "INSERT INTO " + INPUT_TABLE + " VALUES (7, 20, 2014, 75.4)"; - stmt.executeUpdate(sql); - sql = "INSERT INTO " + INPUT_TABLE + " VALUES (6, 18, 2014, 45.3)"; - stmt.executeUpdate(sql); - - } catch (Throwable e) { - throw Throwables.propagate(e); - } - } - - @AfterClass - public static void cleanup() - { - try { - Class.forName(DB_DRIVER).newInstance(); - - Connection con = DriverManager.getConnection(DB_URL, USER_NAME, PSW); - Statement stmt = con.createStatement(); - - String dropInputTable = "DROP TABLE " + INPUT_TABLE; - stmt.executeUpdate(dropInputTable); - - String dropOutputTable = "DROP TABLE " + OUTPUT_TABLE; - stmt.executeUpdate(dropOutputTable); - - } catch (Throwable e) { - throw Throwables.propagate(e); - } - - } - - public void setConfig(Configuration conf) - { - conf.set("dt.operator.jdbcInput.prop.store.userName", USER_NAME); - conf.set("dt.operator.jdbcInput.prop.store.password", PSW); - conf.set("dt.operator.jdbcInput.prop.store.databaseDriver", DB_DRIVER); - conf.set("dt.operator.jdbcInput.prop.batchSize", "5"); - conf.set("dt.operator.jdbcInput.port.outputPort.attr.TUPLE_CLASS", INPUT_TUPLE_CLASS); - conf.set("dt.operator.jdbcInput.prop.store.databaseUrl", DB_URL); - conf.set("dt.operator.jdbcInput.prop.tableName", INPUT_TABLE); - conf.set("dt.operator.jdbcInput.prop.query", QUERY); - - conf.set("dt.operator.jdbcOutput.prop.store.userName", USER_NAME); - conf.set("dt.operator.jdbcOutput.prop.store.password", PSW); - conf.set("dt.operator.jdbcOutput.prop.store.databaseDriver", DB_DRIVER); - conf.set("dt.operator.jdbcOutput.prop.batchSize", "5"); - conf.set("dt.operator.jdbcOutput.port.input.attr.TUPLE_CLASS", OUTPUT_TUPLE_CLASS); - conf.set("dt.operator.jdbcOutput.prop.store.databaseUrl", DB_URL); - conf.set("dt.operator.jdbcOutput.prop.tablename", OUTPUT_TABLE); - } - - public int getNumEntries() - { - Connection con; - try { - con = DriverManager.getConnection(DB_URL,USER_NAME,PSW); - Statement stmt = con.createStatement(); - - String countQuery = "SELECT count(DISTINCT (MONTH, MEANTEMP)) from " + OUTPUT_TABLE; - ResultSet resultSet = stmt.executeQuery(countQuery); - resultSet.next(); - return resultSet.getInt(1); - } catch (SQLException e) { - throw new RuntimeException("fetching count", e); - } - } - - public Map<Integer, Double> getMaxMeanTemp() - { - Map<Integer, Double> result = new HashMap<>(); - Connection con; - try { - con = DriverManager.getConnection(DB_URL,USER_NAME,PSW); - Statement stmt = con.createStatement(); - - String countQuery = "SELECT DISTINCT * from " + OUTPUT_TABLE; - ResultSet resultSet = stmt.executeQuery(countQuery); - while (resultSet.next()) { - result.put(resultSet.getInt("MONTH"), resultSet.getDouble("MEANTEMP")); - - } - return result; - } catch (SQLException e) { - throw new RuntimeException("fetching count", e); - } - } - - @Test - public void MaxPerKeyExampleTest() throws Exception - { - LocalMode lma = LocalMode.newInstance(); - Configuration conf = new Configuration(false); - setConfig(conf); - - MaxPerKeyExamples app = new MaxPerKeyExamples(); - - lma.prepareDAG(app, conf); - - LocalMode.Controller lc = lma.getController(); - ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>() - { - @Override - public Boolean call() throws Exception - { - return getNumEntries() == 2; - } - }); - - lc.run(5000); - - double[] result = new double[2]; - result[0] = getMaxMeanTemp().get(6); - result[1] = getMaxMeanTemp().get(7); - Assert.assertArrayEquals(MEANTEMPS, result, 0.0); - } -}
http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/highlevelapi/src/test/resources/data/word.txt ---------------------------------------------------------------------- diff --git a/demos/highlevelapi/src/test/resources/data/word.txt b/demos/highlevelapi/src/test/resources/data/word.txt deleted file mode 100644 index 7e28409..0000000 --- a/demos/highlevelapi/src/test/resources/data/word.txt +++ /dev/null @@ -1,2 +0,0 @@ -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/highlevelapi/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/demos/highlevelapi/src/test/resources/log4j.properties b/demos/highlevelapi/src/test/resources/log4j.properties deleted file mode 100644 index 592eb19..0000000 --- a/demos/highlevelapi/src/test/resources/log4j.properties +++ /dev/null @@ -1,45 +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. -# - -log4j.rootLogger=INFO,CONSOLE - -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} %M - %m%n -log4j.appender.CONSOLE.threshold=INFO -#log4j.appender.CONSOLE.threshold=${test.log.console.threshold} -test.log.console.threshold=WARN - -log4j.appender.RFA=org.apache.log4j.RollingFileAppender -log4j.appender.RFA.layout=org.apache.log4j.PatternLayout -log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} %M - %m%n -log4j.appender.RFA.File=/tmp/app.log - -# to enable, add SYSLOG to rootLogger -log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender -log4j.appender.SYSLOG.syslogHost=127.0.0.1 -log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout -log4j.appender.SYSLOG.layout.conversionPattern=${dt.cid} %-5p [%t] %c{2} %x - %m%n -log4j.appender.SYSLOG.Facility=LOCAL1 - -#log4j.logger.org=INFO - -#log4j.logger.org.apache.commons.beanutils=warn -log4j.logger.com.datatorrent=INFO -log4j.logger.org.apache.apex=INFO http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/highlevelapi/src/test/resources/sampletweets.txt ---------------------------------------------------------------------- diff --git a/demos/highlevelapi/src/test/resources/sampletweets.txt b/demos/highlevelapi/src/test/resources/sampletweets.txt deleted file mode 100644 index c113130..0000000 --- a/demos/highlevelapi/src/test/resources/sampletweets.txt +++ /dev/null @@ -1,44 +0,0 @@ -Last week, I published a blog announcing that Apex was accepted as an Apache incubator project. -This week, Iâll give you a little more detail on what Apache Apex is, and why itâs important. - -Apache #Hadoop has been around for over a decade. It has become the de-facto big data platform, -allowing enterprises to transform their business operations by turning big data into something useful, meaningful, -and revenue-generating. #Hadoop promised the enablement of big data without incurring the costs you would normally think such powerful -processing systems would demand. This tremendous promise of transforming business operations continues to fuel high growth in the industry. - -It all got started when Hadoop engineers at Yahoo! asked, âHow can we build an efficient search indexing capability?â -The ensuing iterations and some inspiration resulted in the #MapReduce programming model. Although powerful, MapReduce wasnât perfect. - -Mastering MapReduce required a steep learning curve. Migrating applications to MapReduce required an almost complete rewrite. -Equally worrisome was the fact that MapReduce had batch processing paradigm and âcompute going to dataâ at its core, -thus posing a deterrent to Hadoop realizing its true potential. - -Expectedly enough, #MapReduce was an impediment that did little to bolster productization of big data. -Not to be deterred, there were faster substitutes for MapReduce. Just like Hadoop, these models required deeper expertise, were tough to operate and difficult to master. -As such, #Hadoop disrupted the way big data needs were handled, but remained largely under-productized. - -A decade after Hadoop was started, only a small percentage of big data projects are in production. -Data is growing rapidly and the ability to harness big data has become a decisive competitive advantage. -MapReduce impedes this demand (actually more of a scramble) to transform into a data-driven business. - -In hindsight, it is clear that in the early days, the subsequent success of Hadoop was not anticipated. -If they had anticipated Hadoopâs success, the question would have been, âWhat can we do with massively distributed resources?â -The answer to this question, which came about soon after, was YARN (Hadoop 2.0), the next generation Hadoop. -For the first time, #YARN brought the capability of exploring how distributed resources handling big data could perform âa lot of thingsâ, -thus going beyond the early MapReduce paradigm, and in a way beyond batch or even compute-going-to-data paradigms. -YARN presented the capability to allow big data to not just become big in size, but broader in use cases. With its enabling capability as a Hadoop facilitator, -YARN has pushed Hadoop towards realizing its true potential. The Hadoop predicament is similar to what -cellphones would have been without the more popular features such as messaging and internet connectivity. - - -In their early years, cellphones upset the landline market, but did not foster an immediate market furor till -it transformed into the new-age âsmartphoneâ with impressive features. -YARN is most certainly the enabling factor for big data dreaming bigger and wider, and with it, Hadoop 2.0 is now a true de-facto distributed operating system. - -Whatâs needed is bleeding edge YARN-based platforms capable of radically realizing Hadoopâs potential - -Now is the right time to not only productize big data, but to see how setting it in motion can ensure realization of greater business goals. -A Herculean task, this demands platforms that are easy to deploy, require nothing beyond everyday IT expertise, can effortlessly integrate with an existing IT infrastructure while ensuring ease of migration. -The new-age Hadoop platforms need to be designed with an approach to reduce time-to-market by shortening the application lifecycle, from building to launching, thus quickening the realization of revenue for businesses. -They will also have to reduce time for developers to develop, devOps to operationalize, and finally reduce time to insight for business. -Platforms such as these will need to learn, adapt, and change to meet the burgeoning needs of the big data world. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/highlevelapi/src/test/resources/wordcount/word.txt ---------------------------------------------------------------------- diff --git a/demos/highlevelapi/src/test/resources/wordcount/word.txt b/demos/highlevelapi/src/test/resources/wordcount/word.txt deleted file mode 100644 index edd0f51..0000000 --- a/demos/highlevelapi/src/test/resources/wordcount/word.txt +++ /dev/null @@ -1,8 +0,0 @@ -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -word1 word2 word7 word9 word2 word3 word2 word4 word7 word3 word9 word9 word5 word5 word4 word2 word1 error -bye \ No newline at end of file http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/pom.xml ---------------------------------------------------------------------- diff --git a/demos/iteration/pom.xml b/demos/iteration/pom.xml deleted file mode 100644 index 1e2fe7c..0000000 --- a/demos/iteration/pom.xml +++ /dev/null @@ -1,37 +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> - - <artifactId>iteration-demo</artifactId> - <packaging>jar</packaging> - - <name>Apache Apex Malhar Iteration Demo</name> - <description>DataTorrent demo applications that demonstrates the iteration feature.</description> - - <parent> - <groupId>org.apache.apex</groupId> - <artifactId>malhar-demos</artifactId> - <version>3.7.0-SNAPSHOT</version> - </parent> - -</project> http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/assemble/appPackage.xml ---------------------------------------------------------------------- diff --git a/demos/iteration/src/assemble/appPackage.xml b/demos/iteration/src/assemble/appPackage.xml deleted file mode 100644 index 4138cf2..0000000 --- a/demos/iteration/src/assemble/appPackage.xml +++ /dev/null @@ -1,59 +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. - ---> -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>appPackage</id> - <formats> - <format>jar</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <fileSets> - <fileSet> - <directory>${basedir}/target/</directory> - <outputDirectory>/app</outputDirectory> - <includes> - <include>${project.artifactId}-${project.version}.jar</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/target/deps</directory> - <outputDirectory>/lib</outputDirectory> - </fileSet> - <fileSet> - <directory>${basedir}/src/site/conf</directory> - <outputDirectory>/conf</outputDirectory> - <includes> - <include>*.xml</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/META-INF</directory> - <outputDirectory>/META-INF</outputDirectory> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/app</directory> - <outputDirectory>/app</outputDirectory> - </fileSet> - </fileSets> - -</assembly> - http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/main/java/com/datatorrent/demos/iteration/Application.java ---------------------------------------------------------------------- diff --git a/demos/iteration/src/main/java/com/datatorrent/demos/iteration/Application.java b/demos/iteration/src/main/java/com/datatorrent/demos/iteration/Application.java deleted file mode 100644 index 7fbdfd1..0000000 --- a/demos/iteration/src/main/java/com/datatorrent/demos/iteration/Application.java +++ /dev/null @@ -1,171 +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.datatorrent.demos.iteration; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.hadoop.conf.Configuration; - -import com.datatorrent.api.Context; -import com.datatorrent.api.DAG; -import com.datatorrent.api.DefaultInputPort; -import com.datatorrent.api.DefaultOutputPort; -import com.datatorrent.api.StreamingApplication; -import com.datatorrent.api.annotation.ApplicationAnnotation; -import com.datatorrent.common.util.BaseOperator; -import com.datatorrent.common.util.DefaultDelayOperator; -import com.datatorrent.lib.testbench.RandomEventGenerator; - -/** - * Iteration demo : <br> - * - * <pre> - * LocalMode.runApp(new Application(), 600000); // 10 min run - * </pre> - * - * Run Success : <br> - * For successful deployment and run, user should see the Fibonacci sequence, something like the - * following output on the console: - * - * <pre> - * 1 - * 1 - * 2 - * 3 - * 5 - * 8 - * 13 - * 21 - * 34 - * 55 - * ... - * </pre> - * - * - * @since 3.4.0 - */ -@ApplicationAnnotation(name = "IterationDemo") -public class Application implements StreamingApplication -{ - private static final Logger LOG = LoggerFactory.getLogger(Application.class); - private String extraOutputFileName; // for unit test - - public static class FibonacciOperator extends BaseOperator - { - public long currentNumber = 1; - private transient long tempNum; - public transient DefaultInputPort<Object> dummyInputPort = new DefaultInputPort<Object>() - { - @Override - public void process(Object tuple) - { - } - }; - public transient DefaultInputPort<Long> input = new DefaultInputPort<Long>() - { - @Override - public void process(Long tuple) - { - tempNum = (currentNumber == 1) ? 1 : tuple; - } - }; - public transient DefaultOutputPort<Long> output = new DefaultOutputPort<>(); - - - @Override - public void endWindow() - { - output.emit(currentNumber); - currentNumber += tempNum; - if (currentNumber <= 0) { - currentNumber = 1; - } - } - } - - public static class StdoutOperator extends BaseOperator - { - private String extraOutputFileName; // for unit test - private transient PrintStream extraOutputStream; - /** - * This is the input port which receives the tuples that will be written to stdout. - */ - public final transient DefaultInputPort<Object> input = new DefaultInputPort<Object>() - { - @Override - @SuppressWarnings("UseOfSystemOutOrSystemErr") - public void process(Object t) - { - String s = t.toString(); - LOG.info(s); - if (extraOutputStream != null) { - extraOutputStream.println(s); - } - } - }; - - @Override - public void setup(Context.OperatorContext context) - { - if (extraOutputFileName != null) { - try { - extraOutputStream = new PrintStream(new FileOutputStream(extraOutputFileName), true); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - } - - @Override - public void teardown() - { - extraOutputStream.close(); - } - - public void setExtraOutputFileName(String fileName) - { - this.extraOutputFileName = fileName; - } - } - - public void setExtraOutputFileName(String fileName) - { - this.extraOutputFileName = fileName; - } - - @Override - public void populateDAG(DAG dag, Configuration conf) - { - RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator()); - FibonacciOperator fib = dag.addOperator("FIB", FibonacciOperator.class); - DefaultDelayOperator opDelay = dag.addOperator("opDelay", DefaultDelayOperator.class); - StdoutOperator console = new StdoutOperator(); - console.setExtraOutputFileName(extraOutputFileName); - dag.addOperator("console", console); - dag.addStream("dummy_to_operator", rand.integer_data, fib.dummyInputPort); - dag.addStream("operator_to_delay", fib.output, opDelay.input, console.input); - dag.addStream("delay_to_operator", opDelay.output, fib.input); - } - -} http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/main/java/com/datatorrent/demos/iteration/package-info.java ---------------------------------------------------------------------- diff --git a/demos/iteration/src/main/java/com/datatorrent/demos/iteration/package-info.java b/demos/iteration/src/main/java/com/datatorrent/demos/iteration/package-info.java deleted file mode 100644 index d0b62ea..0000000 --- a/demos/iteration/src/main/java/com/datatorrent/demos/iteration/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -/** - * Iteration demonstration application. - */ -package com.datatorrent.demos.iteration; http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/main/resources/META-INF/properties.xml ---------------------------------------------------------------------- diff --git a/demos/iteration/src/main/resources/META-INF/properties.xml b/demos/iteration/src/main/resources/META-INF/properties.xml deleted file mode 100644 index 5212b91..0000000 --- a/demos/iteration/src/main/resources/META-INF/properties.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- - - 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. - ---> -<configuration> - <!-- Memory settings for all demos --> - <property> - <name>dt.attr.MASTER_MEMORY_MB</name> - <value>512</value> - </property> - <property> - <name>dt.attr.DEBUG</name> - <value>true</value> - </property> - <property> - <name>dt.application.*.operator.*.attr.MEMORY_MB</name> - <value>128</value> - </property> - <property> - <name>dt.application.*.operator.*.attr.JVM_OPTIONS</name> - <value>-Xmx128M</value> - </property> - <property> - <name>dt.application.*.operator.*.port.*.attr.BUFFER_MEMORY_MB</name> - <value>128</value> - </property> - -</configuration> http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/test/java/com/datatorrent/demos/iteration/ApplicationTest.java ---------------------------------------------------------------------- diff --git a/demos/iteration/src/test/java/com/datatorrent/demos/iteration/ApplicationTest.java b/demos/iteration/src/test/java/com/datatorrent/demos/iteration/ApplicationTest.java deleted file mode 100644 index 9fb89ac..0000000 --- a/demos/iteration/src/test/java/com/datatorrent/demos/iteration/ApplicationTest.java +++ /dev/null @@ -1,86 +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.datatorrent.demos.iteration; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; - -import org.junit.Assert; -import org.junit.Test; - -import org.apache.hadoop.conf.Configuration; - -import com.datatorrent.api.LocalMode; - -/** - * - */ -public class ApplicationTest -{ - @Test - public void testIterationApp() throws Exception - { - LocalMode lma = LocalMode.newInstance(); - Configuration conf = new Configuration(false); - Application app = new Application(); - String outputFileName = "target/output.txt"; - long timeout = 10 * 1000; // 10 seconds - - new File(outputFileName).delete(); - app.setExtraOutputFileName(outputFileName); - lma.prepareDAG(app, conf); - LocalMode.Controller lc = lma.getController(); - lc.runAsync(); - - long startTime = System.currentTimeMillis(); - do { - try { - Thread.sleep(500); - } catch (InterruptedException ex) { - break; - } - File file = new File(outputFileName); - if (file.length() > 50) { - break; - } - } - while (System.currentTimeMillis() - startTime < timeout); - - lc.shutdown(); - try (BufferedReader br = new BufferedReader(new FileReader(outputFileName))) { - Assert.assertEquals("1", br.readLine()); - Assert.assertEquals("1", br.readLine()); - Assert.assertEquals("2", br.readLine()); - Assert.assertEquals("3", br.readLine()); - Assert.assertEquals("5", br.readLine()); - Assert.assertEquals("8", br.readLine()); - Assert.assertEquals("13", br.readLine()); - Assert.assertEquals("21", br.readLine()); - Assert.assertEquals("34", br.readLine()); - Assert.assertEquals("55", br.readLine()); - Assert.assertEquals("89", br.readLine()); - Assert.assertEquals("144", br.readLine()); - Assert.assertEquals("233", br.readLine()); - Assert.assertEquals("377", br.readLine()); - Assert.assertEquals("610", br.readLine()); - Assert.assertEquals("987", br.readLine()); - } - } -} http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/iteration/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/demos/iteration/src/test/resources/log4j.properties b/demos/iteration/src/test/resources/log4j.properties deleted file mode 100644 index cf0d19e..0000000 --- a/demos/iteration/src/test/resources/log4j.properties +++ /dev/null @@ -1,43 +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. -# - -log4j.rootLogger=DEBUG,CONSOLE - -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} %M - %m%n -log4j.appender.CONSOLE.threshold=${test.log.console.threshold} -test.log.console.threshold=DEBUG - -log4j.appender.RFA=org.apache.log4j.RollingFileAppender -log4j.appender.RFA.layout=org.apache.log4j.PatternLayout -log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} %M - %m%n -log4j.appender.RFA.File=/tmp/app.log - -# to enable, add SYSLOG to rootLogger -log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender -log4j.appender.SYSLOG.syslogHost=127.0.0.1 -log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout -log4j.appender.SYSLOG.layout.conversionPattern=${dt.cid} %-5p [%t] %c{2} %x - %m%n -log4j.appender.SYSLOG.Facility=LOCAL1 - -log4j.logger.org=info -#log4j.logger.org.apache.commons.beanutils=warn -log4j.logger.com.datatorrent=debug -log4j.logger.org.apache.apex=debug http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/machinedata/pom.xml ---------------------------------------------------------------------- diff --git a/demos/machinedata/pom.xml b/demos/machinedata/pom.xml deleted file mode 100644 index 5d5bac2..0000000 --- a/demos/machinedata/pom.xml +++ /dev/null @@ -1,66 +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> - - <artifactId>machinedata-demo</artifactId> - <packaging>jar</packaging> - - <name>Apache Apex Malhar MachineData Demo</name> - <description></description> - - <parent> - <groupId>org.apache.apex</groupId> - <artifactId>malhar-demos</artifactId> - <version>3.7.0-SNAPSHOT</version> - </parent> - - <dependencies> - <dependency> - <groupId>org.apache.apex</groupId> - <artifactId>malhar-contrib</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>redis.clients</groupId> - <artifactId>jedis</artifactId> - <version>2.5.1</version> - </dependency> - <dependency> - <groupId>javax.mail</groupId> - <artifactId>javax.mail-api</artifactId> - <version>1.5.2</version> - </dependency> - <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>javax.mail</artifactId> - <version>1.5.2</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/machinedata/src/assemble/appPackage.xml ---------------------------------------------------------------------- diff --git a/demos/machinedata/src/assemble/appPackage.xml b/demos/machinedata/src/assemble/appPackage.xml deleted file mode 100644 index 4138cf2..0000000 --- a/demos/machinedata/src/assemble/appPackage.xml +++ /dev/null @@ -1,59 +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. - ---> -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>appPackage</id> - <formats> - <format>jar</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <fileSets> - <fileSet> - <directory>${basedir}/target/</directory> - <outputDirectory>/app</outputDirectory> - <includes> - <include>${project.artifactId}-${project.version}.jar</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/target/deps</directory> - <outputDirectory>/lib</outputDirectory> - </fileSet> - <fileSet> - <directory>${basedir}/src/site/conf</directory> - <outputDirectory>/conf</outputDirectory> - <includes> - <include>*.xml</include> - </includes> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/META-INF</directory> - <outputDirectory>/META-INF</outputDirectory> - </fileSet> - <fileSet> - <directory>${basedir}/src/main/resources/app</directory> - <outputDirectory>/app</outputDirectory> - </fileSet> - </fileSets> - -</assembly> - http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/machinedata/src/main/html/global.js ---------------------------------------------------------------------- diff --git a/demos/machinedata/src/main/html/global.js b/demos/machinedata/src/main/html/global.js deleted file mode 100644 index 753f58f..0000000 --- a/demos/machinedata/src/main/html/global.js +++ /dev/null @@ -1,269 +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. - */ -/** - * Declaration and initialization for global variables. - */ - -// url parameters -var params; - -// Data Points -var aggrData; -var aggrDataPoints; -var contData; -var contDataPoints; - -// CPU data table -var cpuTable; -var cpuChart; -var cpuView; - -// ram data table -var ramTable; -var ramChart; -var ramView; - -// hdd data table -var hddTable; -var hddChart; -var hddView; - -// chart options -var chartOptions; - -// Date formatter -var dateFormatter; - -// window look back value -var lookback; -var aggrLookBack; -var contLookBack; -var contRefresh; - -// Get split query string -function QueryString() { - var query_string = {}; - var query = window.location.search.substring(1); - return query; -} -function SplitQuery(query) -{ - var params = {}; - var vars = query.split("&"); - for (var i=0;i<vars.length;i++) - { - var pair = vars[i].split("="); - if(pair.length == 2) - { - params[pair[0]] = pair[1]; - } - } - return params; -} - -// Initialize global variable(s) -function InitializeGlobal() -{ - // Initialize params - params = SplitQuery(QueryString()); - - // Initialize data points - aggrDataPoints = new Array(); - contDataPoints = new Array(); - - // Initialize cpu table - cpuTable = new google.visualization.DataTable(); - cpuTable.addColumn('datetime', 'Time'); - cpuTable.addColumn('number', 'CPU'); - chartOptions = { width: 600, height: 300, legend: 'none', pointSize: 0, lineWidth : 1 }; - cpuChart = new google.visualization.ScatterChart(document.getElementById('chart_div')); - cpuView = new google.visualization.DataView(cpuTable); - - // Initialize ram table - ramTable = new google.visualization.DataTable(); - ramTable.addColumn('datetime', 'Time'); - ramTable.addColumn('number', 'RAM');; - ramChart = new google.visualization.ScatterChart(document.getElementById('chart1_div')); - ramView = new google.visualization.DataView(ramTable); - - // Initialize hdd table - hddTable = new google.visualization.DataTable(); - hddTable.addColumn('datetime', 'Time'); - hddTable.addColumn('number', 'HDD');; - hddChart = new google.visualization.ScatterChart(document.getElementById('chart2_div')); - hddView = new google.visualization.DataView(hddTable); - - // get lookback value - lookback = (new Date().getTime()/1000) - 3600*6; - if (params['lookback'] && (params['lookback'].length > 0)) lookback = (new Date().getTime()/1000) - (3600*(parseInt(params['lookback']))); - aggrLookBack = lookback; - - // get continuos lookback - contLookBack = lookback; - contRefresh = 5; - - // get param lookback - paramLookBack = 6; - if (params['lookback'] && (params['lookback'].length > 0)) paramLookBack = parseInt(params['lookback']); - //if (params['refresh'] && (params['refresh'].length > 0)) contRefresh = parseInt(params['refresh']); -} - - -/** - * Function to create fetch urls from given parameters - */ -function DataUrl() -{ - var url = "json.php?bucket=m"; - url += "&customer="; - if (params['customer']) - { - url += params['customer']; - } - url += "&product="; - if (params['product']) - { - url += params['product']; - } - url += "&os="; - if (params['os']) - { - url += params['os']; - } - url += "&software1="; - if (params['software1']) - { - url += params['software1']; - } - url += "&software2="; - if (params['software2']) - { - url += params['software2']; - } - url += "&software3="; - if (params['software3']) - { - url += params['software3']; - } - url += "&from="; - url += Math.floor(lookback); - return url; -} - -/** - * Creates data table with time stamp and cpu values. - * Draw line chart for time vs cpu. - */ -function DrawCPUChart() -{ - // create/delete rows - if (cpuTable.getNumberOfRows() < aggrDataPoints.length) - { - var numRows = aggrDataPoints.length - cpuTable.getNumberOfRows(); - cpuTable.addRows(numRows); - } else { - for(var i=(cpuTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--) - { - cpuTable.removeRow(i); - } - } - - // Populate data table with time/cpu data points. - for(var i=0; i < cpuTable.getNumberOfRows(); i++) - { - //if(parseFloat(aggrDataPoints[i].cpu) < 500) continue; - cpuTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp))); - cpuTable.setCell(i, 1, parseFloat(aggrDataPoints[i].cpu)); - } - - // Draw line chart. - chartOptions.title = 'CPU Usage (%)'; - cpuChart.draw(cpuView, chartOptions); -} - -/** - * Creates data table with time stamp and revenu values. - * Draw line chart for time vs ram. - */ -function DrawRAMChart() -{ - // create/delete rows - if (ramTable.getNumberOfRows() < aggrDataPoints.length) - { - var numRows = aggrDataPoints.length - ramTable.getNumberOfRows(); - ramTable.addRows(numRows); - } else { - for(var i=(ramTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--) - { - ramTable.removeRow(i); - } - } - - // Populate data table with time/ram data points. - for(var i=0; i < ramTable.getNumberOfRows(); i++) - { - ramTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp))); - ramTable.setCell(i, 1, parseFloat(aggrDataPoints[i].ram)); - } - - // Draw line chart. - chartOptions.title = 'RAM Usage (%)'; - ramChart.draw(ramView, chartOptions); -} - -/** - * Creates data table with time stamp and hdd values. - * Draw line chart for time vs hdd. - */ -function DrawHDDChart() -{ - // create/delete rows - if (hddTable.getNumberOfRows() < aggrDataPoints.length) - { - var numRows = aggrDataPoints.length - hddTable.getNumberOfRows(); - hddTable.addRows(numRows); - } else { - for(var i=(hddTable.getNumberOfRows()-1); i >= aggrDataPoints.length; i--) - { - hddTable.removeRow(i); - } - } - - // Populate data table with time/hdd data points. - for(var i=0; i < hddTable.getNumberOfRows(); i++) - { - hddTable.setCell(i, 0, new Date(parseInt(aggrDataPoints[i].timestamp))); - hddTable.setCell(i, 1, parseInt(aggrDataPoints[i].hdd)); - } - - // Draw line chart. - chartOptions.title = 'HDD Usage (%)'; - hddChart.draw(hddView, chartOptions); -} - -/** - * Sort json array - */ -function sortByKey(array, key) { - return array.sort(function(a, b) { - var x = a[key]; var y = b[key]; - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - }); -} - http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/machinedata/src/main/html/index.php ---------------------------------------------------------------------- diff --git a/demos/machinedata/src/main/html/index.php b/demos/machinedata/src/main/html/index.php deleted file mode 100644 index 6b93570..0000000 --- a/demos/machinedata/src/main/html/index.php +++ /dev/null @@ -1,263 +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. - */ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> -<title>Machine Generated Data Demo </title> - -<link rel="stylesheet" type="text/css" href="malhar.css"> - -<!-- Google charts include --> -<script type="text/javascript" src="https://www.google.com/jsapi"></script> -<script type="text/javascript"> -google.load('visualization', '1', {'packages':['corechart']}); -</script> - -<!-- Malhar charting utils --> -<script type="text/javascript" src="global.js"></script> - -<!-- window onload --> -<script type="text/javascript"> - -function DrawAggrCharts() -{ - // get refresh url - lookback = aggrLookBack; - var url = DataUrl(); - - // fetch data, draw charts - try - { - var connect = new XMLHttpRequest(); - connect.onreadystatechange = function() { - if(connect.readyState==4 && connect.status==200) { - -console.log(url); - aggrData = connect.response; - var pts = JSON.parse(aggrData); - aggrDataPoints = new Array(); - for(var i=0; i < pts.length; i++) aggrDataPoints.push(pts[i]); - DrawCPUChart(); - DrawRAMChart(); - DrawHDDChart(); - //DrawImpressionsChart(); - delete aggrData; - } - } - connect.open('GET', url, true); - connect.send(null); - } catch(e) { - } - aggrLookBack += 30; -} - -function DrawContCharts() -{ - // get refresh url - lookback = contLookBack; - var url = DataUrl(); - //document.getElementById('chart_div').innerHTML = url; - - // fetch data, draw charts - try - { - var connect = new XMLHttpRequest(); - connect.onreadystatechange = function() { - if(connect.readyState==4 && connect.status==200) { - contData = connect.response; - var newPts = JSON.parse(contData); - contDataPoints = new Array(); - for(var i=0; i < newPts.length; i++) contDataPoints.push(newPts[i]); - DrawCtrChart() ; - DrawMarginChart(); - delete contData; - delete newPts; - } - } - connect.open('GET', url, true); - connect.send(null); - } catch(e) { - } - contLookBack += contRefresh; -} - -window.onload = function() { - - // Initialize global - InitializeGlobal(); - - // Inituialize form fields - if (params['customer']) document.getElementById('customer').value = params['customer']; - if (params['product']) document.getElementById('product').value = params['product']; - if (params['os']) document.getElementById('os').value = params['os']; - if (params['software1']) document.getElementById('software1').value = params['software1']; - if (params['software2']) document.getElementById('software2').value = params['software2']; - if (params['software3']) document.getElementById('software3').value = params['software3']; - if (params['refresh']) - { - document.getElementById('refresh').value = params['refresh']; - } else { - document.getElementById('refresh').value = 5; - } - if (params['lookback']) - { - document.getElementById('lookback').value = params['lookback']; - } else { - document.getElementById('lookback').value = 6; - } - - // draw charts - DrawAggrCharts(); - //DrawContCharts(); - setInterval(DrawAggrCharts, 30000); - //setInterval(DrawContCharts, contRefresh * 1000); -}; - -</script> - -</head> -<body> - - <div id="header"> - <ul class="dashboard-modes"> - <li> - <a href="#" class="active">Machine Generated Data Demo </a> - </li> - </ul> - - </div> - - <div id="main"> - <div id="pagecontent"> - <div class="dashboardMgr"> - <div class="inner" style=""> - <h2 class="title">View Real Time Data Charts</h2> - <form method="GET" action="index.php"> - - <label for="customer">Customer ID:</label> - <select name="customer" id="customer" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 1; $i <= 5; $i++) { - print "<option value=\"$i\">Customer $i</option>\n"; - } - ?> - </select> - - <label for="">Product ID:</label> - <select name="product" id="product" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 4; $i <= 6; $i++) { - print "<option value=\"$i\">Product $i</option>\n"; - } - ?> - </select> - - <label for="">Product OS:</label> - <select name="os" id="os" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 10; $i <= 12; $i++) { - print "<option value=\"$i\">OS $i</option>\n"; - } - ?> - </select> - - <label for="software1">Software1 Ver:</label> - <select name="software1" id="software1" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 10; $i <= 12; $i++) { - print "<option value=\"$i\">Software1 Version $i</option>\n"; - } - ?> - </select> - - <label for="software2">Software2 Ver:</label> - <select name="software2" id="software2" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 12; $i <= 14; $i++) { - print "<option value=\"$i\">Software2 Version $i</option>\n"; - } - ?> - </select> - - <label for="software3">Software3 Ver:</label> - <select name="software3" id="software3" style="width:200px;"> - <option value="">ALL</option> - <?php - for ($i = 4; $i <= 6; $i++) { - print "<option value=\"$i\">Software3 Version $i</option>\n"; - } - ?> - </select> - - <label for="">Refresh Interval:</label> - <div class="input-append"> - <input type="text" name="refresh" id="refresh" class="input-small"/> - <span class="add-on">Secs</span> - </div> - - - <label for="">Look Back:</label> - <div class="input-append"> - <input type="text" name="lookback" id="lookback" class="input-small"/> - <span class="add-on">Hours</span> - </div> - - <input type="submit" value="submit" class="btn btn-primary" /> - - </form> - </div> - <div class="collapser-container"> - <div class="collapser"> - <div class="collapse-dot"></div> - <div class="collapse-dot"></div> - <div class="collapse-dot"></div> - </div> - </div> - </div> - <div class="dashboardMain"> - - <!-- <table><tbody> - <tr> - <td><div id="chart_div"></div></td> - <td><div id="chart1_div" ></div></td> - </tr> - <tr> - <td><div id="chart2_div" ></div></td> - <td><div id="chart3_div" ></div></td> - </tr> - <tr> - <td><div id="chart4_div" ></div></td> - <td><div id="chart5_div" ></div></td> - </tr> - </tr></tbody></table> --> - <div class="chart-ctnr" id="chart_div"></div> - <div class="chart-ctnr" id="chart1_div" ></div> - <div class="chart-ctnr" id="chart2_div" ></div> -<!-- <div class="chart-ctnr" id="chart3_div" ></div> - <div class="chart-ctnr" id="chart4_div" ></div> - <div class="chart-ctnr" id="chart5_div" ></div> --> - </div> -</body> -</html> http://git-wip-us.apache.org/repos/asf/apex-malhar/blob/d5bf96ca/demos/machinedata/src/main/html/json.php ---------------------------------------------------------------------- diff --git a/demos/machinedata/src/main/html/json.php b/demos/machinedata/src/main/html/json.php deleted file mode 100644 index 75a7117..0000000 --- a/demos/machinedata/src/main/html/json.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/* - * 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. - */ -header("Content-type: application/json"); -$redis = new Redis(); -$redis->connect('localhost'); -$redis->select(15); -$from = $_GET['from']; -$bucket = $_GET['bucket']; -$customer = $_GET['customer']; -$product = $_GET['product']; -$os = $_GET['os']; -$software1 = $_GET['software1']; -$software2 = $_GET['software2']; -$software3 = $_GET['software3']; - -switch ($bucket) { -case 'D': - $format = 'Ymd'; - $incr = 60 * 60 * 24; - break; -case 'h': - $format = 'YmdH'; - $incr = 60 * 60; - break; -case 'm': - $format = 'YmdHi'; - $incr = 60; - break; -default: - break; -} - -$arr = array(); -if ($customer != '') { - $arr[] = "0:".$customer; -} -if ($product != '') { - $arr[] = "1:".$product; -} -if ($os != '') { - $arr[] = "2:".$os; -} -if ($software1 != '') { - $arr[] = "3:".$software1; -} -if ($software2 != '') { - $arr[] = "4:".$software2; -} -if ($software3 != '') { - $arr[] = "5:".$software3; -} -$subpattern = ""; -if (count($arr) != 0) { - $subpattern = join("|", $arr); -} - -$result = array(); - -while ($from < time()) { - $date = gmdate($format, $from); - if ($subpattern != '') { - $key = $bucket . '|' . $date . '|' . $subpattern; - } else { - $key = $bucket . '|' . $date ; - } - $hash = $redis->hGetAll($key); - if ($hash) { - $cpu = $hash['cpu']; - $ram = $hash['ram']; - $hdd = $hash['hdd']; - $result[] = array('timestamp'=> $from * 1000, 'cpu'=>$cpu, 'ram'=>$ram, 'hdd'=>$hdd); - } - $from += $incr; -} - -array_pop($result); -print json_encode($result); - -?>
