You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2015/11/07 02:54:10 UTC
[06/10] incubator-apex-malhar git commit: Cleanup of web resources
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/f0863913/contrib/src/main/html/machinedata/global.js
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/machinedata/global.js b/contrib/src/main/html/machinedata/global.js
deleted file mode 100644
index 753f58f..0000000
--- a/contrib/src/main/html/machinedata/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/incubator-apex-malhar/blob/f0863913/contrib/src/main/html/machinedata/index.php
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/machinedata/index.php b/contrib/src/main/html/machinedata/index.php
deleted file mode 100644
index dcc595e..0000000
--- a/contrib/src/main/html/machinedata/index.php
+++ /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.
- */
-<!--
- -- Copyright (c) 2012-2013 Malhar, Inc.
- -- All Rights Reserved.
- -->
-
-<!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>Data Torrent : 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 id="logo"><img src="main_banner.png"/></div>
- </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/incubator-apex-malhar/blob/f0863913/contrib/src/main/html/machinedata/json.php
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/machinedata/json.php b/contrib/src/main/html/machinedata/json.php
deleted file mode 100644
index 75a7117..0000000
--- a/contrib/src/main/html/machinedata/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);
-
-?>
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/f0863913/contrib/src/main/html/machinedata/main_banner.png
----------------------------------------------------------------------
diff --git a/contrib/src/main/html/machinedata/main_banner.png b/contrib/src/main/html/machinedata/main_banner.png
deleted file mode 100644
index 9e3724f..0000000
Binary files a/contrib/src/main/html/machinedata/main_banner.png and /dev/null differ