You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/07/10 18:51:43 UTC
[08/45] fixing component version issues and adding currently
refactored components to the parent pom
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-load-average.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-load-average.xml b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-load-average.xml
new file mode 100644
index 0000000..f8ecf6f
--- /dev/null
+++ b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-load-average.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ -->
+
+<!-- The default synapse configuration shipped with the WSO2 Load Balancer
+ This handles the load balancing and the autoscaling of the stratos services
+ -->
+
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
+ *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
+ -->
+
+
+ <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
+ auto-scale your applications.
+ -->
+
+ <task class="org.wso2.carbon.mediator.autoscale2.LoadAverageBasedEC2LoadAnalyzerTask"
+ name="LoadAnalyzer">
+
+
+ <!--
+ The private key for the ec2
+ -->
+ <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
+
+ <!--
+ The certificate for the ec2
+ -->
+ <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
+
+ <!--
+ The amazon instance type for the load balanced service instances.
+ Recommended and the default is m1.large.
+ -->
+ <property name="instanceType" value="m1.large"/>
+
+ <!--
+ The amazon instance type for the instances of the load balancer itself.
+ Default is m1.large. Can be changed to m1.small too.
+ -->
+ <property name="loadBalancerInstanceType" value="m1.large"/>
+
+ <!--
+ The group of the service being load balanced.
+ -->
+ <property name="applicationGroup" value="as-2011-02-23,cloud-mysql,default"/>
+
+ <!--
+ The group of the load balancer.
+ -->
+ <property name="loadBalancerGroup" value="stratos-appserver-lb,cloud-mysql,default"/>
+
+ <!--
+ The Amazon availability zone for the instances. 1-c is given as the default
+ -->
+ <property name="availabilityZone" value="us-east-1c"/>
+
+ <!--
+ Additional information for the amazon instances
+ -->
+ <property name="instanceAdditionalInfo" value="EC2 autoscale instance"/>
+
+ <!--
+ The key pair
+ -->
+ <property name="key" value="stratos-1.0.0-keypair"/>
+
+ <!--
+ The service payload file which should be loaded to the bucket
+ -->
+ <property name="applicationPayload" value="resources/cluster_node.zip"/>
+
+ <!--
+ The load balancer payload file which should be loaded to the bucket
+ -->
+ <property name="loadBalancerPayload" value="/mnt/payload.zip"/>
+
+ <!--
+ The elasticIP property can be overriden by the ELASTIC_IP environment var,
+ which is set in the payload
+ -->
+ <property name="elasticIP" value="${ELASTIC_IP}"/>
+
+ <!--
+ The minimum and maximum limits of the load balanced service instances
+ -->
+ <property name="minAppInstances" value="1"/>
+ <property name="maxAppInstances" value="5"/>
+
+ <!--
+ The minimum and maximum limits of the load balancer instances
+ -->
+ <property name="minLoadBalancerInstances" value="1"/>
+
+ <property name="roundsToAverage" value="10"/>
+
+ <!--
+ The instances spawned at once, per scaling up decision.
+ Default and the recommended value is 1
+ -->
+ <property name="instancesPerScaleUp" value="1"/>
+
+ <!--
+ The low and high limits of the load average
+ -->
+ <property name="loadAverageLowerLimit" value="2"/>
+ <property name="loadAverageHigherLimit" value="5"/>
+
+ <!--
+ The Load Balanced Service Ports
+ -->
+ <property name="serviceHttpPort" value="9763"/>
+ <property name="serviceHttpsPort" value="9443"/>
+
+ <!--
+ The interval to trigger the task in seconds
+ -->
+ <trigger interval="5"/>
+ </task>
+</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-messages-in-flight.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-messages-in-flight.xml b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-messages-in-flight.xml
new file mode 100644
index 0000000..3e66066
--- /dev/null
+++ b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-messages-in-flight.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ -->
+
+<!-- The default synapse configuration shipped with the WSO2 Load Balancer
+ This handles the load balancing and the autoscaling of the stratos services
+ -->
+
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
+ *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
+ -->
+
+
+ <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
+ auto-scale your applications.
+ -->
+
+ <task class="org.wso2.carbon.mediator.autoscale2.MessagesInFlightBasedEC2LoadAnalyzerTask"
+ name="LoadAnalyzer">
+
+
+ <!--
+ The private key for the ec2
+ -->
+ <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
+
+ <!--
+ The certificate for the ec2
+ -->
+ <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
+
+ <!--
+ The amazon instance type for the load balanced service instances.
+ Recommended and the default is m1.large.
+ -->
+ <property name="instanceType" value="m1.large"/>
+
+ <!--
+ The amazon instance type for the instances of the load balancer itself.
+ Default is m1.large. Can be changed to m1.small too.
+ -->
+ <property name="loadBalancerInstanceType" value="m1.large"/>
+
+ <!--
+ The group of the service being load balanced.
+ -->
+ <property name="applicationGroup" value="as-2011-02-23,cloud-mysql,default"/>
+
+ <!--
+ The group of the load balancer.
+ -->
+ <property name="loadBalancerGroup" value="stratos-appserver-lb,cloud-mysql,default"/>
+
+ <!--
+ The Amazon availability zone for the instances. 1-c is given as the default
+ -->
+ <property name="availabilityZone" value="us-east-1c"/>
+
+ <!--
+ Additional information for the amazon instances
+ -->
+ <property name="instanceAdditionalInfo" value="EC2 autoscale instance"/>
+
+ <!--
+ The key pair
+ -->
+ <property name="key" value="stratos-1.0.0-keypair"/>
+
+ <!--
+ The service payload file which should be loaded to the bucket
+ -->
+ <property name="applicationPayload" value="resources/cluster_node.zip"/>
+
+ <!--
+ The load balancer payload file which should be loaded to the bucket
+ -->
+ <property name="loadBalancerPayload" value="/mnt/payload.zip"/>
+
+ <!--
+ The elasticIP property can be overriden by the ELASTIC_IP environment var,
+ which is set in the payload
+ -->
+ <property name="elasticIP" value="${ELASTIC_IP}"/>
+
+ <!--
+ The time in milliseconds which the message takes to expire
+ -->
+ <property name="messageExpiryTime" value="60000"/>
+
+ <!--
+ The minimum and maximum limits of the load balanced service instances
+ -->
+ <property name="minAppInstances" value="1"/>
+ <property name="maxAppInstances" value="5"/>
+
+ <!--
+ The number of load balancer instances
+ -->
+ <property name="loadBalancerInstances" value="1"/>
+
+ <!--
+ The given queue length per node, for the calculation in scaling up
+ -->
+ <property name="queueLengthPerNode" value="400"/>
+ <property name="roundsToAverage" value="10"/>
+
+ <!--
+ The instances spawned at once, per scaling up decision.
+ Default and the recommended value is 1
+ -->
+ <property name="instancesPerScaleUp" value="1"/>
+
+ <!--
+ The interval to trigger the task in seconds
+ -->
+ <trigger interval="5"/>
+ </task>
+</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-service-messages-in-flight.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-service-messages-in-flight.xml b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-service-messages-in-flight.xml
new file mode 100644
index 0000000..7332d38
--- /dev/null
+++ b/components/org.apache.stratos.mediator.autoscale/src/main/resources/synapse-service-messages-in-flight.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://wso2.com) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ -->
+
+<!-- The default synapse configuration shipped with the WSO2 Load Balancer
+ This handles the load balancing and the autoscaling of the stratos services
+ -->
+
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- You can add any flat sequences, endpoints, etc.. to this synapse-messages-in-flight.xml file if you do
+ *not* want to have the defaults given below, specific to WSO2 LB and auto-scaler
+ -->
+
+
+ <!-- Given below is the auto-scale mediator specific task. Uncomment it, if you want to
+ auto-scale your applications.
+ -->
+ <task class="org.wso2.carbon.mediator.autoscale.lbautoscale.ServiceRequestsInFlightAutoscaler"
+ name="LoadAnalyzer">
+
+ <!--
+ The private key for ec2
+ -->
+ <property name="ec2PrivateKey" value="/mnt/payload/pk.pem"/>
+
+ <!--
+ The certificate for ec2
+ -->
+ <property name="ec2Cert" value="/mnt/payload/cert.pem"/>
+ <!--
+ The key pair
+ -->
+ <property name="sshKey" value="stratos-1.0.0-keypair"/>
+
+ <property name="loadBalancer">
+ <loadBalancer>
+ <property name="securityGroup" value="stratos-appserver-lb"/>
+ <property name="instanceType" value="m1.large"/>
+ <property name="instances" value="1"/>
+ <property name="elasticIP" value="${ELASTIC_IP}"/>
+ <property name="availabilityZone" value="us-east-1c"/>
+ <property name="payload" value="/mnt/payload.zip"/>
+ </loadBalancer>
+ </property>
+
+ <property name="services">
+ <services>
+ <defaults>
+ <property name="payload" value="resources/cluster_node.zip"/>
+ <property name="availabilityZone" value="us-east-1c"/>
+ <property name="securityGroup" value="as-2011-02-23"/>
+ <property name="instanceType" value="m1.large"/>
+ <property name="minAppInstances" value="1"/>
+ <property name="maxAppInstances" value="5"/>
+ <property name="queueLengthPerNode" value="400"/>
+ <property name="roundsToAverage" value="10"/>
+ <property name="instancesPerScaleUp" value="1"/>
+ <property name="messageExpiryTime" value="60000"/>
+ </defaults>
+ <service domain="wso2.as.domain">
+ <property name="payload" value="resources/cluster_node.zip"/>
+ <property name="availabilityZone" value="us-east-1c"/>
+ </service>
+ <service domain="wso2.ds.domain">
+ <property name="payload" value="resources/cluster_node.zip"/>
+ <property name="minAppInstances" value="1"/>
+ <property name="maxAppInstances" value="5"/>
+ <property name="queueLengthPerNode" value="400"/>
+ <property name="roundsToAverage" value="10"/>
+ <property name="instancesPerScaleUp" value="1"/>
+ <property name="availabilityZone" value="us-east-1c"/>
+ <property name="securityGroup" value="ds-2011-02-23"/>
+ </service>
+ <service domain="wso2.bps.domain">
+ <property name="payload" value="resources/cluster_node.zip"/>
+ <property name="minAppInstances" value="1"/>
+ <property name="maxAppInstances" value="5"/>
+ <property name="queueLengthPerNode" value="400"/>
+ <property name="roundsToAverage" value="10"/>
+ <property name="instancesPerScaleUp" value="1"/>
+ <property name="availabilityZone" value="us-east-1c"/>
+ <property name="securityGroup" value="bps-2011-02-23"/>
+ </service>
+ </services>
+ </property>
+
+ <!--
+ The interval to trigger the task in seconds
+ -->
+ <trigger interval="5"/>
+ </task>
+</definitions>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.mediator.autoscale/src/test/java/org/apache/stratos/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mediator.autoscale/src/test/java/org/apache/stratos/mediator/autoscale/lbautoscale/AppDomainContextsTest.java b/components/org.apache.stratos.mediator.autoscale/src/test/java/org/apache/stratos/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
new file mode 100644
index 0000000..7d0d9fa
--- /dev/null
+++ b/components/org.apache.stratos.mediator.autoscale/src/test/java/org/apache/stratos/mediator/autoscale/lbautoscale/AppDomainContextsTest.java
@@ -0,0 +1,105 @@
+/**
+ * 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.mediator.autoscale.lbautoscale;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.axis2.clustering.ClusteringAgent;
+import org.apache.axis2.clustering.tribes.TribesClusteringAgent;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.stratos.lb.common.conf.LoadBalancerConfiguration;
+import org.apache.stratos.lb.common.conf.LoadBalancerConfiguration.ServiceConfiguration;
+import org.apache.stratos.lb.common.group.mgt.SubDomainAwareGroupManagementAgent;
+import org.apache.stratos.mediator.autoscale.lbautoscale.util.AutoscaleUtil;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+public class AppDomainContextsTest extends TestCase {
+
+ private static Map<String, Map<String, ?>> map;
+ private LoadBalancerConfiguration lbConfig;
+ ConfigurationContext configCtx;
+ ClusteringAgent clusteringAgent;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
+ clusteringAgent = new TribesClusteringAgent();
+ clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
+ "worker"),
+ "wso2.as1.domain", "worker", -1);
+ clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
+ "mgt"),
+ "wso2.as1.domain", "mgt", -1);
+ clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
+ "mgt"),
+ "wso2.as2.domain", "mgt", -1);
+ configCtx.getAxisConfiguration().setClusteringAgent(clusteringAgent);
+
+ File f = new File("src/test/resources/loadbalancer.conf");
+ System.setProperty("loadbalancer.conf", f.getAbsolutePath());
+ lbConfig = LoadBalancerConfiguration.getInstance();
+
+ map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
+
+ }
+
+
+ public void testRemoval(){
+ // removing a cluster domain with only 1 sub domain
+ lbConfig.removeServiceConfiguration("wso2.as2.domain", "mgt");
+ map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
+
+ Assert.assertEquals(true, !map.containsKey("wso2.as2.domain"));
+
+ // removing a cluster domain with more than 1 sub domain
+ lbConfig.removeServiceConfiguration("wso2.as1.domain", "mgt");
+ map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
+
+ Assert.assertEquals(true, map.containsKey("wso2.as1.domain"));
+ Assert.assertEquals(true, map.get("wso2.as1.domain").get("mgt") == null);
+ Assert.assertEquals(true, map.get("wso2.as1.domain").get("worker") != null);
+ }
+
+ public void testAddition(){
+ ServiceConfiguration config1 = lbConfig.new ServiceConfiguration();
+ config1.setDomain("wso2.as3.domain");
+ config1.setSub_domain("mgt");
+ lbConfig.addServiceConfiguration(config1);
+ clusteringAgent.addGroupManagementAgent(new SubDomainAwareGroupManagementAgent(
+ "mgt"),
+ "wso2.as3.domain", "mgt", -1);
+ map = AutoscaleUtil.getAppDomainContexts(configCtx, lbConfig);
+
+ Assert.assertEquals(true, map.containsKey("wso2.as3.domain"));
+ Assert.assertEquals(true, map.get("wso2.as3.domain").get("mgt") != null);
+ }
+
+ @Deprecated // use only for writing test cases
+ void printKeys(Map<?,?> map){
+ for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
+ Object type = iterator.next();
+ System.out.println(type);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.mediator.autoscale/src/test/resources/loadbalancer.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.mediator.autoscale/src/test/resources/loadbalancer.conf b/components/org.apache.stratos.mediator.autoscale/src/test/resources/loadbalancer.conf
new file mode 100644
index 0000000..7b2a80a
--- /dev/null
+++ b/components/org.apache.stratos.mediator.autoscale/src/test/resources/loadbalancer.conf
@@ -0,0 +1,50 @@
+loadbalancer {
+ instances 1;
+ enable_autoscaler true;
+ # interval between two task executions in milliseconds
+ autoscaler_task_interval 5000;
+ # after an instance booted up, task will wait till this much of time and let the server started up
+ server_startup_delay 15000; #default will be 60000ms
+}
+
+services {
+ defaults {
+ min_app_instances 1;
+ max_app_instances 5;
+ max_requests_per_second 400;
+ alarming_upper_rate 0.65;
+ alarming_lower_rate 0.2;
+ scale_down_factor 0.25;
+ rounds_to_average 10;
+ instances_per_scale_up 1;
+ message_expiry_time 60000;
+ }
+
+ appserver {
+ hosts appserver.cloud-test.wso2.com, as.cloud-test.wso2.com;
+ sub_domain worker1;
+ domains {
+ wso2.as1.domain {
+ hosts as1.cloud-test.wso2.com;
+ min_app_instances 0;
+ sub_domain worker;
+ tenant_range 1-5;
+ }
+ wso2.as1.domain {
+ hosts mgt.as1.cloud-test.wso2.com;
+ min_app_instances 0;
+ sub_domain mgt;
+ tenant_range 1-5;
+ }
+ wso2.as2.domain {
+ hosts mgt.as2.cloud-test.wso2.com;
+ min_app_instances 0;
+ sub_domain mgt;
+ tenant_range 1-5;
+ }
+
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/pom.xml b/components/org.apache.stratos.tenant.activity.ui/pom.xml
new file mode 100644
index 0000000..ad3260a
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/pom.xml
@@ -0,0 +1,144 @@
+<?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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-components-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.tenant.activity.ui</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Stratos - Tenant Activity - User Interface</name>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Name>${project.artifactId}</Bundle-Name>
+ <Private-Package>
+ org.apache.stratos.tenant.activity.ui.internal.*,
+ </Private-Package>
+ <Export-Package>
+ org.apache.stratos.tenant.activity.ui.*,
+ </Export-Package>
+ <Import-Package>
+ org.wso2.carbon.tenant.activity.stub.*; version="${carbon.platform.package.import.version.range}",
+ org.apache.stratos.common.*,
+ javax.servlet;version="${imp.pkg.version.javax.servlet}",
+ javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+ !javax.xml.namespace,
+ javax.xml.namespace; version=0.0.0,
+ org.apache.lucene.*,
+ *;resolution:=optional
+ </Import-Package>
+ <Carbon-Component>UIBundle</Carbon-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec.wso2</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>${version.commons.codec}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.common.ui</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.registry.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>3.0.0.v201112011016</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2.wso2</groupId>
+ <artifactId>axis2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+ <artifactId>axiom</artifactId>
+ <version>${axiom.wso2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.ui</artifactId>
+ <version>${wso2carbon.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.common</artifactId>
+ <version>${apache.stratos.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.tenant.activity.stub</artifactId>
+ <version>4.1.0</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <version.commons.codec>1.4.0.wso2v1</version.commons.codec>
+ </properties>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/clients/TenantActivityServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/clients/TenantActivityServiceClient.java b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/clients/TenantActivityServiceClient.java
new file mode 100644
index 0000000..a7f3674
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/clients/TenantActivityServiceClient.java
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. 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.tenant.activity.ui.clients;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.authenticator.proxy.AuthenticationAdminClient;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.tenant.activity.stub.TenantActivityServiceExceptionException;
+import org.wso2.carbon.tenant.activity.stub.beans.xsd.*;
+import org.apache.stratos.tenant.activity.ui.internal.TenantActivityUIServiceComponent;
+import org.wso2.carbon.ui.CarbonUIUtil;
+import org.wso2.carbon.user.core.UserStoreException;
+import org.wso2.carbon.utils.ServerConstants;
+import org.wso2.carbon.tenant.activity.stub.TenantActivityServiceStub;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+import java.rmi.RemoteException;
+
+public class TenantActivityServiceClient {
+ private static final Log log = LogFactory.getLog(TenantActivityServiceClient.class);
+
+ private TenantActivityServiceStub stub;
+ private String epr;
+
+
+ public TenantActivityServiceClient(
+ String cookie, String backendServerURL, ConfigurationContext configContext)
+ throws RegistryException {
+
+ epr = backendServerURL + "TenantMonitorService";
+
+ try {
+ stub = new TenantActivityServiceStub(configContext, epr);
+ ServiceClient client = stub._getServiceClient();
+ Options option = client.getOptions();
+ option.setManageSession(true);
+ option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate TenantMonitorService service client. " + axisFault.getMessage();
+ log.error(msg, axisFault);
+ throw new RegistryException(msg, axisFault);
+ }
+ }
+
+ public TenantActivityServiceClient(ServletConfig config, HttpSession session)
+ throws RegistryException {
+ String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+ String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+ ConfigurationContext configContext = (ConfigurationContext) config.
+ getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+ epr = backendServerURL + "TenantActivityService";
+
+ try {
+ stub = new TenantActivityServiceStub(configContext, epr);
+
+ ServiceClient client = stub._getServiceClient();
+ Options option = client.getOptions();
+ option.setManageSession(true);
+ option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate TenantMonitorService service client. " + axisFault.getMessage();
+ log.error(msg, axisFault);
+ throw new RegistryException(msg, axisFault);
+ }
+ }
+
+ public TenantActivityServiceClient(String url, ServletConfig config, HttpSession session)
+ throws Exception {
+ //String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+ ConfigurationContext configContext = (ConfigurationContext) config.
+ getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+ try {
+ String cookie = login(url + "/services/",
+ TenantActivityUIServiceComponent.stratosConfiguration.getAdminUserName(),
+ TenantActivityUIServiceComponent.stratosConfiguration.getAdminPassword(),
+ configContext);
+ epr = url + "/services/TenantActivityService";
+ stub = new TenantActivityServiceStub(configContext, epr);
+ ServiceClient client = stub._getServiceClient();
+ Options option = client.getOptions();
+ option.setManageSession(true);
+ option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie);
+
+ } catch (AxisFault axisFault) {
+ String msg = "Failed to initiate TenantMonitorService service client. ";
+ log.error(msg, axisFault);
+ throw new RegistryException(msg, axisFault);
+ }
+ }
+
+
+ public int getActiveTenantCount() throws TenantActivityServiceExceptionException, RemoteException {
+ int count = stub.getActiveTenantCount();
+ return count;
+ }
+
+ /*public String[] getActiveTenantList() throws TenantActivityServiceExceptionException, RemoteException {
+ return stub.getActiveTenantList();
+ } */
+
+ public PaginatedTenantDataBean getPaginatedActiveTenantList(int pageNumber) throws TenantActivityServiceExceptionException, RemoteException {
+ return stub.retrievePaginatedActiveTenants(pageNumber);
+ }
+
+ /* public TenantDataBean[] getAllActiveTenantList() throws TenantActivityServiceExceptionException, RemoteException {
+ return stub.getAllActiveTenantList();
+ }*/
+
+ public boolean isTenantActiveInService(String domainName) throws TenantActivityServiceExceptionException, RemoteException {
+ return stub.isActiveTenantOnService(domainName);
+ }
+
+ private String login(String serverUrl, String userName,
+ String password, ConfigurationContext confContext) throws UserStoreException {
+ String sessionCookie = null;
+ try {
+ AuthenticationAdminClient client =
+ new AuthenticationAdminClient(confContext, serverUrl, null, null, false);
+ //TODO : get the correct IP
+ boolean isLogin = client.login(userName, password, "127.0.0.1");
+ if (isLogin) {
+ sessionCookie = client.getAdminCookie();
+ }
+ } catch (Exception e) {
+ throw new UserStoreException("Error in login to the server server: " + serverUrl +
+ "username: " + userName + ".", e);
+ }
+ return sessionCookie;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/internal/TenantActivityUIServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/internal/TenantActivityUIServiceComponent.java b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/internal/TenantActivityUIServiceComponent.java
new file mode 100644
index 0000000..d8c8eea
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/internal/TenantActivityUIServiceComponent.java
@@ -0,0 +1,55 @@
+package org.apache.stratos.tenant.activity.ui.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+import org.apache.stratos.common.util.StratosConfiguration;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+/**
+ * @scr.component name="org.wso2.stratos.tenant.activity.ui" immediate="true"
+ * @scr.reference name="config.context.service"
+ * interface="org.wso2.stratos.utils.ConfigurationContextService"
+ * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService"
+ * unbind="unsetConfigurationContextService"
+ * @scr.reference name="stratos.config.service"
+ * interface="org.wso2.stratos.stratos.common.util.StratosConfiguration" cardinality="1..1"
+ * policy="dynamic" bind="setStratosConfigurationService" unbind="unsetStratosConfigurationService"
+ */
+public class TenantActivityUIServiceComponent {
+ private static Log log = LogFactory.getLog(TenantActivityUIServiceComponent.class);
+ public static ConfigurationContextService contextService;
+ public static StratosConfiguration stratosConfiguration;
+
+ protected void activate(ComponentContext context) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.error("******* Tenant Activity UI bundle is activated ******* ");
+ }
+ } catch (Throwable e) {
+ log.error("******* Error in activating Tenant Activity UI bundle ******* ", e);
+ }
+ }
+
+ protected void deactivate(ComponentContext context) {
+ if (log.isDebugEnabled()) {
+ log.debug("******* Tenant Activity UI bundle is deactivated ******* ");
+ }
+ }
+
+ protected void setStratosConfigurationService(StratosConfiguration stratosConfigService) {
+ TenantActivityUIServiceComponent.stratosConfiguration = stratosConfigService;
+ }
+
+ protected void unsetStratosConfigurationService(StratosConfiguration ccService) {
+ TenantActivityUIServiceComponent.stratosConfiguration = null;
+ }
+
+ protected void setConfigurationContextService(ConfigurationContextService contextService) {
+ TenantActivityUIServiceComponent.contextService = contextService;
+ }
+
+ protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
+ TenantActivityUIServiceComponent.contextService = null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/ManagerConfigurations.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/ManagerConfigurations.java b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/ManagerConfigurations.java
new file mode 100644
index 0000000..294cb15
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/ManagerConfigurations.java
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+*
+* WSO2 Inc. 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.tenant.activity.ui.utils;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.common.util.CommonUtil;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+public class ManagerConfigurations {
+
+ private static final String CONFIG_FILE = "throttling-agent-config.xml";
+
+ private static final String MANAGER_SERVICE_URL_PARAM_NAME = "managerServiceUrl";
+ private static final String USERNAME_PARAM_NAME = "userName";
+ private static final String PASSWORD_PARAM_NAME = "password";
+
+
+ private String managerServerUrl;
+ private String userName;
+ private String password;
+
+ private final static Log log = LogFactory.getLog(ManagerConfigurations.class);
+
+ private static final String CONFIG_NS =
+ "http://wso2.com/stratos/multitenancy/throttling/agent/config";
+ private static final String PARAMTERS_ELEMENT_NAME = "parameters";
+ private static final String PARAMTER_ELEMENT_NAME = "parameter";
+ private static final String PARAMTER_NAME_ATTR_NAME = "name";
+ private Map<String, String> parameters = new HashMap<String, String>();
+
+
+
+
+ public String getConfigFileName() throws Exception {
+
+ String configFileName = CarbonUtils.getCarbonConfigDirPath() +
+ File.separator + StratosConstants.MULTITENANCY_CONFIG_FOLDER +
+ File.separator + CONFIG_FILE;
+
+ return configFileName;
+
+ }
+
+
+ public ManagerConfigurations() throws Exception {
+
+ String throttlingAgentConfigFile = this.getConfigFileName();
+ try {
+ OMElement meteringConfig =
+ CommonUtil.buildOMElement(new FileInputStream(throttlingAgentConfigFile));
+ deSerialize(meteringConfig);
+ Map<String, String> throttlingAgentParams = getParameters();
+ this.setUserName(throttlingAgentParams.get(USERNAME_PARAM_NAME));
+ this.setPassword(throttlingAgentParams.get(PASSWORD_PARAM_NAME));
+ this.setManagerServerUrl(throttlingAgentParams.get(MANAGER_SERVICE_URL_PARAM_NAME));
+ } catch (FileNotFoundException e) {
+ String msg = "Unable to find the file: " + throttlingAgentConfigFile + ".";
+ log.error(msg, e);
+ }
+ }
+
+ public void deSerialize(OMElement throttlingConfigEle) throws Exception {
+ Iterator meteringConfigChildIt = throttlingConfigEle.getChildElements();
+ while (meteringConfigChildIt.hasNext()) {
+ Object meteringConfigChild = meteringConfigChildIt.next();
+ if (!(meteringConfigChild instanceof OMElement)) {
+ continue;
+ }
+ OMElement meteringConfigChildEle = (OMElement) meteringConfigChild;
+ if (new QName(CONFIG_NS, PARAMTERS_ELEMENT_NAME, "").equals(meteringConfigChildEle
+ .getQName())) {
+ Iterator parametersChildIt = meteringConfigChildEle.getChildElements();
+ while (parametersChildIt.hasNext()) {
+ Object taskConfigChild = parametersChildIt.next();
+ if (!(taskConfigChild instanceof OMElement)) {
+ continue;
+ }
+ OMElement parameterChildEle = (OMElement) taskConfigChild;
+ if (!new QName(CONFIG_NS, PARAMTER_ELEMENT_NAME, "").equals(parameterChildEle
+ .getQName())) {
+ continue;
+ }
+ String parameterName =
+ parameterChildEle.getAttributeValue(new QName(PARAMTER_NAME_ATTR_NAME));
+ String parameterValue = parameterChildEle.getText();
+ parameters.put(parameterName, parameterValue);
+ }
+ }
+ }
+ }
+
+ public Map<String, String> getParameters() {
+ return parameters;
+ }
+
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getManagerServerUrl() {
+ return managerServerUrl;
+ }
+
+ public void setManagerServerUrl(String managerServerUrl) {
+ this.managerServerUrl = managerServerUrl;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/TenantMonitorUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/TenantMonitorUtil.java b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/TenantMonitorUtil.java
new file mode 100644
index 0000000..54d9c83
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/java/org/apache/stratos/tenant/activity/ui/utils/TenantMonitorUtil.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2005-2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. 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.tenant.activity.ui.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.config.CloudServiceConfig;
+import org.apache.stratos.common.config.CloudServiceConfigParser;
+import org.apache.stratos.common.config.CloudServicesDescConfig;
+
+import java.util.*;
+
+import org.wso2.carbon.tenant.activity.stub.beans.xsd.PaginatedTenantDataBean;
+import org.wso2.carbon.tenant.activity.stub.beans.xsd.TenantDataBean;
+
+public class TenantMonitorUtil {
+ private static final Log log = LogFactory.getLog(TenantMonitorUtil.class);
+
+ public static Map<String, String[]> tenantList = new HashMap<String, String[]>();
+ public static Map<String, TenantDataBean[]> tenantDataList = new HashMap<String, TenantDataBean[]>();
+
+
+ private static ManagerConfigurations managerConfig = null;
+
+
+ public static ManagerConfigurations getManagerConfig() {
+ return managerConfig;
+ }
+
+ public static void setManagerConfig(ManagerConfigurations managerConfig) {
+ TenantMonitorUtil.managerConfig = managerConfig;
+ }
+
+ /* public static Map<String, Integer> getActiveTenantCount(ServletConfig config, HttpSession session) throws Exception {
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ try {
+ CloudServicesDescConfig cloudServicesDescConfig = CloudServiceConfigParser.loadCloudServicesConfiguration();
+
+ Map<String, CloudServiceConfig> cloudServicesConfigs = cloudServicesDescConfig.getCloudServiceConfigs();
+ for (String serviceName : cloudServicesConfigs.keySet()) {
+ String backEndURL = cloudServicesConfigs.get(serviceName).getLink();
+ System.out.println(backEndURL);
+ if (backEndURL == null) {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(config, session);
+ map.put(serviceName, client.getActiveTenantCount());
+ for (String nn : client.getActiveTenantList()) {
+ System.out.println(nn);
+ }
+ } catch (Exception e) {
+ log.error("Failed to get active tenants for manager service");
+ }
+
+ } else {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(backEndURL, config, session);
+ map.put(serviceName, client.getActiveTenantCount());
+ } catch (Exception e) {
+ log.error("failed to get Active tenants for" + serviceName + e.toString());
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ log.error("Error while retrieving cloud desc configuration");
+
+ }
+ return map;
+ }*/
+
+ public static Map<String, CloudServiceConfig> getCloudServiceConfigMap() {
+ try {
+ CloudServicesDescConfig cloudServicesDescConfig = CloudServiceConfigParser.loadCloudServicesConfiguration();
+ return cloudServicesDescConfig.getCloudServiceConfigs();
+ } catch (Exception e) {
+ log.error("Error while getting service names " + e.toString());
+ }
+ return null;
+ }
+
+ public static PaginatedTenantDataBean getPaginatedTenantData(int pageNumber, String serviceName) {
+ int entriesPerPage = 15;
+ List<TenantDataBean> tenantListOnService = Arrays.asList(tenantDataList.get(serviceName));
+ List<TenantDataBean> tenantUsages = new ArrayList<TenantDataBean>();
+ int i = 0;
+ int numberOfPages = 0;
+ for (TenantDataBean tenant : tenantListOnService) {
+ if (i % entriesPerPage == 0) {
+ numberOfPages++;
+ }
+ if (numberOfPages == pageNumber) {
+ tenantUsages.add(tenant);
+ }
+ i++;
+
+ }
+ PaginatedTenantDataBean paginatedTenantInfo = new PaginatedTenantDataBean();
+ paginatedTenantInfo.setTenantInfoBeans(
+ tenantUsages.toArray(new TenantDataBean[tenantUsages.size()]));
+ paginatedTenantInfo.setNumberOfPages(numberOfPages);
+ return paginatedTenantInfo;
+ }
+
+ public static boolean isTenantActiveOnService(String serviceName, String domain) {
+ boolean status = false;
+ for (TenantDataBean tenantBean : tenantDataList.get(serviceName)) {
+ if (tenantBean.getDomain().equalsIgnoreCase(domain)) {
+ status = true;
+ }
+ }
+ return status;
+ }
+
+ public static Map<String, String> getAdminParameters() {
+ Map<String, String> adminParameters = new HashMap<String, String>();
+ if (managerConfig == null) {
+ try {
+ managerConfig = new ManagerConfigurations();
+ } catch (Exception e) {
+ log.error("Failed to get administrator credentials" + e.toString());
+ }
+ }
+ adminParameters.put("userName", managerConfig.getUserName());
+ adminParameters.put("password", managerConfig.getPassword());
+ return adminParameters;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/META-INF/component.xml
new file mode 100644
index 0000000..a163b36
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/META-INF/component.xml
@@ -0,0 +1,35 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ -->
+<component xmlns="http://products.wso2.org/carbon">
+ <!-- sample menu configuration -->
+ <menus>
+ <menu>
+ <id>all_tenant_monitor_menu</id>
+ <i18n-key>Tenant Activity Monitor</i18n-key>
+ <i18n-bundle>org.wso2.carbon.tenant.activity.ui.i18n.Resources</i18n-bundle>
+ <parent-menu>monitor_menu</parent-menu>
+ <link>../tenant-activity/tenant-activity.jsp</link>
+ <region>region4</region>
+ <order>50</order>
+ <style-class>manage</style-class>
+ <icon>../tenant-activity/images/tenant-usage-report.gif</icon>
+ <require-permission>/permission/protected/monitor/userUsage</require-permission>
+ <require-super-tenant>true</require-super-tenant>
+ </menu>
+ </menus>
+</component>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/JSResources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/JSResources.properties b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/JSResources.properties
new file mode 100644
index 0000000..f038b96
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/JSResources.properties
@@ -0,0 +1 @@
+session.timed.out=Session timed out. Please login again
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/Resources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/Resources.properties b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/Resources.properties
new file mode 100644
index 0000000..85081f9
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/org/apache/stratos/tenant/activity/ui/i18n/Resources.properties
@@ -0,0 +1,11 @@
+service.name=Service Name
+active.user.count=Active User Count
+active.tenants.services= Active Tenants on Services
+view.list=View List
+active.tenant.count=Active Tenant Count
+active.tenants.on= Active Tenants on
+tenant.domain= Tenant Domain
+active.status=State
+enter.tenant.domain=Enter Tenant Domain
+tenant.status=Tenant State
+tenant.state.on.services.for.tenant= Tenant State on Services For Tenant Domain
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/css/tenant-usage.css
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/css/tenant-usage.css b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/css/tenant-usage.css
new file mode 100644
index 0000000..5c85728
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/css/tenant-usage.css
@@ -0,0 +1,28 @@
+.disableLink {
+ color: #aaaaaa;
+}
+
+.pageLinks {
+ background: #FFFFFF none repeat scroll 0%;
+ border: 1px solid #DDDDDD;
+ padding: 2px 3px;
+ text-decoration: none;
+ margin: 0px;
+ margin-left: 2px;
+ margin-right: 2px;
+}
+
+.pageLinks-selected {
+ background: #e8e9ae none repeat scroll 0%;
+ border: 1px solid #DDDDDD;
+ padding: 2px 3px;
+ text-decoration: none;
+ margin: 0px;
+ margin-left: 2px;
+ margin-right: 2px;
+}
+
+a {
+ color: #386698;
+ cursor: pointer;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/images/view-usage.png
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/images/view-usage.png b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/images/view-usage.png
new file mode 100644
index 0000000..3d036c0
Binary files /dev/null and b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/images/view-usage.png differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/userguide.html
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/userguide.html b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/userguide.html
new file mode 100644
index 0000000..2c6a979
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/docs/userguide.html
@@ -0,0 +1,76 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you under the Apache License,
+ ~ Version 2.0 (the "License"); you may not use this file except
+ ~ in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>View Usage - User Guide</title>
+ <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" />
+</head>
+
+<body>
+<h1>View Usage</h1>
+
+<p>
+You can view usage of the stratos resource by your organization from this page
+</p>
+
+<p>
+<img src="images/view-usage.png" alt="View Usage"/>
+<div><strong>Figure1: View Usage</strong></div>
+</p>
+
+<p>
+
+<table>
+ <thead>
+ <td>
+ The Form Field
+ </td>
+ <td>
+ Description
+ </td>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Year-Month</td>
+ <td>The year and the month the usage is metered.</td>
+ </tr>
+ <tr>
+ <td>Number of Users</td>
+ <td>Number of users of your stratos account.</td>
+ </tr>
+ <tr>
+ <td>Active data storage</td>
+ <td>The registry data storage amount.</td>
+ </tr>
+ <tr>
+ <td>Registry Total Bandwidth</td>
+ <td>Total bandwidth consumed by the registry accesses.</td>
+ </tr>
+ <tr>
+ <td>Service Total Bandwidth</td>
+ <td>The bandwidth consumed by the web services.</td>
+ </tr>
+ </tbody>
+</table>
+
+</p>
+
+</body>
+
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant-ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant-ajaxprocessor.jsp b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant-ajaxprocessor.jsp
new file mode 100644
index 0000000..0c9a988
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant-ajaxprocessor.jsp
@@ -0,0 +1,59 @@
+<%--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ page import="org.json.JSONObject" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Invoice" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Payment" %>
+<%@ page import="org.wso2.carbon.billing.mgt.ui.utils.BillingUtil" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.clients.TenantActivityServiceClient" %>
+<%@ page import="java.io.Console" %>
+<%@ page import="javax.rmi.CORBA.Util" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.utils.TenantMonitorUtil" %>
+<%@ page import="org.wso2.carbon.tenant.activity.stub.beans.xsd.PaginatedTenantDataBean" %>
+
+<%
+ String serverUrl = request.getParameter("backEndUrl");
+ String serviceName = request.getParameter("serviceName");
+ String domainName = request.getParameter("domainName");
+
+ boolean state = false;
+ if (serverUrl == null || "null".equals(serverUrl.trim())) {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(config, session);
+ state = client.isTenantActiveInService(domainName);
+ } catch (Exception e) {
+ }
+
+ } else {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(serverUrl, config, session);
+ state = client.isTenantActiveInService(domainName);
+ } catch (Exception e) {
+ }
+ }
+
+ try {
+ JSONObject obj = new JSONObject();
+ obj.put("isActive", state);
+ obj.put("service", serviceName);
+ out.write(obj.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+%>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant.jsp b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant.jsp
new file mode 100644
index 0000000..d938710
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/find-tenant.jsp
@@ -0,0 +1,110 @@
+<!--
+~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+~
+~ WSO2 Inc. 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.
+-->
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="carbon" uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.utils.TenantMonitorUtil" %>
+<%@ page import="org.apache.stratos.common.config.CloudServiceConfig" %>
+<%@ page import="java.util.Map" %>
+<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+<script type="text/javascript" src="../ajax/js/prototype.js"></script>
+<script type="text/javascript" src="js/tenant_config.js"></script>
+
+<carbon:jsi18n
+ resourceBundle="org.wso2.carbon.tenant.activity.ui.i18n.JSResources"
+ request="<%=request%>"/>
+
+<fmt:bundle basename="org.wso2.carbon.tenant.activity.ui.i18n.Resources">
+ <carbon:breadcrumb
+ label="govern.view_tenants.menu"
+ resourceBundle="org.wso2.carbon.tenant.activity.ui.i18n.Resources"
+ topPage="true"
+ request="<%=request%>"/>
+ <%
+ String domainNameStr = request.getParameter("domain");
+ %>
+ <div id="middle">
+ <h2><fmt:message key="tenant.state.on.services.for.tenant"/> "<%=domainNameStr%>"</h2>
+
+ <div id="workArea">
+ <table id="activeStateTable" cellpadding="0" cellspacing="0" border="0" style="width:100%"
+ class="styledLeft">
+ <thead>
+ <tr>
+ <th style="padding-left:5px;text-align:left;width:40%"><fmt:message key="service.name"/></th>
+ <th style="padding-left:5px;text-align:left;"><fmt:message key="tenant.status"/></th>
+ </tr>
+ </thead>
+ </table>
+ </div>
+ </div>
+</fmt:bundle>
+<%
+ String domainName = request.getParameter("domain");
+ Map<String, CloudServiceConfig> cloudServicesConfigs = TenantMonitorUtil.getCloudServiceConfigMap();
+%>
+
+<script type="text/javascript">
+
+ function getStats() {
+ var serviceArray = new Array();
+ <%
+ for(String serviceName : cloudServicesConfigs.keySet()){
+ %>
+ var serviceObj = new Object();
+ serviceObj.backEndUrl = '<%=cloudServicesConfigs.get(serviceName).getLink()%>';
+ serviceObj.serviceName = '<%=serviceName%>';
+ serviceObj.domainName = '<%=domainName%>';
+ serviceArray.push(serviceObj);
+ <% }
+ %>
+
+ for (var i = 0; i < serviceArray.length; i++) {
+
+ jQuery.ajax({
+ type: 'GET',
+ url: 'find-tenant-ajaxprocessor.jsp',
+ data: 'backEndUrl=' + serviceArray[i].backEndUrl + '&serviceName=' + serviceArray[i].serviceName + '&domainName=' + serviceArray[i].domainName,
+ dataType: 'json',
+ async: true,
+ success: function(msg) {
+ var resp = msg;
+ var active = 'Active';
+ var inActive = 'Inactive';
+ if (resp.isActive === true) {
+ document.getElementById('activeStateTable').innerHTML += '<tr><td>' + resp.service + '</td><td>' + active + '</td></tr>';
+ }
+ else {
+ document.getElementById('activeStateTable').innerHTML += '<tr><td>' + resp.service + '</td><td>' + inActive + '</td></tr>';
+ }
+ },
+ error:function () {
+ CARBON.showErrorDialog('Could not connect to server');
+ //document.getElementById('serviceStatTable').innerHTML += '<tr><td>' + eresp.servic + '</td><td>' + resp.count + '</td></tr>';
+ document.getElementById('activeStateTable').innerHTML += 'Not Available';
+ }
+ });
+ }
+ }
+</script>
+
+<body onload="getStats();">
+<div>
+</div>
+</body>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/get-data-ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/get-data-ajaxprocessor.jsp b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/get-data-ajaxprocessor.jsp
new file mode 100644
index 0000000..15f558b
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/get-data-ajaxprocessor.jsp
@@ -0,0 +1,66 @@
+<%--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. 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.
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ page import="org.json.JSONObject" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Invoice" %>
+<%@ page import="org.wso2.carbon.billing.mgt.stub.beans.xsd.Payment" %>
+<%@ page import="org.wso2.carbon.billing.mgt.ui.utils.BillingUtil" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.clients.TenantActivityServiceClient" %>
+<%@ page import="java.io.Console" %>
+<%@ page import="javax.rmi.CORBA.Util" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.utils.TenantMonitorUtil" %>
+<%@ page import="org.wso2.carbon.tenant.activity.stub.beans.xsd.PaginatedTenantDataBean" %>
+
+<%
+ String serverUrl = request.getParameter("backEndUrl");
+ String serviceName = request.getParameter("serviceName");
+
+
+ int count = 0;
+ if (serverUrl == null || "null".equals(serverUrl.trim())) {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(config, session);
+ // TenantMonitorUtil.tenantDataList.put(serviceName, client.getAllActiveTenantList());
+ count=client.getActiveTenantCount();
+ } catch (Exception e) {
+ }
+
+ } else {
+ try {
+ TenantActivityServiceClient client = new TenantActivityServiceClient(serverUrl, config, session);
+ // count = client.getAllActiveTenantList().length;
+ count=client.getActiveTenantCount();
+ if (count > 0) {
+ // TenantMonitorUtil.tenantDataList.put(serviceName, client.getAllActiveTenantList());
+ } else {
+ TenantMonitorUtil.tenantDataList.put(serviceName, null);
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ try {
+ JSONObject obj = new JSONObject();
+ obj.put("count", count);
+ obj.put("service", serviceName);
+ out.write(obj.toString());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+%>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/instance-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/instance-usage-report.gif b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/instance-usage-report.gif
new file mode 100644
index 0000000..4a1ae6a
Binary files /dev/null and b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/instance-usage-report.gif differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/search.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/search.gif b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/search.gif
new file mode 100644
index 0000000..cfe76b5
Binary files /dev/null and b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/search.gif differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/tenant-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/tenant-usage-report.gif b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/tenant-usage-report.gif
new file mode 100644
index 0000000..a9b04e2
Binary files /dev/null and b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/tenant-usage-report.gif differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/user-usage-report.gif
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/user-usage-report.gif b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/user-usage-report.gif
new file mode 100644
index 0000000..9070c35
Binary files /dev/null and b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/images/user-usage-report.gif differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/show-active-tenants.jsp
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/show-active-tenants.jsp b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/show-active-tenants.jsp
new file mode 100644
index 0000000..7f9e0cc
--- /dev/null
+++ b/components/org.apache.stratos.tenant.activity.ui/src/main/resources/web/tenant-activity/show-active-tenants.jsp
@@ -0,0 +1,129 @@
+<!--
+~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+~
+~ WSO2 Inc. 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.
+-->
+<%@ page import="java.util.List" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.clients.TenantActivityServiceClient" %>
+<%@ page import="org.wso2.carbon.tenant.activity.ui.utils.TenantMonitorUtil" %>
+<%@ page import="java.util.Map" %>
+<%@ page import="org.wso2.carbon.tenant.reg.agent.client.util.Util" %>
+<%@ page import="org.apache.stratos.common.config.CloudServiceConfig" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
+<%@ page import="org.wso2.carbon.CarbonConstants" %>
+<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
+<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.Calendar" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="org.wso2.carbon.tenant.activity.stub.TenantActivityServiceStub" %>
+<%@ page import="org.wso2.carbon.tenant.activity.stub.beans.xsd.TenantDataBean" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/>
+<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script>
+<script type="text/javascript" src="../registry_common/js/registry_common.js"></script>
+<script type="text/javascript" src="../ajax/js/prototype.js"></script>
+<script type="text/javascript" src="js/tenant_config.js"></script>
+
+<carbon:jsi18n
+ resourceBundle="org.wso2.carbon.tenant.activity.ui.i18n.JSResources"
+ request="<%=request%>"/>
+
+<fmt:bundle basename="org.wso2.carbon.tenant.activity.ui.i18n.Resources">
+ <carbon:breadcrumb
+ label="govern.view_tenants.menu"
+ resourceBundle="org.wso2.carbon.tenant.activity.ui.i18n.Resources"
+ topPage="true"
+ request="<%=request%>"/>
+ <%
+ String serviceNameStr = request.getParameter("serviceName");
+ %>
+
+ <div id="middle">
+ <h2><fmt:message key="active.tenants.on"/> <%=serviceNameStr%>
+ </h2>
+
+ <div id="workArea">
+ <table id="serviceStatTable1" cellpadding="0" cellspacing="0" border="0" style="width:100%"
+ class="styledLeft">
+ <thead>
+ <tr>
+ <th style="padding-left:5px;text-align:left;width:30%"><fmt:message key="tenant.domain"/></th>
+ <th style="padding-left:5px;text-align:left;"><fmt:message
+ key="active.status"/></th>
+ </tr>
+ </thead>
+ <tbody>
+ <%
+ String pageNumberStr = request.getParameter("pageNumber");
+ if (pageNumberStr == null) {
+ pageNumberStr = "0";
+
+ }
+ int pageNumber = 1;
+ try {
+ pageNumber = Integer.parseInt(pageNumberStr);
+ } catch (NumberFormatException ignored) {
+ // page number format exception
+ }
+ int numberOfPages = 1;
+ try {
+ String backEndUrl = TenantMonitorUtil.getCloudServiceConfigMap().get(request.getParameter("serviceName")).getLink();
+ TenantActivityServiceClient client;
+ if (backEndUrl == null || "null".equals(backEndUrl.trim())) {
+ client = new TenantActivityServiceClient(config, session);
+ } else {
+ client = new TenantActivityServiceClient(backEndUrl, config, session);
+ }
+ for (TenantDataBean bean : client.getPaginatedActiveTenantList(pageNumber).getTenantInfoBeans()) {
+ %>
+ <tr>
+ <td><%=bean.getDomain()%>
+ </td>
+ <td>Active</td>
+ </tr>
+ <%
+ }
+ } catch (Exception e) {
+ %>
+ <tr>
+ <td>No Data Available for this Service</td>
+ </tr>
+ <% }
+ String reDirectPage = "show-active-tenants.jsp?serviceName=" + serviceNameStr + "&";
+ %>
+ <carbon:paginator pageNumber="<%=pageNumber%>" numberOfPages="<%=numberOfPages%>"
+ page="<%=reDirectPage%>" pageNumberParameterName="pageNumber"/>
+ </tbody>
+ </table>
+ <input type='hidden' name='serviceName' id="serviceName"/>
+ </div>
+ </div>
+</fmt:bundle>
+
+<script type="text/javascript">
+
+ function getStats() {
+ console.log("In the getStat() function");
+
+ }
+ function showTenants(serviceNameKey) {
+ }
+</script>