Repository: stratos Updated Branches: refs/heads/stratos-4.1.x d620bdf3d -> d750ecc37
http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/Member_Status_Filter/js/member-status-filter.js ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/Member_Status_Filter/js/member-status-filter.js b/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/Member_Status_Filter/js/member-status-filter.js new file mode 100644 index 0000000..b79a2ac --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/Member_Status_Filter/js/member-status-filter.js @@ -0,0 +1,142 @@ +/* + * + * 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 applicationId; +var clusterId; +var time = '30 Min'; +var vars; +$(document).ready(function () { + var query = parent.window.location.search.substring(1); + vars = query.split("&"); + + applicationId = getRequestParam('applicationId'); + clusterId = getRequestParam('clusterId'); + + console.log("Application Id: " + applicationId); + console.log("Cluster Id: " + clusterId); + + loadApplication(); + if (applicationId != null) { + document.getElementById("application-filter").value = applicationId; + loadCluster(applicationId); + gadgets.HubSettings.onConnect = function () { + publish(time); + } + } + + $('body').on('click', '#application-filter', function () { + var e = document.getElementById("application-filter"); + applicationId = e.options[e.selectedIndex].value; + loadCluster(applicationId); + publish(time); + }) + $('body').on('click', '#cluster-filter', function () { + var e = document.getElementById("cluster-filter"); + clusterId = e.options[e.selectedIndex].value; + publish(time); + }) + + +}); + +function getRequestParam(variable) { + for (var i = 0; i < vars.length; i++) { + var pair = vars[i].split("="); + if (pair[0] == variable) { + return pair[1]; + } + } + return null; +} + +function loadApplication() { + console.log("Getting Application Ids"); + $.ajax({ + url: '/portal/apis/applications', + dataType: 'json', + success: function (result) { + console.log(JSON.stringify(result)); + var applicationIds = []; + var records = JSON.parse(JSON.stringify(result)); + records.forEach(function (record, i) { + applicationIds.push(record.ApplicationId); + }); + + var elem = document.getElementById('application-filter'); + for (i = 0; i < applicationIds.length; i = i + 1) { + var option = document.createElement("option"); + option.text = applicationIds[i]; + option.value = applicationIds[i]; + elem.appendChild(option); + } + document.getElementById('application').appendChild(elem); + } + }); +} + +function loadCluster(application) { + $.ajax({ + url: '/portal/apis/clusters&applicationId=' + application, + dataType: 'json', + success: function (result) { + var elem = document.getElementById('cluster-filter'); + var clusterIds = []; + var clusterAlias = []; + var records = JSON.parse(JSON.stringify(result)); + records.forEach(function (record, i) { + clusterIds.push(record.ClusterId); + clusterAlias.push(record.ClusterAlias); + }); + + if (elem != null) { + elem.parentNode.removeChild(elem); + } + + var clusterList = document.createElement('select'); + clusterList.id = "cluster-filter"; + + var optionList = ""; + + optionList += "<option value= 'All Clusters'>All Clusters</option>"; + for (i = 0; i < clusterIds.length; i = i + 1) { + optionList += "<option value='" + clusterIds[i] + "'>" + clusterAlias[i] + "</option>"; + } + + clusterList.innerHTML = optionList; + document.getElementById('cluster').appendChild(clusterList); + } + }); + if (clusterId != null) { + document.getElementById("cluster-filter").value = clusterId; + } else { + var e = document.getElementById("cluster-filter"); + clusterId = e.options[e.selectedIndex].value; + } +} + +function publish(time) { + var application = applicationId; + var cluster = clusterId; + var time = time; + var data = {applicationId: application, clusterId: cluster, timeInterval: time}; + gadgets.Hub.publish("member-status-filter", data); + console.log("Publishing filter values: " + JSON.stringify(data)); +} + http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/artifacts.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/artifacts.xml b/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/artifacts.xml new file mode 100644 index 0000000..22ac7bd --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/Gadget_Member_Status_Filter/artifacts.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifact name="Gadget_Member_Status_Filter" version="1.0.0" type="dashboards/gadget" serverRole="DataAnalyticsServer"> + <file>Member_Status_Filter</file> +</artifact> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Layout/artifact.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Layout/artifact.xml b/extensions/das/metering-service/capps/stratos-metering-service/Layout/artifact.xml new file mode 100644 index 0000000..7ba8375 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/Layout/artifact.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifact name="Layout" version="1.0.0" type="dashboards/layout" serverRole="DataAnalyticsServer"> + <file>single-column</file> +</artifact> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.hbs ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.hbs b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.hbs new file mode 100644 index 0000000..ee20924 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.hbs @@ -0,0 +1,27 @@ +<!-- + + 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. + +--> +<div class="container"> +<div class="row"> + <div id="a" class="col-md-12 ues-component-box"></div> + <div id="b" class="col-md-12 ues-component-box"></div> + <div id="c" class="col-md-12 ues-component-box"></div> +</div> +</div> http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.jpg ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.jpg b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.jpg new file mode 100644 index 0000000..62a72c7 Binary files /dev/null and b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.jpg differ http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.png ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.png b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.png new file mode 100644 index 0000000..51e0fa6 Binary files /dev/null and b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/index.png differ http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/layout.json ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/layout.json b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/layout.json new file mode 100644 index 0000000..a1328f5 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/Layout/single-column/layout.json @@ -0,0 +1,8 @@ +{ + "id": "single-column", + "title": "Single Column", + "description": "This is a layout generated through single-column.io", + "thumbnail": "store://layout/single-column/index.png", + "url": "store://layout/single-column/index.hbs" +} + http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/artifact.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/artifact.xml b/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/artifact.xml new file mode 100644 index 0000000..85a5157 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/artifact.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifact name="SparkScript_ScalingDecision" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer"> + <file>scaling_details.xml</file> +</artifact> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/scaling_details.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/scaling_details.xml b/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/scaling_details.xml new file mode 100644 index 0000000..13ef83e --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SaprkScript_ScalingDecision/scaling_details.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + + 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. + +--> +<Analytics> + <Name>scaling_details</Name> + <Script> + CREATE TEMPORARY TABLE scaling_decision + USING CarbonAnalytics + OPTIONS (tableName "SCALING_DECISION"); + + create temporary table scaling_details + using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "SCALING_DETAILS"); + + INSERT OVERWRITE TABLE scaling_details select time(timestamp),scaling_decision_id, cluster_id, + min_instance_count, max_instance_count, rif_predicted, rif_threshold,rif_required_instances, mc_predicted, + mc_threshold, mc_required_instances,la_predicted, la_threshold ,la_required_instances,required_instance_count + ,active_instance_count, additional_instance_count, scaling_reason from scaling_decision; + + </Script> + <CronExpression>29 * * * * ?</CronExpression> +</Analytics> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/artifact.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/artifact.xml b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/artifact.xml new file mode 100644 index 0000000..406f982 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/artifact.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifact name="SparkScript_MemberInfo" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer"> + <file>member_information.xml</file> +</artifact> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/member_information.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/member_information.xml b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/member_information.xml new file mode 100644 index 0000000..ef838b6 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberInfo/member_information.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + + 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. + +--> +<Analytics> + <Name>member_information</Name> + <Script> + CREATE TEMPORARY TABLE memberinfo + USING CarbonAnalytics + OPTIONS (tableName "MEMBER_INFO"); + + create temporary table member_details + using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "MEMBER_INFORMATION"); + + INSERT OVERWRITE TABLE member_details select member_id, instance_type, image_id, host_name, + private_IP_addresses, public_IP_addresses, hypervisor, cpu, ram, os_name, os_version from memberinfo; + </Script> + <CronExpression>29 * * * * ?</CronExpression> +</Analytics> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/artifact.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/artifact.xml b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/artifact.xml new file mode 100644 index 0000000..7ac2591 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/artifact.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifact name="SparkScript_MemberLifecycle" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer"> + <file>member_count.xml</file> +</artifact> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/member_count.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/member_count.xml b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/member_count.xml new file mode 100644 index 0000000..b8dba80 --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/SparkScript_MemberLifecycle/member_count.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + + 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. + +--> +<Analytics> + <Name>member_count</Name> + <Script> + CREATE TEMPORARY TABLE memberstatus + USING CarbonAnalytics + OPTIONS (tableName "MEMBER_LIFECYCLE"); + + create temporary table member_count + using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "MEMBER_COUNT"); + + ;WITH MemberCount as + (select application_id, cluster_id, cluster_alias, + count(case when member_status='Created' and timestamp > current_time(null)-60000 and + timestamp<= current_time(null) then 1 else NULL end) as created_instance_count, + count(case when member_status='Initialized' and timestamp > current_time(null)-60000 and + timestamp<= current_time(null) then 1 else NULL end) as initialized_instance_count, + count(case when member_status='Active' and timestamp > current_time(null)-60000 and + timestamp<= current_time(null) then 1 else NULL end) as active_instance_count, + count(case when member_status='Terminated' and timestamp > current_time(null)-60000 and + timestamp<= current_time(null) then 1 else NULL end) as terminated_instance_count + from memberstatus group by application_id, cluster_id, cluster_alias) + INSERT INTO table member_count + select current_time(null)-60000, current_time(null), application_id, cluster_id, cluster_alias, + created_instance_count,initialized_instance_count,active_instance_count, + terminated_instance_count from MemberCount; + + create temporary table member_status_new + using CarbonJDBC options (dataSource "WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB", tableName "MEMBER_STATUS"); + + INSERT OVERWRITE TABLE member_status_new select timestamp, application_id, cluster_id, member_id, + member_status from memberstatus; + </Script> + <CronExpression>59 * * * * ?</CronExpression> +</Analytics> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/capps/stratos-metering-service/artifacts.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/capps/stratos-metering-service/artifacts.xml b/extensions/das/metering-service/capps/stratos-metering-service/artifacts.xml new file mode 100644 index 0000000..a88344d --- /dev/null +++ b/extensions/das/metering-service/capps/stratos-metering-service/artifacts.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<artifacts> + <artifact name="stratos-metering-service" version="1.0.0" type="carbon/application"> + <dependency artifact="EventStream_MemberInfo" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <dependency artifact="EventStream_MemberLifecycle" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventStream_ScalingDecision" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventStore_MemberInfo" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <dependency artifact="EventStore_MemberLifecycle" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventStore_ScalingDecision" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventReceiver_MemberInfo" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventReceiver_MemberLifecycle" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="EventReceiver_ScalingDecision" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="SparkScript_MemberInfo" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <dependency artifact="SparkScript_MemberLifecycle" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="SparkScript_ScalingDecision" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="Gadget_Member_Count" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <dependency artifact="Gadget_Member_Information" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="Gadget_Member_Status" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <!--<dependency artifact="Gadget_Member_Status_Filter" version="1.0.0" include="true"--> + <!--serverRole="DataAnalyticsServer"/>--> + <dependency artifact="Gadget_Member_Details_Filter" version="1.0.0" include="true" + serverRole="DataAnalyticsServer"/> + <dependency artifact="Layout" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/> + <!--<dependency artifact="Dashboard" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>--> + </artifact> +</artifacts> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/pom.xml b/extensions/das/metering-service/pom.xml new file mode 100644 index 0000000..a37e528 --- /dev/null +++ b/extensions/das/metering-service/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>stratos-das-extension</artifactId> + <groupId>org.apache.stratos</groupId> + <version>4.1.3</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>apache-stratos-metering-service</artifactId> + <packaging>pom</packaging> + <name>Apache Stratos - Metering Service</name> + <description>Apache Stratos Metering Service</description> + <modules> + <module>spark-udfs</module> + <module>capps</module> + </modules> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/spark-udfs/README.md ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/spark-udfs/README.md b/extensions/das/metering-service/spark-udfs/README.md new file mode 100644 index 0000000..c00190a --- /dev/null +++ b/extensions/das/metering-service/spark-udfs/README.md @@ -0,0 +1,6 @@ +This directory contains Spark UDFs (user Defined Function) required for executing the spark queries with UDFs. +Follow the below steps to use UDF in spark environment: +1. Add the jar files of each spark-udfs to '<DAS-HOME>/repository/components/lib'. + Example: spark-time-udf-4.2.0-SNAPSHOT.jar +2. Add each UDF class path to 'spark-udf-config.xml' file in '<DAS-HOME>/repository/conf/spark/' folder. + Example: <class-name>org.apache.stratos.das.extension.spark.udf.TimeUDF</class-name> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/spark-udfs/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/spark-udfs/pom.xml b/extensions/das/metering-service/spark-udfs/pom.xml new file mode 100644 index 0000000..4e826b9 --- /dev/null +++ b/extensions/das/metering-service/spark-udfs/pom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>apache-stratos-metering-service</artifactId> + <groupId>org.apache.stratos</groupId> + <version>4.1.3</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>spark-udfs</artifactId> + <packaging>pom</packaging> + <name>apache-stratos-spark-udfs</name> + <description>Apache Stratos - Metering Service Spark UDFs</description> + <modules> + <module>spark-time-udf</module> + </modules> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/spark-udfs/spark-time-udf/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/spark-udfs/spark-time-udf/pom.xml b/extensions/das/metering-service/spark-udfs/spark-time-udf/pom.xml new file mode 100644 index 0000000..928bfdb --- /dev/null +++ b/extensions/das/metering-service/spark-udfs/spark-time-udf/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>spark-udfs</artifactId> + <groupId>org.apache.stratos</groupId> + <version>4.1.3</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.stratos</groupId> + <artifactId>spark-time-udf</artifactId> + <name>apache-stratos-spark-time-udf</name> + <description>Apache Stratos - Metering Service Spark Time UDF</description> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/metering-service/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java ---------------------------------------------------------------------- diff --git a/extensions/das/metering-service/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java b/extensions/das/metering-service/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java new file mode 100644 index 0000000..0b8f408 --- /dev/null +++ b/extensions/das/metering-service/spark-udfs/spark-time-udf/src/main/java/org/apache/stratos/das/extension/spark/udf/TimeUDF.java @@ -0,0 +1,49 @@ +/* + * 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.das.extension.spark.udf; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Implementing UDF for implementing spark sql query related to time. + */ +public class TimeUDF { + /** + * Convert time(ms) to DateFormat + * + * @param timeStamp time in ms + * @return date as String + */ + public String time(Long timeStamp) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date date = new Date(timeStamp.longValue()); + return sdf.format(date); + } + + /** + * Get the current time in ms + * + * @param param + * @return + */ + public long current_time(Integer param) { + return System.currentTimeMillis(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/das/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/das/pom.xml b/extensions/das/pom.xml new file mode 100644 index 0000000..47e5251 --- /dev/null +++ b/extensions/das/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>stratos-extensions</artifactId> + <groupId>org.apache.stratos</groupId> + <version>4.1.3</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>stratos-das-extension</artifactId> + <packaging>pom</packaging> + <name>Apache Stratos - DAS Extension</name> + <description>Apache Stratos extensions for DAS.</description> + <modules> + <module>metering-service</module> + </modules> + + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/9c1fdc75/extensions/pom.xml ---------------------------------------------------------------------- diff --git a/extensions/pom.xml b/extensions/pom.xml index 8626914..39caea1 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -34,5 +34,6 @@ <modules> <module>cep</module> <module>load-balancer</module> + <module>das</module> </modules> </project> \ No newline at end of file
