From 9d3df24a1c78275f9e8a91f8b47065c252563abe Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 4 Jul 2015 11:13:25 +0530 Subject: [PATCH 001/126] adding Health Statistics.jag --- .../console/healthStatistics.jag | 69 +++++++++++++++++++ .../console/jaggery.conf | 10 ++- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 components/org.apache.stratos.manager.console/console/healthStatistics.jag diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag new file mode 100644 index 0000000000..45937c82b6 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -0,0 +1,69 @@ +<% +/* + * + * 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. + * + */ +//add login validator for pages +include('/controllers/login/validator.jag'); +include('/controllers/menu/menu_generator.jag'); + +var log = new Log("apacheStratos.appconfig"), + error = [], + caramel = require('caramel'), +// dataTSV=require('/controllers/datatsv/data2.json'), + context = caramel.configs().context, + menuJson = require('/controllers/menu/menu.json'), + JsonFile = require("/controllers/datatsv/json.json"), + userPermissions = session.get('PERMISSIONS'); + +//create left menu +var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); +//create metro block +var metro_menu = metroGenerator('/healthStatistics', menuJson.menu, userPermissions); + +var log = new Log(); +var config = {"driverClassName":"org.apache.cassandra.cql.jdbc.CassandraDriver"}; +log.info(JsonFile); +var db = null; +var result = null; + +/*try { + db = new Database("WSO2BAM_CASSANDRA_DATASOURCE_3"); + db.query("USE AGENTHEALTH_STAT"); + + result = db.query("SELECT * FROM AGENTHEALTH_STAT"); + + } finally { + if (db != null) { + db.close(); + } + } + */ +caramel.render({ + breadcrumbPathLevelOne: 'health', + //dataTSV: JSON.stringify(dataTSV), + Json: JSON.stringify(JsonFile), + result:result, + error: error +}); + + + + +%> \ No newline at end of file diff --git a/components/org.apache.stratos.manager.console/console/jaggery.conf b/components/org.apache.stratos.manager.console/console/jaggery.conf index 7e1fa497db..2279a3c17e 100644 --- a/components/org.apache.stratos.manager.console/console/jaggery.conf +++ b/components/org.apache.stratos.manager.console/console/jaggery.conf @@ -23,10 +23,16 @@ "path": "/configure_form.jag" }, { - "url": "/users/", - "path": "/users.jag" + "url": "/users/", + "path": "/users.jag" + }, + { + "url": "/healthStatistics/", + "path": "/healthStatistics.jag" }, { + + "url": "/users/*", "path": "/users_form.jag" }, From 71b9586e72b017f19ff6782695f7e3eb7917ba32 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 4 Jul 2015 11:26:38 +0530 Subject: [PATCH 002/126] Health Statistics Render --- .../console/healthStatistics.jag | 2 +- .../theme0/renderers/healthStatistics.js | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 45937c82b6..c1d32c7acc 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -56,7 +56,7 @@ var result = null; } */ caramel.render({ - breadcrumbPathLevelOne: 'health', + breadcrumbPathLevelOne: 'healthStatistics', //dataTSV: JSON.stringify(dataTSV), Json: JSON.stringify(JsonFile), result:result, diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js new file mode 100644 index 0000000000..d40fa1d611 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js @@ -0,0 +1,95 @@ +/* + * + * 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. + * + */ +var render = function (theme, data, meta, require) { + + if(data.error.length == 0 ){ + theme('index', { + page_meta: [ + { + partial:'index_title', + context:{ + page_title:'Apache Stratos - Health Stats', + page_description:'Apache Stratos - Health Statistics' + } + } + ], + header:[ + { + partial: 'index_header', + context:{ + } + } + ], + right_menu_help:[ + { + partial:'index_right_menu_help', + context:{ + + } + } + ], + content: [ + { + partial: 'healthStatistics', + context:{ + dataTSV:data.dataTSV, + Json:data.Json, + result:data.result, + content_title:'Health Statistics' + } + } + ] + }); + }else{ + theme('index', { + page_meta: [ + { + partial:'index_title', + context:{ + page_title:'Apache Stratos Home - Error', + page_description:'Apache Stratos Home - Error' + } + } + ], + header:[ + { + partial: 'index_header', + context:{ + } + } + ], + content: [ + + { + partial: 'error_page', + context:{ + error:data.error, + content_title:'Sorry Something went Wrong...! ', + content_body:{ + + } + + } + } + ] + }); + } +}; \ No newline at end of file From bfc7b468e7b666b5a1ef15a661da949c5058fbff Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 4 Jul 2015 12:03:23 +0530 Subject: [PATCH 003/126] Health Statistics Partial class --- .../js/healthStatistics/healthStatistics.js | 0 .../theme0/partials/healthStatistics.hbs | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js create mode 100644 components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs new file mode 100644 index 0000000000..459c26d705 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -0,0 +1,56 @@ + + + + + +
+
+
+

Health statistics

+
+
+ +
+
+
+
+ + +
+ +
+
+
+ +
+
+
+ + + + + + From fdbef4922517910ea6ee7ffcebc95a07fdc5c7d2 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 4 Jul 2015 12:05:04 +0530 Subject: [PATCH 004/126] Health Statistics Charts --- .../js/healthStatistics/healthStatistics.js | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index e69de29bb2..32b485bedd 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -0,0 +1,132 @@ +var dataJson = null; + +var requestInFlight = null; +var memoryConsumptions = null; +var loadAvg = null; + +var currentMembers = null; + +function bodyOnLoad(data){ + dataJson=data; + + $("#rowTable > a").html(""); + $.each(dataJson, function (i, model) { + $("#rowTable").append($('' + + '
' + + '
' + + '
' + + '
' + + '

' + model.cluster_id + '

' + + '
') + ); + }); +}; + +function onclickFunction(elements) { + $('#mainTitle').html(elements.id); + var id = elements.id; + $('#rowTable').hide(); + + $.each(dataJson, function (i, model) { + if (model.cluster_id.trim() == elements.id.trim()) { + currentMembers = model.member_ids; + return false; + } + }); + + $('#menu').show(); + + setCharts(requestInFlight, memoryConsumptions, loadAvg); + currentCluster = id; + $.each(currentMembers[0], function (i, model) { + $("#sideMenu").append($('
  • ' + + '' + + '' + model + '' + + '
  • ') + ); + }); +}; + +function onclickSideMenu(element){ + $.each(currentMembers[0], function (i, model) { + if (i.trim() == element.id.trim()) { + $('#mainTitle').html(model); + } + }); + + var id = element.id; + setCharts(requestInFlight, memoryConsumptions, loadAvg); +} + +function setCharts(requestInFlight, memoryConsumptions, loadAvg){ + // bar charts + var barChart = c3.generate({ + bindto: '#chart1', + data: { + type: 'bar', + json: [ + { 'indicator': 'X', 'total': 100 }, + { 'indicator': 'Y', 'total': 200 }, + { 'indicator': 'Z', 'total': 300 } + ], + keys: { + x: 'indicator', + value: ['total'] + } + }, + axis: { + x: { + label: 'X Axis', + position: 'outer-center', + type: 'category', + } + }, + bar: { + width: { + ratio: 0.5 + } + }, + grid: { + y: { + lines: [{value: 150, text: 'label at value 150'}] + } + } + }); + + // spline charts + var splineChart = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 140, 200, 150, 50], + ['data3', 10, 120, 90, 40, 250, 150] + ], + type: 'spline' + }, + axis: { + x: { + position: 'outer-center', + label: 'X Axis' + } + } + }); + + // spline charts + var splineChart1 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 140, 200, 150, 50], + ], + type: 'area' + }, + axis: { + x: { + position: 'outer-center', + label: 'X Axis' + } + } + }); +} \ No newline at end of file From e51db929527a91dcc056351a2160e074a5fc8618 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 7 Jul 2015 11:49:25 +0530 Subject: [PATCH 005/126] Health Statistics OutPut Adapter and Event Formatter without Flight Request --- .../eventformatters/Average_Member_Load_Average.xml | 10 ++++++++++ .../Average_Member_Memory_Consumption.xml | 10 ++++++++++ .../OutPutadaptorRDBMStoPublishHealthStat.xml | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml create mode 100644 extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml create mode 100644 extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml diff --git a/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml b/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml new file mode 100644 index 0000000000..1a669ba0d7 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml @@ -0,0 +1,10 @@ + + + + + + Average_Member_Load_Average_ + insert + + diff --git a/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml b/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml new file mode 100644 index 0000000000..79f41e008f --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml @@ -0,0 +1,10 @@ + + + + + + Average_Member_Memory_Consumption + insert + + diff --git a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml new file mode 100644 index 0000000000..bb9dd39e10 --- /dev/null +++ b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml @@ -0,0 +1,5 @@ + + + RDBMStoPublishHealthStat + From bb090ee082bcee3c00ca9b0482a692a4974ba92a Mon Sep 17 00:00:00 2001 From: Ashan Dhananjaya Date: Wed, 8 Jul 2015 12:28:01 +0530 Subject: [PATCH 006/126] Update OutPutadaptorRDBMStoPublishHealthStat.xml --- .../OutPutadaptorRDBMStoPublishHealthStat.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml index bb9dd39e10..a7cdcf8309 100644 --- a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml +++ b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml @@ -1,5 +1,5 @@ - - RDBMStoPublishHealthStat + DataSourcetoPublishHealthStatRDBMS From 7484b0b29665098a0a7fe958f40a0fa92e97d543 Mon Sep 17 00:00:00 2001 From: Ashan Dhananjaya Date: Wed, 8 Jul 2015 12:29:13 +0530 Subject: [PATCH 007/126] Update Average_Member_Load_Average.xml --- .../artifacts/eventformatters/Average_Member_Load_Average.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml b/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml index 1a669ba0d7..20fb4ee8e4 100644 --- a/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml +++ b/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml @@ -4,7 +4,7 @@ - Average_Member_Load_Average_ + Average_Member_Load_Average insert From 3643b5f99bce9bd389ba1973c90e5193392befb1 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 12:40:23 +0530 Subject: [PATCH 008/126] Event Formatter Flight Request And Data Source --- .../Request_In_Flight_Formatter.xml | 10 ++++++++ .../OutPutadaptorRDBMStoPublishHealthStat.xml | 5 ++++ .../datasources/master-datasources.xml | 23 ++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml create mode 100644 extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml diff --git a/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml b/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml new file mode 100644 index 0000000000..ab608cfbb3 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml @@ -0,0 +1,10 @@ + + + + + + Request_In_Flight_Formatter + insert + + diff --git a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml new file mode 100644 index 0000000000..a7cdcf8309 --- /dev/null +++ b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml @@ -0,0 +1,5 @@ + + + DataSourcetoPublishHealthStatRDBMS + diff --git a/tools/stratos-installer/templates/datasources/master-datasources.xml b/tools/stratos-installer/templates/datasources/master-datasources.xml index 34dee42360..a8528c9daa 100644 --- a/tools/stratos-installer/templates/datasources/master-datasources.xml +++ b/tools/stratos-installer/templates/datasources/master-datasources.xml @@ -27,7 +27,28 @@ - + + + DataSourcetoPublishHealthStatRDBMS + The datasource used for registry and user manager + + jdbc/DataSourcetoPublishHealthStatRDBMS + + + + jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS + root + root + com.mysql.jdbc.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + WSO2_CARBON_DB The datasource used for registry and user manager From 3921c529a4c4b6faac04caf587ade745aaccdd37 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 12:45:59 +0530 Subject: [PATCH 009/126] Data Source --- .../datasources/master-datasources.xml | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/tools/stratos-installer/templates/datasources/master-datasources.xml b/tools/stratos-installer/templates/datasources/master-datasources.xml index a8528c9daa..34dee42360 100644 --- a/tools/stratos-installer/templates/datasources/master-datasources.xml +++ b/tools/stratos-installer/templates/datasources/master-datasources.xml @@ -27,28 +27,7 @@ - - - DataSourcetoPublishHealthStatRDBMS - The datasource used for registry and user manager - - jdbc/DataSourcetoPublishHealthStatRDBMS - - - - jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS - root - root - com.mysql.jdbc.Driver - 50 - 60000 - true - SELECT 1 - 30000 - - - - + WSO2_CARBON_DB The datasource used for registry and user manager From c4064a35e9a3d392a69528141156d44d03bcc31f Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 12:48:52 +0530 Subject: [PATCH 010/126] Data Source Changes --- .../templates/datasources/master-datasources.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/stratos-installer/templates/datasources/master-datasources.xml b/tools/stratos-installer/templates/datasources/master-datasources.xml index 34dee42360..651c66b4c5 100644 --- a/tools/stratos-installer/templates/datasources/master-datasources.xml +++ b/tools/stratos-installer/templates/datasources/master-datasources.xml @@ -27,7 +27,7 @@ - + WSO2_CARBON_DB The datasource used for registry and user manager From ef1694049ff762fe5f379598aadbd5a7cf25a4f4 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 12:50:19 +0530 Subject: [PATCH 011/126] Data Source Changes --- .../datasources/master-datasources.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/stratos-installer/templates/datasources/master-datasources.xml b/tools/stratos-installer/templates/datasources/master-datasources.xml index 651c66b4c5..3444d11e0d 100644 --- a/tools/stratos-installer/templates/datasources/master-datasources.xml +++ b/tools/stratos-installer/templates/datasources/master-datasources.xml @@ -28,6 +28,26 @@ + + DataSourcetoPublishHealthStatRDBMS + The datasource used for registry and user manager + + jdbc/DataSourcetoPublishHealthStatRDBMS + + + + jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS + root + root + com.mysql.jdbc.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + WSO2_CARBON_DB The datasource used for registry and user manager From 5ca895ef030f6aaeba56183d982aa5ae95db9337 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 13:16:05 +0530 Subject: [PATCH 012/126] ReadMe File to deploy cep artifacts --- extensions/cep/artifacts/README.md | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 extensions/cep/artifacts/README.md diff --git a/extensions/cep/artifacts/README.md b/extensions/cep/artifacts/README.md new file mode 100644 index 0000000000..ab075485bb --- /dev/null +++ b/extensions/cep/artifacts/README.md @@ -0,0 +1,63 @@ +CEP Configuration For Health Stat UI +==================================== + + +CEP Configuration +================= + +Prerequisites: + +Download MySQL JDBC connector for Java add it to [Apache Stratos] OR +[External CEP HOME ]/repository/components/lib/ directory. + +Configuring the datasource +========================== + +You can find the master-datasource.xml file in [Apache Stratos] OR +[External CEP HOME ]/repository/conf/datasources.Create a datasource to connect with the +MYSQL server as u prefer or you can copy paste this into master-datasource.xml + + + DataSourcetoPublishHealthStatRDBMS + The datasource used for registry and user manager + + jdbc/DataSourcetoPublishHealthStatRDBMS + + + + jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS + root + root + com.mysql.jdbc.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + +Configuring output: MySQL event Adapter to publish health stats from CEP to RDBMS +================================================================================= + +As the very first step we have to create the data source.I will explain how to configure output +MySQL event adapter using the management console. Deploy the event adapter which is in +artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml into +[Apache Stratos] OR [External CEP HOME ]/repository/deployment/server/outputeventadaptors/ directory. +Please find OutPutadaptorRDBMStoPublishHealthStat here[2] and paste it to the above directory. + +Configuring Event fomratters. +============================= + +You can specify an event formatter configuration using an XML file and save it in +[Apache Stratos] OR [External CEP HOME ]/repository/deployment/server/eventformatters directory. +In here you can get the 3 formatters artifacts/eventformatters/ + +Names, + +Average_Member_Load_Average +Average_Member_Memory_Consumption +Requests_In_Flight Formatter + +depoly them in the previously mentioned directory. \ No newline at end of file From e0bb022309d35bddede16a4b5d4d38924ab758fc Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 8 Jul 2015 14:11:07 +0530 Subject: [PATCH 013/126] Health Spealling Correction --- .../{AverageHeathRequest.xml => AverageHealthRequest.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extensions/cep/artifacts/executionplans/{AverageHeathRequest.xml => AverageHealthRequest.xml} (100%) diff --git a/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml b/extensions/cep/artifacts/executionplans/AverageHealthRequest.xml similarity index 100% rename from extensions/cep/artifacts/executionplans/AverageHeathRequest.xml rename to extensions/cep/artifacts/executionplans/AverageHealthRequest.xml From 4c65e705be822fd420b4e48ebafef789c8686b76 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 00:00:08 +0530 Subject: [PATCH 014/126] Adding the Time Stamp to the Cartridge Agent Payload --- .../publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java | 2 ++ .../cep/artifacts/streamdefinitions/stream-manager-config.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java index 1dc42409a0..5b07060e4f 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPHealthStatisticsPublisher.java @@ -56,6 +56,7 @@ private static StreamDefinition createStreamDefinition() { payloadData.add(new Attribute("cluster_instance_id", AttributeType.STRING)); payloadData.add(new Attribute("network_partition_id", AttributeType.STRING)); payloadData.add(new Attribute("member_id", AttributeType.STRING)); + payloadData.add(new Attribute("timeStamp", AttributeType.LONG)); payloadData.add(new Attribute("partition_id", AttributeType.STRING)); payloadData.add(new Attribute("health_description", AttributeType.STRING)); payloadData.add(new Attribute("value", AttributeType.DOUBLE)); @@ -90,6 +91,7 @@ public void publish(String clusterId, String clusterInstanceId, String networkPa payload.add(clusterInstanceId); payload.add(networkPartitionId); payload.add(memberId); + payload.add(System.currentTimeMillis()); payload.add(partitionId); payload.add(health); payload.add(value); diff --git a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml index 4c4c7e0c9c..61e0e67b4e 100644 --- a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml +++ b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml @@ -96,6 +96,7 @@ + From e09334cd98f245a4633c992f02db2878ac24d3d0 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 12:52:53 +0530 Subject: [PATCH 015/126] Adding the Time Stamp to the In FLight Request Payload --- .../cep/WSO2CEPInFlightRequestPublisher.java | 2 + .../Average_Member_Load_Average.xml | 10 ----- .../Average_Member_Memory_Consumption.xml | 10 ----- .../FlightRequestEventFormatterHealthStat.xml | 42 ++++++++++++++++++ ...ageLoadAverageEventFormatterHealthStat.xml | 43 +++++++++++++++++++ ...eMemoryAverageEventFormatterHealthStat.xml | 40 +++++++++++++++++ .../Request_In_Flight_Formatter.xml | 10 ----- .../stream-manager-config.xml | 3 ++ 8 files changed, 130 insertions(+), 30 deletions(-) delete mode 100644 extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml delete mode 100644 extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml create mode 100644 extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml create mode 100644 extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml create mode 100644 extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml delete mode 100644 extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java index 2ed888381a..e3c10b7d64 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/wso2/cep/WSO2CEPInFlightRequestPublisher.java @@ -53,6 +53,7 @@ private static StreamDefinition createStreamDefinition() { // Set payload definition payloadData.add(new Attribute("cluster_id", AttributeType.STRING)); payloadData.add(new Attribute("cluster_instance_id", AttributeType.STRING)); + payloadData.add(new Attribute("timeStamp", AttributeType.LONG)); payloadData.add(new Attribute("network_partition_id", AttributeType.STRING)); payloadData.add(new Attribute("in_flight_request_count", AttributeType.DOUBLE)); streamDefinition.setPayloadData(payloadData); @@ -76,6 +77,7 @@ public void publish(String clusterId, String clusterInstanceId, String networkPa List payload = new ArrayList(); payload.add(clusterId); payload.add(clusterInstanceId); + payload.add(System.currentTimeMillis()); payload.add(networkPartitionId); payload.add((double) inFlightRequestCount); diff --git a/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml b/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml deleted file mode 100644 index 20fb4ee8e4..0000000000 --- a/extensions/cep/artifacts/eventformatters/Average_Member_Load_Average.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - Average_Member_Load_Average - insert - - diff --git a/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml b/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml deleted file mode 100644 index 79f41e008f..0000000000 --- a/extensions/cep/artifacts/eventformatters/Average_Member_Memory_Consumption.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - Average_Member_Memory_Consumption - insert - - diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml new file mode 100644 index 0000000000..3609865d9a --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -0,0 +1,42 @@ + + + + + + Request_In_Flight_Formatter + insert + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DataSourcetoPublishHealthStatRDBMS + FlightRequestEventFormatterHealthStat + + diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml new file mode 100644 index 0000000000..aa36fffcb3 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml @@ -0,0 +1,43 @@ + + + + + + Average_Member_Load_Average + insert + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DataSourcetoPublishHealthStatRDBMS + MemberAverageLoadAverageEventFormatterHealthStat + + diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml new file mode 100644 index 0000000000..709efe0c20 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml @@ -0,0 +1,40 @@ + + + + + + Average_Member_Memory_Consumption + insert + + + + + + + + + + + + + + + + + + + + + + + + + + + DataSourcetoPublishHealthStatRDBMS + MemberAverageMemoryAverageEventFormatterHealthStat + + diff --git a/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml b/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml deleted file mode 100644 index ab608cfbb3..0000000000 --- a/extensions/cep/artifacts/eventformatters/Request_In_Flight_Formatter.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - Request_In_Flight_Formatter - insert - - diff --git a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml index 61e0e67b4e..1a0043ccc2 100644 --- a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml +++ b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml @@ -32,6 +32,7 @@ + @@ -221,6 +222,7 @@ + @@ -237,6 +239,7 @@ + From 225952ebdf9a65bb5921c945ae7ef8d20cc955ef Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 14:50:36 +0530 Subject: [PATCH 016/126] Updating Read Me --- extensions/cep/artifacts/README.md | 14 ++--- ...lthRequest.xml => AverageHeathRequest.xml} | 52 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) rename extensions/cep/artifacts/executionplans/{AverageHealthRequest.xml => AverageHeathRequest.xml} (58%) diff --git a/extensions/cep/artifacts/README.md b/extensions/cep/artifacts/README.md index ab075485bb..6152b140db 100644 --- a/extensions/cep/artifacts/README.md +++ b/extensions/cep/artifacts/README.md @@ -21,13 +21,13 @@ MYSQL server as u prefer or you can copy paste this into master-datasource.xml DataSourcetoPublishHealthStatRDBMS The datasource used for registry and user manager - jdbc/DataSourcetoPublishHealthStatRDBMS + jdbc/[Your DB:DataSourcetoPublishHealthStatRDBMS] - jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS - root - root + jdbc:mysql://localhost:3306/[Your DB:DataSourcetoPublishHealthStatRDBMS] + wso2carbon + wso2carbon com.mysql.jdbc.Driver 50 60000 @@ -56,8 +56,8 @@ In here you can get the 3 formatters artifacts/eventformatters/ Names, -Average_Member_Load_Average -Average_Member_Memory_Consumption -Requests_In_Flight Formatter +MemberAverageLoadAverageEventFormatterHealthStat +MemberAverageMemoryAverageEventFormatterHealthStat +FlightRequestEventFormatterHealthStat depoly them in the previously mentioned directory. \ No newline at end of file diff --git a/extensions/cep/artifacts/executionplans/AverageHealthRequest.xml b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml similarity index 58% rename from extensions/cep/artifacts/executionplans/AverageHealthRequest.xml rename to extensions/cep/artifacts/executionplans/AverageHeathRequest.xml index b60a0bf9f6..960d010fd1 100644 --- a/extensions/cep/artifacts/executionplans/AverageHealthRequest.xml +++ b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml @@ -21,16 +21,16 @@ --> - This will average health stats of an instance over a minute. - - false - 0 - - - - - + This will average health stats of an instance over a minute. + + false + 0 + + + + + - - - - - - - + + + + + + + From 3c3fc11eb17eeee8f1bf457c6c0ffc2157b9f168 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 14:53:56 +0530 Subject: [PATCH 017/126] Flight Request Count Formatter --- .../FlightRequestEventFormatterHealthStat.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml index 3609865d9a..7ec3b887fe 100644 --- a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -1,15 +1,4 @@ - - - - - Request_In_Flight_Formatter - insert - - - - From 431710d81db18a9b115af9090b91c596f8c58f7b Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 14:58:38 +0530 Subject: [PATCH 018/126] Changing SQL Column Assembly --- .../FlightRequestEventFormatterHealthStat.xml | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml index 7ec3b887fe..a44ef04563 100644 --- a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -3,26 +3,28 @@ statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventformatter"> - - - - - - - - + + + + + - - + + + + + + + DataSourcetoPublishHealthStatRDBMS From 9c0fce9081c299c34031d602c94ea712602c7a6c Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 18:54:09 +0530 Subject: [PATCH 019/126] Sending Member Load Average data to the RDBMS with TimeStamp --- ...berAverageLoadAverageEventFormatterHealthStat.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml index aa36fffcb3..14dec14770 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml @@ -1,16 +1,4 @@ - - - - - Average_Member_Load_Average - insert - - - - - From efa25eb255cadbf2843e5f0d0e13b34c09535f91 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 18:55:30 +0530 Subject: [PATCH 020/126] Sending Member Memory Consumption data to the RDBMS with TimeStamp --- ...rAverageMemoryAverageEventFormatterHealthStat.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml index 709efe0c20..2bf47f7473 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml @@ -1,16 +1,4 @@ - - - - - Average_Member_Memory_Consumption - insert - - - - - From d168c16593a8dc303f2e15e81d1c5aac2a6d7823 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 9 Jul 2015 21:20:37 +0530 Subject: [PATCH 021/126] Adding the licenses Header --- .../FlightRequestEventFormatterHealthStat.xml | 18 ++++++++++++++++++ ...rageLoadAverageEventFormatterHealthStat.xml | 18 ++++++++++++++++++ ...geMemoryAverageEventFormatterHealthStat.xml | 18 ++++++++++++++++++ .../OutPutadaptorRDBMStoPublishHealthStat.xml | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml index a44ef04563..f7d3bc66bf 100644 --- a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -1,4 +1,22 @@ + diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml index 14dec14770..af7d9a2060 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml @@ -1,4 +1,22 @@ + diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml index 2bf47f7473..8ec30f1055 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml @@ -1,4 +1,22 @@ + diff --git a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml index a7cdcf8309..04d3cc7ba8 100644 --- a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml +++ b/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml @@ -1,4 +1,22 @@ + DataSourcetoPublishHealthStatRDBMS From d4115ed96f89dc02c16d2dc88865ce6a55d3e8c6 Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 10 Jul 2015 00:22:11 +0530 Subject: [PATCH 022/126] Health Statistics DataSource and its Assembly --- .../modules/distribution/src/assembly/bin.xml | 9 ++++ .../src/main/conf/healthstat-datasources.xml | 48 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 08de3f92ed..7fbdd4daa2 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -620,6 +620,15 @@ true 600 + + + + src/main/conf/healthstat-datasources.xml + ${pom.artifactId}-${pom.version}/repository/conf/datasources + true + 600 + + src/main/conf/identity.xml diff --git a/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml b/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml new file mode 100644 index 0000000000..df7f421a53 --- /dev/null +++ b/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml @@ -0,0 +1,48 @@ + + + + + + org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader + + + + + DataSourcetoPublishHealthStatRDBMS + The datasource used for registry and user manager + + jdbc/DataSourcetoPublishHealthStatRDBMS + + + + jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS + root + root + com.mysql.jdbc.Driver + 50 + 60000 + true + SELECT 1 + 30000 + + + + + From b1a40e896de063a804e1d2619673a090d1c62d7c Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 10 Jul 2015 00:24:19 +0530 Subject: [PATCH 023/126] changing local passwords --- .../distribution/src/main/conf/healthstat-datasources.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml b/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml index df7f421a53..932d1e8aa2 100644 --- a/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml +++ b/products/stratos/modules/distribution/src/main/conf/healthstat-datasources.xml @@ -33,8 +33,8 @@ jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS - root - root + wso2carbon + wso2carbon com.mysql.jdbc.Driver 50 60000 From a6a7c4660a0b4e94ec87f76ace58d4abe0a3a174 Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 10 Jul 2015 11:19:44 +0530 Subject: [PATCH 024/126] changing database coloumns and removed datasource --- .../FlightRequestEventFormatterHealthStat.xml | 2 +- ...ageLoadAverageEventFormatterHealthStat.xml | 7 ++++++- ...eMemoryAverageEventFormatterHealthStat.xml | 8 ++++++++ .../datasources/master-datasources.xml | 20 ------------------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml index f7d3bc66bf..62311c0f26 100644 --- a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -36,7 +36,7 @@ - + diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml index af7d9a2060..183d689651 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageLoadAverageEventFormatterHealthStat.xml @@ -39,8 +39,13 @@ - + + + + + + DataSourcetoPublishHealthStatRDBMS diff --git a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml index 8ec30f1055..60dcdb3eab 100644 --- a/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/MemberAverageMemoryAverageEventFormatterHealthStat.xml @@ -34,6 +34,14 @@ statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventformatte + + + + + + + + diff --git a/tools/stratos-installer/templates/datasources/master-datasources.xml b/tools/stratos-installer/templates/datasources/master-datasources.xml index 3444d11e0d..651c66b4c5 100644 --- a/tools/stratos-installer/templates/datasources/master-datasources.xml +++ b/tools/stratos-installer/templates/datasources/master-datasources.xml @@ -28,26 +28,6 @@ - - DataSourcetoPublishHealthStatRDBMS - The datasource used for registry and user manager - - jdbc/DataSourcetoPublishHealthStatRDBMS - - - - jdbc:mysql://localhost:3306/DataSourcetoPublishHealthStatRDBMS - root - root - com.mysql.jdbc.Driver - 50 - 60000 - true - SELECT 1 - 30000 - - - WSO2_CARBON_DB The datasource used for registry and user manager From 78270c1b255c8e03690d6e09ae10a7ddff8308f6 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 10:23:29 +0530 Subject: [PATCH 025/126] Java Beans for the REST API --- .../healthStatistics/AverageMemberMemory.java | 91 +++++++++++++++++++ .../healthStatistics/InFlightRequest.java | 84 +++++++++++++++++ .../healthStatistics/MemberLoadAverage.java | 82 +++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java new file mode 100755 index 0000000000..d0f19b5790 --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java @@ -0,0 +1,91 @@ +/* + * 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.stratos.common.beans.healthStatistics; + + +public class AverageMemberMemory { + + private static final long serialVersionUID = -7788619177798333711L; + + private String clusterId; + private String clusterInstanceId; + private Double memberAverageMemoryConsumption; + private Integer timeStamp; + private String memberId; + private String networkPartitionId; + + public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + this.timeStamp = timeStamp; + this.memberId = memberId; + this.networkPartitionId = networkPartitionId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getMemberAverageMemoryConsumption() { + return memberAverageMemoryConsumption; + } + + public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumption) { + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + + +} diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java new file mode 100755 index 0000000000..7cec648fc9 --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java @@ -0,0 +1,84 @@ +/* + * 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.stratos.common.beans.healthStatistics; + + +public class InFlightRequest { + + private static final long serialVersionUID = -7788619177798333712L; + + private String clusterId; + private String clusterInstanceId; + private Integer timeStamp; + private Double inFlightRequestCount; + private String networkPartitionId; + + public InFlightRequest(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.timeStamp = timeStamp; + this.inFlightRequestCount = inFlightRequestCount; + this.networkPartitionId = networkPartitionId; + } + + + + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getInFlightRequestCount() { + return inFlightRequestCount; + } + + public void setInFlightRequestCount(Double inFlightRequestCount) { + this.inFlightRequestCount = inFlightRequestCount; + } + + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + +} diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java new file mode 100755 index 0000000000..06b921b10a --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java @@ -0,0 +1,82 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.apache.stratos.common.beans.healthStatistics; + +/** + * + * @author NLiyanage + */ +public class MemberLoadAverage { + private static final long serialVersionUID = -7788619177798333712L; + + private String clusterId; + private String clusterInstanceId; + private Integer timeStamp; + private Double memberAverageLoadAverage; + private String memberId; + private String networkPartitionId; + + public MemberLoadAverage(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.timeStamp = timeStamp; + this.memberAverageLoadAverage = memberAverageLoadAverage; + this.memberId = memberId; + this.networkPartitionId = networkPartitionId; + } + + + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getMemberAverageLoadAverage() { + return memberAverageLoadAverage; + } + + public void setMemberAverageLoadAverage(Double memberAverageLoadAverage) { + this.memberAverageLoadAverage = memberAverageLoadAverage; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + +} From 3933aeb466158bb4adce6c5807645e09dd4475bf Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 11:55:43 +0530 Subject: [PATCH 026/126] REST Bean to get Average Memory Conumption --- .../healthStatistics/AverageMemberMemory.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java new file mode 100755 index 0000000000..1b3aa53301 --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java @@ -0,0 +1,91 @@ +/* + * 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.stratos.common.beans.healthStatistics; + + +public class AverageMemberMemory { + + private static final long serialVersionUID = -7788619177798333711L; + + private String clusterId; + private String clusterInstanceId; + private Double memberAverageMemoryConsumption; + private Integer timeStamp; + private String memberId; + private String networkPartitionId; + + public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + this.timeStamp = timeStamp; + this.memberId = memberId; + this.networkPartitionId = networkPartitionId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getMemberAverageMemoryConsumption() { + return memberAverageMemoryConsumption; + } + + public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumption) { + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + + +} From 6e209791417305bf7d1f1ff4d95d9d1bac93cf2f Mon Sep 17 00:00:00 2001 From: Ashan Dhananjaya Date: Sat, 11 Jul 2015 11:59:22 +0530 Subject: [PATCH 027/126] Delete InFlightRequest.java --- .../healthStatistics/InFlightRequest.java | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java deleted file mode 100755 index 7cec648fc9..0000000000 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java +++ /dev/null @@ -1,84 +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.stratos.common.beans.healthStatistics; - - -public class InFlightRequest { - - private static final long serialVersionUID = -7788619177798333712L; - - private String clusterId; - private String clusterInstanceId; - private Integer timeStamp; - private Double inFlightRequestCount; - private String networkPartitionId; - - public InFlightRequest(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { - this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; - this.timeStamp = timeStamp; - this.inFlightRequestCount = inFlightRequestCount; - this.networkPartitionId = networkPartitionId; - } - - - - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - - public Double getInFlightRequestCount() { - return inFlightRequestCount; - } - - public void setInFlightRequestCount(Double inFlightRequestCount) { - this.inFlightRequestCount = inFlightRequestCount; - } - - - public Integer getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(Integer timeStamp) { - this.timeStamp = timeStamp; - } - - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - -} From 454a4d65dfab8f42288280a5e5e03f08d5e42c6f Mon Sep 17 00:00:00 2001 From: Ashan Dhananjaya Date: Sat, 11 Jul 2015 11:59:32 +0530 Subject: [PATCH 028/126] Delete AverageMemberMemory.java --- .../healthStatistics/AverageMemberMemory.java | 91 ------------------- 1 file changed, 91 deletions(-) delete mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java deleted file mode 100755 index d0f19b5790..0000000000 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.stratos.common.beans.healthStatistics; - - -public class AverageMemberMemory { - - private static final long serialVersionUID = -7788619177798333711L; - - private String clusterId; - private String clusterInstanceId; - private Double memberAverageMemoryConsumption; - private Integer timeStamp; - private String memberId; - private String networkPartitionId; - - public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { - this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; - this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; - this.timeStamp = timeStamp; - this.memberId = memberId; - this.networkPartitionId = networkPartitionId; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - - public Double getMemberAverageMemoryConsumption() { - return memberAverageMemoryConsumption; - } - - public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumption) { - this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; - } - - public Integer getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(Integer timeStamp) { - this.timeStamp = timeStamp; - } - - public String getMemberId() { - return memberId; - } - - public void setMemberId(String memberId) { - this.memberId = memberId; - } - - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - - -} From 6b4c22f27d43ab5849ec1f210ea9bf1db2cbc54f Mon Sep 17 00:00:00 2001 From: Ashan Dhananjaya Date: Sat, 11 Jul 2015 11:59:40 +0530 Subject: [PATCH 029/126] Delete MemberLoadAverage.java --- .../healthStatistics/MemberLoadAverage.java | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java deleted file mode 100755 index 06b921b10a..0000000000 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/MemberLoadAverage.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.apache.stratos.common.beans.healthStatistics; - -/** - * - * @author NLiyanage - */ -public class MemberLoadAverage { - private static final long serialVersionUID = -7788619177798333712L; - - private String clusterId; - private String clusterInstanceId; - private Integer timeStamp; - private Double memberAverageLoadAverage; - private String memberId; - private String networkPartitionId; - - public MemberLoadAverage(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { - this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; - this.timeStamp = timeStamp; - this.memberAverageLoadAverage = memberAverageLoadAverage; - this.memberId = memberId; - this.networkPartitionId = networkPartitionId; - } - - - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - - public Double getMemberAverageLoadAverage() { - return memberAverageLoadAverage; - } - - public void setMemberAverageLoadAverage(Double memberAverageLoadAverage) { - this.memberAverageLoadAverage = memberAverageLoadAverage; - } - - public Integer getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(Integer timeStamp) { - this.timeStamp = timeStamp; - } - - public String getMemberId() { - return memberId; - } - - public void setMemberId(String memberId) { - this.memberId = memberId; - } - - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - -} From c54c26d1e7d5d1fda3fa97b52c9fd920659bae3a Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 12:26:36 +0530 Subject: [PATCH 030/126] REST Bean to get Average Memory Conumption --- .../healthStatistics/AverageMemberMemory.java | 170 ++++++++---------- 1 file changed, 79 insertions(+), 91 deletions(-) mode change 100755 => 100644 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java old mode 100755 new mode 100644 index 1b3aa53301..b76872180b --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java @@ -1,91 +1,79 @@ -/* - * 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.stratos.common.beans.healthStatistics; - - -public class AverageMemberMemory { - - private static final long serialVersionUID = -7788619177798333711L; - - private String clusterId; - private String clusterInstanceId; - private Double memberAverageMemoryConsumption; - private Integer timeStamp; - private String memberId; - private String networkPartitionId; - - public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { - this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; - this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; - this.timeStamp = timeStamp; - this.memberId = memberId; - this.networkPartitionId = networkPartitionId; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - - public Double getMemberAverageMemoryConsumption() { - return memberAverageMemoryConsumption; - } - - public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumption) { - this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; - } - - public Integer getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(Integer timeStamp) { - this.timeStamp = timeStamp; - } - - public String getMemberId() { - return memberId; - } - - public void setMemberId(String memberId) { - this.memberId = memberId; - } - - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.apache.stratos.common.beans.healthStatistics; +import java.util.Date; + + +public class AverageMemberMemory { + + private static final long serialVersionUID = -7788619177798333711L; + + private String clusterId; + private String clusterInstanceId; + private Double memberAverageMemoryConsumption; + private Integer timeStamp; + private String memberId; + private String networkPartitionId; + + public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + this.timeStamp = timeStamp; + this.memberId = memberId; + this.networkPartitionId = networkPartitionId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getMemberAverageMemoryConsumption() { + return memberAverageMemoryConsumption; + } + + public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumption) { + this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + + +} From 0f71e5e203fc77988898a41b8c106a6eb3e1efc9 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 12:32:24 +0530 Subject: [PATCH 031/126] REST Bean to get Average Memory Conumption --- ...Memory.java => AverageMemoryConsumption.java} | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/{AverageMemberMemory.java => AverageMemoryConsumption.java} (81%) diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java similarity index 81% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java index b76872180b..46dcf15ea5 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemberMemory.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java @@ -1,14 +1,9 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.apache.stratos.common.beans.healthStatistics; -import java.util.Date; - - -public class AverageMemberMemory { +/** + * Created by dk on 11/07/2015. + */ +public class AverageMemoryConsumption { private static final long serialVersionUID = -7788619177798333711L; private String clusterId; @@ -18,7 +13,7 @@ public class AverageMemberMemory { private String memberId; private String networkPartitionId; - public AverageMemberMemory(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + public AverageMemoryConsumption(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; @@ -77,3 +72,4 @@ public void setNetworkPartitionId(String networkPartitionId) { } + From 60bf51565090766cd966c5d487df76e0fc9f3a40 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 12:37:15 +0530 Subject: [PATCH 032/126] REST Bean to get Average Load Average --- .../healthStatistics/AverageLoadAverage.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java new file mode 100755 index 0000000000..04f64ebd1a --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java @@ -0,0 +1,94 @@ +/* + * 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.stratos.common.beans.healthStatistics; + + +public class AverageLoadAverage { + private static final long serialVersionUID = -7788619177798333712L; + + private String clusterId; + private String clusterInstanceId; + private Integer timeStamp; + private Double memberAverageLoadAverage; + private String memberId; + private String networkPartitionId; + + public AverageLoadAverage(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.timeStamp = timeStamp; + this.memberAverageLoadAverage = memberAverageLoadAverage; + this.memberId = memberId; + this.networkPartitionId = networkPartitionId; + + + } + + + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getMemberAverageLoadAverage() { + return memberAverageLoadAverage; + } + + public void setMemberAverageLoadAverage(Double memberAverageLoadAverage) { + this.memberAverageLoadAverage = memberAverageLoadAverage; + } + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getMemberId() { + return memberId; + } + + public void setMemberId(String memberId) { + this.memberId = memberId; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + +} From 5b2ce68dee4bdcb3f11d78a19877bb74f2ca5373 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 12:39:00 +0530 Subject: [PATCH 033/126] REST Bean to get In Flight Request --- .../healthStatistics/InFlightRequest.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java new file mode 100755 index 0000000000..d2dd454c72 --- /dev/null +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java @@ -0,0 +1,85 @@ +/* + * 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.stratos.common.beans.healthStatistics; + + +public class InFlightRequest { + + private static final long serialVersionUID = -7788619177798333712L; + + private String clusterId; + private String clusterInstanceId; + private Integer timeStamp; + private Double inFlightRequestCount; + private String networkPartitionId; + + public InFlightRequest(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { + this.clusterId = clusterId; + this.clusterInstanceId = clusterInstanceId; + this.timeStamp = timeStamp; + this.inFlightRequestCount = inFlightRequestCount; + this.networkPartitionId = networkPartitionId; + } + + + + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterInstanceId() { + return clusterInstanceId; + } + + public void setClusterInstanceId(String clusterInstanceId) { + this.clusterInstanceId = clusterInstanceId; + } + + public Double getInFlightRequestCount() { + return inFlightRequestCount; + } + + public void setInFlightRequestCount(Double inFlightRequestCount) { + this.inFlightRequestCount = inFlightRequestCount; + } + + + public Integer getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(Integer timeStamp) { + this.timeStamp = timeStamp; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + public void setNetworkPartitionId(String networkPartitionId) { + this.networkPartitionId = networkPartitionId; + } + +} From 57efe03195b1df24e8a31cd4d0a0a78f3049e784 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 13:06:17 +0530 Subject: [PATCH 034/126] DataBase Connection for HealthStat --- .../AverageMemoryConsumption.java | 22 +++++- .../org.apache.stratos.rest.endpoint/pom.xml | 10 +++ .../endpoint/handlers/ConnectionHandler.java | 74 +++++++++++++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java index 46dcf15ea5..788ff7a076 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java @@ -1,8 +1,24 @@ +/* + * 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.stratos.common.beans.healthStatistics; -/** - * Created by dk on 11/07/2015. - */ public class AverageMemoryConsumption { private static final long serialVersionUID = -7788619177798333711L; diff --git a/components/org.apache.stratos.rest.endpoint/pom.xml b/components/org.apache.stratos.rest.endpoint/pom.xml index e661dfdbd2..a3cb4e2eaf 100644 --- a/components/org.apache.stratos.rest.endpoint/pom.xml +++ b/components/org.apache.stratos.rest.endpoint/pom.xml @@ -99,6 +99,16 @@ ${wso2carbon.version} provided + + org.wso2.carbon + org.wso2.carbon.ndatasource.rdbms + 4.2.0 + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + 4.2.0 + org.wso2.carbon org.wso2.carbon.identity.oauth.stub diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java new file mode 100644 index 0000000000..c558fa764f --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java @@ -0,0 +1,74 @@ +/* + * 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.stratos.rest.endpoint.handlers; + +import org.wso2.carbon.ndatasource.core.DataSourceManager; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; + +public class ConnectionHandler { + public ResultSet GetsqlConnection(String sql) { + + DataSource dataSource = null; + String stringSql = sql; + ResultSet resultSet = null; + + try{ + boolean isJndiLookup = true; + + if(isJndiLookup) { + + // Obtain the datasource via a JNDI lookup, by passing the jndi config name + dataSource = (DataSource) InitialContext.doLookup("jdbc/DataSourcetoPublishHealthStatRDBMS"); + + } else { + + // Obtain the datasource by passing the data source name + dataSource = (DataSource) DataSourceManager.getInstance() + .getDataSourceRepository().getDataSource("DataSourcetoPublishHealthStatRDBMS") + .getDSObject(); + } + + + if (dataSource != null) { + Connection connection = dataSource.getConnection(); + Statement statement = connection.createStatement(); + + resultSet = statement.executeQuery(stringSql); + + resultSet.close(); + statement.close(); + connection.close(); + } + + + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Error " + e.getMessage()); + } + return resultSet; + } +} + From 24ab63f17f183c8f17ab3102eedf56452cbda5d9 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 11 Jul 2015 22:30:05 +0530 Subject: [PATCH 035/126] REST API Imlementation --- ...erage.java => AverageLoadAverageBean.java} | 4 +- ...java => AverageMemoryConsumptionBean.java} | 4 +- ...tRequest.java => InFlightRequestBean.java} | 4 +- .../console/controllers/rest/rest_calls.jag | 4 ++ .../rest/endpoint/api/StratosApiV41.java | 49 +++++++++++++++++++ .../rest/endpoint/api/StratosApiV41Utils.java | 41 ++++++++++++++++ 6 files changed, 100 insertions(+), 6 deletions(-) rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/{AverageLoadAverage.java => AverageLoadAverageBean.java} (89%) rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/{AverageMemoryConsumption.java => AverageMemoryConsumptionBean.java} (91%) rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/{InFlightRequest.java => InFlightRequestBean.java} (89%) diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java similarity index 89% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java index 04f64ebd1a..54d2f0ff8e 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverage.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java @@ -20,7 +20,7 @@ package org.apache.stratos.common.beans.healthStatistics; -public class AverageLoadAverage { +public class AverageLoadAverageBean { private static final long serialVersionUID = -7788619177798333712L; private String clusterId; @@ -30,7 +30,7 @@ public class AverageLoadAverage { private String memberId; private String networkPartitionId; - public AverageLoadAverage(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { + public AverageLoadAverageBean(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java similarity index 91% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java index 788ff7a076..f1f730477b 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumption.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java @@ -19,7 +19,7 @@ package org.apache.stratos.common.beans.healthStatistics; -public class AverageMemoryConsumption { +public class AverageMemoryConsumptionBean { private static final long serialVersionUID = -7788619177798333711L; private String clusterId; @@ -29,7 +29,7 @@ public class AverageMemoryConsumption { private String memberId; private String networkPartitionId; - public AverageMemoryConsumption(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + public AverageMemoryConsumptionBean(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java similarity index 89% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java index d2dd454c72..b44d38a30d 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequest.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java @@ -20,7 +20,7 @@ package org.apache.stratos.common.beans.healthStatistics; -public class InFlightRequest { +public class InFlightRequestBean { private static final long serialVersionUID = -7788619177798333712L; @@ -30,7 +30,7 @@ public class InFlightRequest { private Double inFlightRequestCount; private String networkPartitionId; - public InFlightRequest(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { + public InFlightRequestBean(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index 7b020fa0cf..850baabe19 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -27,6 +27,10 @@ RESTCalls = new function(){ return this.sendReceive("GET","/tenants",{}); }; + this.getClusterDetails = function(){ + return this.sendReceive("GET","/averageMemberMemory/getByClusterId",{}); + }; + this.deployPartitionDefinition = function(partitionDefinition){ return this.send("POST","/networkPartitions", partitionDefinition); }; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index fa369f527c..0480278cd6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -34,6 +34,7 @@ import org.apache.stratos.common.beans.artifact.repository.GitNotificationPayloadBean; import org.apache.stratos.common.beans.cartridge.CartridgeBean; import org.apache.stratos.common.beans.cartridge.CartridgeGroupBean; +import org.apache.stratos.common.beans.healthStatistics.AverageMemoryConsumptionBean; import org.apache.stratos.common.beans.kubernetes.KubernetesClusterBean; import org.apache.stratos.common.beans.kubernetes.KubernetesHostBean; import org.apache.stratos.common.beans.kubernetes.KubernetesMasterBean; @@ -50,9 +51,13 @@ import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; import org.apache.stratos.rest.endpoint.exception.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.ws.rs.*; import javax.ws.rs.core.Context; @@ -183,6 +188,14 @@ public Response getDeploymentPolicy( public Response getDeploymentPolicies() throws RestAPIException { DeploymentPolicyBean[] deploymentPolicies = StratosApiV41Utils.getDeployementPolicies(); + List averageMemberMemoryList = new ArrayList(); + try { + averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); + Response.status(HttpServletResponse.SC_OK); + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + if (deploymentPolicies == null || deploymentPolicies.length == 0) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( ResponseMessageBean.ERROR, "No deployment policies found")).build(); @@ -1756,7 +1769,17 @@ public Response notifyRepository( @AuthorizationAction("/permission/admin") public Response addUser( UserInfoBean userInfoBean) throws RestAPIException { + log.info("****************1********************************************************************"+"134123414123"); + + log.info("****************1********************************************************************"+"\"tomcat-single-signon.mywso2is.wso2is.domain\""); + List averageMemberMemoryList = new ArrayList(); + try { + averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); + Response.status(HttpServletResponse.SC_OK); + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } StratosApiV41Utils.addUser(userInfoBean); log.info("Successfully added an user with Username " + userInfoBean.getUserName()); URI url = uriInfo.getAbsolutePathBuilder().path(userInfoBean.getUserName()).build(); @@ -2120,4 +2143,30 @@ public Response getIaasProviders() } return Response.ok(iaasProviderInfoBean).build(); } + + private static final String GET_AVERAGE_MEMBER_MEMORY_BY_CLUSTER_ID = "/averageMemberMemory/getByClusterId"; + private static final String GET_AVERAGE_MEMBER_MEMORY_BY_MEMBER_ID = "/averageMemberMemory/getByMemberId"; + + @GET + @Path("/averageMemberMemory/getByClusterId") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/admin/stratos") + public List GetAverageMemberMemoryByClusterId() throws RestAPIException { + + log.info("****************1********************************************************************"+"134123414123"); + + log.info("****************1********************************************************************"+"\"tomcat-single-signon.mywso2is.wso2is.domain\""); + + List averageMemberMemoryList = new ArrayList(); + try { + averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); + Response.status(HttpServletResponse.SC_OK); + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return averageMemberMemoryList; + } + } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 3ce9554578..08f387e77a 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -42,6 +42,7 @@ import org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean; import org.apache.stratos.common.beans.artifact.repository.GitNotificationPayloadBean; import org.apache.stratos.common.beans.cartridge.*; +import org.apache.stratos.common.beans.healthStatistics.AverageMemoryConsumptionBean; import org.apache.stratos.common.beans.kubernetes.KubernetesClusterBean; import org.apache.stratos.common.beans.kubernetes.KubernetesHostBean; import org.apache.stratos.common.beans.kubernetes.KubernetesMasterBean; @@ -78,6 +79,7 @@ import org.apache.stratos.rest.endpoint.Constants; import org.apache.stratos.rest.endpoint.ServiceHolder; import org.apache.stratos.rest.endpoint.exception.*; +import org.apache.stratos.rest.endpoint.handlers.ConnectionHandler; import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -95,6 +97,9 @@ import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.rmi.RemoteException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; @@ -3643,4 +3648,40 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { throw new RestAPIException(message, e); } } + + + public static List getAverageMemberMemoryByClusterId() throws RestAPIException { + + /*String sql = "SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'" + + " ,TIMESTAMP FROM MemberAverageMemoryAverageEventFormatterHealthStat" + + " WHERE CLUSTER_ID= " + clusterId + + " AND `TIMESTAMP`>= " + System.currentTimeMillis() + + " AND `TIMESTAMP`<= " + endTime + + " GROUP BY TIMESTAMP"; +*/ + + String sql="SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION',TIMESTAMP,CLUSTER_ID FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE CLUSTER_ID =\"tomcat-single-signon.mywso2is.wso2is.domain\"AND NOW() + INTERVAL 1 DAY GROUP BY TIMESTAMP;"; + + + List averageMemberMemoryList = new ArrayList();; + ConnectionHandler connectionHandler = new ConnectionHandler(); + + ResultSet result = connectionHandler.GetsqlConnection(sql); + log.info("****************2********************************************************************"); + + log.info("************2************************************************************************"); + + log.info("****************2********************************************************************"); +log.error(result); + try { + while (result.next()) { + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getInt("TIMESTAMP"), "", "")); + } + } catch (SQLException e) { + throw new RestAPIException(e.getMessage(), e); + } + + + return averageMemberMemoryList; + } } From c0b43eaa9087dfec11d191c9e74bd9b0685cb422 Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 12 Jul 2015 02:11:16 +0530 Subject: [PATCH 036/126] REST API Changes --- .../stratos/rest/endpoint/api/StratosApiV41.java | 10 +++++++--- .../stratos/rest/endpoint/api/StratosApiV41Utils.java | 2 +- .../rest/endpoint/handlers/ConnectionHandler.java | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 0480278cd6..1eb9d46a28 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -2001,6 +2001,8 @@ public Response getKubernetesHostClusters() throws RestAPIException { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( ResponseMessageBean.ERROR, "No kubernetes clusters found")).build(); } + + return Response.ok().entity(availableKubernetesClusters).build(); } @@ -2152,7 +2154,7 @@ public Response getIaasProviders() @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") - public List GetAverageMemberMemoryByClusterId() throws RestAPIException { + public Response GetAverageMemberMemoryByClusterId() throws RestAPIException { log.info("****************1********************************************************************"+"134123414123"); @@ -2161,12 +2163,14 @@ public List GetAverageMemberMemoryByClusterId() th List averageMemberMemoryList = new ArrayList(); try { averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); - Response.status(HttpServletResponse.SC_OK); + + log.info("****************1********************************************************************"+averageMemberMemoryList); + } catch (RestAPIException ex) { Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } + return Response.ok(averageMemberMemoryList).build(); - return averageMemberMemoryList; } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 08f387e77a..27ec5519ea 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3675,7 +3675,7 @@ public static List getAverageMemberMemoryByCluster log.error(result); try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getInt("TIMESTAMP"), "", "")); + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java index c558fa764f..e47af878e8 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java @@ -58,9 +58,7 @@ public ResultSet GetsqlConnection(String sql) { resultSet = statement.executeQuery(stringSql); - resultSet.close(); - statement.close(); - connection.close(); + } From 4b01bd84fea0233e89d42e9929305a09380679a0 Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 13 Jul 2015 20:59:51 +0530 Subject: [PATCH 037/126] Changes --- .../apache/stratos/rest/endpoint/api/StratosApiV41Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 27ec5519ea..08f387e77a 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3675,7 +3675,7 @@ public static List getAverageMemberMemoryByCluster log.error(result); try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getInt("TIMESTAMP"), "", "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); From 5ab9159744f136e649174f7293adabe5c77fb4bd Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 14 Jul 2015 01:44:35 +0530 Subject: [PATCH 038/126] Commiting the REST API for Health Statistics UI --- .../AverageLoadAverageBean.java | 8 +- .../AverageMemoryConsumptionBean.java | 8 +- .../healthStatistics/InFlightRequestBean.java | 8 +- .../rest/endpoint/api/StratosApiV41.java | 112 ++++++++++---- .../rest/endpoint/api/StratosApiV41Utils.java | 137 +++++++++++++++--- .../endpoint/handlers/ConnectionHandler.java | 4 +- 6 files changed, 218 insertions(+), 59 deletions(-) diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java index 54d2f0ff8e..ec6639b8dc 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java @@ -25,12 +25,12 @@ public class AverageLoadAverageBean { private String clusterId; private String clusterInstanceId; - private Integer timeStamp; + private Long timeStamp; private Double memberAverageLoadAverage; private String memberId; private String networkPartitionId; - public AverageLoadAverageBean(String clusterId, String clusterInstanceId, Integer timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { + public AverageLoadAverageBean(String clusterId, String clusterInstanceId, Long timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; @@ -67,11 +67,11 @@ public void setMemberAverageLoadAverage(Double memberAverageLoadAverage) { this.memberAverageLoadAverage = memberAverageLoadAverage; } - public Integer getTimeStamp() { + public Long getTimeStamp() { return timeStamp; } - public void setTimeStamp(Integer timeStamp) { + public void setTimeStamp(Long timeStamp) { this.timeStamp = timeStamp; } diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java index f1f730477b..6314ce81c2 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java @@ -25,11 +25,11 @@ public class AverageMemoryConsumptionBean { private String clusterId; private String clusterInstanceId; private Double memberAverageMemoryConsumption; - private Integer timeStamp; + private Long timeStamp; private String memberId; private String networkPartitionId; - public AverageMemoryConsumptionBean(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Integer timeStamp, String memberId, String networkPartitionId) { + public AverageMemoryConsumptionBean(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Long timeStamp, String memberId, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; @@ -62,11 +62,11 @@ public void setMemberAverageMemoryConsumption(Double memberAverageMemoryConsumpt this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; } - public Integer getTimeStamp() { + public Long getTimeStamp() { return timeStamp; } - public void setTimeStamp(Integer timeStamp) { + public void setTimeStamp(Long timeStamp) { this.timeStamp = timeStamp; } diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java index b44d38a30d..f71365a6be 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java @@ -26,11 +26,11 @@ public class InFlightRequestBean { private String clusterId; private String clusterInstanceId; - private Integer timeStamp; + private Long timeStamp; private Double inFlightRequestCount; private String networkPartitionId; - public InFlightRequestBean(String clusterId, String clusterInstanceId, Integer timeStamp, Double inFlightRequestCount, String networkPartitionId) { + public InFlightRequestBean(String clusterId, String clusterInstanceId, Long timeStamp, Double inFlightRequestCount, String networkPartitionId) { this.clusterId = clusterId; this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; @@ -66,11 +66,11 @@ public void setInFlightRequestCount(Double inFlightRequestCount) { } - public Integer getTimeStamp() { + public Long getTimeStamp() { return timeStamp; } - public void setTimeStamp(Integer timeStamp) { + public void setTimeStamp(Long timeStamp) { this.timeStamp = timeStamp; } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 1eb9d46a28..b0c2840bb8 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -189,12 +189,6 @@ public Response getDeploymentPolicies() throws RestAPIException { DeploymentPolicyBean[] deploymentPolicies = StratosApiV41Utils.getDeployementPolicies(); List averageMemberMemoryList = new ArrayList(); - try { - averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); - Response.status(HttpServletResponse.SC_OK); - } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } if (deploymentPolicies == null || deploymentPolicies.length == 0) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( @@ -1769,17 +1763,7 @@ public Response notifyRepository( @AuthorizationAction("/permission/admin") public Response addUser( UserInfoBean userInfoBean) throws RestAPIException { - log.info("****************1********************************************************************"+"134123414123"); - - log.info("****************1********************************************************************"+"\"tomcat-single-signon.mywso2is.wso2is.domain\""); - List averageMemberMemoryList = new ArrayList(); - try { - averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); - Response.status(HttpServletResponse.SC_OK); - } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } StratosApiV41Utils.addUser(userInfoBean); log.info("Successfully added an user with Username " + userInfoBean.getUserName()); URI url = uriInfo.getAbsolutePathBuilder().path(userInfoBean.getUserName()).build(); @@ -2146,31 +2130,107 @@ public Response getIaasProviders() return Response.ok(iaasProviderInfoBean).build(); } - private static final String GET_AVERAGE_MEMBER_MEMORY_BY_CLUSTER_ID = "/averageMemberMemory/getByClusterId"; - private static final String GET_AVERAGE_MEMBER_MEMORY_BY_MEMBER_ID = "/averageMemberMemory/getByMemberId"; + @GET + @Path("/averageClusterMemory/{Id}/{Interval}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/admin/stratos") + public Response getAverageClusterMemoryByClusterId( + @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + + String averageMemberMemoryList=null; + try { + averageMemberMemoryList = StratosApiV41Utils.getAverageClusterMemoryByClusterId(Id, Interval); + + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return Response.ok(averageMemberMemoryList).build(); + + } @GET - @Path("/averageMemberMemory/getByClusterId") + @Path("/averageMemberMemory/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") - public Response GetAverageMemberMemoryByClusterId() throws RestAPIException { + public Response getAverageMemberMemoryByMemberId( + @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { - log.info("****************1********************************************************************"+"134123414123"); + String averageMemberMemoryList=null; + try { + averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByMemberId(Id, Interval); - log.info("****************1********************************************************************"+"\"tomcat-single-signon.mywso2is.wso2is.domain\""); + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } - List averageMemberMemoryList = new ArrayList(); + return Response.ok(averageMemberMemoryList).build(); + + } + + @GET + @Path("/averageMemberLoad/{Id}/{Interval}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/admin/stratos") + public Response getAverageMemberLoadByMemberId( + @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + + String averageMemberLoadList=null; try { - averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByClusterId(); + averageMemberLoadList = StratosApiV41Utils.getAverageMemberLoadByMemberId(Id, Interval); + + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return Response.ok(averageMemberLoadList).build(); + + } - log.info("****************1********************************************************************"+averageMemberMemoryList); + + @GET + @Path("/averageClusterLoad/{Id}/{Interval}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/admin/stratos") + public Response getAverageClusterLoadByClusterId( + @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + + String averageMemberLoadList=null; + try { + averageMemberLoadList = StratosApiV41Utils.getAverageClusterLoadByClusterId(Id, Interval); } catch (RestAPIException ex) { Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } - return Response.ok(averageMemberMemoryList).build(); + + return Response.ok(averageMemberLoadList).build(); } + + @GET + @Path("/averageClusterFlightRequest/{Id}/{Interval}") + @Consumes("application/json") + @Produces("application/json") + @AuthorizationAction("/permission/admin/stratos") + public Response getAverageClusterFlightRequestCountByClusterId( + @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + + String averageClusterFlightRequestCount=null; + try { + averageClusterFlightRequestCount = StratosApiV41Utils.getAverageClusterFlightRequestCountByClusterId(Id, Interval); + + } catch (RestAPIException ex) { + Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + + return Response.ok(averageClusterFlightRequestCount).build(); + + } + + } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 08f387e77a..2186611540 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.rest.endpoint.api; +import com.google.gson.Gson; import org.apache.axis2.AxisFault; import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.lang.StringUtils; @@ -42,7 +43,9 @@ import org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean; import org.apache.stratos.common.beans.artifact.repository.GitNotificationPayloadBean; import org.apache.stratos.common.beans.cartridge.*; +import org.apache.stratos.common.beans.healthStatistics.AverageLoadAverageBean; import org.apache.stratos.common.beans.healthStatistics.AverageMemoryConsumptionBean; +import org.apache.stratos.common.beans.healthStatistics.InFlightRequestBean; import org.apache.stratos.common.beans.kubernetes.KubernetesClusterBean; import org.apache.stratos.common.beans.kubernetes.KubernetesHostBean; import org.apache.stratos.common.beans.kubernetes.KubernetesMasterBean; @@ -1917,7 +1920,7 @@ public static ApplicationInfoBean getApplicationRuntime(String applicationId) ApplicationManager.acquireReadLockForApplication(applicationId); Application application = ApplicationManager.getApplications(). getApplication(applicationId); - if(application != null) { + if (application != null) { if (application.getInstanceContextCount() > 0 || (applicationContext != null && applicationContext.getStatus().equals("Deployed"))) { @@ -3650,38 +3653,136 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { } - public static List getAverageMemberMemoryByClusterId() throws RestAPIException { + public static String getAverageClusterMemoryByClusterId(String Id,String Interval) throws RestAPIException { - /*String sql = "SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'" + - " ,TIMESTAMP FROM MemberAverageMemoryAverageEventFormatterHealthStat" - + " WHERE CLUSTER_ID= " + clusterId - + " AND `TIMESTAMP`>= " + System.currentTimeMillis() - + " AND `TIMESTAMP`<= " + endTime - + " GROUP BY TIMESTAMP"; -*/ - String sql="SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION',TIMESTAMP,CLUSTER_ID FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE CLUSTER_ID =\"tomcat-single-signon.mywso2is.wso2is.domain\"AND NOW() + INTERVAL 1 DAY GROUP BY TIMESTAMP;"; + String sql=" SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'," + + " TIMESTAMP From MemberAverageMemoryAverageEventFormatterHealthStat " + + "WHERE CLUSTER_ID = \""+Id+"\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + + "NOW() - INTERVAL "+Interval+" HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; + List averageMemberMemoryList = new ArrayList(); - List averageMemberMemoryList = new ArrayList();; ConnectionHandler connectionHandler = new ConnectionHandler(); + ResultSet result = connectionHandler.getsqlConnection(sql); + + try { + while (result.next()) { + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); + } + } catch (SQLException e) { + throw new RestAPIException(e.getMessage(), e); + } + String json = new Gson().toJson(averageMemberMemoryList); + + return json; + } - ResultSet result = connectionHandler.GetsqlConnection(sql); - log.info("****************2********************************************************************"); - log.info("************2************************************************************************"); + public static String getAverageClusterLoadByClusterId(String Id,String Interval) throws RestAPIException { + + + String sql=" SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + + " TIMESTAMP From MemberAverageLoadAverageEventFormatterHealthStat " + + "WHERE CLUSTER_ID = \""+Id+"\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + + "NOW() - INTERVAL "+Interval+" HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; + + List averageMemberLoadList = new ArrayList(); + + ConnectionHandler connectionHandler = new ConnectionHandler(); + ResultSet result = connectionHandler.getsqlConnection(sql); - log.info("****************2********************************************************************"); -log.error(result); try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getInt("TIMESTAMP"), "", "")); + averageMemberLoadList.add(new AverageLoadAverageBean("", "", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "", "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); } + String json = new Gson().toJson(averageMemberLoadList); + + return json; + } + - return averageMemberMemoryList; + + public static String getAverageMemberMemoryByMemberId(String Id,String Interval) throws RestAPIException { + + String memberIDQuery="SELECT TIMESTAMP," + + "MEMBER_AVERAGE_MEMORY_CONSUMPTION FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE " + + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + + "> NOW() - INTERVAL "+Interval+" HOUR AND MEMBER_ID =\""+Id+"\""; + + + List averageMemberMemoryList = new ArrayList(); + ConnectionHandler connectionHandler = new ConnectionHandler(); + + ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + + try { + while (result.next()) { + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); + } + } catch (SQLException e) { + throw new RestAPIException(e.getMessage(), e); + } + String json = new Gson().toJson(averageMemberMemoryList); + + return json; } + + public static String getAverageMemberLoadByMemberId(String Id,String Interval) throws RestAPIException { + + String memberIDQuery="SELECT TIMESTAMP," + + "MEMBER_AVERAGE_LOAD_AVERAGE FROM MemberAverageLoadAverageEventFormatterHealthStat WHERE " + + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + + "> NOW() - INTERVAL "+Interval+" HOUR AND MEMBER_ID =\""+Id+"\""; + + + List averageMemberLoadList = new ArrayList(); + ConnectionHandler connectionHandler = new ConnectionHandler(); + + ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + + try { + while (result.next()) { + + averageMemberLoadList.add(new AverageLoadAverageBean("", "", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "", "")); + } + } catch (SQLException e) { + throw new RestAPIException(e.getMessage(), e); + } + String json = new Gson().toJson(averageMemberLoadList); + + return json; + } + + + public static String getAverageClusterFlightRequestCountByClusterId(String Id,String Interval) throws RestAPIException { + + String memberIDQuery="SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,TIMESTAMP FROM " + + "FlightRequestEventFormatterHealthStat WHERE from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > NOW() - " + + "INTERVAL "+Interval+" HOUR AND CLUSTER_ID = \""+Id+"\"" + + "GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\");"; + + + List inFlightRequestBeanList = new ArrayList(); + ConnectionHandler connectionHandler = new ConnectionHandler(); + + ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + + try { + while (result.next()) { + inFlightRequestBeanList.add(new InFlightRequestBean("", "", result.getLong("TIMESTAMP"), result.getDouble("FLIGHT_REQUEST_COUNT"), "")); + } + } catch (SQLException e) { + throw new RestAPIException(e.getMessage(), e); + } + String json = new Gson().toJson(inFlightRequestBeanList); + + return json; + } + + } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java index e47af878e8..3bf662973d 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java @@ -29,7 +29,7 @@ import java.sql.Statement; public class ConnectionHandler { - public ResultSet GetsqlConnection(String sql) { + public ResultSet getsqlConnection(String sql) { DataSource dataSource = null; String stringSql = sql; @@ -55,10 +55,8 @@ public ResultSet GetsqlConnection(String sql) { if (dataSource != null) { Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); - resultSet = statement.executeQuery(stringSql); - } From 7112c1aacd3d5f787c6dcf4a61ef2f7325413c02 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 14 Jul 2015 13:04:49 +0530 Subject: [PATCH 039/126] Implement Changes --- .../AverageLoadAverageBean.java | 22 +----------------- .../AverageMemoryConsumptionBean.java | 23 +------------------ .../healthStatistics/InFlightRequestBean.java | 22 +----------------- .../rest/endpoint/api/StratosApiV41Utils.java | 10 ++++---- 4 files changed, 8 insertions(+), 69 deletions(-) diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java index ec6639b8dc..340948fb7c 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageLoadAverageBean.java @@ -24,21 +24,15 @@ public class AverageLoadAverageBean { private static final long serialVersionUID = -7788619177798333712L; private String clusterId; - private String clusterInstanceId; private Long timeStamp; private Double memberAverageLoadAverage; private String memberId; - private String networkPartitionId; - public AverageLoadAverageBean(String clusterId, String clusterInstanceId, Long timeStamp, Double memberAverageLoadAverage, String memberId, String networkPartitionId) { + public AverageLoadAverageBean(String clusterId, Long timeStamp, Double memberAverageLoadAverage, String memberId) { this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; this.memberAverageLoadAverage = memberAverageLoadAverage; this.memberId = memberId; - this.networkPartitionId = networkPartitionId; - - } @@ -51,13 +45,6 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } public Double getMemberAverageLoadAverage() { return memberAverageLoadAverage; @@ -83,12 +70,5 @@ public void setMemberId(String memberId) { this.memberId = memberId; } - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } } diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java index 6314ce81c2..7335b75633 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/AverageMemoryConsumptionBean.java @@ -23,19 +23,15 @@ public class AverageMemoryConsumptionBean { private static final long serialVersionUID = -7788619177798333711L; private String clusterId; - private String clusterInstanceId; private Double memberAverageMemoryConsumption; private Long timeStamp; private String memberId; - private String networkPartitionId; - public AverageMemoryConsumptionBean(String clusterId, String clusterInstanceId, Double memberAverageMemoryConsumption, Long timeStamp, String memberId, String networkPartitionId) { + public AverageMemoryConsumptionBean(String clusterId, Double memberAverageMemoryConsumption, Long timeStamp, String memberId) { this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; this.memberAverageMemoryConsumption = memberAverageMemoryConsumption; this.timeStamp = timeStamp; this.memberId = memberId; - this.networkPartitionId = networkPartitionId; } public String getClusterId() { @@ -46,14 +42,6 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - public Double getMemberAverageMemoryConsumption() { return memberAverageMemoryConsumption; } @@ -78,14 +66,5 @@ public void setMemberId(String memberId) { this.memberId = memberId; } - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - - } diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java index f71365a6be..f120801d6a 100755 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/healthStatistics/InFlightRequestBean.java @@ -25,17 +25,13 @@ public class InFlightRequestBean { private static final long serialVersionUID = -7788619177798333712L; private String clusterId; - private String clusterInstanceId; private Long timeStamp; private Double inFlightRequestCount; - private String networkPartitionId; - public InFlightRequestBean(String clusterId, String clusterInstanceId, Long timeStamp, Double inFlightRequestCount, String networkPartitionId) { + public InFlightRequestBean(String clusterId, Long timeStamp, Double inFlightRequestCount) { this.clusterId = clusterId; - this.clusterInstanceId = clusterInstanceId; this.timeStamp = timeStamp; this.inFlightRequestCount = inFlightRequestCount; - this.networkPartitionId = networkPartitionId; } @@ -49,14 +45,6 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } - public String getClusterInstanceId() { - return clusterInstanceId; - } - - public void setClusterInstanceId(String clusterInstanceId) { - this.clusterInstanceId = clusterInstanceId; - } - public Double getInFlightRequestCount() { return inFlightRequestCount; } @@ -74,12 +62,4 @@ public void setTimeStamp(Long timeStamp) { this.timeStamp = timeStamp; } - public String getNetworkPartitionId() { - return networkPartitionId; - } - - public void setNetworkPartitionId(String networkPartitionId) { - this.networkPartitionId = networkPartitionId; - } - } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 2186611540..0297712ffd 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3668,7 +3668,7 @@ public static String getAverageClusterMemoryByClusterId(String Id,String Interva try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); @@ -3694,7 +3694,7 @@ public static String getAverageClusterLoadByClusterId(String Id,String Interval) try { while (result.next()) { - averageMemberLoadList.add(new AverageLoadAverageBean("", "", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "", "")); + averageMemberLoadList.add(new AverageLoadAverageBean("", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); @@ -3722,7 +3722,7 @@ public static String getAverageMemberMemoryByMemberId(String Id,String Interval) try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", "", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "", "")); + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); @@ -3748,7 +3748,7 @@ public static String getAverageMemberLoadByMemberId(String Id,String Interval) t try { while (result.next()) { - averageMemberLoadList.add(new AverageLoadAverageBean("", "", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "", "")); + averageMemberLoadList.add(new AverageLoadAverageBean("", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "")); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); @@ -3774,7 +3774,7 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id,St try { while (result.next()) { - inFlightRequestBeanList.add(new InFlightRequestBean("", "", result.getLong("TIMESTAMP"), result.getDouble("FLIGHT_REQUEST_COUNT"), "")); + inFlightRequestBeanList.add(new InFlightRequestBean("", result.getLong("TIMESTAMP"), result.getDouble("FLIGHT_REQUEST_COUNT"))); } } catch (SQLException e) { throw new RestAPIException(e.getMessage(), e); From f32dbea9fb7b64988910faf43310b4ec154f2a88 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 14 Jul 2015 19:41:56 +0530 Subject: [PATCH 040/126] Event Publishing Changes --- .../rest/endpoint/api/StratosApiV41.java | 2 + .../FlightRequestEventFormatterHealthStat.xml | 75 +++++++------------ .../AverageInFlightRequestsFinder.xml | 6 +- .../stream-manager-config.xml | 1 + 4 files changed, 34 insertions(+), 50 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index b0c2840bb8..fe33c1d7e1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -1290,6 +1290,8 @@ public Response getApplicationRuntime( } } + + /** * Delete an application. * diff --git a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml index 62311c0f26..4a0687fa79 100644 --- a/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml +++ b/extensions/cep/artifacts/eventformatters/FlightRequestEventFormatterHealthStat.xml @@ -1,51 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - DataSourcetoPublishHealthStatRDBMS - FlightRequestEventFormatterHealthStat - + + + + + + + + + + + + + + + + + + + + + + + + + DataSourcetoPublishHealthStatRDBMS + FlightRequestEventFormatterHealthStat + + \ No newline at end of file diff --git a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml index 20b94dab11..3286a40e6f 100644 --- a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml +++ b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml @@ -19,7 +19,6 @@ under the License. --> - This will average the number of requests in flight over a minute. @@ -32,12 +31,12 @@ @@ -46,3 +45,4 @@ valueOf="average_in_flight_requests" version="1.0.0"/> + \ No newline at end of file diff --git a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml index 1a0043ccc2..ac46c1b6a6 100644 --- a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml +++ b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml @@ -63,6 +63,7 @@ + From 45e8c1652350b7d8d0badae2ea090acabd4ccbd2 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 14 Jul 2015 23:17:11 +0530 Subject: [PATCH 041/126] Adding Changes accoding to the CODE review.Changing REST urls on suggestion by Reka. --- .../rest/endpoint/api/StratosApiV41.java | 53 ++++++++++--------- .../rest/endpoint/api/StratosApiV41Utils.java | 44 ++++++++------- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index fe33c1d7e1..b2d229bf1c 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -51,9 +51,6 @@ import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; import org.apache.stratos.rest.endpoint.exception.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.servlet.http.HttpServletRequest; @@ -774,8 +771,7 @@ public Response addApplication(ApplicationBean applicationDefinition) throws Res } /** - * Add application - * + * Add applicatio * @param applicationDefinition Application Definition * @return 201 if application is successfully added * @throws RestAPIException @@ -1290,7 +1286,7 @@ public Response getApplicationRuntime( } } - + /** * Delete an application. @@ -2133,19 +2129,20 @@ public Response getIaasProviders() } @GET - @Path("/averageClusterMemory/{Id}/{Interval}") + @Path("/cluster/averageMemory/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterMemoryByClusterId( - @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberMemoryList=null; + String averageMemberMemoryList = null; try { averageMemberMemoryList = StratosApiV41Utils.getAverageClusterMemoryByClusterId(Id, Interval); } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Could Not get Cluster Memory Average Data")).build(); } return Response.ok(averageMemberMemoryList).build(); @@ -2153,19 +2150,20 @@ public Response getAverageClusterMemoryByClusterId( } @GET - @Path("/averageMemberMemory/{Id}/{Interval}") + @Path("/member/averageMemory/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberMemoryByMemberId( - @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberMemoryList=null; + String averageMemberMemoryList = null; try { averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByMemberId(Id, Interval); } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Could Not get Member Memory Average Data")).build(); } return Response.ok(averageMemberMemoryList).build(); @@ -2173,19 +2171,20 @@ public Response getAverageMemberMemoryByMemberId( } @GET - @Path("/averageMemberLoad/{Id}/{Interval}") + @Path("/member/averageLoad/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberLoadByMemberId( - @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberLoadList=null; + String averageMemberLoadList = null; try { averageMemberLoadList = StratosApiV41Utils.getAverageMemberLoadByMemberId(Id, Interval); } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Could Not get Member Load Average Data")).build(); } return Response.ok(averageMemberLoadList).build(); @@ -2194,19 +2193,20 @@ public Response getAverageMemberLoadByMemberId( @GET - @Path("/averageClusterLoad/{Id}/{Interval}") + @Path("/cluster/averageLoad/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterLoadByClusterId( - @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberLoadList=null; + String averageMemberLoadList = null; try { averageMemberLoadList = StratosApiV41Utils.getAverageClusterLoadByClusterId(Id, Interval); } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Could Not get Cluster Load Average Data")).build(); } return Response.ok(averageMemberLoadList).build(); @@ -2215,19 +2215,20 @@ public Response getAverageClusterLoadByClusterId( @GET - @Path("/averageClusterFlightRequest/{Id}/{Interval}") + @Path("/cluster/flightRequestCount/{Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterFlightRequestCountByClusterId( - @PathParam("Id") String Id,@PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageClusterFlightRequestCount=null; + String averageClusterFlightRequestCount = null; try { averageClusterFlightRequestCount = StratosApiV41Utils.getAverageClusterFlightRequestCountByClusterId(Id, Interval); } catch (RestAPIException ex) { - Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Could Not get In Flight Request Data")).build(); } return Response.ok(averageClusterFlightRequestCount).build(); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 0297712ffd..746d1c5905 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3653,18 +3653,18 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { } - public static String getAverageClusterMemoryByClusterId(String Id,String Interval) throws RestAPIException { + public static String getAverageClusterMemoryByClusterId(String Id, String Interval) throws RestAPIException { - String sql=" SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'," + + String averageClusterMemoryQuery = "SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'," + " TIMESTAMP From MemberAverageMemoryAverageEventFormatterHealthStat " + - "WHERE CLUSTER_ID = \""+Id+"\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + - "NOW() - INTERVAL "+Interval+" HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; + "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + + "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; List averageMemberMemoryList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(sql); + ResultSet result = connectionHandler.getsqlConnection(averageClusterMemoryQuery); try { while (result.next()) { @@ -3679,18 +3679,18 @@ public static String getAverageClusterMemoryByClusterId(String Id,String Interva } - public static String getAverageClusterLoadByClusterId(String Id,String Interval) throws RestAPIException { + public static String getAverageClusterLoadByClusterId(String Id, String Interval) throws RestAPIException { - String sql=" SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + + String averageClusterLoadQuery = "SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + " TIMESTAMP From MemberAverageLoadAverageEventFormatterHealthStat " + - "WHERE CLUSTER_ID = \""+Id+"\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + - "NOW() - INTERVAL "+Interval+" HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; + "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + + "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; List averageMemberLoadList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(sql); + ResultSet result = connectionHandler.getsqlConnection(averageClusterLoadQuery); try { while (result.next()) { @@ -3705,14 +3705,12 @@ public static String getAverageClusterLoadByClusterId(String Id,String Interval) } + public static String getAverageMemberMemoryByMemberId(String Id, String Interval) throws RestAPIException { - - public static String getAverageMemberMemoryByMemberId(String Id,String Interval) throws RestAPIException { - - String memberIDQuery="SELECT TIMESTAMP," + + String memberIDQuery = "SELECT TIMESTAMP," + "MEMBER_AVERAGE_MEMORY_CONSUMPTION FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + - "> NOW() - INTERVAL "+Interval+" HOUR AND MEMBER_ID =\""+Id+"\""; + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; List averageMemberMemoryList = new ArrayList(); @@ -3732,18 +3730,18 @@ public static String getAverageMemberMemoryByMemberId(String Id,String Interval) return json; } - public static String getAverageMemberLoadByMemberId(String Id,String Interval) throws RestAPIException { + public static String getAverageMemberLoadByMemberId(String Id, String Interval) throws RestAPIException { - String memberIDQuery="SELECT TIMESTAMP," + + String memberIDLoadQuery = "SELECT TIMESTAMP," + "MEMBER_AVERAGE_LOAD_AVERAGE FROM MemberAverageLoadAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + - "> NOW() - INTERVAL "+Interval+" HOUR AND MEMBER_ID =\""+Id+"\""; + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; List averageMemberLoadList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + ResultSet result = connectionHandler.getsqlConnection(memberIDLoadQuery); try { while (result.next()) { @@ -3759,18 +3757,18 @@ public static String getAverageMemberLoadByMemberId(String Id,String Interval) t } - public static String getAverageClusterFlightRequestCountByClusterId(String Id,String Interval) throws RestAPIException { + public static String getAverageClusterFlightRequestCountByClusterId(String Id, String Interval) throws RestAPIException { - String memberIDQuery="SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,TIMESTAMP FROM " + + String clusterIDQueryFlightCount = "SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,TIMESTAMP FROM " + "FlightRequestEventFormatterHealthStat WHERE from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > NOW() - " + - "INTERVAL "+Interval+" HOUR AND CLUSTER_ID = \""+Id+"\"" + + "INTERVAL " + Interval + " HOUR AND CLUSTER_ID = \"" + Id + "\"" + "GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\");"; List inFlightRequestBeanList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + ResultSet result = connectionHandler.getsqlConnection(clusterIDQueryFlightCount); try { while (result.next()) { From 3888ceb4d75258fa5286daf41a22dff264d5c2a5 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 15 Jul 2015 19:38:46 +0530 Subject: [PATCH 042/126] Commiting Java docs on methods which i have implemented for the REST api. --- .../rest/endpoint/api/StratosApiV41.java | 36 ++++++++++++++ .../rest/endpoint/api/StratosApiV41Utils.java | 49 ++++++++++++++++--- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index b2d229bf1c..ef9f1cbbe2 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -2128,6 +2128,13 @@ public Response getIaasProviders() return Response.ok(iaasProviderInfoBean).build(); } + /** + * + * @param Id + * @param Interval + * @return 200 if average memory consumption can get and memory consumption values + * @throws RestAPIException + */ @GET @Path("/cluster/averageMemory/{Id}/{Interval}") @Consumes("application/json") @@ -2149,6 +2156,13 @@ public Response getAverageClusterMemoryByClusterId( } + /** + * + * @param Id + * @param Interval + * @return 200 if average memory consumption can get and memory consumption values + * @throws RestAPIException + */ @GET @Path("/member/averageMemory/{Id}/{Interval}") @Consumes("application/json") @@ -2170,6 +2184,14 @@ public Response getAverageMemberMemoryByMemberId( } + /** + * + * @param Id + * @param Interval + * @return 200 if average load consumption can get and load average consumption values + * @throws RestAPIException + */ + @GET @Path("/member/averageLoad/{Id}/{Interval}") @Consumes("application/json") @@ -2191,6 +2213,13 @@ public Response getAverageMemberLoadByMemberId( } + /** + * + * @param Id + * @param Interval + * @return 200 if average load consumption can get and load average consumption values + * @throws RestAPIException + */ @GET @Path("/cluster/averageLoad/{Id}/{Interval}") @@ -2213,6 +2242,13 @@ public Response getAverageClusterLoadByClusterId( } + /** + * + * @param Id + * @param Interval + * @return 200 if average request in flight can get and in flight request count + * @throws RestAPIException + */ @GET @Path("/cluster/flightRequestCount/{Id}/{Interval}") diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 746d1c5905..0a9aa2bf16 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3652,6 +3652,13 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { } } + /** + * + * @param Id + * @param Interval + * @return Average of Cluster Memory Data + * @throws RestAPIException + */ public static String getAverageClusterMemoryByClusterId(String Id, String Interval) throws RestAPIException { @@ -3678,6 +3685,13 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv return json; } + /** + * + * @param Id + * @param Interval + * @return Average Cluster Load average data + * @throws RestAPIException + */ public static String getAverageClusterLoadByClusterId(String Id, String Interval) throws RestAPIException { @@ -3704,10 +3718,18 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval return json; } + /** + * + * @param Id + * @param Interval + * @return Average Member Memory Average data + * @throws RestAPIException + */ + public static String getAverageMemberMemoryByMemberId(String Id, String Interval) throws RestAPIException { - String memberIDQuery = "SELECT TIMESTAMP," + + String memberIfQueryforMemory = "SELECT TIMESTAMP," + "MEMBER_AVERAGE_MEMORY_CONSUMPTION FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; @@ -3716,7 +3738,7 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval List averageMemberMemoryList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(memberIDQuery); + ResultSet result = connectionHandler.getsqlConnection(memberIfQueryforMemory); try { while (result.next()) { @@ -3730,9 +3752,17 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval return json; } + /** + * + * @param Id + * @param Interval + * @return Average Member Load Average data + * @throws RestAPIException + */ + public static String getAverageMemberLoadByMemberId(String Id, String Interval) throws RestAPIException { - String memberIDLoadQuery = "SELECT TIMESTAMP," + + String memberLoadAverageQuery = "SELECT TIMESTAMP," + "MEMBER_AVERAGE_LOAD_AVERAGE FROM MemberAverageLoadAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; @@ -3741,7 +3771,7 @@ public static String getAverageMemberLoadByMemberId(String Id, String Interval) List averageMemberLoadList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(memberIDLoadQuery); + ResultSet result = connectionHandler.getsqlConnection(memberLoadAverageQuery); try { while (result.next()) { @@ -3756,10 +3786,17 @@ public static String getAverageMemberLoadByMemberId(String Id, String Interval) return json; } + /** + * + * @param Id + * @param Interval + * @return Average Cluster Flight request Count data + * @throws RestAPIException + */ public static String getAverageClusterFlightRequestCountByClusterId(String Id, String Interval) throws RestAPIException { - String clusterIDQueryFlightCount = "SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,TIMESTAMP FROM " + + String clusterIDQueryforFlightCount = "SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,TIMESTAMP FROM " + "FlightRequestEventFormatterHealthStat WHERE from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > NOW() - " + "INTERVAL " + Interval + " HOUR AND CLUSTER_ID = \"" + Id + "\"" + "GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\");"; @@ -3768,7 +3805,7 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id, S List inFlightRequestBeanList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); - ResultSet result = connectionHandler.getsqlConnection(clusterIDQueryFlightCount); + ResultSet result = connectionHandler.getsqlConnection(clusterIDQueryforFlightCount); try { while (result.next()) { From 3702641ac6c22bac5cf8c8ef183d2a15cdaf8e36 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 15 Jul 2015 23:37:16 +0530 Subject: [PATCH 043/126] Commiting REST call methods to the REST API from jaggery, to get data for the graphs. And some changes for UI --- .../console/controllers/rest/rest_calls.jag | 18 ++++- .../console/healthStatistics.jag | 69 ++++++++++++++----- .../theme0/js/custom/applications_topology.js | 31 ++++++--- .../theme0/renderers/healthStatistics.js | 8 ++- 4 files changed, 98 insertions(+), 28 deletions(-) mode change 100644 => 100755 components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index 850baabe19..1f0a838526 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -28,7 +28,19 @@ RESTCalls = new function(){ }; this.getClusterDetails = function(){ - return this.sendReceive("GET","/averageMemberMemory/getByClusterId",{}); + var Id="single-cartridge-app.my-php.php.domain"; + + var Interval="500"; + + return this.sendReceive("GET","/averageClusterLoad/" +Id+"/"+Interval,{}); + }; + + this.getMemberDetails = function(){ + var Id="tomcat-single-signon.mywso2is.wso2is.domain795dc7af-8317-4071-bbbd-5ac006e3a9ea"; + + var Interval="500"; + + return this.sendReceive("GET","/averageMemberLoad/" +Id+"/"+Interval,{}); }; this.deployPartitionDefinition = function(partitionDefinition){ @@ -374,18 +386,22 @@ RESTCalls = new function(){ } if (responseREST.xhr.status >= 200 && responseREST.xhr.status < 300) { //if success if (responseREST.data != null && responseREST.data != undefined) { + log.info("******************1"+responseREST.data); session.put("get-status", { "message": parse(responseREST.data).message, "status": "success" }); } } else if (responseREST.xhr.status >= 300 && responseREST.xhr.status < 400) { //if redirects if (responseREST.data != null && responseREST.data != undefined) { + log.info("******************2"+responseREST.data); session.put("get-status", { "message": parse(responseREST.data).message, "status": "warning" }); } } else if (responseREST.xhr.status >= 400 && responseREST.xhr.status < 500) { //if client error if (responseREST.data != null && responseREST.data != undefined) { + log.info("******************3"+responseREST.data); session.put("get-status", { "message": parse(responseREST.data).message, "status": "error" }); } } else if (responseREST.xhr.status >= 500 && responseREST.xhr.status < 600) { //if server error if (responseREST.data != null && responseREST.data != undefined) { + log.info("******************4"+responseREST.data); session.put("get-status", { "message": parse(responseREST.data).message, "status": "error" }); } } else { diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index c1d32c7acc..967d554fe0 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -26,39 +26,76 @@ include('/controllers/menu/menu_generator.jag'); var log = new Log("apacheStratos.appconfig"), error = [], caramel = require('caramel'), -// dataTSV=require('/controllers/datatsv/data2.json'), context = caramel.configs().context, + util = require('/controllers/rest/rest_calls.jag'), menuJson = require('/controllers/menu/menu.json'), - JsonFile = require("/controllers/datatsv/json.json"), + util = require('/controllers/rest/rest_calls.jag'), + Id = request.getParameter('Id'), + Type = request.getParameter('Type'), userPermissions = session.get('PERMISSIONS'); //create left menu var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); //create metro block -var metro_menu = metroGenerator('/healthStatistics', menuJson.menu, userPermissions); +var metro_menu = metroGenerator('/health', menuJson.menu, userPermissions); var log = new Log(); var config = {"driverClassName":"org.apache.cassandra.cql.jdbc.CassandraDriver"}; -log.info(JsonFile); +log.debug(Id); var db = null; var result = null; -/*try { - db = new Database("WSO2BAM_CASSANDRA_DATASOURCE_3"); - db.query("USE AGENTHEALTH_STAT"); +log.info(")))))))))))))))))))))))))))))))))))))))))1"); +//var newtRY = util.RESTCalls.getMemberDetails(); +//log.info(newtRY+")))))))))))))))))))))))))))))))))))))))))2"); +var newtRY2 = util.RESTCalls.getClusterDetails(); +log.info(newtRY2+")))))))))))))))))))))))))))))))))))))))))2"); + +(function () { + + var action = request.getParameter("action"); + + if(action == "memoryConsumption") { + try { + + cluster= getData(); + log.info("@@@@@@@@@@@@@@@@"+cluster); + + log.info("DDDDDDDDDDDDDDDDDDDDDDDDDDDDD"+action); + + } catch (e) { + throw new Error("Error while getting Category Activity data for "+ e); + } + + }else if(action == "loadAverage"){ + try { + log.info("DDDDDDDDDDDDDDDDDDDDDDDDDDDDD"+action); + + } catch (e) { + throw new Error("Error while getting Category Activity data for "+ e); + } + + }else if(action == "requestInFlight"){ + try { + + log.info("DDDDDDDDDDDDDDDDDDDDDDDDDDDDD"+action); + + } catch (e) { + throw new Error("Error while getting Category Activity data for "+ e); + } + + } + return cluster; + +}()); - result = db.query("SELECT * FROM AGENTHEALTH_STAT"); - } finally { - if (db != null) { - db.close(); - } - } - */ caramel.render({ breadcrumbPathLevelOne: 'healthStatistics', - //dataTSV: JSON.stringify(dataTSV), - Json: JSON.stringify(JsonFile), + Id:Id, + //newtRY:JSON.stringify(newtRY), + newtRY2:JSON.stringify(newtRY2), + Type: Type, result:result, error: error }); diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js old mode 100644 new mode 100755 index 4e617ea5eb..b64446f6c2 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -48,7 +48,7 @@ function genTree(data){ function clusterInstances(items, collector, parent){ for(var prop in items){ if (items.hasOwnProperty(prop)) { - var cur_name = items[prop].clusterId + items[prop].instanceId, + var cur_name = items[prop].clusterId, alias = items[prop].alias, hostNames = items[prop].hostNames.toString(), serviceName = items[prop].serviceName, @@ -139,7 +139,7 @@ function genTree(data){ function update(source) { - // ************** Generate the tree diagram ***************** + // ************** Generate the tree diagram ***************** var margin = {top: 80, right: 120, bottom: 20, left: 120}, width = 900 - margin.right - margin.left, height = 900 - margin.top - margin.bottom; @@ -203,12 +203,14 @@ function update(source) { }else{ var accessURLHTML =''; } + div_html = "Cluster Id: " + d.name + "
    " + "Cluster Alias: " + d.alias + "
    " + accessURLHTML + "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + - "Status: " + d.status; + "Status: " + d.status + "

    " + + ""; } else if (d.type == 'members') { if((typeof d.ports != 'undefined') && (d.ports.length > 0)) { @@ -224,13 +226,15 @@ function update(source) { } else{ var portsHTML =''; } + div_html = "Member Id: " + d.name + "
    " + "Default Private IP: " + d.defaultPrivateIP + "
    " + "Default Public IP: " + d.defaultPublicIP + "
    " + portsHTML + "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + - "Status: " + d.status; + "Status: " + d.status + "

    " + + ""; } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + @@ -247,7 +251,8 @@ function update(source) { } return div_html; }); - // add popover on nodes + + // add popover on nodes nodeEnter.append("rect") .attr("x", -15) .attr("y", -15) @@ -565,9 +570,6 @@ function addJsplumbGroup(groupJSON, cartridgeCounter){ } } } - - - } var initapp = 0; @@ -581,5 +583,18 @@ $("a[href='#application']").on('shown.bs.tab', function(e) { } }); +function showHealthStat(element){ + var currentURL = window.location.href; + var splitTense = currentURL.split('console'); + var newURL = splitTense[0] + "console/healthStatistics/"; + + var form = $('
    ' + + '' + + '' + '
    '); + + $('body').append(form); + $(form).submit(); +} + diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js index d40fa1d611..2ea6976247 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js @@ -50,10 +50,12 @@ var render = function (theme, data, meta, require) { { partial: 'healthStatistics', context:{ - dataTSV:data.dataTSV, - Json:data.Json, + Id:data.Id, + newtRY:data.newtRY, + newtRY2:data.newtRY2, + Type: data.Type, result:data.result, - content_title:'Health Statistics' + content_title:'Health Stats' } } ] From 85c06f40099aab5f34ebec283abc7c7402fbeb18 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 16 Jul 2015 02:20:14 +0530 Subject: [PATCH 044/126] Adding UI changes on healthStatistic.hbs --- .../theme0/partials/healthStatistics.hbs | 80 ++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs index 459c26d705..0aeed4800d 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -3,10 +3,13 @@ + +
    -

    Health statistics

    +

    {{Id}}

    +

    Type : {{Type}}

    @@ -17,6 +20,7 @@ +
    - + {{#if condition}} +
    +
    +
    +

    In Flight Request Count

    +
    +
    + + + + + +
    +
    +
    +
    +
    +
    +
    + {{/if}} -
    -
    -
    + -
    -
    -
    - - + + + + function type(d) { + d.timeStamp = parseDate(d.timeStamp); + d.memberAverageMemoryConsumption = +d.memberAverageMemoryConsumption; + return d; + } + } + + /*function ajaxfirst () { + var formtype='applicationtopology'; + + $.ajax({ + type: "GET", + url: caramel.context + "/controllers/healthStatistics/healthStatistics_getrequest.jag", + dataType: 'json', + data: {"formtype": formtype }, + success: function (data) { + console.info("%%%%%%%"+data) - - - - + if (data.status == 'error') { + var n = noty({text: data.message, layout: 'bottomRight', type: 'error'}); + } else if (data.status == 'warning') { + var n = noty({text: data.message, layout: 'bottomRight', type: 'warning'}); + } else { + var n = noty({text: data.message, layout: 'bottomRight', type: 'success'}); + } + window.setTimeout(function(){ + location.reload(); + }, 1000); + } + }).always(function () {}); + }*/ + \ No newline at end of file From 5d85797a6e4e048976a1357c1e078f6a0095dcff Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 26 Jul 2015 10:55:54 +0530 Subject: [PATCH 054/126] Health Stat Publisher event formatter.This is to send all health stats using one formatter to the database. --- .../HealthStatPublishEventFormatter.xml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml diff --git a/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml b/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml new file mode 100644 index 0000000000..eaeaccedb7 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + DataSourcetoPublishHealthStatRDBMS + HealthStatistics + + \ No newline at end of file From 70a0e13ceff6dca7a6591ee010e609a1a74ed3ee Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 26 Jul 2015 14:44:17 +0530 Subject: [PATCH 055/126] Adding flight count data to a new export stream definition to create a single table. --- .../executionplans/AverageInFlightRequestsFinder.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml index 3286a40e6f..0ef629e9e8 100644 --- a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml +++ b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml @@ -37,12 +37,15 @@ define partition avg_rif_cluster_partition by avg_rif_concat.avg_rif_cluster_network; from avg_rif_concat#window.timeBatch(1 min) select cluster_id, cluster_instance_id,timeStamp, network_partition_id, avg(in_flight_request_count) as count - insert into average_in_flight_requests + insert into average_in_flight_requests partition by avg_rif_cluster_partition; + from average_in_flight_requests select cluster_id as ID,timeStamp,count as value,"in_flight_request_count" as type insert into health_statistics_stats; ]]> + \ No newline at end of file From 89f12ac8a93777f9beced73b9f57148590b1f032 Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 26 Jul 2015 20:26:53 +0530 Subject: [PATCH 056/126] Chaning Health Stat topic. --- .../theme0/partials/healthStatistics.hbs | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs index 7a30355b66..e07af431e6 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -108,7 +108,8 @@
    -

    {{Type}} : {{Id}}

    +

    {{Type}} Statistics

    +

    {{Id}}

    @@ -256,7 +257,7 @@ function bodyOnLoad () { var type="{{{Type}}}"; console.info(type); - if (type!="cluster") { + if (type!="Cluster") { loadAverageChart(); memoryAverageDataChart(); } @@ -583,29 +584,4 @@ } } - /*function ajaxfirst () { - var formtype='applicationtopology'; - - $.ajax({ - type: "GET", - url: caramel.context + "/controllers/healthStatistics/healthStatistics_getrequest.jag", - dataType: 'json', - data: {"formtype": formtype }, - success: function (data) { - console.info("%%%%%%%"+data) - - if (data.status == 'error') { - var n = noty({text: data.message, layout: 'bottomRight', type: 'error'}); - } else if (data.status == 'warning') { - var n = noty({text: data.message, layout: 'bottomRight', type: 'warning'}); - } else { - var n = noty({text: data.message, layout: 'bottomRight', type: 'success'}); - } - window.setTimeout(function(){ - location.reload(); - }, 1000); - } - }).always(function () {}); - }*/ - \ No newline at end of file From cdd7534a7f74ad7ed0fa8ab82eada47edd8a852f Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 26 Jul 2015 23:01:43 +0530 Subject: [PATCH 057/126] Adding the new stream definition which create a new export stream that can use to create a single table. --- .../stream-manager-config.xml | 72 ++++++++++++------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml index ac46c1b6a6..a4be624eff 100644 --- a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml +++ b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml @@ -36,7 +36,7 @@ - + gradient of in flight request count @@ -105,35 +105,38 @@ + - average load average stats - average load average stats - - - - - - - - - - - + average load average stats + average load average stats + + + + + + + + + + + + - average memory consumption stats - average memory consumption stats - - - - - - - - - - - + average memory consumption stats + average memory consumption stats + + + + + + + + + + + + gradient load average stats @@ -150,6 +153,21 @@ + + health statistics stats + health statistics stats + + + + + + + + + + + + gradient memoryconsumption stats gradient memoryconsumption stats From d6e134e46d5b9069a474bdf2efa56b9647163a24 Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 27 Jul 2015 12:11:11 +0530 Subject: [PATCH 058/126] Adding few minor changes to the UI --- .../theme0/partials/healthStatistics.hbs | 152 +++--------------- 1 file changed, 24 insertions(+), 128 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs index e07af431e6..ffc22fe852 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -1,121 +1,14 @@ - - -
    -

    {{Type}} Statistics

    -

    {{Id}}

    - - +

    {{type}} Statistics

    +

    {{id}}

    + +
    - Back + Back
    @@ -130,7 +23,7 @@
    -
    +
    @@ -149,7 +42,7 @@
    -
    +
    @@ -169,7 +62,7 @@
    -
    +
    @@ -181,6 +74,7 @@ + @@ -200,16 +94,16 @@ if(buttonName == 'InFlight'){ - $('#rowTable1').empty(); - $('#rowTable1').html(''); + $('#chart1').empty(); + $('#chart1').html(''); }else if(buttonName == 'LoadAverage'){ - $('#rowTable2').empty(); - $('#rowTable2').html(''); + $('#chart2').empty(); + $('#chart2').html(''); }else{ - $('#rowTable3').empty(); - $('#rowTable3').html(''); + $('#chart3').empty(); + $('#chart3').html(''); } @@ -229,17 +123,17 @@ if(data.status!='error'){ if(buttonName == 'InFlight'){ - $('#rowTable1').empty(); + $('#chart1').empty(); jsonDataFlightRequest = data; inFlightRequestCountChart(); } else if(buttonName == 'LoadAverage'){ - $('#rowTable2').empty(); + $('#chart2').empty(); jsonDataLoadAvg = data; loadAverageChart(); } else{ - $('#rowTable3').empty(); + $('#chart3').empty(); jsonDataMemoryAvg = data; memoryAverageDataChart(); } @@ -251,11 +145,13 @@ } + }).always(function () {}); } function bodyOnLoad () { - var type="{{{Type}}}"; + + var type="{{{type}}}"; console.info(type); if (type!="Cluster") { loadAverageChart(); @@ -302,7 +198,7 @@ " Time: " + new Date(d.timeStamp) + ""; }) - var svg = d3.select("#rowTable2").append("svg") + var svg = d3.select("#chart2").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") @@ -388,7 +284,7 @@ .x(function(d) { return x2(d.timeStamp); }) .y(function(d) { return y2(d.inFlightRequestCount); }); - var svg = d3.select("#rowTable1").append("svg") + var svg = d3.select("#chart1").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom); @@ -510,7 +406,7 @@ .y0(height2) .y1(function(d) { return y2(d.memberAverageMemoryConsumption); }); - var svg = d3.select("#rowTable3").append("svg") + var svg = d3.select("#chart3").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom); From e7f7379303aaea7815e11c9453437b131c152b0f Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 27 Jul 2015 13:12:48 +0530 Subject: [PATCH 059/126] css style sheets for the health statistics UI --- .../console/themes/theme0/css/custom.css | 92 ++++++++++++++++++- .../themes/theme0/helpers/healthStatistic.js | 0 .../theme0/js/{ => d3.tip}/d3.tip.v0.6.3.js | 0 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js rename components/org.apache.stratos.manager.console/console/themes/theme0/js/{ => d3.tip}/d3.tip.v0.6.3.js (100%) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css index a8b1b3a159..40138e9e50 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css @@ -73,8 +73,8 @@ body{ background: url('../images/stratos_background.png') no-repeat; background .slidewindow .tab-handles .slidewindow-handle, .slidewindow.right .tab-handles .slidewindow-handle { display: block; float: none; } .slidewindow-content { - background-color: white; - font-size:16px; + background-color: white; + font-size:16px; position: relative; float: left; z-index: 1; @@ -106,7 +106,7 @@ body{ background: url('../images/stratos_background.png') no-repeat; background position: relative; float: left; z-index: 0; - cursor:pointer; + cursor:pointer; } @@ -233,4 +233,88 @@ div#textform>div>h3 { h3.panel-title { color: #999; -} \ No newline at end of file +} + + +svg { + font: 10px sans-serif; +} + +.area { + fill: #00BFFF; + clip-path: url(#clip); +} + +.axis path, +.axis line { + fill: none; + stroke: #000; + shape-rendering: crispEdges; +} + +.d3-tip { + line-height: 1; + font-weight: bold; + padding: 12px; + background: rgba(0, 0, 0, 0.8); + color: #fff; + border-radius: 2px; +} + +/* Creates a small triangle extender for the tooltip */ +.d3-tip:after { + box-sizing: border-box; + display: inline; + font-size: 10px; + width: 100%; + line-height: 1; + color: rgba(0, 0, 0, 0.8); + content: "\25BC"; + position: absolute; + text-align: center; +} + +/* Style northward tooltips differently */ +.d3-tip.n:after { + margin: -1px 0 0 0; + top: 100%; + left: 0; +} + +.brush .extent { + stroke: #fff; + fill-opacity: .125; + shape-rendering: crispEdges; +} +svg { + font: 10px sans-serif; +} + +.brush .extent { + stroke: #fff; + fill-opacity: .125; + shape-rendering: crispEdges; +} + + +.x.axis path { + display: none; +} + +.line { + fill: none; + stroke: green; + stroke-width: 1.5px; +} + +body { + font: 10px sans-serif; +} + +.area1 { + fill: orange; +} + +.area2 { + fill: red; +} diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js b/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip.v0.6.3.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js similarity index 100% rename from components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip.v0.6.3.js rename to components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js From 598318e4c78624263902f1e0f59b4d823ecac763 Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 27 Jul 2015 19:42:14 +0530 Subject: [PATCH 060/126] Adding the helper js file for the health statistics UI --- .../themes/theme0/helpers/healthStatistic.js | 28 +++++++++++++++++++ .../theme0/renderers/healthStatistics.js | 9 ++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js b/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js index e69de29bb2..3c3496c0a2 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/helpers/healthStatistic.js @@ -0,0 +1,28 @@ +/* + * + * 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. + * + */ + +var resources = function (page, meta) { + return { + js: ['bootstrap-switch-3.0.2/bootstrap-switch.min.js', 'custom/script.js', 'd3js-v3/d3.v3.min.js' , + 'dagre-v0.7.0/dagre.min.js', 'd3.tip/d3.tip.v0.6.3.js', 'canvg/canvg.js'], + css: ['bootstrap-switch-3.0.2/bootstrap-switch.min.css', 'custom/style.css', 'custom/topology.css'] + }; +}; diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js index 2ea6976247..9988f4edc1 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js @@ -51,11 +51,14 @@ var render = function (theme, data, meta, require) { partial: 'healthStatistics', context:{ Id:data.Id, - newtRY:data.newtRY, - newtRY2:data.newtRY2, + Alias:data.Alias, + loadAverageData:data.loadAverageData, + memoryAverageDetails:data.memoryAverageDetails, + flightRequestDetails:data.flightRequestDetails, Type: data.Type, result:data.result, - content_title:'Health Stats' + content_title:'Health Stats', + condition: data.Type != 'member' } } ] From 80e621492c43cc10cb1d19873052795bfe67e251 Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 27 Jul 2015 19:45:40 +0530 Subject: [PATCH 061/126] Commiting the tip js library --- .../themes/theme0/js/d3.tip/d3.tip.v0.6.3.js | 280 ------------------ 1 file changed, 280 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js index 6cfa3cb66b..e69de29bb2 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js @@ -1,280 +0,0 @@ -// d3.tip -// Copyright (c) 2013 Justin Palmer -// -// Tooltips for d3.js SVG visualizations - -// Public - contructs a new tooltip -// -// Returns a tip -d3.tip = function() { - var direction = d3_tip_direction, - offset = d3_tip_offset, - html = d3_tip_html, - node = initNode(), - svg = null, - point = null, - target = null - - function tip(vis) { - svg = getSVGNode(vis) - point = svg.createSVGPoint() - document.body.appendChild(node) - } - - // Public - show the tooltip on the screen - // - // Returns a tip - tip.show = function() { - var args = Array.prototype.slice.call(arguments) - if(args[args.length - 1] instanceof SVGElement) target = args.pop() - - var content = html.apply(this, args), - poffset = offset.apply(this, args), - dir = direction.apply(this, args), - nodel = d3.select(node), i = 0, - coords - - nodel.html(content) - .style({ opacity: 1, 'pointer-events': 'all' }) - - while(i--) nodel.classed(directions[i], false) - coords = direction_callbacks.get(dir).apply(this) - nodel.classed(dir, true).style({ - top: (coords.top + poffset[0]) + 'px', - left: (coords.left + poffset[1]) + 'px' - }) - - return tip - } - - // Public - hide the tooltip - // - // Returns a tip - tip.hide = function() { - nodel = d3.select(node) - nodel.style({ opacity: 0, 'pointer-events': 'none' }) - return tip - } - - // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. - // - // n - name of the attribute - // v - value of the attribute - // - // Returns tip or attribute value - tip.attr = function(n, v) { - if (arguments.length < 2 && typeof n === 'string') { - return d3.select(node).attr(n) - } else { - var args = Array.prototype.slice.call(arguments) - d3.selection.prototype.attr.apply(d3.select(node), args) - } - - return tip - } - - // Public: Proxy style calls to the d3 tip container. Sets or gets a style value. - // - // n - name of the property - // v - value of the property - // - // Returns tip or style property value - tip.style = function(n, v) { - if (arguments.length < 2 && typeof n === 'string') { - return d3.select(node).style(n) - } else { - var args = Array.prototype.slice.call(arguments) - d3.selection.prototype.style.apply(d3.select(node), args) - } - - return tip - } - - // Public: Set or get the direction of the tooltip - // - // v - One of n(north), s(south), e(east), or w(west), nw(northwest), - // sw(southwest), ne(northeast) or se(southeast) - // - // Returns tip or direction - tip.direction = function(v) { - if (!arguments.length) return direction - direction = v == null ? v : d3.functor(v) - - return tip - } - - // Public: Sets or gets the offset of the tip - // - // v - Array of [x, y] offset - // - // Returns offset or - tip.offset = function(v) { - if (!arguments.length) return offset - offset = v == null ? v : d3.functor(v) - - return tip - } - - // Public: sets or gets the html value of the tooltip - // - // v - String value of the tip - // - // Returns html value or tip - tip.html = function(v) { - if (!arguments.length) return html - html = v == null ? v : d3.functor(v) - - return tip - } - - function d3_tip_direction() { return 'n' } - function d3_tip_offset() { return [0, 0] } - function d3_tip_html() { return ' ' } - - var direction_callbacks = d3.map({ - n: direction_n, - s: direction_s, - e: direction_e, - w: direction_w, - nw: direction_nw, - ne: direction_ne, - sw: direction_sw, - se: direction_se - }), - - directions = direction_callbacks.keys() - - function direction_n() { - var bbox = getScreenBBox() - return { - top: bbox.n.y - node.offsetHeight, - left: bbox.n.x - node.offsetWidth / 2 - } - } - - function direction_s() { - var bbox = getScreenBBox() - return { - top: bbox.s.y, - left: bbox.s.x - node.offsetWidth / 2 - } - } - - function direction_e() { - var bbox = getScreenBBox() - return { - top: bbox.e.y - node.offsetHeight / 2, - left: bbox.e.x - } - } - - function direction_w() { - var bbox = getScreenBBox() - return { - top: bbox.w.y - node.offsetHeight / 2, - left: bbox.w.x - node.offsetWidth - } - } - - function direction_nw() { - var bbox = getScreenBBox() - return { - top: bbox.nw.y - node.offsetHeight, - left: bbox.nw.x - node.offsetWidth - } - } - - function direction_ne() { - var bbox = getScreenBBox() - return { - top: bbox.ne.y - node.offsetHeight, - left: bbox.ne.x - } - } - - function direction_sw() { - var bbox = getScreenBBox() - return { - top: bbox.sw.y, - left: bbox.sw.x - node.offsetWidth - } - } - - function direction_se() { - var bbox = getScreenBBox() - return { - top: bbox.se.y, - left: bbox.e.x - } - } - - function initNode() { - var node = d3.select(document.createElement('div')) - node.style({ - position: 'absolute', - opacity: 0, - pointerEvents: 'none', - boxSizing: 'border-box' - }) - - return node.node() - } - - function getSVGNode(el) { - el = el.node() - if(el.tagName.toLowerCase() == 'svg') - return el - - return el.ownerSVGElement - } - - // Private - gets the screen coordinates of a shape - // - // Given a shape on the screen, will return an SVGPoint for the directions - // n(north), s(south), e(east), w(west), ne(northeast), se(southeast), nw(northwest), - // sw(southwest). - // - // +-+-+ - // | | - // + + - // | | - // +-+-+ - // - // Returns an Object {n, s, e, w, nw, sw, ne, se} - function getScreenBBox() { - var targetel = target || d3.event.target, - bbox = {}, - matrix = targetel.getScreenCTM(), - tbbox = targetel.getBBox(), - width = tbbox.width, - height = tbbox.height, - x = tbbox.x, - y = tbbox.y, - scrollTop = document.documentElement.scrollTop || document.body.scrollTop, - scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft - - - point.x = x + scrollLeft - point.y = y + scrollTop - bbox.nw = point.matrixTransform(matrix) - point.x += width - bbox.ne = point.matrixTransform(matrix) - point.y += height - bbox.se = point.matrixTransform(matrix) - point.x -= width - bbox.sw = point.matrixTransform(matrix) - point.y -= height / 2 - bbox.w = point.matrixTransform(matrix) - point.x += width - bbox.e = point.matrixTransform(matrix) - point.x -= width / 2 - point.y -= height / 2 - bbox.n = point.matrixTransform(matrix) - point.y += height - bbox.s = point.matrixTransform(matrix) - - return bbox - } - - return tip -}; From 3be909f1a21af8f662fc3fce29bce77cecac55f2 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 00:04:05 +0530 Subject: [PATCH 062/126] application topology button changes --- .../theme0/js/custom/applications_topology.js | 278 ++++++++++-------- 1 file changed, 150 insertions(+), 128 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js index 290ed7fcf7..d7b5bcd63c 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -20,11 +20,11 @@ */ //create JSON from topology -function genTree(data){ +function genTree(data) { var rawout = []; var alias; - var rootnode ={}; + var rootnode = {}; rootnode.name = data.id; rootnode.parent = null; rootnode.status = data.status; @@ -32,8 +32,8 @@ function genTree(data){ rawout.push(rootnode); //application instances - function applicationInstances(items, collector, parent){ - for(var prop in items){ + function applicationInstances(items, collector, parent) { + for (var prop in items) { if (items.hasOwnProperty(prop)) { var cur_name = items[prop].instanceId, status = items[prop].status, @@ -46,8 +46,8 @@ function genTree(data){ } } - function clusterInstances(items, collector, parent){ - for(var prop in items){ + function clusterInstances(items, collector, parent) { + for (var prop in items) { if (items.hasOwnProperty(prop)) { var cur_name = items[prop].clusterId, alias = items[prop].alias, @@ -55,35 +55,37 @@ function genTree(data){ serviceName = items[prop].serviceName, status = items[prop].status; - if(items[prop].accessUrls){ + if (items[prop].accessUrls) { accessUrls = items[prop].accessUrls; - }else{ + } else { accessUrls = ''; } var type = 'clusters'; - rawout.push({"name": cur_name, "parent": parent, "type": type, "status": status, - "alias":alias, "hostNames": hostNames, "serviceName": serviceName, - "accessUrls":accessUrls + rawout.push({ + "name": cur_name, "parent": parent, "type": type, "status": status, + "alias": alias, "hostNames": hostNames, "serviceName": serviceName, + "accessUrls": accessUrls }); clustermembers(items[prop].member, collector, cur_name) } } } - function groupInstances(items, collector, parent){ - for(var prop in items){ + function groupInstances(items, collector, parent) { + for (var prop in items) { if (items.hasOwnProperty(prop)) { var cur_name = items[prop].groupId + items[prop].instanceId, instanceId = items[prop].instanceId, groupId = items[prop].groupId, status = items[prop].status; var type = 'groups'; - rawout.push({"name": cur_name, "parent": parent, "type": type, "status": status, - "groupId":groupId, "instanceId":instanceId + rawout.push({ + "name": cur_name, "parent": parent, "type": type, "status": status, + "groupId": groupId, "instanceId": instanceId }); clusterInstances(items[prop].clusterInstances, collector, cur_name); - if(items[prop].hasOwnProperty('groupInstances')){ + if (items[prop].hasOwnProperty('groupInstances')) { groupInstances(items[prop].groupInstances, collector, cur_name) } @@ -91,8 +93,8 @@ function genTree(data){ } } - function clustermembers(items, collector, parent){ - for(var prop in items){ + function clustermembers(items, collector, parent) { + for (var prop in items) { if (items.hasOwnProperty(prop)) { var cur_name = items[prop].memberId, defaultPrivateIP = items[prop].defaultPrivateIP, @@ -102,9 +104,10 @@ function genTree(data){ partitionId = items[prop].partitionId, status = items[prop].status; var type = 'members'; - rawout.push({"name": cur_name, "parent": parent, "type": type, "status": status, - "defaultPrivateIP":defaultPrivateIP, "defaultPublicIP":defaultPublicIP,"ports":ports, - "networkPartitionId":networkPartitionId, "partitionId":partitionId + rawout.push({ + "name": cur_name, "parent": parent, "type": type, "status": status, + "defaultPrivateIP": defaultPrivateIP, "defaultPublicIP": defaultPublicIP, "ports": ports, + "networkPartitionId": networkPartitionId, "partitionId": partitionId }); } } @@ -148,13 +151,16 @@ function update(source) { var i = 0; var tree = d3.layout.tree() - .separation(function(a, b) { return ((a.parent == source) && (b.parent == source)) ? 5 : 4; }) - .size([height+100, width]); + .separation(function (a, b) { + return ((a.parent == source) && (b.parent == source)) ? 5 : 4; + }) + .size([height + 100, width]); var diagonal = d3.svg.diagonal() .projection(function (d) { return [d.x, d.y]; }); + function redraw() { svg.attr("transform", "translate(" + d3.event.translate + ")" @@ -194,15 +200,15 @@ function update(source) { }) .attr('data-content', function (d) { if (d.type == 'clusters') { - if(d.accessUrls != ''){ + if (d.accessUrls != '') { var accessURLHTML = "Access URLs: "; - for(var i=0;i"+ d.accessUrls[i] + - "
    " ; + for (var i = 0; i < d.accessUrls.length; i++) { + accessURLHTML += "" + d.accessUrls[i] + + "
    "; } - }else{ - var accessURLHTML =''; + } else { + var accessURLHTML = ''; } div_html = "Cluster Id: " + d.name + "
    " + @@ -211,21 +217,21 @@ function update(source) { "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'members') { - if((typeof d.ports != 'undefined') && (d.ports.length > 0)) { + if ((typeof d.ports != 'undefined') && (d.ports.length > 0)) { var portsHTML = "Ports:
    "; - for(var i=0;i" + @@ -235,7 +241,7 @@ function update(source) { "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + @@ -246,9 +252,9 @@ function update(source) { "Status: " + d.status; } else { - div_html = "Alias: " + d.name + "
    "+ + div_html = "Alias: " + d.name + "
    " + "Status: " + d.status; - alias =d.name; + alias = d.name; } return div_html; @@ -271,7 +277,7 @@ function update(source) { return "#c0392b"; } else if (d.status == 'Terminating') { return "#c0392b"; - }else{ + } else { return "#CCC"; } }); @@ -303,13 +309,13 @@ function update(source) { .attr("dy", ".35em") .attr("text-anchor", "middle") .text(function (d) { - if(d.type == 'members') { + if (d.type == 'members') { return ''; - }else if(d.type == 'clusters') { + } else if (d.type == 'clusters') { return d.alias; - }else if(d.type == 'groups'){ + } else if (d.type == 'groups') { return d.groupId; - }else{ + } else { return d.name; } @@ -324,46 +330,52 @@ function update(source) { // Enter the links. link.enter().insert("path", "g") - .style('fill','none') - .style('stroke-width','2') - .style('stroke','#ccc') + .style('fill', 'none') + .style('stroke-width', '2') + .style('stroke', '#ccc') .attr("class", "link") .attr("d", diagonal); //enable popovers on nodes $('svg .node').popover({ 'trigger': 'manual' - ,'container': '.application-topology' - ,'placement': 'auto' - ,'white-space': 'nowrap' - ,'html':'true' - ,delay: {show: 50, hide: 400} + , 'container': '.application-topology' + , 'placement': 'auto' + , 'white-space': 'nowrap' + , 'html': 'true' + , delay: {show: 50, hide: 400} }); var timer, popover_parent; + function hidePopover(elem) { $(elem).popover('hide'); } + $('svg .node').hover( - function() { + function () { var self = this; clearTimeout(timer); $('.popover').hide(); //Hide any open popovers on other elements. popover_parent = self $(self).popover('show'); }, - function() { + function () { var self = this; - timer = setTimeout(function(){hidePopover(self)},300); + timer = setTimeout(function () { + hidePopover(self) + }, 300); }); $(document).on({ - mouseenter: function() { + mouseenter: function () { clearTimeout(timer); }, - mouseleave: function() { + mouseleave: function () { var self = this; - timer = setTimeout(function(){hidePopover(popover_parent)},300); + timer = setTimeout(function () { + hidePopover(popover_parent) + }, 300); } }, '.popover'); @@ -372,15 +384,15 @@ function update(source) { //Application view // repaint -function Repaint(){ - $("#whiteboard").resize(function(){ +function Repaint() { + $("#whiteboard").resize(function () { jsPlumb.repaintEverything(); }); } // drag -function DragEl(el){ - jsPlumb.draggable($(el) ,{ - containment:"#whiteboard" +function DragEl(el) { + jsPlumb.draggable($(el), { + containment: "#whiteboard" }); } @@ -388,10 +400,10 @@ function DragEl(el){ // JsPlumb Config var color = "gray", exampleColor = "#00f", - arrowCommon = { foldback:0.7, fillStyle:color, width:14 }; + arrowCommon = {foldback: 0.7, fillStyle: color, width: 14}; jsPlumb.importDefaults({ - Connector : [ "Bezier", { curviness:63 } ], + Connector: ["Bezier", {curviness: 63}], /*Overlays: [ [ "Arrow", { location:0.7 }, arrowCommon ], ]*/ @@ -399,63 +411,65 @@ jsPlumb.importDefaults({ var nodeDropOptions = { - activeClass:"dragActive" + activeClass: "dragActive" }; var bottomConnectorOptions = { - endpoint:"Rectangle", - paintStyle:{ width:25, height:21, fillStyle:'#666' }, - isSource:true, - connectorStyle : { strokeStyle:"#666" }, - isTarget:false, - maxConnections:20 + endpoint: "Rectangle", + paintStyle: {width: 25, height: 21, fillStyle: '#666'}, + isSource: true, + connectorStyle: {strokeStyle: "#666"}, + isTarget: false, + maxConnections: 20 }; var endpointOptions = { - isTarget:true, - endpoint:"Dot", - paintStyle:{ - fillStyle:"gray" + isTarget: true, + endpoint: "Dot", + paintStyle: { + fillStyle: "gray" }, dropOptions: nodeDropOptions, - maxConnections:1 + maxConnections: 1 }; var groupOptions = { - isTarget:true, - endpoint:"Dot", - paintStyle:{ - fillStyle:"gray" + isTarget: true, + endpoint: "Dot", + paintStyle: { + fillStyle: "gray" }, dropOptions: nodeDropOptions, - maxConnections:1 + maxConnections: 1 }; var generatedCartridgeEndpointOptions = { - isTarget:false, - endpoint:"Dot", - paintStyle:{ - fillStyle:"gray" + isTarget: false, + endpoint: "Dot", + paintStyle: { + fillStyle: "gray" }, dropOptions: '', - maxConnections:1 + maxConnections: 1 }; var generatedGroupOptions = { - isTarget:false, - endpoint:"Dot", - paintStyle:{ - fillStyle:"gray" + isTarget: false, + endpoint: "Dot", + paintStyle: { + fillStyle: "gray" }, dropOptions: nodeDropOptions, - maxConnections:1 + maxConnections: 1 }; -function dagrePosition(){ +function dagrePosition() { // construct dagre graph from JsPlumb graph var g = new dagre.graphlib.Graph(); - g.setGraph({ranksep:'80'}); - g.setDefaultEdgeLabel(function() { return {}; }); + g.setGraph({ranksep: '80'}); + g.setDefaultEdgeLabel(function () { + return {}; + }); var nodes = $(".stepnode"); for (var i = 0; i < nodes.length; i++) { @@ -465,53 +479,57 @@ function dagrePosition(){ var edges = jsPlumb.getAllConnections(); for (var i = 0; i < edges.length; i++) { var c = edges[i]; - g.setEdge(c.source.id,c.target.id ); + g.setEdge(c.source.id, c.target.id); } // calculate the layout (i.e. node positions) dagre.layout(g); // Applying the calculated layout - g.nodes().forEach(function(v) { + g.nodes().forEach(function (v) { $("#" + v).css("left", g.node(v).x + "px"); $("#" + v).css("top", g.node(v).y + "px"); }); jsPlumb.repaintEverything(); } //add group to editor -var cartridgeCounter =0; +var cartridgeCounter = 0; //add group to editor -function addJsplumbGroup(groupJSON, cartridgeCounter){ +function addJsplumbGroup(groupJSON, cartridgeCounter) { - var divRoot = $('
    ').attr({'id':cartridgeCounter+'-'+groupJSON.alias,'data-type':'group','data-ctype':groupJSON.alias}) + var divRoot = $('
    ').attr({ + 'id': cartridgeCounter + '-' + groupJSON.alias, + 'data-type': 'group', + 'data-ctype': groupJSON.alias + }) .text(groupJSON.alias) .addClass('input-false') .addClass('application') .attr('data-toggle', 'tooltip') - .attr('title',groupJSON.alias) + .attr('title', groupJSON.alias) .addClass('stepnode') .appendTo('#whiteboard'); jsPlumb.addEndpoint($(divRoot), { - anchor:"BottomCenter" + anchor: "BottomCenter" }, bottomConnectorOptions); DragEl($(divRoot)); - if(groupJSON['components']['cartridges']) { + if (groupJSON['components']['cartridges']) { genJsplumbCartridge(groupJSON['components']['cartridges'], divRoot, groupJSON.alias); } - if(groupJSON['components']['groups']){ + if (groupJSON['components']['groups']) { genJsplumbGroups(groupJSON['components']['groups'], divRoot, groupJSON.alias); } - function genJsplumbCartridge(item, currentParent, parentName){ + function genJsplumbCartridge(item, currentParent, parentName) { for (var prop in item) { var id = item[prop].type; - var divCartridge = $('
    ').attr({'id':cartridgeCounter+'-'+parentName+'-'+item[prop].type} ) + var divCartridge = $('
    ').attr({'id': cartridgeCounter + '-' + parentName + '-' + item[prop].type}) .text(item[prop].type) .addClass('input-false') .addClass('stepnode') .attr('data-toggle', 'tooltip') - .attr('title',item[prop].type ) + .attr('title', item[prop].type) .appendTo('#whiteboard'); @@ -521,12 +539,12 @@ function addJsplumbGroup(groupJSON, cartridgeCounter){ //add connection options jsPlumb.connect({ - source:$(currentParent), - target:$(divCartridge), - paintStyle:{strokeStyle:"blue", lineWidth:1 }, - Connector : [ "Bezier", { curviness:63 } ], - anchors:["BottomCenter", "TopCenter"], - endpoint:"Dot" + source: $(currentParent), + target: $(divCartridge), + paintStyle: {strokeStyle: "blue", lineWidth: 1}, + Connector: ["Bezier", {curviness: 63}], + anchors: ["BottomCenter", "TopCenter"], + endpoint: "Dot" }); DragEl($(divCartridge)); @@ -535,17 +553,21 @@ function addJsplumbGroup(groupJSON, cartridgeCounter){ function genJsplumbGroups(item, currentParent, parentName) { for (var prop in item) { - var divGroup = $('
    ').attr({'id':cartridgeCounter+'-'+parentName+'-'+item[prop]['name'],'data-type':'group','data-ctype':item[prop]['name'] }) + var divGroup = $('
    ').attr({ + 'id': cartridgeCounter + '-' + parentName + '-' + item[prop]['name'], + 'data-type': 'group', + 'data-ctype': item[prop]['name'] + }) .text(item[prop]['name']) .addClass('stepnode') .attr('data-toggle', 'tooltip') - .attr('title',item[prop]['name']) + .attr('title', item[prop]['name']) .addClass('input-false') .appendTo('#whiteboard'); jsPlumb.addEndpoint($(divGroup), { - anchor:"BottomCenter" + anchor: "BottomCenter" }, bottomConnectorOptions); jsPlumb.addEndpoint($(divGroup), { @@ -554,21 +576,21 @@ function addJsplumbGroup(groupJSON, cartridgeCounter){ //add connection options jsPlumb.connect({ - source:$(currentParent), - target:$(divGroup), - paintStyle:{strokeStyle:"blue", lineWidth:1 }, - Connector : [ "Bezier", { curviness:63 } ], - anchors:["BottomCenter", "TopCenter"], - endpoint:"Dot" + source: $(currentParent), + target: $(divGroup), + paintStyle: {strokeStyle: "blue", lineWidth: 1}, + Connector: ["Bezier", {curviness: 63}], + anchors: ["BottomCenter", "TopCenter"], + endpoint: "Dot" }); DragEl($(divGroup)); - if(item[prop].hasOwnProperty('cartridges')) { - genJsplumbCartridge(item[prop].cartridges, divGroup, parentName+'-'+item[prop]['name'] ); + if (item[prop].hasOwnProperty('cartridges')) { + genJsplumbCartridge(item[prop].cartridges, divGroup, parentName + '-' + item[prop]['name']); } - if(item[prop].hasOwnProperty('groups')) { - genJsplumbGroups(item[prop].groups, divGroup, parentName+'-'+item[prop]['name']) + if (item[prop].hasOwnProperty('groups')) { + genJsplumbGroups(item[prop].groups, divGroup, parentName + '-' + item[prop]['name']) } } } @@ -576,8 +598,8 @@ function addJsplumbGroup(groupJSON, cartridgeCounter){ var initapp = 0; -$("a[href='#application']").on('shown.bs.tab', function(e) { - if(initapp == 0){ +$("a[href='#application']").on('shown.bs.tab', function (e) { + if (initapp == 0) { addJsplumbGroup(applicationJSON, cartridgeCounter); //reposition after group add dagrePosition(); @@ -585,7 +607,7 @@ $("a[href='#application']").on('shown.bs.tab', function(e) { } }); -function showHealthStat(element){ +function showHealthStat(element) { var currentURL = window.location.href; var splitTense = currentURL.split('console'); var newURL = splitTense[0] + "console/healthStatistics/"; From 9782be595f932b1243b657497280f8c94dc5eeac Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 00:05:14 +0530 Subject: [PATCH 063/126] Health statistics event formatter changing the output table assembly --- .../HealthStatPublishEventFormatter.xml | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml b/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml index eaeaccedb7..0f3e336fd6 100644 --- a/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml +++ b/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml @@ -1,26 +1,47 @@ + - - - - - - + + + + + + DataSourcetoPublishHealthStatRDBMS - HealthStatistics + HealthStatisticsTable - \ No newline at end of file + + \ No newline at end of file From 60a2232fda13166f7a9e3307c0198a837e147e72 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 00:07:17 +0530 Subject: [PATCH 064/126] cluster variable -> Cluster --- .../healthStatistics/healthStatistics_getrequest.jag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag b/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag index fe42cefd50..a6df7c852c 100755 --- a/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag @@ -58,7 +58,7 @@ try { switch (formtype) { case "MemoryConsumption": - if(ChartType == "cluster"){ + if(ChartType == "Cluster"){ formSubmit = util.RESTCalls.getClusterMemoryAverageDetails(IdValue, DurationVal); break; } @@ -68,7 +68,7 @@ try { } case "LoadAverage": - if(ChartType == "cluster"){ + if(ChartType == "Cluster"){ formSubmit = util.RESTCalls.getClusterLoadAverageDetails(IdValue, DurationVal); break; } From 2b3de728184f13feef3752f0f3df3fc9847a3747 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 00:08:27 +0530 Subject: [PATCH 065/126] Connection handler class modification --- .../stratos/rest/endpoint/handlers/ConnectionHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java index 0d4d9feb70..12a657dd08 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/ConnectionHandler.java @@ -22,7 +22,6 @@ import org.wso2.carbon.ndatasource.core.DataSourceManager; import javax.naming.InitialContext; -import javax.naming.NamingException; import javax.sql.DataSource; import java.sql.Connection; import java.sql.ResultSet; @@ -30,17 +29,19 @@ import java.sql.Statement; public class ConnectionHandler { + Connection connection; DataSource dataSource = null; String stringSql = null; ResultSet resultSet = null; + boolean isJndiLookup = true; + public ResultSet getsqlConnection(String sql) { dataSource = null; stringSql = sql; resultSet = null; try{ - boolean isJndiLookup = true; if(isJndiLookup) { From 7269f4fb1232d245b7b5407dc08a07b47cbd69da Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 13:11:40 +0530 Subject: [PATCH 066/126] Changed the back button location and the headline margins. --- .../themes/theme0/partials/healthStatistics.hbs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs index ffc22fe852..956327a939 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -1,14 +1,16 @@
    -

    {{type}} Statistics

    +

    {{type}} Statistics

    {{id}}

    +
    -
    - Back +
    + + Back
    @@ -74,10 +76,7 @@ - - - - + \ No newline at end of file + \ No newline at end of file From 1490310cae3ba085fbb77d84346dd66fd2b12132 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 28 Jul 2015 21:46:44 +0530 Subject: [PATCH 068/126] New health statistic js which include the javasripts for charts. --- .../js/healthStatistics/healthStatistics.js | 524 ++++++++++++++---- 1 file changed, 406 insertions(+), 118 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index 32b485bedd..a1e9f7c85b 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -1,132 +1,420 @@ -var dataJson = null; - -var requestInFlight = null; -var memoryConsumptions = null; -var loadAvg = null; - -var currentMembers = null; - -function bodyOnLoad(data){ - dataJson=data; - - $("#rowTable > a").html(""); - $.each(dataJson, function (i, model) { - $("#rowTable").append($('' + - '
    ' + - '
    ' + - '
    ' + - '
    ' + - '

    ' + model.cluster_id + '

    ' + - '
    ') - ); - }); -}; +/* + * + * 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. + * + */ +var jsonDataLoadAvg; +var jsonDataFlightRequest; +var jsonDataMemoryAvg; +var type; + +function DurationOnClick(element){ + var buttonId = element.id; + var buttonName = element.name; + var buttonIds = ["1Hour", "30Min", "1Day" , "1Week", "1Month"]; + var chartType = $('#chartType').val(); + var idValue = $('#IdValue').val(); -function onclickFunction(elements) { - $('#mainTitle').html(elements.id); - var id = elements.id; - $('#rowTable').hide(); + if ('InFlight' != buttonName) { + if ('LoadAverage' == buttonName) { + $('#chart2').empty(); + $('#chart2').html(''); + + } else { + $('#chart3').empty(); + $('#chart3').html(''); - $.each(dataJson, function (i, model) { - if (model.cluster_id.trim() == elements.id.trim()) { - currentMembers = model.member_ids; - return false; } - }); + } else { + $('#chart1').empty(); + $('#chart1').html(''); - $('#menu').show(); + } - setCharts(requestInFlight, memoryConsumptions, loadAvg); - currentCluster = id; - $.each(currentMembers[0], function (i, model) { - $("#sideMenu").append($('
  • ' + - '' + - '' + model + '' + - '
  • ') - ); - }); -}; + $(buttonIds).each(function(i, e) { -function onclickSideMenu(element){ - $.each(currentMembers[0], function (i, model) { - if (i.trim() == element.id.trim()) { - $('#mainTitle').html(model); - } + $('#'+e+'[name='+buttonName+']').css("color", ""); }); - var id = element.id; - setCharts(requestInFlight, memoryConsumptions, loadAvg); -} + $('#'+buttonId+'[name='+buttonName+']').css("color", "Blue"); -function setCharts(requestInFlight, memoryConsumptions, loadAvg){ - // bar charts - var barChart = c3.generate({ - bindto: '#chart1', - data: { - type: 'bar', - json: [ - { 'indicator': 'X', 'total': 100 }, - { 'indicator': 'Y', 'total': 200 }, - { 'indicator': 'Z', 'total': 300 } - ], - keys: { - x: 'indicator', - value: ['total'] - } - }, - axis: { - x: { - label: 'X Axis', - position: 'outer-center', - type: 'category', - } - }, - bar: { - width: { - ratio: 0.5 - } - }, - grid: { - y: { - lines: [{value: 150, text: 'label at value 150'}] - } - } - }); + $.ajax({ + type: "GET", + url: caramel.context + "/controllers/healthStatistics/healthStatistics_getrequest.jag", + dataType: 'json', + data: {"formtype": buttonName, "idValue":idValue, "chartType": chartType, "duration": buttonId}, + success: function (data) { - // spline charts - var splineChart = c3.generate({ - bindto: '#chart2', - data: { - columns: [ - ['data1', 30, 200, 100, 400, 150, 250], - ['data2', 130, 100, 140, 200, 150, 50], - ['data3', 10, 120, 90, 40, 250, 150] - ], - type: 'spline' - }, - axis: { - x: { - position: 'outer-center', - label: 'X Axis' - } - } - }); + if('error' != data.status){ + if('InFlight' == buttonName){ + $('#chart1').empty(); + jsonDataFlightRequest = data; + inFlightRequestCountChart(); + } + else if('LoadAverage' == buttonName){ + $('#chart2').empty(); + jsonDataLoadAvg = data; + loadAverageChart(); + } + else{ + $('#chart3').empty(); + jsonDataMemoryAvg = data; + memoryAverageDataChart(); + } + + }else{ - // spline charts - var splineChart1 = c3.generate({ - bindto: '#chart3', - data: { - columns: [ - ['data1', 30, 200, 100, 400, 150, 250], - ['data2', 130, 100, 140, 200, 150, 50], - ], - type: 'area' - }, - axis: { - x: { - position: 'outer-center', - label: 'X Axis' + var n = noty({text: data.message, layout: 'bottomRight', type: 'error'}); } + + } - }); + + }).always(function () {}); +} + +function bodyOnLoad (loadAverageData,flightRequestDetails,memoryAverageDetails) { + + + jsonDataLoadAvg = loadAverageData; + + jsonDataFlightRequest = flightRequestDetails; + + jsonDataMemoryAvg = memoryAverageDetails; + + loadAverageChart(); + memoryAverageDataChart(); + inFlightRequestCountChart(); + +} + +function loadAverageChart () { + var margin = {top: 20, right: 20, bottom: 30, left: 50}, + width = 600 - margin.left - margin.right, + height = 300 - margin.top - margin.bottom; + + var parseDate = d3.time.format("%d-%b-%y").parse; + + var x = d3.time.scale() + .range([0, width]); + + var y = d3.scale.linear() + .range([height, 0]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var area = d3.svg.area() + .x(function(d) { return x(d.timeStamp); }) + .y0(height) + .y1(function(d) {return y(d.memberAverageLoadAverage); }); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "Load Average: " + d.memberAverageLoadAverage + + " Time: " + new Date(d.timeStamp) + ""; + }) + + var svg = d3.select("#chart2").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + svg.call(tip); + + var data = jsonDataLoadAvg; + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + + svg.append("path") + .datum(data) + .attr("class", "area1") + .attr("d", area); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Load Average"); + + svg.selectAll(".area") + .data(data) + .enter().append("rect") + .attr("class", "area1") + .attr("x", function(d) { return x(d.timeStamp); }) + .attr("width", 1) + .attr("y", function(d) { return y(d.memberAverageLoadAverage); }) + .attr("height", function(d) { return height - y(d.memberAverageLoadAverage); }) + .on('mouseover', tip.show) + .on('mouseout', tip.hide) +} + +function inFlightRequestCountChart () { + + var margin = {top: 10, right: 10, bottom: 100, left: 40}, + margin2 = {top: 220, right: 10, bottom: 20, left: 40}, + width = 600 - margin.left - margin.right, + height = 300 - margin.top - margin.bottom, + height2 = 300 - margin2.top - margin2.bottom; + + var parseDate = d3.time.format("%b %Y").parse; + + var x = d3.time.scale().range([0, width]), + x2 = d3.time.scale().range([0, width]), + y = d3.scale.linear().range([height, 0]), + y2 = d3.scale.linear().range([height2, 0]); + + var xAxis = d3.svg.axis().scale(x).orient("bottom"), + xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), + yAxis = d3.svg.axis().scale(y).orient("left"); + + var brush = d3.svg.brush() + .x(x2) + .on("brush", brushed); + + var line = d3.svg.line() + .interpolate("linear") + .x(function(d) { return x(d.timeStamp); }) + .y(function(d) { return y(d.inFlightRequestCount); }); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "Flight Request Count: " + d.inFlightRequestCount + + " Time: " + new Date(d.timeStamp) + ""; + }) + + var line2 = d3.svg.line() + .interpolate("linear") + .x(function(d) { return x2(d.timeStamp); }) + .y(function(d) { return y2(d.inFlightRequestCount); }); + + var svg = d3.select("#chart1").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom); + + svg.append("defs").append("clipPath") + .attr("id", "clip") + .append("rect") + .attr("width", width) + .attr("height", height); + + var focus = svg.append("g") + .attr("class", "focus") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + var context = svg.append("g") + .attr("class", "context") + .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); + + + svg.call(tip); + + var data = jsonDataFlightRequest; + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([0, d3.max(data, function(d) { return d.inFlightRequestCount; })]); + + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([0, d3.max(data, function(d) { return d.inFlightRequestCount; })]); + x2.domain(x.domain()); + y2.domain(y.domain()); + + focus.append("path") + .datum(data) + .attr("class", "line") + .attr("d", line); + + focus.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + focus.append("g") + .attr("class", "y axis") + .call(yAxis); + + context.append("path") + .datum(data) + .attr("class", "line") + .attr("d", line2); + + context.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height2 + ")") + .call(xAxis2); + + context.append("g") + .attr("class", "x brush") + .call(brush) + .selectAll("rect") + .attr("y", -6) + .attr("height", height2 + 7); + + svg.selectAll(".line2") + .data(data) + .enter().append("rect") + .attr("class", "line") + .attr("x", function(d) { return x(d.timeStamp); }) + .attr("width", 1) + .attr("y", function(d) { return y(d.inFlightRequestCount); }) + .attr("height", function(d) { return height - y(d.inFlightRequestCount); }) + .on('mouseover', tip.show) + .on('mouseout', tip.hide) + + + function brushed() { + x.domain(brush.empty() ? x2.domain() : brush.extent()); + focus.select(".line").attr("d", line); + focus.select(".x.axis").call(xAxis); + } + + function type(d) { + d.timeStamp = parseDate(d.timeStamp); + d.inFlightRequestCount = +d.inFlightRequestCount; + return d; + } +} + +function memoryAverageDataChart () { + var margin = {top: 10, right: 10, bottom: 100, left: 40}, + margin2 = {top: 220, right: 10, bottom: 20, left: 40}, + width = 600 - margin.left - margin.right, + height = 300 - margin.top - margin.bottom, + height2 = 300 - margin2.top - margin2.bottom; + + var parseDate = d3.time.format("%b %Y").parse; + + var x = d3.time.scale().range([0, width]), + x2 = d3.time.scale().range([0, width]), + y = d3.scale.linear().range([height, 0]), + y2 = d3.scale.linear().range([height2, 0]); + + var xAxis = d3.svg.axis().scale(x).orient("bottom"), + xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), + yAxis = d3.svg.axis().scale(y).orient("left"); + + var brush = d3.svg.brush() + .x(x2) + .on("brush", brushed); + + var area = d3.svg.area() + .interpolate("linear") + .x(function(d) { return x(d.timeStamp); }) + .y0(height) + .y1(function(d) { return y(d.memberAverageMemoryConsumption); }); + + var area2 = d3.svg.area() + .interpolate("linear") + .x(function(d) { return x2(d.timeStamp); }) + .y0(height2) + .y1(function(d) { return y2(d.memberAverageMemoryConsumption); }); + + var svg = d3.select("#chart3").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom); + + svg.append("defs").append("clipPath") + .attr("id", "clip") + .append("rect") + .attr("width", width) + .attr("height", height); + + var focus = svg.append("g") + .attr("class", "focus") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + var context = svg.append("g") + .attr("class", "context") + .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); + + var data = jsonDataMemoryAvg; + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([-2, d3.max(data, function(d) { return d.memberAverageMemoryConsumption; })]); + + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([-2, d3.max(data, function(d) { return d.memberAverageMemoryConsumption; })]); + x2.domain(x.domain()); + y2.domain(y.domain()); + + focus.append("path") + .datum(data) + .attr("class", "area") + .attr("d", area); + + focus.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + focus.append("g") + .attr("class", "y axis") + .call(yAxis); + + context.append("path") + .datum(data) + .attr("class", "area") + .attr("d", area2); + + context.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height2 + ")") + .call(xAxis2); + + context.append("g") + .attr("class", "x brush") + .call(brush) + .selectAll("rect") + .attr("y", -6) + .attr("height", height2 + 7); + + + function brushed() { + x.domain(brush.empty() ? x2.domain() : brush.extent()); + focus.select(".area").attr("d", area); + focus.select(".x.axis").call(xAxis); + } + + function type(d) { + d.timeStamp = parseDate(d.timeStamp); + d.memberAverageMemoryConsumption = +d.memberAverageMemoryConsumption; + return d; + } } \ No newline at end of file From 3e3cc078a26bd195a9c3a500ededb11ce6a2a85e Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 29 Jul 2015 01:31:17 +0530 Subject: [PATCH 069/126] Adding averages/flight counts in to the New output stream definiton which use to create a single table in the database. --- .../executionplans/AverageHeathRequest.xml | 63 +++++++++++-------- .../AverageInFlightRequestsFinder.xml | 2 +- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml index 960d010fd1..c406e6804d 100644 --- a/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml +++ b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml @@ -19,7 +19,6 @@ under the License. --> - This will average health stats of an instance over a minute. @@ -31,30 +30,44 @@ Date: Wed, 29 Jul 2015 11:52:53 +0530 Subject: [PATCH 070/126] removing unused variables. --- .../console/healthStatistics.jag | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 71e98587d5..895c5ca84f 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -26,13 +26,13 @@ include('/controllers/menu/menu_generator.jag'); var log = new Log("apacheStratos.appconfig"), error = [], caramel = require('caramel'), - Alias = request.getParameter('Alias'), + alias = request.getParameter('Alias'), context = caramel.configs().context, util = require('/controllers/rest/rest_calls.jag'), menuJson = require('/controllers/menu/menu.json'), util = require('/controllers/rest/rest_calls.jag'), - Id = request.getParameter('Id'), - Type = request.getParameter('Type'), + id = request.getParameter('Id'), + type = request.getParameter('Type'), userPermissions = session.get('PERMISSIONS'); //create left menu @@ -44,11 +44,11 @@ var loadAverageData, flightRequestDetails, memoryAverageDetails=null; -if(Type!='cluster'){ +if('Cluster' != type){ try { - memoryAverageDetails = util.RESTCalls.getMemberMemoryAvrageDetails(Id, 800); + memoryAverageDetails = util.RESTCalls.getMemberMemoryAvrageDetails(Id, 1); } catch (e) { throw new Error("Error while getting Category Activity data for " + e); @@ -56,37 +56,37 @@ if(Type!='cluster'){ try { - loadAverageData = util.RESTCalls.getMemberLoadAverageDetails(Id, 800); + loadAverageData = util.RESTCalls.getMemberLoadAverageDetails(id,1); } catch (e) { - throw new Error("Error while getting Category Activity data for " + e); + throw new Error("Error while getting Category Activity data for "+ e); } flightRequestDetails = null; -} else { +}else{ try { - memoryAverageDetails = util.RESTCalls.getClusterMemoryAverageDetails(Id, 800); + memoryAverageDetails = util.RESTCalls.getClusterMemoryAverageDetails(id,1); } catch (e) { - throw new Error("Error while getting Category Activity data for " + e); + throw new Error("Error while getting Category Activity data for "+ e); } try { - - flightRequestDetails = util.RESTCalls.getFlightRequestDetails(Id, 800); + flightRequestDetails = util.RESTCalls.getFlightRequestDetails(id,1); } catch (e) { - throw new Error("Error while getting Category Activity data for " + e); + throw new Error("Error while getting Category Activity data for "+ e); } try { - loadAverageData = util.RESTCalls.getClusterLoadAverageDetails(Id, 800); + loadAverageData = util.RESTCalls.getClusterLoadAverageDetails(id,1); + } catch (e) { @@ -98,9 +98,9 @@ if(Type!='cluster'){ caramel.render({ breadcrumbPathLevelOne: 'healthStatistics', - Id:Id, - Type: Type, - Alias: Alias, + id:id, + type: type, + alias: alias, loadAverageData:JSON.stringify(loadAverageData), memoryAverageDetails:JSON.stringify(memoryAverageDetails), flightRequestDetails:JSON.stringify(flightRequestDetails), From 064b4b3187302ba0aa044db7560eb7797e76480c Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 29 Jul 2015 19:30:28 +0530 Subject: [PATCH 071/126] REST api changes code improvements. --- .../rest/endpoint/api/StratosApiV41.java | 17 +-- .../rest/endpoint/api/StratosApiV41Utils.java | 143 +++++++++--------- 2 files changed, 81 insertions(+), 79 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 7cc27b5bf1..76dcd7dcbf 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -772,6 +772,7 @@ public Response addApplication(ApplicationBean applicationDefinition) throws Res /** * Add applicatio + * * @param applicationDefinition Application Definition * @return 201 if application is successfully added * @throws RestAPIException @@ -1287,7 +1288,6 @@ public Response getApplicationRuntime( } - /** * Delete an application. * @@ -2129,7 +2129,6 @@ public Response getIaasProviders() } /** - * * @param Id * @param Interval * @return 200 if average memory consumption can get and memory consumption values @@ -2143,7 +2142,7 @@ public Response getIaasProviders() public Response getAverageClusterMemoryByClusterId( @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageClusterMemoryList = null; + String averageClusterMemoryList; try { averageClusterMemoryList = StratosApiV41Utils.getAverageClusterMemoryByClusterId(Id, Interval); @@ -2161,7 +2160,6 @@ public Response getAverageClusterMemoryByClusterId( } /** - * * @param Id * @param Interval * @return 200 if average memory consumption can get and memory consumption values @@ -2175,7 +2173,7 @@ public Response getAverageClusterMemoryByClusterId( public Response getAverageMemberMemoryByMemberId( @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberMemoryList = null; + String averageMemberMemoryList; try { averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByMemberId(Id, Interval); @@ -2193,7 +2191,6 @@ public Response getAverageMemberMemoryByMemberId( } /** - * * @param Id * @param Interval * @return 200 if average load consumption can get and load average consumption values @@ -2208,7 +2205,7 @@ public Response getAverageMemberMemoryByMemberId( public Response getAverageMemberLoadByMemberId( @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageMemberLoadList = null; + String averageMemberLoadList; try { averageMemberLoadList = StratosApiV41Utils.getAverageMemberLoadByMemberId(Id, Interval); @@ -2227,7 +2224,6 @@ public Response getAverageMemberLoadByMemberId( } /** - * * @param Id * @param Interval * @return 200 if average load consumption can get and load average consumption values @@ -2242,7 +2238,7 @@ public Response getAverageMemberLoadByMemberId( public Response getAverageClusterLoadByClusterId( @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageClusterLoadList = null; + String averageClusterLoadList; try { averageClusterLoadList = StratosApiV41Utils.getAverageClusterLoadByClusterId(Id, Interval); @@ -2260,7 +2256,6 @@ public Response getAverageClusterLoadByClusterId( } /** - * * @param Id * @param Interval * @return 200 if average request in flight can get and in flight request count @@ -2275,7 +2270,7 @@ public Response getAverageClusterLoadByClusterId( public Response getAverageClusterFlightRequestCountByClusterId( @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { - String averageClusterFlightRequestCount = null; + String averageClusterFlightRequestCount; try { averageClusterFlightRequestCount = StratosApiV41Utils.getAverageClusterFlightRequestCountByClusterId(Id, Interval); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index eb7d5b92bf..9caf9fbae9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -1573,11 +1573,7 @@ private static void validateGroupsInApplicationDefinition(ApplicationBean applic // Validate top level group deployment policy with cartridges if (group.getCartridges() != null) { - if (group.getDeploymentPolicy() != null) { - groupParentHasDeploymentPolicy = true; - } else { - groupParentHasDeploymentPolicy = false; - } + groupParentHasDeploymentPolicy = group.getDeploymentPolicy() != null; validateCartridgesForDeploymentPolicy(group.getCartridges(), groupParentHasDeploymentPolicy); } @@ -3653,7 +3649,6 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { } /** - * * @param Id * @param Interval * @return Average of Cluster Memory Data @@ -3661,11 +3656,17 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { */ public static String getAverageClusterMemoryByClusterId(String Id, String Interval) throws RestAPIException { + String averageClusterMemoryQuery = "SELECT value AS MEMBER_AVERAGE_MEMORY_CONSUMPTION,ID,timeStamp " + + "FROM HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR " + + "AND ID = \"" + Id + "\" AND type = \"cluster_average_memory_consumption\" GROUP " + + "BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; +/* String averageClusterMemoryQuery = "SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'," + "CLUSTER_ID, TIMESTAMP From MemberAverageMemoryAverageEventFormatterHealthStat " + "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; +*/ List averageClusterMemoryList = new ArrayList(); @@ -3674,7 +3675,7 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv try { while (result.next()) { - averageClusterMemoryList.add(new AverageMemoryConsumptionBean(result.getString("CLUSTER_ID"), result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "")); + averageClusterMemoryList.add(new AverageMemoryConsumptionBean(result.getString("ID"), result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), "")); } } catch (SQLException ex) { log.error("SQLException: ", ex); @@ -3684,9 +3685,7 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv throw new RestAPIException(ex.getMessage()); } finally { try { - if (connectionHandler != null) { - connectionHandler.closeConnection(); - } + connectionHandler.closeConnection(); } catch (SQLException ex) { log.error("SQLException: ", ex); throw new RestAPIException(ex.getMessage()); @@ -3694,18 +3693,15 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv } - if(averageClusterMemoryList.isEmpty()==true) - { - return null; - }else { + if (!averageClusterMemoryList.isEmpty()) { - String json = new Gson().toJson(averageClusterMemoryList); - return json; + return new Gson().toJson(averageClusterMemoryList); + } else { + return null; } } /** - * * @param Id * @param Interval * @return Average Cluster Load average data @@ -3713,12 +3709,15 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv */ public static String getAverageClusterLoadByClusterId(String Id, String Interval) throws RestAPIException { + String averageClusterLoadQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM " + + "HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR" + + " AND ID = \"" + Id + "\" AND type = \"cluster_average_load_average\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; - String averageClusterLoadQuery = "SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + + /* String averageClusterLoadQuery = "SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + "CLUSTER_ID, TIMESTAMP From MemberAverageLoadAverageEventFormatterHealthStat " + "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; - +*/ List averageMemberLoadList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); @@ -3726,7 +3725,7 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval try { while (result.next()) { - averageMemberLoadList.add(new AverageLoadAverageBean(result.getString("CLUSTER_ID"), result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "")); + averageMemberLoadList.add(new AverageLoadAverageBean(result.getString("ID"), result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), "")); } } catch (SQLException ex) { log.error("SQLException: ", ex); @@ -3736,9 +3735,7 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval throw new RestAPIException(ex.getMessage()); } finally { try { - if (connectionHandler != null) { - connectionHandler.closeConnection(); - } + connectionHandler.closeConnection(); } catch (SQLException ex) { log.error("SQLException: ", ex); throw new RestAPIException(ex.getMessage()); @@ -3746,19 +3743,17 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval } - if(averageMemberLoadList.isEmpty()==true) - { - return null; - }else{ + if (!averageMemberLoadList.isEmpty()) { + + return new Gson().toJson(averageMemberLoadList); - String json = new Gson().toJson(averageMemberLoadList); - return json; + } else { + return null; } } /** - * * @param Id * @param Interval * @return Average Member Memory Average data @@ -3766,10 +3761,18 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval */ public static String getAverageMemberMemoryByMemberId(String Id, String Interval) throws RestAPIException { + + String memberIfQueryforMemory = "SELECT value AS MEMBER_AVERAGE_MEMORY_CONSUMPTION,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR AND " + + "ID =\"" + Id + "\" AND type = \'member_average_memory_consumption\' GROUP BY " + + "from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + +/* String memberIfQueryforMemory = "SELECT TIMESTAMP,MEMBER_ID," + "MEMBER_AVERAGE_MEMORY_CONSUMPTION FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; +*/ List averageMemberMemoryList = new ArrayList(); @@ -3779,7 +3782,7 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval try { while (result.next()) { - averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"),result.getString("MEMBER_ID"))); + averageMemberMemoryList.add(new AverageMemoryConsumptionBean("", result.getDouble("MEMBER_AVERAGE_MEMORY_CONSUMPTION"), result.getLong("TIMESTAMP"), result.getString("ID"))); } } catch (SQLException ex) { log.error("SQLException: ", ex); @@ -3789,28 +3792,24 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval throw new RestAPIException(ex.getMessage()); } finally { try { - if (connectionHandler != null) { - connectionHandler.closeConnection(); - } + connectionHandler.closeConnection(); } catch (SQLException ex) { log.error("SQLException: ", ex); throw new RestAPIException(ex.getMessage()); } } - if(averageMemberMemoryList.isEmpty()==true) { + if (!averageMemberMemoryList.isEmpty()) { + return new Gson().toJson(averageMemberMemoryList); - return null; + } else { - }else{ - String json = new Gson().toJson(averageMemberMemoryList); - return json; + return null; } } /** - * * @param Id * @param Interval * @return Average Member Load Average data @@ -3818,10 +3817,16 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval */ public static String getAverageMemberLoadByMemberId(String Id, String Interval) throws RestAPIException { + String memberLoadAverageQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR" + + " AND ID = \"" + Id + "\" AND type = \'member_average_load_average\' GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + +/* String memberLoadAverageQuery = "SELECT TIMESTAMP,MEMBER_ID," + "MEMBER_AVERAGE_LOAD_AVERAGE FROM MemberAverageLoadAverageEventFormatterHealthStat WHERE " + "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; +*/ List averageMemberLoadList = new ArrayList(); @@ -3832,37 +3837,33 @@ public static String getAverageMemberLoadByMemberId(String Id, String Interval) try { while (result.next()) { - averageMemberLoadList.add(new AverageLoadAverageBean("", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), result.getString("MEMBER_ID"))); + averageMemberLoadList.add(new AverageLoadAverageBean("", result.getLong("TIMESTAMP"), result.getDouble("MEMBER_AVERAGE_LOAD_AVERAGE"), result.getString("ID"))); } + } catch (SQLException ex) { + log.error("SQLException: ", ex); + throw new RestAPIException(ex.getMessage()); + } catch (Exception ex) { + log.error("Exception: ", ex); + throw new RestAPIException(ex.getMessage()); + } finally { + try { + connectionHandler.closeConnection(); } catch (SQLException ex) { log.error("SQLException: ", ex); throw new RestAPIException(ex.getMessage()); - } catch (Exception ex) { - log.error("Exception: ", ex); - throw new RestAPIException(ex.getMessage()); - } finally { - try { - if (connectionHandler != null) { - connectionHandler.closeConnection(); - } - } catch (SQLException ex) { - log.error("SQLException: ", ex); - throw new RestAPIException(ex.getMessage()); - } } + } - if(averageMemberLoadList.isEmpty()==true) { + if (!averageMemberLoadList.isEmpty()) { + return new Gson().toJson(averageMemberLoadList); + } else { return null; - }else{ - String json = new Gson().toJson(averageMemberLoadList); - return json; - } + } } /** - * * @param Id * @param Interval * @return Average Cluster Flight request Count data @@ -3870,10 +3871,19 @@ public static String getAverageMemberLoadByMemberId(String Id, String Interval) */ public static String getAverageClusterFlightRequestCountByClusterId(String Id, String Interval) throws RestAPIException { + //delete FROM testTable WHERE from_unixtime(timeStamp/1000,"%Y-%m-%d %H:%i") < NOW() - INTERVAL 2232 HOUR + + + String clusterIDQueryforFlightCount = "SELECT value AS FLIGHT_REQUEST_COUNT,ID,timeStamp FROM " + + "HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR " + + "AND ID = \"" + Id + "\" AND type = \'in_flight_request_count\' GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + +/* String clusterIDQueryforFlightCount = "SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,CLUSTER_ID,TIMESTAMP FROM " + "FlightRequestEventFormatterHealthStat WHERE from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > NOW() - " + "INTERVAL " + Interval + " HOUR AND CLUSTER_ID = \"" + Id + "\"" + "GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\");"; +*/ List inFlightRequestBeanList = new ArrayList(); @@ -3883,7 +3893,7 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id, S try { while (result.next()) { - inFlightRequestBeanList.add(new InFlightRequestBean(result.getString("CLUSTER_ID"), result.getLong("TIMESTAMP"), result.getDouble("FLIGHT_REQUEST_COUNT"))); + inFlightRequestBeanList.add(new InFlightRequestBean(result.getString("ID"), result.getLong("TIMESTAMP"), result.getDouble("FLIGHT_REQUEST_COUNT"))); } } catch (SQLException ex) { log.error("SQLException: ", ex); @@ -3893,23 +3903,20 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id, S throw new RestAPIException(ex.getMessage()); } finally { try { - if (connectionHandler != null) { - connectionHandler.closeConnection(); - } + connectionHandler.closeConnection(); } catch (SQLException ex) { log.error("SQLException: ", ex); throw new RestAPIException(ex.getMessage()); } } - if (inFlightRequestBeanList.isEmpty() == true) { - - return null; + if (!inFlightRequestBeanList.isEmpty()) { + return new Gson().toJson(inFlightRequestBeanList); } else { - String json = new Gson().toJson(inFlightRequestBeanList); - return json; + return null; + } } From cabb1d04a4fd0acb1a3df1e3da6e259b9c25beca Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 30 Jul 2015 02:48:17 +0530 Subject: [PATCH 072/126] application topology changes. --- .../themes/theme0/js/custom/applications_topology.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js index d7b5bcd63c..f8ea7702bb 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -160,7 +160,6 @@ function update(source) { .projection(function (d) { return [d.x, d.y]; }); - function redraw() { svg.attr("transform", "translate(" + d3.event.translate + ")" @@ -217,7 +216,7 @@ function update(source) { "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'members') { if ((typeof d.ports != 'undefined') && (d.ports.length > 0)) { @@ -241,7 +240,7 @@ function update(source) { "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + @@ -348,7 +347,6 @@ function update(source) { var timer, popover_parent; - function hidePopover(elem) { $(elem).popover('hide'); } @@ -463,7 +461,7 @@ var generatedGroupOptions = { maxConnections: 1 }; -function dagrePosition() { +function dagrePosition(){ // construct dagre graph from JsPlumb graph var g = new dagre.graphlib.Graph(); g.setGraph({ranksep: '80'}); From 36b2308f9fe503b297d03a2a706b09ce4bb63ba3 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 30 Jul 2015 13:32:59 +0530 Subject: [PATCH 073/126] Fixed the bug in the button when onclick the colour doesn't change problem. --- .../theme0/js/healthStatistics/healthStatistics.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index a1e9f7c85b..b40d722d34 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -25,11 +25,11 @@ var type; function DurationOnClick(element){ var buttonId = element.id; - var buttonName = element.name; + var buttonName = $(element).attr("name"); var buttonIds = ["1Hour", "30Min", "1Day" , "1Week", "1Month"]; var chartType = $('#chartType').val(); var idValue = $('#IdValue').val(); - + if ('InFlight' != buttonName) { if ('LoadAverage' == buttonName) { $('#chart2').empty(); @@ -46,12 +46,11 @@ function DurationOnClick(element){ } - $(buttonIds).each(function(i, e) { - - $('#'+e+'[name='+buttonName+']').css("color", ""); + $("button[name=" + buttonName + "]").each(function () { + $(this).css("color", ""); }); - $('#'+buttonId+'[name='+buttonName+']').css("color", "Blue"); + $(element).css("color", "Red"); $.ajax({ type: "GET", From 09da05a3a3b950439e12cdb050aead5b334b2bce Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 31 Jul 2015 19:38:38 +0530 Subject: [PATCH 074/126] comments for the charts implementation. --- .../js/healthStatistics/healthStatistics.js | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index b40d722d34..480b4e5b75 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -23,13 +23,26 @@ var jsonDataFlightRequest; var jsonDataMemoryAvg; var type; +function DurationOnClick(ref) { + + var buttonName = $(ref).attr("name"); + + $("button[name=" + buttonName + "]").each(function () { + $(this).css("color", ""); + }); + + $(ref).css("color", "Blue"); +} + +//onclick function which will trigger the option for 30mints,1 hour etc function DurationOnClick(element){ var buttonId = element.id; var buttonName = $(element).attr("name"); var buttonIds = ["1Hour", "30Min", "1Day" , "1Week", "1Month"]; var chartType = $('#chartType').val(); var idValue = $('#IdValue').val(); - + + //here the spinner will indicate untill the data loads to the map if ('InFlight' != buttonName) { if ('LoadAverage' == buttonName) { $('#chart2').empty(); @@ -45,13 +58,14 @@ function DurationOnClick(element){ $('#chart1').html(''); } - + //after user click the option here we are changing the option black to red. $("button[name=" + buttonName + "]").each(function () { $(this).css("color", ""); }); $(element).css("color", "Red"); + //ajax call to get the data to the charts from the database. $.ajax({ type: "GET", url: caramel.context + "/controllers/healthStatistics/healthStatistics_getrequest.jag", @@ -78,6 +92,7 @@ function DurationOnClick(element){ }else{ + //print error message in any case. var n = noty({text: data.message, layout: 'bottomRight', type: 'error'}); } @@ -87,6 +102,9 @@ function DurationOnClick(element){ }).always(function () {}); } + +//body onload function will trigger when the page loads at the very first. +//the charts will feeds with the defuakt data set, function bodyOnLoad (loadAverageData,flightRequestDetails,memoryAverageDetails) { @@ -96,13 +114,17 @@ function bodyOnLoad (loadAverageData,flightRequestDetails,memoryAverageDetails) jsonDataMemoryAvg = memoryAverageDetails; + //calling the charts loadAverageChart(); memoryAverageDataChart(); inFlightRequestCountChart(); } + +//this is the load avergae chart for cluster/member function loadAverageChart () { + var margin = {top: 20, right: 20, bottom: 30, left: 50}, width = 600 - margin.left - margin.right, height = 300 - margin.top - margin.bottom; @@ -112,9 +134,11 @@ function loadAverageChart () { var x = d3.time.scale() .range([0, width]); + //defines the maximum and minimum values we have to plot in the available space. var y = d3.scale.linear() .range([height, 0]); + //provides an API method called d3.svg.axis to create axes. var xAxis = d3.svg.axis() .scale(x) .orient("bottom"); @@ -136,14 +160,17 @@ function loadAverageChart () { " Time: " + new Date(d.timeStamp) + ""; }) + //selecting the data needs to append var svg = d3.select("#chart2").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + //calling the tool tip svg.call(tip); + //initializing the json array list to the map root element var data = jsonDataLoadAvg; x.domain(d3.extent(data, function(d) { return d.timeStamp; })); @@ -154,11 +181,13 @@ function loadAverageChart () { .attr("class", "area1") .attr("d", area); + ////append the created X axis to the svg container svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); + //append the created Y axis to the svg container svg.append("g") .attr("class", "y axis") .call(yAxis) @@ -193,9 +222,12 @@ function inFlightRequestCountChart () { var x = d3.time.scale().range([0, width]), x2 = d3.time.scale().range([0, width]), + + //defines the maximum and minimum values we have to plot in the available space. y = d3.scale.linear().range([height, 0]), y2 = d3.scale.linear().range([height2, 0]); + //provides an API method called d3.svg.axis to create axes. var xAxis = d3.svg.axis().scale(x).orient("bottom"), xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), yAxis = d3.svg.axis().scale(y).orient("left"); @@ -204,6 +236,7 @@ function inFlightRequestCountChart () { .x(x2) .on("brush", brushed); + //to draw a line var line = d3.svg.line() .interpolate("linear") .x(function(d) { return x(d.timeStamp); }) @@ -217,6 +250,7 @@ function inFlightRequestCountChart () { " Time: " + new Date(d.timeStamp) + ""; }) + //to draw a line var line2 = d3.svg.line() .interpolate("linear") .x(function(d) { return x2(d.timeStamp); }) @@ -240,7 +274,7 @@ function inFlightRequestCountChart () { .attr("class", "context") .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); - + //calling the tool tip svg.call(tip); var data = jsonDataFlightRequest; @@ -259,11 +293,13 @@ function inFlightRequestCountChart () { .attr("class", "line") .attr("d", line); + //append the created X axis to the svg container focus.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); + //append the created Y axis to the svg container focus.append("g") .attr("class", "y axis") .call(yAxis); @@ -321,9 +357,12 @@ function memoryAverageDataChart () { var x = d3.time.scale().range([0, width]), x2 = d3.time.scale().range([0, width]), + + //defines the maximum and minimum values we have to plot in the available space. y = d3.scale.linear().range([height, 0]), y2 = d3.scale.linear().range([height2, 0]); + //provides an API method called d3.svg.axis to create axes. var xAxis = d3.svg.axis().scale(x).orient("bottom"), xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), yAxis = d3.svg.axis().scale(y).orient("left"); @@ -378,11 +417,13 @@ function memoryAverageDataChart () { .attr("class", "area") .attr("d", area); + //append the created X axis to the svg container focus.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); + //append the created Y axis to the svg container focus.append("g") .attr("class", "y axis") .call(yAxis); From 145bc25cb0e9fd06bbc7887df46680f023577b69 Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 31 Jul 2015 19:45:50 +0530 Subject: [PATCH 075/126] Commiting the Ui changes --- .../console/healthStatistics.jag | 1 + .../console/themes/theme0/renderers/healthStatistics.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 895c5ca84f..5bbfead9a1 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -51,6 +51,7 @@ if('Cluster' != type){ memoryAverageDetails = util.RESTCalls.getMemberMemoryAvrageDetails(Id, 1); } catch (e) { + throw new Error("Error while getting Category Activity data for " + e); } diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js index 9988f4edc1..a6921b5f6a 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js @@ -50,15 +50,15 @@ var render = function (theme, data, meta, require) { { partial: 'healthStatistics', context:{ - Id:data.Id, - Alias:data.Alias, + id:data.id, + alias:data.alias, loadAverageData:data.loadAverageData, memoryAverageDetails:data.memoryAverageDetails, flightRequestDetails:data.flightRequestDetails, - Type: data.Type, + type: data.type, result:data.result, content_title:'Health Stats', - condition: data.Type != 'member' + condition: data.type != 'Member' } } ] From 55b1a915753e8c4d631e257f2f0510fde495bb5d Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 31 Jul 2015 19:47:16 +0530 Subject: [PATCH 076/126] Commiting the changes of rest_call jag --- .../console/controllers/rest/rest_calls.jag | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index bd41fab191..5e4d027606 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -28,35 +28,28 @@ RESTCalls = new function(){ }; this.getFlightRequestDetails = function(Id,DurationVal){ - var Id = Id; - var Interval = DurationVal; return this.sendReceive("GET","/cluster/flightRequestCount/" +Id+"/"+DurationVal,{}); }; this.getClusterMemoryAverageDetails = function(Id,DurationVal){ - var Id = Id; - var Interval = DurationVal; + return this.sendReceive("GET","/cluster/averageMemory/" +Id+"/"+Interval,{}); }; this.getClusterLoadAverageDetails = function(Id,DurationVal){ - var Id = Id; - var Interval = DurationVal; + return this.sendReceive("GET","/cluster/averageLoad/" +Id+"/"+Interval,{}); }; this.getMemberLoadAverageDetails = function(Id,DurationVal){ - var Id = Id; - var Interval = DurationVal; return this.sendReceive("GET","/member/averageLoad/" +Id+"/"+Interval,{}); }; this.getMemberMemoryAvrageDetails = function(Id,DurationVal){ - var Interval = DurationVal; return this.sendReceive("GET","/member/averageMemory/" +Id+"/"+Interval,{}); }; @@ -515,4 +508,4 @@ RESTCalls = new function(){ }; -%> \ No newline at end of file +%> From 2968805abd52b71db42d42337e91c779a10814ba Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 31 Jul 2015 23:27:25 +0530 Subject: [PATCH 077/126] Bug in the UI fixed. --- .../console/themes/theme0/css/custom.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css index 40138e9e50..b63dfd916d 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/css/custom.css @@ -307,10 +307,6 @@ svg { stroke-width: 1.5px; } -body { - font: 10px sans-serif; -} - .area1 { fill: orange; } From db5e234191bb46704e9ae80f0abd3e1556c0d373 Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 31 Jul 2015 23:56:36 +0530 Subject: [PATCH 078/126] Enabling the left menu in the health statistics page. --- .../console/healthStatistics.jag | 24 +++---------------- .../theme0/renderers/healthStatistics.js | 8 +++++++ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 5bbfead9a1..1acae7ca8c 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -26,7 +26,7 @@ include('/controllers/menu/menu_generator.jag'); var log = new Log("apacheStratos.appconfig"), error = [], caramel = require('caramel'), - alias = request.getParameter('Alias'), + alias = request.getParameter('Alias'), //applicaion name context = caramel.configs().context, util = require('/controllers/rest/rest_calls.jag'), menuJson = require('/controllers/menu/menu.json'), @@ -37,8 +37,7 @@ var log = new Log("apacheStratos.appconfig"), //create left menu var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); -//create metro block -var metro_menu = metroGenerator('/healthStatistics', menuJson.menu, userPermissions); +var log = new Log(); var loadAverageData, flightRequestDetails, @@ -74,24 +73,6 @@ if('Cluster' != type){ } catch (e) { throw new Error("Error while getting Category Activity data for "+ e); - - } - - try { - flightRequestDetails = util.RESTCalls.getFlightRequestDetails(id,1); - - } catch (e) { - - throw new Error("Error while getting Category Activity data for "+ e); - } - - try { - loadAverageData = util.RESTCalls.getClusterLoadAverageDetails(id,1); - - - } catch (e) { - - throw new Error("Error while getting Category Activity data for "+ e); } } @@ -102,6 +83,7 @@ caramel.render({ id:id, type: type, alias: alias, + left_menu: leftMenu, loadAverageData:JSON.stringify(loadAverageData), memoryAverageDetails:JSON.stringify(memoryAverageDetails), flightRequestDetails:JSON.stringify(flightRequestDetails), diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js index a6921b5f6a..26605ff190 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/renderers/healthStatistics.js @@ -38,6 +38,14 @@ var render = function (theme, data, meta, require) { } } ], + left_menu:[ + { + partial:'index_left_menu', + context:{ + left_menu:data.left_menu + } + } + ], right_menu_help:[ { partial:'index_right_menu_help', From 8c7f487333968aaafbc6099374fe2a670b7b35a4 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 1 Aug 2015 01:02:00 +0530 Subject: [PATCH 079/126] adding margin to the back button. --- .../console/themes/theme0/partials/healthStatistics.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs index e52b4cc0eb..ec6571fb16 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/healthStatistics.hbs @@ -30,7 +30,7 @@
    - Back + Back
    @@ -95,4 +95,4 @@ - \ No newline at end of file + From d6f2831d9086da2f8222a55877b3db1ea332201c Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 1 Aug 2015 13:03:44 +0530 Subject: [PATCH 080/126] Commiting a new button to the Show Health Statistic in topology view pop-over. --- .../console/themes/theme0/js/custom/applications_topology.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js index f8ea7702bb..847f268fb2 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -216,7 +216,7 @@ function update(source) { "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'members') { if ((typeof d.ports != 'undefined') && (d.ports.length > 0)) { @@ -240,7 +240,7 @@ function update(source) { "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + From 9886b3dd7afe897dae835ff88004e2593bc19d97 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 1 Aug 2015 13:11:22 +0530 Subject: [PATCH 081/126] Changing button name to the Member/Cluster Health Statistic in topology view pop-over. --- .../console/themes/theme0/js/custom/applications_topology.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js index 847f268fb2..10f461fd4c 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -216,7 +216,7 @@ function update(source) { "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'members') { if ((typeof d.ports != 'undefined') && (d.ports.length > 0)) { @@ -240,7 +240,7 @@ function update(source) { "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + "Status: " + d.status + "

    " + - ""; + ""; } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + From 8389da439a6623e925005ae755ddde9fd6c3a655 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 1 Aug 2015 23:15:03 +0530 Subject: [PATCH 082/126] Commiting the REST API changes which is reviewd by Lahirus. Id to Cluster_ID or Member_ID in the url. --- .../rest/endpoint/api/StratosApiV41.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 76dcd7dcbf..5f1335d18a 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -2135,12 +2135,12 @@ public Response getIaasProviders() * @throws RestAPIException */ @GET - @Path("/cluster/averageMemory/{Id}/{Interval}") + @Path("/cluster/averageMemory/{cluster-Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterMemoryByClusterId( - @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { String averageClusterMemoryList; try { @@ -2166,12 +2166,12 @@ public Response getAverageClusterMemoryByClusterId( * @throws RestAPIException */ @GET - @Path("/member/averageMemory/{Id}/{Interval}") + @Path("/member/averageMemory/{member-Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberMemoryByMemberId( - @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { String averageMemberMemoryList; try { @@ -2198,12 +2198,12 @@ public Response getAverageMemberMemoryByMemberId( */ @GET - @Path("/member/averageLoad/{Id}/{Interval}") + @Path("/member/averageLoad/{member-Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberLoadByMemberId( - @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { String averageMemberLoadList; try { @@ -2231,12 +2231,12 @@ public Response getAverageMemberLoadByMemberId( */ @GET - @Path("/cluster/averageLoad/{Id}/{Interval}") + @Path("/cluster/averageLoad/{cluster-Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterLoadByClusterId( - @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { String averageClusterLoadList; try { @@ -2263,12 +2263,12 @@ public Response getAverageClusterLoadByClusterId( */ @GET - @Path("/cluster/flightRequestCount/{Id}/{Interval}") + @Path("/cluster/flightRequestCount/{cluster-Id}/{Interval}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterFlightRequestCountByClusterId( - @PathParam("Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { String averageClusterFlightRequestCount; try { From 764e35c919d3c3c61c7cca1ca9d768e89e7edb91 Mon Sep 17 00:00:00 2001 From: dk Date: Sun, 2 Aug 2015 19:24:30 +0530 Subject: [PATCH 083/126] mysql table clearing method implementation. --- .../rest/endpoint/api/StratosApiV41Utils.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 9caf9fbae9..a18506c4fc 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3920,4 +3920,35 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id, S } } + + public static void deleteTableData() throws RestAPIException { + + String deleteTableDataquery = "DELETE FROM HealthStatisticsTable WHERE " + + "from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") < NOW() - INTERVAL 2160 HOUR"; + + ConnectionHandler connectionHandler = new ConnectionHandler(); + + try { + + ResultSet result = connectionHandler.getsqlConnection(deleteTableDataquery); + result.next(); + + } catch (SQLException ex) { + log.error("SQLException: ", ex); + throw new RestAPIException(ex.getMessage()); + } catch (Exception ex) { + log.error("Exception: ", ex); + throw new RestAPIException(ex.getMessage()); + } finally { + try { + connectionHandler.closeConnection(); + } catch (SQLException ex) { + log.error("SQLException: ", ex); + throw new RestAPIException(ex.getMessage()); + } + } + + + } + } From 71e5436f96c19e78e2f2d0230a612d712731460f Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 3 Aug 2015 02:23:42 +0530 Subject: [PATCH 084/126] Commenting on the healthStatistic jag implementation --- .../console/healthStatistics.jag | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 1acae7ca8c..6b6539b203 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -39,7 +39,8 @@ var log = new Log("apacheStratos.appconfig"), var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); var log = new Log(); -var loadAverageData, +//this will get default data using a rest call to the charts. +var loadAverageData, flightRequestDetails, memoryAverageDetails=null; @@ -77,7 +78,7 @@ if('Cluster' != type){ } - +//rendering the data caramel.render({ breadcrumbPathLevelOne: 'healthStatistics', id:id, From e8b30c29c9b2ef3edd9314991a8a71f218df522f Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 3 Aug 2015 15:56:58 +0530 Subject: [PATCH 085/126] Commiting the REST jaggery method changes. --- .../console/controllers/rest/rest_calls.jag | 8 ++++---- .../HealthStatPublishEventFormatter.xml | 0 .../OutPutadaptorRDBMStoPublishHealthStat.xml | 0 .../{artifacts => healthStatisticsArtifacts}/README.md | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename extensions/cep/{artifacts/eventformatters => healthStatisticsArtifacts}/HealthStatPublishEventFormatter.xml (100%) rename extensions/cep/{artifacts/outputeventadaptors => healthStatisticsArtifacts}/OutPutadaptorRDBMStoPublishHealthStat.xml (100%) rename extensions/cep/{artifacts => healthStatisticsArtifacts}/README.md (100%) diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index 5e4d027606..be5171862d 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -34,24 +34,24 @@ RESTCalls = new function(){ this.getClusterMemoryAverageDetails = function(Id,DurationVal){ - return this.sendReceive("GET","/cluster/averageMemory/" +Id+"/"+Interval,{}); + return this.sendReceive("GET","/cluster/averageMemory/" +Id+"/"+DurationVal,{}); }; this.getClusterLoadAverageDetails = function(Id,DurationVal){ - return this.sendReceive("GET","/cluster/averageLoad/" +Id+"/"+Interval,{}); + return this.sendReceive("GET","/cluster/averageLoad/" +Id+"/"+DurationVal,{}); }; this.getMemberLoadAverageDetails = function(Id,DurationVal){ - return this.sendReceive("GET","/member/averageLoad/" +Id+"/"+Interval,{}); + return this.sendReceive("GET","/member/averageLoad/" +Id+"/"+DurationVal,{}); }; this.getMemberMemoryAvrageDetails = function(Id,DurationVal){ - return this.sendReceive("GET","/member/averageMemory/" +Id+"/"+Interval,{}); + return this.sendReceive("GET","/member/averageMemory/" +Id+"/"+DurationVal,{}); }; this.deployPartitionDefinition = function(partitionDefinition){ diff --git a/extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml b/extensions/cep/healthStatisticsArtifacts/HealthStatPublishEventFormatter.xml similarity index 100% rename from extensions/cep/artifacts/eventformatters/HealthStatPublishEventFormatter.xml rename to extensions/cep/healthStatisticsArtifacts/HealthStatPublishEventFormatter.xml diff --git a/extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml b/extensions/cep/healthStatisticsArtifacts/OutPutadaptorRDBMStoPublishHealthStat.xml similarity index 100% rename from extensions/cep/artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml rename to extensions/cep/healthStatisticsArtifacts/OutPutadaptorRDBMStoPublishHealthStat.xml diff --git a/extensions/cep/artifacts/README.md b/extensions/cep/healthStatisticsArtifacts/README.md similarity index 100% rename from extensions/cep/artifacts/README.md rename to extensions/cep/healthStatisticsArtifacts/README.md From b5d396c2b02409162efb3b85e88352d5348a44be Mon Sep 17 00:00:00 2001 From: dk Date: Mon, 3 Aug 2015 20:21:54 +0530 Subject: [PATCH 086/126] d3 tool tip enabling library. --- .../themes/theme0/js/d3.tip/d3.tip.v0.6.3.js | 280 ++++++++++++++++++ 1 file changed, 280 insertions(+) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js index e69de29bb2..ea938819b5 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/d3.tip/d3.tip.v0.6.3.js @@ -0,0 +1,280 @@ +// d3.tip +// Copyright (c) 2013 Justin Palmer +// +// Tooltips for d3.js SVG visualizations + +// Public - contructs a new tooltip +// +// Returns a tip +d3.tip = function() { + var direction = d3_tip_direction, + offset = d3_tip_offset, + html = d3_tip_html, + node = initNode(), + svg = null, + point = null, + target = null + + function tip(vis) { + svg = getSVGNode(vis) + point = svg.createSVGPoint() + document.body.appendChild(node) + } + + // Public - show the tooltip on the screen + // + // Returns a tip + tip.show = function() { + var args = Array.prototype.slice.call(arguments) + if(args[args.length - 1] instanceof SVGElement) target = args.pop() + + var content = html.apply(this, args), + poffset = offset.apply(this, args), + dir = direction.apply(this, args), + nodel = d3.select(node), i = 0, + coords + + nodel.html(content) + .style({ opacity: 1, 'pointer-events': 'all' }) + + while(i--) nodel.classed(directions[i], false) + coords = direction_callbacks.get(dir).apply(this) + nodel.classed(dir, true).style({ + top: (coords.top + poffset[0]) + 'px', + left: (coords.left + poffset[1]) + 'px' + }) + + return tip + } + + // Public - hide the tooltip + // + // Returns a tip + tip.hide = function() { + nodel = d3.select(node) + nodel.style({ opacity: 0, 'pointer-events': 'none' }) + return tip + } + + // Public: Proxy attr calls to the d3 tip container. Sets or gets attribute value. + // + // n - name of the attribute + // v - value of the attribute + // + // Returns tip or attribute value + tip.attr = function(n, v) { + if (arguments.length < 2 && typeof n === 'string') { + return d3.select(node).attr(n) + } else { + var args = Array.prototype.slice.call(arguments) + d3.selection.prototype.attr.apply(d3.select(node), args) + } + + return tip + } + + // Public: Proxy style calls to the d3 tip container. Sets or gets a style value. + // + // n - name of the property + // v - value of the property + // + // Returns tip or style property value + tip.style = function(n, v) { + if (arguments.length < 2 && typeof n === 'string') { + return d3.select(node).style(n) + } else { + var args = Array.prototype.slice.call(arguments) + d3.selection.prototype.style.apply(d3.select(node), args) + } + + return tip + } + + // Public: Set or get the direction of the tooltip + // + // v - One of n(north), s(south), e(east), or w(west), nw(northwest), + // sw(southwest), ne(northeast) or se(southeast) + // + // Returns tip or direction + tip.direction = function(v) { + if (!arguments.length) return direction + direction = v == null ? v : d3.functor(v) + + return tip + } + + // Public: Sets or gets the offset of the tip + // + // v - Array of [x, y] offset + // + // Returns offset or + tip.offset = function(v) { + if (!arguments.length) return offset + offset = v == null ? v : d3.functor(v) + + return tip + } + + // Public: sets or gets the html value of the tooltip + // + // v - String value of the tip + // + // Returns html value or tip + tip.html = function(v) { + if (!arguments.length) return html + html = v == null ? v : d3.functor(v) + + return tip + } + + function d3_tip_direction() { return 'n' } + function d3_tip_offset() { return [0, 0] } + function d3_tip_html() { return ' ' } + + var direction_callbacks = d3.map({ + n: direction_n, + s: direction_s, + e: direction_e, + w: direction_w, + nw: direction_nw, + ne: direction_ne, + sw: direction_sw, + se: direction_se + }), + + directions = direction_callbacks.keys() + + function direction_n() { + var bbox = getScreenBBox() + return { + top: bbox.n.y - node.offsetHeight, + left: bbox.n.x - node.offsetWidth / 2 + } + } + + function direction_s() { + var bbox = getScreenBBox() + return { + top: bbox.s.y, + left: bbox.s.x - node.offsetWidth / 2 + } + } + + function direction_e() { + var bbox = getScreenBBox() + return { + top: bbox.e.y - node.offsetHeight / 2, + left: bbox.e.x + } + } + + function direction_w() { + var bbox = getScreenBBox() + return { + top: bbox.w.y - node.offsetHeight / 2, + left: bbox.w.x - node.offsetWidth + } + } + + function direction_nw() { + var bbox = getScreenBBox() + return { + top: bbox.nw.y - node.offsetHeight, + left: bbox.nw.x - node.offsetWidth + } + } + + function direction_ne() { + var bbox = getScreenBBox() + return { + top: bbox.ne.y - node.offsetHeight, + left: bbox.ne.x + } + } + + function direction_sw() { + var bbox = getScreenBBox() + return { + top: bbox.sw.y, + left: bbox.sw.x - node.offsetWidth + } + } + + function direction_se() { + var bbox = getScreenBBox() + return { + top: bbox.se.y, + left: bbox.e.x + } + } + + function initNode() { + var node = d3.select(document.createElement('div')) + node.style({ + position: 'absolute', + opacity: 0, + pointerEvents: 'none', + boxSizing: 'border-box' + }) + + return node.node() + } + + function getSVGNode(el) { + el = el.node() + if(el.tagName.toLowerCase() == 'svg') + return el + + return el.ownerSVGElement + } + + // Private - gets the screen coordinates of a shape + // + // Given a shape on the screen, will return an SVGPoint for the directions + // n(north), s(south), e(east), w(west), ne(northeast), se(southeast), nw(northwest), + // sw(southwest). + // + // +-+-+ + // | | + // + + + // | | + // +-+-+ + // + // Returns an Object {n, s, e, w, nw, sw, ne, se} + function getScreenBBox() { + var targetel = target || d3.event.target, + bbox = {}, + matrix = targetel.getScreenCTM(), + tbbox = targetel.getBBox(), + width = tbbox.width, + height = tbbox.height, + x = tbbox.x, + y = tbbox.y, + scrollTop = document.documentElement.scrollTop || document.body.scrollTop, + scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft + + + point.x = x + scrollLeft + point.y = y + scrollTop + bbox.nw = point.matrixTransform(matrix) + point.x += width + bbox.ne = point.matrixTransform(matrix) + point.y += height + bbox.se = point.matrixTransform(matrix) + point.x -= width + bbox.sw = point.matrixTransform(matrix) + point.y -= height / 2 + bbox.w = point.matrixTransform(matrix) + point.x += width + bbox.e = point.matrixTransform(matrix) + point.x -= width / 2 + point.y -= height / 2 + bbox.n = point.matrixTransform(matrix) + point.y += height + bbox.s = point.matrixTransform(matrix) + + return bbox + } + + return tip +}; From 9bd6304ae4b274db7a83d60b90b13aae6a12fee3 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 4 Aug 2015 14:00:16 +0530 Subject: [PATCH 087/126] Removing table data deletion method. --- .../rest/endpoint/api/StratosApiV41Utils.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index a18506c4fc..1874b3534f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3921,34 +3921,4 @@ public static String getAverageClusterFlightRequestCountByClusterId(String Id, S } - public static void deleteTableData() throws RestAPIException { - - String deleteTableDataquery = "DELETE FROM HealthStatisticsTable WHERE " + - "from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") < NOW() - INTERVAL 2160 HOUR"; - - ConnectionHandler connectionHandler = new ConnectionHandler(); - - try { - - ResultSet result = connectionHandler.getsqlConnection(deleteTableDataquery); - result.next(); - - } catch (SQLException ex) { - log.error("SQLException: ", ex); - throw new RestAPIException(ex.getMessage()); - } catch (Exception ex) { - log.error("Exception: ", ex); - throw new RestAPIException(ex.getMessage()); - } finally { - try { - connectionHandler.closeConnection(); - } catch (SQLException ex) { - log.error("SQLException: ", ex); - throw new RestAPIException(ex.getMessage()); - } - } - - - } - } From 4054b291ead09c6f80550ff6abf7b44303a88181 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 4 Aug 2015 22:18:09 +0530 Subject: [PATCH 088/126] adding export stream to AverageHeathRequest excution plan. --- .../artifacts/executionplans/AverageHeathRequest.xml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml index c406e6804d..c92fc28554 100644 --- a/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml +++ b/extensions/cep/artifacts/executionplans/AverageHeathRequest.xml @@ -72,11 +72,16 @@ - - + - From 2db724ff3b21092827c556f70de1090db5a805f3 Mon Sep 17 00:00:00 2001 From: dk Date: Tue, 4 Aug 2015 22:19:12 +0530 Subject: [PATCH 089/126] Commiting the changes of configuaration document for CEP adapters. --- .../cep/healthStatisticsArtifacts/README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/extensions/cep/healthStatisticsArtifacts/README.md b/extensions/cep/healthStatisticsArtifacts/README.md index 6152b140db..355fcf5949 100644 --- a/extensions/cep/healthStatisticsArtifacts/README.md +++ b/extensions/cep/healthStatisticsArtifacts/README.md @@ -47,17 +47,20 @@ artifacts/outputeventadaptors/OutPutadaptorRDBMStoPublishHealthStat.xml into [Apache Stratos] OR [External CEP HOME ]/repository/deployment/server/outputeventadaptors/ directory. Please find OutPutadaptorRDBMStoPublishHealthStat here[2] and paste it to the above directory. -Configuring Event fomratters. +Configuring Event fomratter. ============================= You can specify an event formatter configuration using an XML file and save it in [Apache Stratos] OR [External CEP HOME ]/repository/deployment/server/eventformatters directory. -In here you can get the 3 formatters artifacts/eventformatters/ +In here you can get the formatter, -Names, +HealthStatPublishEventFormatter -MemberAverageLoadAverageEventFormatterHealthStat -MemberAverageMemoryAverageEventFormatterHealthStat -FlightRequestEventFormatterHealthStat +depoly them in the previously mentioned directory. -depoly them in the previously mentioned directory. \ No newline at end of file +Configuring OutPut Adapter. +============================ + +You can Copy this OutPutadaptorRDBMStoPublishHealthStat.xml OutPut adapter and paste it to the Outputvenetadaptors +folder in this directory, +[Apache Stratos] OR [External CEP HOME ]/repository/deployment/server/outputvenetadaptors directory. From 0b84314889e86c07e108605587c09c5c45cca05e Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 5 Aug 2015 13:07:43 +0530 Subject: [PATCH 090/126] REST API changes in StratosApiV41.java to enable quering using Start_Time and End_Time --- .../rest/endpoint/api/StratosApiV41.java | 62 +++++++++++-------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 5f1335d18a..cff3bb4c7e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -2129,22 +2129,24 @@ public Response getIaasProviders() } /** + * * @param Id - * @param Interval - * @return 200 if average memory consumption can get and memory consumption values + * @param startTime + * @param endTime + * @return 200 if average memory consumption can get and memory consumption values cluster * @throws RestAPIException */ @GET - @Path("/cluster/averageMemory/{cluster-Id}/{Interval}") + @Path("/cluster/averageMemory/{cluster-Id}/{startTime}/{endTime}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterMemoryByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { String averageClusterMemoryList; try { - averageClusterMemoryList = StratosApiV41Utils.getAverageClusterMemoryByClusterId(Id, Interval); + averageClusterMemoryList = StratosApiV41Utils.getAverageClusterMemoryByClusterId(Id, startTime, endTime); } catch (RestAPIException ex) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( @@ -2160,22 +2162,24 @@ public Response getAverageClusterMemoryByClusterId( } /** + * * @param Id - * @param Interval - * @return 200 if average memory consumption can get and memory consumption values + * @param startTime + * @param endTime + * @return 200 if average memory consumption can get and memory consumption values member * @throws RestAPIException */ @GET - @Path("/member/averageMemory/{member-Id}/{Interval}") + @Path("/member/averageMemory/{member-Id}/{startTime}/{endTime}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberMemoryByMemberId( - @PathParam("member-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { String averageMemberMemoryList; try { - averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByMemberId(Id, Interval); + averageMemberMemoryList = StratosApiV41Utils.getAverageMemberMemoryByMemberId(Id, startTime, endTime); } catch (RestAPIException ex) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( @@ -2191,23 +2195,24 @@ public Response getAverageMemberMemoryByMemberId( } /** + * * @param Id - * @param Interval - * @return 200 if average load consumption can get and load average consumption values + * @param startTime + * @param endTime + * @return 200 if average load consumption can get and load average consumption values member * @throws RestAPIException */ - @GET - @Path("/member/averageLoad/{member-Id}/{Interval}") + @Path("/member/averageLoad/{member-Id}/{startTime}/{endTime}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberLoadByMemberId( - @PathParam("member-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { String averageMemberLoadList; try { - averageMemberLoadList = StratosApiV41Utils.getAverageMemberLoadByMemberId(Id, Interval); + averageMemberLoadList = StratosApiV41Utils.getAverageMemberLoadByMemberId(Id, startTime, endTime); } catch (RestAPIException ex) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( @@ -2224,23 +2229,24 @@ public Response getAverageMemberLoadByMemberId( } /** + * * @param Id - * @param Interval - * @return 200 if average load consumption can get and load average consumption values + * @param startTime + * @param endTime + * @return 200 if average load consumption can get and load average consumption values for cluster * @throws RestAPIException */ - @GET - @Path("/cluster/averageLoad/{cluster-Id}/{Interval}") + @Path("/cluster/averageLoad/{cluster-Id}/{startTime}/{endTime}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterLoadByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { String averageClusterLoadList; try { - averageClusterLoadList = StratosApiV41Utils.getAverageClusterLoadByClusterId(Id, Interval); + averageClusterLoadList = StratosApiV41Utils.getAverageClusterLoadByClusterId(Id, startTime, endTime); } catch (RestAPIException ex) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( @@ -2256,23 +2262,25 @@ public Response getAverageClusterLoadByClusterId( } /** + * * @param Id - * @param Interval - * @return 200 if average request in flight can get and in flight request count + * @param startTime + * @param endTime + * @return 200 if average request in flight can get and in flight request count cluster * @throws RestAPIException */ @GET - @Path("/cluster/flightRequestCount/{cluster-Id}/{Interval}") + @Path("/cluster/flightRequestCount/{cluster-Id}/{startTime}/{endTime}") @Consumes("application/json") @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterFlightRequestCountByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("Interval") String Interval) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { String averageClusterFlightRequestCount; try { - averageClusterFlightRequestCount = StratosApiV41Utils.getAverageClusterFlightRequestCountByClusterId(Id, Interval); + averageClusterFlightRequestCount = StratosApiV41Utils.getAverageClusterFlightRequestCountByClusterId(Id, startTime, endTime); } catch (RestAPIException ex) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( From beea1272681791bdb18ccfbb49e48f8fd44b5682 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 5 Aug 2015 18:34:58 +0530 Subject: [PATCH 091/126] Commiting the implementation for search health statistics data by giving the start time and end time. --- .../rest/endpoint/api/StratosApiV41.java | 15 ++- .../rest/endpoint/api/StratosApiV41Utils.java | 101 +++++++----------- 2 files changed, 48 insertions(+), 68 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index cff3bb4c7e..0a02728a79 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -2142,7 +2142,8 @@ public Response getIaasProviders() @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterMemoryByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) + throws RestAPIException { String averageClusterMemoryList; try { @@ -2175,7 +2176,8 @@ public Response getAverageClusterMemoryByClusterId( @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberMemoryByMemberId( - @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) + throws RestAPIException { String averageMemberMemoryList; try { @@ -2208,7 +2210,8 @@ public Response getAverageMemberMemoryByMemberId( @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageMemberLoadByMemberId( - @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { + @PathParam("member-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) + throws RestAPIException { String averageMemberLoadList; try { @@ -2242,7 +2245,8 @@ public Response getAverageMemberLoadByMemberId( @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterLoadByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) + throws RestAPIException { String averageClusterLoadList; try { @@ -2276,7 +2280,8 @@ public Response getAverageClusterLoadByClusterId( @Produces("application/json") @AuthorizationAction("/permission/admin/stratos") public Response getAverageClusterFlightRequestCountByClusterId( - @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) throws RestAPIException { + @PathParam("cluster-Id") String Id, @PathParam("startTime") String startTime, @PathParam("endTime") String endTime) + throws RestAPIException { String averageClusterFlightRequestCount; try { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 1874b3534f..a1d199d052 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -3650,23 +3650,19 @@ public static IaasProviderInfoBean getIaasProviders() throws RestAPIException { /** * @param Id - * @param Interval - * @return Average of Cluster Memory Data + * @param startTime + * @param endTime + * @return 200 if average memory consumption can get and memory consumption values cluster * @throws RestAPIException */ - public static String getAverageClusterMemoryByClusterId(String Id, String Interval) throws RestAPIException { + public static String getAverageClusterMemoryByClusterId(String Id, String startTime, String endTime) throws RestAPIException { + + + String averageClusterMemoryQuery = "SELECT value AS MEMBER_AVERAGE_MEMORY_CONSUMPTION,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE ID = \"" + Id + "\" AND timeStamp BETWEEN " + startTime + " AND " + endTime + " AND " + + "type = \"cluster_average_memory_consumption\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; - String averageClusterMemoryQuery = "SELECT value AS MEMBER_AVERAGE_MEMORY_CONSUMPTION,ID,timeStamp " + - "FROM HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR " + - "AND ID = \"" + Id + "\" AND type = \"cluster_average_memory_consumption\" GROUP " + - "BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; -/* - String averageClusterMemoryQuery = "SELECT SUM(MEMBER_AVERAGE_MEMORY_CONSUMPTION) AS 'MEMBER_AVERAGE_MEMORY_CONSUMPTION'," + - "CLUSTER_ID, TIMESTAMP From MemberAverageMemoryAverageEventFormatterHealthStat " + - "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + - "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; -*/ List averageClusterMemoryList = new ArrayList(); @@ -3703,21 +3699,19 @@ public static String getAverageClusterMemoryByClusterId(String Id, String Interv /** * @param Id - * @param Interval - * @return Average Cluster Load average data + * @param startTime + * @param endTime + * @return 200 if average load consumption can get and load average consumption values for cluster * @throws RestAPIException */ - public static String getAverageClusterLoadByClusterId(String Id, String Interval) throws RestAPIException { - String averageClusterLoadQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM " + - "HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR" + - " AND ID = \"" + Id + "\" AND type = \"cluster_average_load_average\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + public static String getAverageClusterLoadByClusterId(String Id, String startTime, String endTime) throws RestAPIException { + + String averageClusterLoadQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE ID = \"" + Id + "\" AND timeStamp BETWEEN " + startTime + " AND " + endTime + " AND " + + "type = \"cluster_average_load_average\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + - /* String averageClusterLoadQuery = "SELECT SUM(MEMBER_AVERAGE_LOAD_AVERAGE) AS 'MEMBER_AVERAGE_LOAD_AVERAGE'," + - "CLUSTER_ID, TIMESTAMP From MemberAverageLoadAverageEventFormatterHealthStat " + - "WHERE CLUSTER_ID = \"" + Id + "\" AND from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > " + - "NOW() - INTERVAL " + Interval + " HOUR GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H : %i\");"; -*/ List averageMemberLoadList = new ArrayList(); ConnectionHandler connectionHandler = new ConnectionHandler(); @@ -3755,24 +3749,18 @@ public static String getAverageClusterLoadByClusterId(String Id, String Interval /** * @param Id - * @param Interval - * @return Average Member Memory Average data + * @param startTime + * @param endTime + * @return 200 if average memory consumption can get and memory consumption values member * @throws RestAPIException */ - public static String getAverageMemberMemoryByMemberId(String Id, String Interval) throws RestAPIException { + public static String getAverageMemberMemoryByMemberId(String Id, String startTime, String endTime) throws RestAPIException { String memberIfQueryforMemory = "SELECT value AS MEMBER_AVERAGE_MEMORY_CONSUMPTION,ID,timeStamp FROM HealthStatisticsTable " + - "WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR AND " + - "ID =\"" + Id + "\" AND type = \'member_average_memory_consumption\' GROUP BY " + - "from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; + "WHERE ID = \"" + Id + "\" AND timeStamp BETWEEN " + startTime + " AND " + endTime + " AND " + + "type = \"member_average_memory_consumption\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; -/* - String memberIfQueryforMemory = "SELECT TIMESTAMP,MEMBER_ID," + - "MEMBER_AVERAGE_MEMORY_CONSUMPTION FROM MemberAverageMemoryAverageEventFormatterHealthStat WHERE " + - "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + - "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; -*/ List averageMemberMemoryList = new ArrayList(); @@ -3811,22 +3799,17 @@ public static String getAverageMemberMemoryByMemberId(String Id, String Interval /** * @param Id - * @param Interval - * @return Average Member Load Average data + * @param startTime + * @param endTime + * @return 200 if average load consumption can get and load average consumption values member * @throws RestAPIException */ - public static String getAverageMemberLoadByMemberId(String Id, String Interval) throws RestAPIException { + public static String getAverageMemberLoadByMemberId(String Id, String startTime, String endTime) throws RestAPIException { - String memberLoadAverageQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM HealthStatisticsTable " + - "WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR" + - " AND ID = \"" + Id + "\" AND type = \'member_average_load_average\' GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; -/* - String memberLoadAverageQuery = "SELECT TIMESTAMP,MEMBER_ID," + - "MEMBER_AVERAGE_LOAD_AVERAGE FROM MemberAverageLoadAverageEventFormatterHealthStat WHERE " + - "from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") " + - "> NOW() - INTERVAL " + Interval + " HOUR AND MEMBER_ID =\"" + Id + "\""; -*/ + String memberLoadAverageQuery = "SELECT value AS MEMBER_AVERAGE_LOAD_AVERAGE,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE ID = \"" + Id + "\" AND timeStamp BETWEEN " + startTime + " AND " + endTime + " AND " + + "type = \"member_average_load_average\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; List averageMemberLoadList = new ArrayList(); @@ -3865,25 +3848,17 @@ public static String getAverageMemberLoadByMemberId(String Id, String Interval) /** * @param Id - * @param Interval - * @return Average Cluster Flight request Count data + * @param startTime + * @param endTime + * @return 200 if average request in flight can get and in flight request count cluster * @throws RestAPIException */ - public static String getAverageClusterFlightRequestCountByClusterId(String Id, String Interval) throws RestAPIException { - - //delete FROM testTable WHERE from_unixtime(timeStamp/1000,"%Y-%m-%d %H:%i") < NOW() - INTERVAL 2232 HOUR - + public static String getAverageClusterFlightRequestCountByClusterId(String Id, String startTime, String endTime) throws RestAPIException { - String clusterIDQueryforFlightCount = "SELECT value AS FLIGHT_REQUEST_COUNT,ID,timeStamp FROM " + - "HealthStatisticsTable WHERE from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\") > NOW() - INTERVAL " + Interval + " HOUR " + - "AND ID = \"" + Id + "\" AND type = \'in_flight_request_count\' GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; -/* - String clusterIDQueryforFlightCount = "SELECT SUM(FLIGHT_REQUEST_COUNT) AS FLIGHT_REQUEST_COUNT,CLUSTER_ID,TIMESTAMP FROM " + - "FlightRequestEventFormatterHealthStat WHERE from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\") > NOW() - " + - "INTERVAL " + Interval + " HOUR AND CLUSTER_ID = \"" + Id + "\"" + - "GROUP BY from_unixtime(TIMESTAMP/1000,\"%Y-%m-%d %H:%i\");"; -*/ + String clusterIDQueryforFlightCount = "SELECT value AS FLIGHT_REQUEST_COUNT,ID,timeStamp FROM HealthStatisticsTable " + + "WHERE ID = \"" + Id + "\" AND timeStamp BETWEEN " + startTime + " AND " + endTime + " AND " + + "type = \"in_flight_request_count\" GROUP BY from_unixtime(timeStamp/1000,\"%Y-%m-%d %H:%i\");"; List inFlightRequestBeanList = new ArrayList(); From 4ad2c7ad38bf31acafd24ccf532c1b8a76b50a20 Mon Sep 17 00:00:00 2001 From: dk Date: Wed, 5 Aug 2015 23:25:33 +0530 Subject: [PATCH 092/126] Changing UI for the new REST API. --- .../console/healthStatistics.jag | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/healthStatistics.jag b/components/org.apache.stratos.manager.console/console/healthStatistics.jag index 6b6539b203..d573ef9ea8 100644 --- a/components/org.apache.stratos.manager.console/console/healthStatistics.jag +++ b/components/org.apache.stratos.manager.console/console/healthStatistics.jag @@ -39,45 +39,6 @@ var log = new Log("apacheStratos.appconfig"), var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); var log = new Log(); -//this will get default data using a rest call to the charts. -var loadAverageData, - flightRequestDetails, - memoryAverageDetails=null; - -if('Cluster' != type){ - - try { - - memoryAverageDetails = util.RESTCalls.getMemberMemoryAvrageDetails(Id, 1); - - } catch (e) { - - throw new Error("Error while getting Category Activity data for " + e); - } - - try { - - loadAverageData = util.RESTCalls.getMemberLoadAverageDetails(id,1); - - } catch (e) { - - throw new Error("Error while getting Category Activity data for "+ e); - } - - flightRequestDetails = null; - -}else{ - - try { - - memoryAverageDetails = util.RESTCalls.getClusterMemoryAverageDetails(id,1); - - } catch (e) { - throw new Error("Error while getting Category Activity data for "+ e); - } - -} - //rendering the data caramel.render({ breadcrumbPathLevelOne: 'healthStatistics', @@ -85,9 +46,6 @@ caramel.render({ type: type, alias: alias, left_menu: leftMenu, - loadAverageData:JSON.stringify(loadAverageData), - memoryAverageDetails:JSON.stringify(memoryAverageDetails), - flightRequestDetails:JSON.stringify(flightRequestDetails), error: error }); From ef4cd288a42572cde528b7244207245025ce41d1 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 6 Aug 2015 00:18:08 +0530 Subject: [PATCH 093/126] Changing UI REST call methods to the new REST Api. --- .../console/controllers/rest/rest_calls.jag | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag index be5171862d..7cabd61ab1 100644 --- a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -27,31 +27,31 @@ RESTCalls = new function(){ return this.sendReceive("GET","/tenants",{}); }; - this.getFlightRequestDetails = function(Id,DurationVal){ + this.getFlightRequestDetails = function(Id,startDate,endDate){ - return this.sendReceive("GET","/cluster/flightRequestCount/" +Id+"/"+DurationVal,{}); + return this.sendReceive("GET","/cluster/flightRequestCount/" +Id+"/"+startDate+"/"+endDate,{}); }; - this.getClusterMemoryAverageDetails = function(Id,DurationVal){ + this.getClusterMemoryAverageDetails = function(Id,startDate,endDate){ - return this.sendReceive("GET","/cluster/averageMemory/" +Id+"/"+DurationVal,{}); + return this.sendReceive("GET","/cluster/averageMemory/" +Id+"/"+startDate+"/"+endDate,{}); }; - this.getClusterLoadAverageDetails = function(Id,DurationVal){ + this.getClusterLoadAverageDetails = function(Id,startDate,endDate){ - return this.sendReceive("GET","/cluster/averageLoad/" +Id+"/"+DurationVal,{}); + return this.sendReceive("GET","/cluster/averageLoad/" +Id+"/"+startDate+"/"+endDate,{}); }; - this.getMemberLoadAverageDetails = function(Id,DurationVal){ + this.getMemberLoadAverageDetails = function(Id,startDate,endDate){ - return this.sendReceive("GET","/member/averageLoad/" +Id+"/"+DurationVal,{}); + return this.sendReceive("GET","/member/averageLoad/" +Id+"/"+startDate+"/"+endDate,{}); }; - this.getMemberMemoryAvrageDetails = function(Id,DurationVal){ + this.getMemberMemoryAvrageDetails = function(Id,startDate,endDate){ - return this.sendReceive("GET","/member/averageMemory/" +Id+"/"+DurationVal,{}); + return this.sendReceive("GET","/member/averageMemory/" +Id+"/"+startDate+"/"+endDate,{}); }; this.deployPartitionDefinition = function(partitionDefinition){ From 0566bf5c8f3a8cc351e5304ef13a5c3132f62b60 Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 6 Aug 2015 02:03:53 +0530 Subject: [PATCH 094/126] UI changes on the new REST API methods. --- .../js/healthStatistics/healthStatistics.js | 218 +++++++++++++----- 1 file changed, 166 insertions(+), 52 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index 480b4e5b75..007c434f39 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -21,7 +21,6 @@ var jsonDataLoadAvg; var jsonDataFlightRequest; var jsonDataMemoryAvg; -var type; function DurationOnClick(ref) { @@ -125,89 +124,204 @@ function bodyOnLoad (loadAverageData,flightRequestDetails,memoryAverageDetails) //this is the load avergae chart for cluster/member function loadAverageChart () { - var margin = {top: 20, right: 20, bottom: 30, left: 50}, + var margin = {top: 10, right: 10, bottom: 100, left: 40}, + margin2 = {top: 220, right: 10, bottom: 20, left: 40}, width = 600 - margin.left - margin.right, - height = 300 - margin.top - margin.bottom; + height = 300 - margin.top - margin.bottom, + height2 = 300 - margin2.top - margin2.bottom; - var parseDate = d3.time.format("%d-%b-%y").parse; + var parseDate = d3.time.format("%b %Y").parse; - var x = d3.time.scale() - .range([0, width]); + var x = d3.time.scale().range([0, width]), + x2 = d3.time.scale().range([0, width]), //defines the maximum and minimum values we have to plot in the available space. - var y = d3.scale.linear() - .range([height, 0]); + y = d3.scale.linear().range([height, 0]), + y2 = d3.scale.linear().range([height2, 0]); //provides an API method called d3.svg.axis to create axes. - var xAxis = d3.svg.axis() - .scale(x) - .orient("bottom"); + var xAxis = d3.svg.axis().scale(x).orient("bottom"), + xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), + yAxis = d3.svg.axis().scale(y).orient("left"); - var yAxis = d3.svg.axis() - .scale(y) - .orient("left"); + var brush = d3.svg.brush() + .x(x2) + .on("brush", brushed); var area = d3.svg.area() + .interpolate("linear") .x(function(d) { return x(d.timeStamp); }) .y0(height) - .y1(function(d) {return y(d.memberAverageLoadAverage); }); + .y1(function(d) { return y(d.memberAverageLoadAverage); }); - var tip = d3.tip() - .attr('class', 'd3-tip') - .offset([-10, 0]) - .html(function(d) { - return "Load Average: " + d.memberAverageLoadAverage + - " Time: " + new Date(d.timeStamp) + ""; - }) + var area2 = d3.svg.area() + .interpolate("linear") + .x(function(d) { return x2(d.timeStamp); }) + .y0(height2) + .y1(function(d) { return y2(d.memberAverageLoadAverage); }); - //selecting the data needs to append var svg = d3.select("#chart2").append("svg") .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .append("g") + .attr("height", height + margin.top + margin.bottom); + + svg.append("defs").append("clipPath") + .attr("id", "clip") + .append("rect") + .attr("width", width) + .attr("height", height); + + var focus = svg.append("g") + .attr("class", "focus") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - //calling the tool tip - svg.call(tip); + var context = svg.append("g") + .attr("class", "context") + .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); - //initializing the json array list to the map root element var data = jsonDataLoadAvg; x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + y.domain([-2, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([-2, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + x2.domain(x.domain()); + y2.domain(y.domain()); - svg.append("path") + focus.append("path") .datum(data) - .attr("class", "area1") + .attr("class", "area") .attr("d", area); - ////append the created X axis to the svg container - svg.append("g") + //append the created X axis to the svg container + focus.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); //append the created Y axis to the svg container - svg.append("g") + focus.append("g") .attr("class", "y axis") - .call(yAxis) - .append("text") - .attr("transform", "rotate(-90)") - .attr("y", 6) - .attr("dy", ".71em") - .style("text-anchor", "end") - .text("Load Average"); - - svg.selectAll(".area") - .data(data) - .enter().append("rect") - .attr("class", "area1") - .attr("x", function(d) { return x(d.timeStamp); }) - .attr("width", 1) - .attr("y", function(d) { return y(d.memberAverageLoadAverage); }) - .attr("height", function(d) { return height - y(d.memberAverageLoadAverage); }) - .on('mouseover', tip.show) - .on('mouseout', tip.hide) + .call(yAxis); + + context.append("path") + .datum(data) + .attr("class", "area") + .attr("d", area2); + + context.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height2 + ")") + .call(xAxis2); + + context.append("g") + .attr("class", "x brush") + .call(brush) + .selectAll("rect") + .attr("y", -6) + .attr("height", height2 + 7); + + + function brushed() { + x.domain(brush.empty() ? x2.domain() : brush.extent()); + focus.select(".area").attr("d", area); + focus.select(".x.axis").call(xAxis); + } + + function type(d) { + d.timeStamp = parseDate(d.timeStamp); + d.memberAverageLoadAverage = +d.memberAverageLoadAverage; + return d; + } + + /* + + var margin = {top: 20, right: 20, bottom: 30, left: 50}, + width = 600 - margin.left - margin.right, + height = 300 - margin.top - margin.bottom; + + var parseDate = d3.time.format("%d-%b-%y").parse; + + var x = d3.time.scale() + .range([0, width]); + + //defines the maximum and minimum values we have to plot in the available space. + var y = d3.scale.linear() + .range([height, 0]); + + //provides an API method called d3.svg.axis to create axes. + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var area = d3.svg.area() + .x(function(d) { return x(d.timeStamp); }) + .y0(height) + .y1(function(d) {return y(d.memberAverageLoadAverage); }); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function(d) { + return "Load Average: " + d.memberAverageLoadAverage + + " Time: " + new Date(d.timeStamp) + ""; + }) + + //selecting the data needs to append + var svg = d3.select("#chart2").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + svg.call(tip); + + //initializing the json array list to the map root element + var data = jsonDataLoadAvg; + + x.domain(d3.extent(data, function(d) { return d.timeStamp; })); + y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + + svg.append("path") + .datum(data) + .attr("class", "area1") + .attr("d", area); + + ////append the created X axis to the svg container + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + //append the created Y axis to the svg container + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Load Average"); + + svg.selectAll(".area") + .data(data) + .enter().append("rect") + .attr("class", "area1") + .attr("x", function(d) { return x(d.timeStamp); }) + .attr("width", 1) + .attr("y", function(d) { return y(d.memberAverageLoadAverage); }) + .attr("height", function(d) { return height - y(d.memberAverageLoadAverage); }) + .on('mouseover', tip.show) + .on('mouseout', tip.hide) + */ + + } function inFlightRequestCountChart () { From cdec6f4b3604f2cbdab4d76e9b8d3121e208a52f Mon Sep 17 00:00:00 2001 From: dk Date: Thu, 6 Aug 2015 18:19:12 +0530 Subject: [PATCH 095/126] health statistic get request methods will call the trigger the rest_calls jag for statistics data. --- .../healthStatistics_getrequest.jag | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag b/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag index 6f1e937767..282c9f3b98 100755 --- a/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag +++ b/components/org.apache.stratos.manager.console/console/controllers/healthStatistics/healthStatistics_getrequest.jag @@ -29,59 +29,79 @@ var log = new Log("apachestratos.configure_request"), var formSubmit; var DurationVal; +//creatingTimeObjects +var startTime = new Date(); +var endTime = new Date(); + + //add login validator for pages include('/controllers/login/validator.jag'); -switch (Duration) { - case "30Min": - DurationVal = .5; - break; - case "1Hour": - DurationVal = 1; - break; - case "1Day": - DurationVal = 24; - break; - case "1Week": - DurationVal = 168; - break; - case "1Month": - DurationVal = 672; - break; +if(Duration!="30Min"){ + + switch (Duration) { + + case "1Hour": + DurationVal = 1; + break; + case "1Day": + DurationVal = 24; + break; + case "1Week": + DurationVal = 168; + break; + case "1Month": + DurationVal = 672; + break; + } + + +//substratcting hour from current time + startTime.setHours(endTime.getHours() - DurationVal); + +}else{ + + +//substratcting hour from current time + startTime.setMinutes(endTime.getMinutes() - 30); + } +//switch to trigger the rest call when needs try { switch (formtype) { case "MemoryConsumption": if("Cluster" == ChartType){ - formSubmit = util.RESTCalls.getClusterMemoryAverageDetails(IdValue, DurationVal); + + formSubmit = util.RESTCalls.getClusterMemoryAverageDetails(IdValue, startTime.getTime(),endTime.getTime()); break; } else{ - formSubmit = util.RESTCalls.getMemberMemoryAvrageDetails(IdValue, DurationVal); + formSubmit = util.RESTCalls.getMemberMemoryAvrageDetails(IdValue, startTime.getTime(),endTime.getTime()); break; } case "LoadAverage": if("Cluster" == ChartType){ - formSubmit = util.RESTCalls.getClusterLoadAverageDetails(IdValue, DurationVal); + formSubmit = util.RESTCalls.getClusterLoadAverageDetails(IdValue, startTime.getTime(),endTime.getTime()); break; } else{ - formSubmit = util.RESTCalls.getMemberLoadAverageDetails(IdValue, DurationVal); + formSubmit = util.RESTCalls.getMemberLoadAverageDetails(IdValue, startTime.getTime(),endTime.getTime()); break; } case "InFlight": - formSubmit = util.RESTCalls.getFlightRequestDetails(IdValue, DurationVal); + formSubmit = util.RESTCalls.getFlightRequestDetails(IdValue, startTime.getTime(),endTime.getTime()); break; default: session.put("deploy-status", { "message": "Sorry Endpoint Error", "status": "error" }); } +//vaidating the response and return if (formSubmit == undefined) { print({"status": 'error', "message": "No Data found!"}); From 8517d377baed921e6f75d1c3e0a58f51bcfdcd4e Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 7 Aug 2015 13:19:16 +0530 Subject: [PATCH 096/126] Configuration part for enabling and disabling the health statistic UI. --- .../console/config/console.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/org.apache.stratos.manager.console/console/config/console.json b/components/org.apache.stratos.manager.console/console/config/console.json index 45cd1c1adf..055b2d4357 100644 --- a/components/org.apache.stratos.manager.console/console/config/console.json +++ b/components/org.apache.stratos.manager.console/console/config/console.json @@ -1,5 +1,8 @@ { "backendServerConfiguration": { "url": "%https.host%/api/v4.1" + }, + "healthStatistics": { + "UI_enable": "false" } } \ No newline at end of file From 723b78f55fa07098f174b18df53669d91f3d9bf9 Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 7 Aug 2015 14:48:41 +0530 Subject: [PATCH 097/126] Adding the enabling UI feature configuration property to the jag file. --- .../console/applications_form.jag | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.manager.console/console/applications_form.jag b/components/org.apache.stratos.manager.console/console/applications_form.jag index ad1745ca8b..a626e1e13a 100644 --- a/components/org.apache.stratos.manager.console/console/applications_form.jag +++ b/components/org.apache.stratos.manager.console/console/applications_form.jag @@ -26,6 +26,7 @@ var log = new Log("apachestratos.applications_form"), error = [], list_data, caramel = require('caramel'), + config = require('/config/console.json'), context = caramel.configs().context, menuJson = require('/controllers/menu/menu.json'), util = require('/controllers/rest/rest_calls.jag'), @@ -90,7 +91,7 @@ if (!elements) { } - +var healthStatisticEnable=config.healthStatistics.UI_enable; var formtype = elements.formtype; switch (formtype) { @@ -109,6 +110,7 @@ switch (formtype) { var caramelData = { breadcrumbPathLevelOne: breadcrumbPathLevelOne, breadcrumbPathLevelTwo: '', + healthStatisticEnable:healthStatisticEnable, left_menu: leftMenu, isForm: isForm, isEdit: isEdit, From d30b81df45d07093e93d13b424f9626b7775e14e Mon Sep 17 00:00:00 2001 From: dk Date: Fri, 7 Aug 2015 17:08:55 +0530 Subject: [PATCH 098/126] Commiting the new UI changes for charts against the REST API --- .../js/healthStatistics/healthStatistics.js | 565 ++++++++++-------- 1 file changed, 330 insertions(+), 235 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js index 007c434f39..0cefd23ffd 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/healthStatistics/healthStatistics.js @@ -35,36 +35,45 @@ function DurationOnClick(ref) { //onclick function which will trigger the option for 30mints,1 hour etc function DurationOnClick(element){ + var buttonId = element.id; var buttonName = $(element).attr("name"); - var buttonIds = ["1Hour", "30Min", "1Day" , "1Week", "1Month"]; var chartType = $('#chartType').val(); var idValue = $('#IdValue').val(); //here the spinner will indicate untill the data loads to the map if ('InFlight' != buttonName) { + if ('LoadAverage' == buttonName) { - $('#chart2').empty(); - $('#chart2').html(''); + $('#container2').empty(); + $('#container2').html(''); } else { - $('#chart3').empty(); - $('#chart3').html(''); + + $('#container1').empty(); + $('#container1').html(''); } } else { - $('#chart1').empty(); - $('#chart1').html(''); + $('#container3').empty(); + $('#container3').html(''); + } + //after user click the option here we are changing the option black to red. $("button[name=" + buttonName + "]").each(function () { $(this).css("color", ""); }); $(element).css("color", "Red"); + restCaller(buttonName,idValue,chartType,buttonId); + +} + +//ajax call to the UI back end get the data to the charts +function restCaller(buttonName,idValue,chartType,buttonId){ - //ajax call to get the data to the charts from the database. $.ajax({ type: "GET", url: caramel.context + "/controllers/healthStatistics/healthStatistics_getrequest.jag", @@ -73,20 +82,34 @@ function DurationOnClick(element){ success: function (data) { if('error' != data.status){ + if('InFlight' == buttonName){ - $('#chart1').empty(); + + $('#lineChartSVGchart3').empty(); + $('#container3').empty(); + $('#container3').append(html3); jsonDataFlightRequest = data; inFlightRequestCountChart(); + + } else if('LoadAverage' == buttonName){ - $('#chart2').empty(); + + $('#lineChartSVGchart2').empty(); + $('#container2').empty(); + $('#container2').append(html2); jsonDataLoadAvg = data; loadAverageChart(); + } else{ - $('#chart3').empty(); + + $('#lineChartSVGchart1').empty(); + $('#container1').empty(); + $('#container1').append(html1); jsonDataMemoryAvg = data; memoryAverageDataChart(); + } }else{ @@ -99,24 +122,37 @@ function DurationOnClick(element){ } }).always(function () {}); + + } +//body onload function will trigger when the page loads +function bodyOnLoad () { + + var buttonNames; + var chartType = $('#chartType').val(); + if(chartType!="Cluster"){ + + buttonNames = ["LoadAverage", "MemoryConsumption"]; -//body onload function will trigger when the page loads at the very first. -//the charts will feeds with the defuakt data set, -function bodyOnLoad (loadAverageData,flightRequestDetails,memoryAverageDetails) { + }else{ + buttonNames = ["InFlight", "LoadAverage", "MemoryConsumption"]; + } - jsonDataLoadAvg = loadAverageData; + buttonNames.forEach(function(entry) { + initialLoad(entry,chartType); - jsonDataFlightRequest = flightRequestDetails; + }); + +} - jsonDataMemoryAvg = memoryAverageDetails; +//initialy acalling to the REST API and get data for the chart +function initialLoad(buttonName,chartType){ - //calling the charts - loadAverageChart(); - memoryAverageDataChart(); - inFlightRequestCountChart(); + var idValue = $('#IdValue').val(); + var buttonId = "1Hour"; + restCaller(buttonName,idValue,chartType,buttonId); } @@ -181,11 +217,11 @@ function loadAverageChart () { var data = jsonDataLoadAvg; x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([-2, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([-2, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); + y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); x2.domain(x.domain()); y2.domain(y.domain()); @@ -235,232 +271,247 @@ function loadAverageChart () { return d; } - /* - - var margin = {top: 20, right: 20, bottom: 30, left: 50}, - width = 600 - margin.left - margin.right, - height = 300 - margin.top - margin.bottom; - - var parseDate = d3.time.format("%d-%b-%y").parse; - - var x = d3.time.scale() - .range([0, width]); - - //defines the maximum and minimum values we have to plot in the available space. - var y = d3.scale.linear() - .range([height, 0]); - - //provides an API method called d3.svg.axis to create axes. - var xAxis = d3.svg.axis() - .scale(x) - .orient("bottom"); - - var yAxis = d3.svg.axis() - .scale(y) - .orient("left"); - - var area = d3.svg.area() - .x(function(d) { return x(d.timeStamp); }) - .y0(height) - .y1(function(d) {return y(d.memberAverageLoadAverage); }); - - var tip = d3.tip() - .attr('class', 'd3-tip') - .offset([-10, 0]) - .html(function(d) { - return "Load Average: " + d.memberAverageLoadAverage + - " Time: " + new Date(d.timeStamp) + ""; - }) - - //selecting the data needs to append - var svg = d3.select("#chart2").append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .append("g") - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - svg.call(tip); - - //initializing the json array list to the map root element - var data = jsonDataLoadAvg; - - x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([0, d3.max(data, function(d) { return d.memberAverageLoadAverage; })]); - - svg.append("path") - .datum(data) - .attr("class", "area1") - .attr("d", area); - - ////append the created X axis to the svg container - svg.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + height + ")") - .call(xAxis); - - //append the created Y axis to the svg container - svg.append("g") - .attr("class", "y axis") - .call(yAxis) - .append("text") - .attr("transform", "rotate(-90)") - .attr("y", 6) - .attr("dy", ".71em") - .style("text-anchor", "end") - .text("Load Average"); - - svg.selectAll(".area") - .data(data) - .enter().append("rect") - .attr("class", "area1") - .attr("x", function(d) { return x(d.timeStamp); }) - .attr("width", 1) - .attr("y", function(d) { return y(d.memberAverageLoadAverage); }) - .attr("height", function(d) { return height - y(d.memberAverageLoadAverage); }) - .on('mouseover', tip.show) - .on('mouseout', tip.hide) - */ + } function inFlightRequestCountChart () { - var margin = {top: 10, right: 10, bottom: 100, left: 40}, - margin2 = {top: 220, right: 10, bottom: 20, left: 40}, - width = 600 - margin.left - margin.right, - height = 300 - margin.top - margin.bottom, - height2 = 300 - margin2.top - margin2.bottom; - - var parseDate = d3.time.format("%b %Y").parse; - - var x = d3.time.scale().range([0, width]), - x2 = d3.time.scale().range([0, width]), - - //defines the maximum and minimum values we have to plot in the available space. - y = d3.scale.linear().range([height, 0]), - y2 = d3.scale.linear().range([height2, 0]); - - //provides an API method called d3.svg.axis to create axes. - var xAxis = d3.svg.axis().scale(x).orient("bottom"), - xAxis2 = d3.svg.axis().scale(x2).orient("bottom"), - yAxis = d3.svg.axis().scale(y).orient("left"); - - var brush = d3.svg.brush() - .x(x2) - .on("brush", brushed); - - //to draw a line - var line = d3.svg.line() - .interpolate("linear") - .x(function(d) { return x(d.timeStamp); }) - .y(function(d) { return y(d.inFlightRequestCount); }); - - var tip = d3.tip() - .attr('class', 'd3-tip') - .offset([-10, 0]) - .html(function(d) { - return "Flight Request Count: " + d.inFlightRequestCount + - " Time: " + new Date(d.timeStamp) + ""; - }) - - //to draw a line - var line2 = d3.svg.line() - .interpolate("linear") - .x(function(d) { return x2(d.timeStamp); }) - .y(function(d) { return y2(d.inFlightRequestCount); }); - - var svg = d3.select("#chart1").append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom); - - svg.append("defs").append("clipPath") - .attr("id", "clip") - .append("rect") - .attr("width", width) - .attr("height", height); - - var focus = svg.append("g") - .attr("class", "focus") - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - var context = svg.append("g") - .attr("class", "context") - .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); - //calling the tool tip - svg.call(tip); - var data = jsonDataFlightRequest; + var DURATION = 50; + var DELAY = 500; + + function drawLineChart( elementId, data ) { + // parse helper functions on top + //var parse = d3.time.format( '%Y-%m-%d' ).parse; + // data manipulation first + + //sample2.forEach(function(d) { d.time = new Date(d.time * 1000); }); + + + data.forEach(function(data) { data.timeStamp = new Date(data.timeStamp); }); + // data manipulation first + + + // TODO code duplication check how you can avoid that + var containerEl = document.getElementById( elementId ), + width = containerEl.clientWidth, + height = width * 0.4, + margin = { + top : 30, + right : 10, + left : 10 + }, + + detailWidth = 98, + detailHeight = 55, + detailMargin = 10, + + container = d3.select( containerEl ), + svg = container.select( 'svg' ) + .attr( 'width', width ) + .attr( 'height', height + margin.top ), + + x = d3.time.scale().range( [ 0, width - detailWidth ] ), + xAxis = d3.svg.axis().scale( x ) + .ticks ( 8 ) + .tickSize( -height ), + xAxisTicks = d3.svg.axis().scale( x ) + .ticks( 16 ) + .tickSize( -height ) + .tickFormat( '' ), + y = d3.scale.linear().range( [ height, 0 ] ), + yAxisTicks = d3.svg.axis().scale( y ) + .ticks( 12 ) + .tickSize( width ) + .tickFormat( '' ) + .orient( 'right' ), + + area = d3.svg.area() + .interpolate( 'linear' ) + .x( function( d ) { return x( d.timeStamp ) + detailWidth / 2; } ) + .y0( height ) + .y1( function( d ) { return y( d.inFlightRequestCount ); } ), + + line = d3.svg.line() + .interpolate( 'linear' ) + .x( function( d ) { return x( d.timeStamp ) + detailWidth / 2; } ) + .y( function( d ) { return y( d.inFlightRequestCount ); } ), + + startData = data.map( function( datum ) { + return { + timeStamp : datum.timeStamp, + value : 0 + }; + } ), + + circleContainer; + + // Compute the minimum and maximum date, and the maximum price. + x.domain( [ data[ 0 ].timeStamp, data[ data.length - 1 ].timeStamp ] ); + // hacky hacky hacky :( + y.domain( [ 0, d3.max( data, function( d ) { return d.inFlightRequestCount; } ) + 100 ] ); + + svg.append( 'g' ) + .attr( 'class', 'lineChart--xAxisTicks' ) + .attr( 'transform', 'translate(' + detailWidth / 2 + ',' + height + ')' ) + .call( xAxisTicks ); + + svg.append( 'g' ) + .attr( 'class', 'lineChart--xAxis' ) + .attr( 'transform', 'translate(' + detailWidth / 2 + ',' + ( height + 7 ) + ')' ) + .call( xAxis ); + + svg.append( 'g' ) + .attr( 'class', 'lineChart--yAxisTicks' ) + .call( yAxisTicks ); + + // Add the line path. + svg.append( 'path' ) + .datum( startData ) + .attr( 'class', 'lineChart--areaLine' ) + .attr( 'd', line ) + .transition() + .duration( DURATION ) + .delay( DURATION / 2 ) + .attrTween( 'd', tween( data, line ) ) + .each( 'end', function() { + drawCircles( data ); + } ); + + + // Add the area path. + svg.append( 'path' ) + .datum( startData ) + .attr( 'class', 'lineChart--area' ) + .attr( 'd', area ) + .transition() + .duration( DURATION ) + .attrTween( 'd', tween( data, area ) ); + + // Helper functions!!! + function drawCircle( datum, index ) { + circleContainer.datum( datum ) + .append( 'circle' ) + .attr( 'class', 'lineChart--circle' ) + .attr( 'r', 0 ) + .attr( + 'cx', + function( d ) { + return x( d.timeStamp ) + detailWidth / 2; + } + ) + .attr( + 'cy', + function( d ) { + return y( d.inFlightRequestCount ); + } + ) + .on( 'mouseenter', function( d ) { + d3.select( this ) + .attr( + 'class', + 'lineChart--circle lineChart--circle__highlighted' + ) + .attr( 'r', 4 ); + + d.active = true; + + showCircleDetail( d ); + } ) + .on( 'mouseout', function( d ) { + d3.select( this ) + .attr( + 'class', + 'lineChart--circle' + ) + .attr( 'r', 4 ); + + if ( d.active ) { + hideCircleDetails(); + + d.active = false; + } + } ) + .on( 'click touch', function( d ) { + if ( d.active ) { + showCircleDetail( d ) + } else { + hideCircleDetails(); + } + } ) + .transition() + .delay( DURATION / 10 * index ) + .attr( 'r', 4 ); + } - x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([0, d3.max(data, function(d) { return d.inFlightRequestCount; })]); + function drawCircles( data ) { + circleContainer = svg.append( 'g' ); + data.forEach( function( datum, index ) { + drawCircle( datum, index ); + } ); + } - x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([0, d3.max(data, function(d) { return d.inFlightRequestCount; })]); - x2.domain(x.domain()); - y2.domain(y.domain()); + function hideCircleDetails() { + circleContainer.selectAll( '.lineChart--bubble' ) + .remove(); + } - focus.append("path") - .datum(data) - .attr("class", "line") - .attr("d", line); + function showCircleDetail( data ) { + var details = circleContainer.append( 'g' ) + .attr( 'class', 'lineChart--bubble' ) + .attr( + 'transform', + function() { + var result = 'translate('; - //append the created X axis to the svg container - focus.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + height + ")") - .call(xAxis); + result += x( data.timeStamp ); + result += ', '; + result += y( data.inFlightRequestCount ) - detailHeight - detailMargin; + result += ')'; - //append the created Y axis to the svg container - focus.append("g") - .attr("class", "y axis") - .call(yAxis); + return result; + } + ); - context.append("path") - .datum(data) - .attr("class", "line") - .attr("d", line2); + details.append( 'path' ) + .attr( 'd', 'M2.99990186,0 C1.34310181,0 0,1.34216977 0,2.99898218 L0,47.6680579 C0,49.32435 1.34136094,50.6670401 3.00074875,50.6670401 L44.4095996,50.6670401 C48.9775098,54.3898926 44.4672607,50.6057129 49,54.46875 C53.4190918,50.6962891 49.0050244,54.4362793 53.501875,50.6670401 L94.9943116,50.6670401 C96.6543075,50.6670401 98,49.3248703 98,47.6680579 L98,2.99898218 C98,1.34269006 96.651936,0 95.0000981,0 L2.99990186,0 Z M2.99990186,0' ) + .attr( 'width', detailWidth ) + .attr( 'height', detailHeight ); - context.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + height2 + ")") - .call(xAxis2); + var text = details.append( 'text' ) + .attr( 'class', 'lineChart--bubble--text' ); - context.append("g") - .attr("class", "x brush") - .call(brush) - .selectAll("rect") - .attr("y", -6) - .attr("height", height2 + 7); - svg.selectAll(".line2") - .data(data) - .enter().append("rect") - .attr("class", "line") - .attr("x", function(d) { return x(d.timeStamp); }) - .attr("width", 1) - .attr("y", function(d) { return y(d.inFlightRequestCount); }) - .attr("height", function(d) { return height - y(d.inFlightRequestCount); }) - .on('mouseover', tip.show) - .on('mouseout', tip.hide) + text.append( 'tspan' ) + .attr( 'class', 'lineChart--bubble--value' ) + .attr( 'x', detailWidth / 2 ) + .attr( 'y', detailHeight / 4 * 3 ) + .attr( 'text-anchor', 'middle' ) + .text( data.inFlightRequestCount ); + console.info(data.inFlightRequestCount); + } + function tween( b, callback ) { + return function( a ) { + var i = d3.interpolateArray( a, b ); - function brushed() { - x.domain(brush.empty() ? x2.domain() : brush.extent()); - focus.select(".line").attr("d", line); - focus.select(".x.axis").call(xAxis); + return function( t ) { + return callback( i ( t ) ); + }; + }; + } } - function type(d) { - d.timeStamp = parseDate(d.timeStamp); - d.inFlightRequestCount = +d.inFlightRequestCount; - return d; - } -} + var data = jsonDataFlightRequest; + drawLineChart('chart3',data); + function memoryAverageDataChart () { + var margin = {top: 10, right: 10, bottom: 100, left: 40}, margin2 = {top: 220, right: 10, bottom: 20, left: 40}, width = 600 - margin.left - margin.right, @@ -487,17 +538,33 @@ function memoryAverageDataChart () { var area = d3.svg.area() .interpolate("linear") - .x(function(d) { return x(d.timeStamp); }) + .x(function (d) { + return x(d.timeStamp); + }) .y0(height) - .y1(function(d) { return y(d.memberAverageMemoryConsumption); }); + .y1(function (d) { + return y(d.memberAverageMemoryConsumption); + }); var area2 = d3.svg.area() .interpolate("linear") - .x(function(d) { return x2(d.timeStamp); }) + .x(function (d) { + return x2(d.timeStamp); + }) .y0(height2) - .y1(function(d) { return y2(d.memberAverageMemoryConsumption); }); + .y1(function (d) { + return y2(d.memberAverageMemoryConsumption); + }); + + var tip = d3.tip() + .attr('class', 'd3-tip') + .offset([-10, 0]) + .html(function (d) { + return "Flight Request Count: " + d.memberAverageMemoryConsumption + + " Time: " + new Date(d.timeStamp) + ""; + }) - var svg = d3.select("#chart3").append("svg") + var svg = d3.select("#chart1").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom); @@ -515,14 +582,23 @@ function memoryAverageDataChart () { .attr("class", "context") .attr("transform", "translate(" + margin2.left + "," + margin2.top + ")"); + svg.call(tip); var data = jsonDataMemoryAvg; - x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([-2, d3.max(data, function(d) { return d.memberAverageMemoryConsumption; })]); + x.domain(d3.extent(data, function (d) { + return d.timeStamp; + })); + y.domain([0, d3.max(data, function (d) { + return d.memberAverageMemoryConsumption; + })]); - x.domain(d3.extent(data, function(d) { return d.timeStamp; })); - y.domain([-2, d3.max(data, function(d) { return d.memberAverageMemoryConsumption; })]); + x.domain(d3.extent(data, function (d) { + return d.timeStamp; + })); + y.domain([0, d3.max(data, function (d) { + return d.memberAverageMemoryConsumption; + })]); x2.domain(x.domain()); y2.domain(y.domain()); @@ -559,6 +635,22 @@ function memoryAverageDataChart () { .attr("y", -6) .attr("height", height2 + 7); + svg.selectAll(".area2") + .data(data) + .enter().append("rect") + .attr("class", "area") + .attr("x", function (d) { + return x(d.timeStamp); + }) + .attr("width", 1) + .attr("y", function (d) { + return y(d.memberAverageMemoryConsumption); + }) + .attr("height", function (d) { + return height - y(d.memberAverageMemoryConsumption); + }) + .on('mouseover', tip.show) + .on('mouseout', tip.hide) function brushed() { x.domain(brush.empty() ? x2.domain() : brush.extent()); @@ -571,4 +663,7 @@ function memoryAverageDataChart () { d.memberAverageMemoryConsumption = +d.memberAverageMemoryConsumption; return d; } -} \ No newline at end of file +} + +} + From 3642c359112ec6f421616972ed2d68ccce170102 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 8 Aug 2015 08:19:32 +0530 Subject: [PATCH 099/126] Configuration to enable disable health stat UI. This will implement show or hide the button. --- .../theme0/js/custom/applications_topology.js | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js index 10f461fd4c..ea0b072713 100755 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/js/custom/applications_topology.js @@ -55,16 +55,15 @@ function genTree(data) { serviceName = items[prop].serviceName, status = items[prop].status; - if (items[prop].accessUrls) { + if(items[prop].accessUrls){ accessUrls = items[prop].accessUrls; - } else { + }else{ accessUrls = ''; } var type = 'clusters'; - rawout.push({ - "name": cur_name, "parent": parent, "type": type, "status": status, - "alias": alias, "hostNames": hostNames, "serviceName": serviceName, - "accessUrls": accessUrls + rawout.push({"name": cur_name, "parent": parent, "type": type, "status": status, + "alias":alias, "hostNames": hostNames, "serviceName": serviceName, + "accessUrls":accessUrls }); clustermembers(items[prop].member, collector, cur_name) } @@ -210,13 +209,21 @@ function update(source) { var accessURLHTML = ''; } - div_html = "Cluster Id: " + d.name + "
    " + + var stringHTML = "Cluster Id: " + d.name + "
    " + "Cluster Alias: " + d.alias + "
    " + accessURLHTML + "HostNames: " + d.hostNames + "
    " + "Service Name: " + d.serviceName + "
    " + - "Status: " + d.status + "

    " + - ""; + "Status: " + d.status + "

    "; + + //enabling the health statistics button + if(healthStatisticEnable){ + div_html = stringHTML.concat(" "); + } + //disbaling the health statistics button + else{ + div_html = stringHTML; + } } else if (d.type == 'members') { if ((typeof d.ports != 'undefined') && (d.ports.length > 0)) { @@ -229,18 +236,27 @@ function update(source) { } portsHTML += "
    " - } else { - var portsHTML = ''; + } else{ + var portsHTML =''; } - div_html = "Member Id: " + d.name + "
    " + + var stringHTML = "Member Id: " + d.name + "
    " + "Default Private IP: " + d.defaultPrivateIP + "
    " + "Default Public IP: " + d.defaultPublicIP + "
    " + portsHTML + "Network Partition Id: " + d.networkPartitionId + "
    " + "Partition Id: " + d.partitionId + "
    " + - "Status: " + d.status + "

    " + - ""; + "Status: " + d.status + "

    "; + + //enabling the health statistics button + if(healthStatisticEnable){ + div_html = stringHTML.concat(" "); + } + //disabling the health statistics button + else{ + div_html = stringHTML; + } + } else if (d.type == 'groups') { div_html = "Group Instance Id: " + d.instanceId + "
    " + @@ -350,7 +366,6 @@ function update(source) { function hidePopover(elem) { $(elem).popover('hide'); } - $('svg .node').hover( function () { var self = this; @@ -605,7 +620,8 @@ $("a[href='#application']").on('shown.bs.tab', function (e) { } }); -function showHealthStat(element) { +//function to send topology data to the health statistics ui +function showHealthStat(element){ var currentURL = window.location.href; var splitTense = currentURL.split('console'); var newURL = splitTense[0] + "console/healthStatistics/"; From ff4f633777d83a27ddc76e5ccd0b4021dfc21926 Mon Sep 17 00:00:00 2001 From: dk Date: Sat, 8 Aug 2015 11:27:19 +0530 Subject: [PATCH 100/126] Adding Div button to the HBS file --- .../console/themes/theme0/partials/applications_topology.hbs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs index 72300bc581..53b0f74fc1 100644 --- a/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs +++ b/components/org.apache.stratos.manager.console/console/themes/theme0/partials/applications_topology.hbs @@ -88,6 +88,7 @@