You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/03 11:19:40 UTC
[3/5] refactoring cartridge agent - adding org.apache
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/java/org/apache/stratos/cartridge/agent/service/CartridgeAgentService.java
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/java/org/apache/stratos/cartridge/agent/service/CartridgeAgentService.java b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/java/org/apache/stratos/cartridge/agent/service/CartridgeAgentService.java
new file mode 100644
index 0000000..2136164
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/java/org/apache/stratos/cartridge/agent/service/CartridgeAgentService.java
@@ -0,0 +1,68 @@
+/**
+ * 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.cartridge.agent.service;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cartridge.agent.ClusteringClient;
+import org.apache.stratos.cartridge.agent.exception.CartridgeAgentException;
+import org.apache.stratos.cartridge.agent.internal.CartridgeAgentConstants;
+import org.apache.stratos.cartridge.agent.internal.DataHolder;
+import org.apache.stratos.cartridge.agent.registrant.Registrant;
+
+/**
+ * Web service used for allowing {@link Registrant}s to register themselves with the Cartridge Agent
+ *
+ * @see Registrant
+ */
+@SuppressWarnings("unused")
+public class CartridgeAgentService {
+ private static final Log log = LogFactory.getLog(CartridgeAgentService.class);
+
+ public boolean register(Registrant registrant) throws CartridgeAgentException {
+
+ MessageContext messageContext = MessageContext.getCurrentMessageContext();
+ ConfigurationContext configurationContext = messageContext.getConfigurationContext();
+ ClusteringClient clusteringClient =
+ (ClusteringClient) configurationContext.getProperty(CartridgeAgentConstants.CLUSTERING_CLIENT);
+ if (registrant.getRemoteHost() == null || registrant.getRemoteHost().isEmpty()) {
+ String remoteAddr = (String) messageContext.getProperty("REMOTE_ADDR");
+ registrant.setRemoteHost(remoteAddr);
+ }
+ log.info("Trying to add new registrant " + registrant + "...");
+ clusteringClient.joinGroup(registrant, configurationContext);
+// Main.getHealthChecker().start(registrant);
+ DataHolder.getHealthChecker().start(registrant);
+ return true;
+
+ }
+
+ public boolean unregister(String domain, String subDomain, String hostName) throws CartridgeAgentException {
+
+ MessageContext messageContext = MessageContext.getCurrentMessageContext();
+ ConfigurationContext configurationContext = messageContext.getConfigurationContext();
+ ClusteringClient clusteringClient =
+ (ClusteringClient) configurationContext.getProperty(CartridgeAgentConstants.CLUSTERING_CLIENT);
+ clusteringClient.removeClusterDomain(domain, subDomain, hostName, configurationContext);
+ return true;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/resources/META-INF/services.xml b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..1eb8777
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.agent/2.1.3/src/main/resources/META-INF/services.xml
@@ -0,0 +1,37 @@
+<!--
+ ~ 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.
+ ~
+ -->
+<serviceGroup>
+ <service name="CartridgeAgentService" scope="transportsession">
+ <transports>
+ <transport>https</transport>
+ </transports>
+ <description>
+ Admin service for ADC activities
+ </description>
+ <parameter name="ServiceClass">org.wso2.carbon.cartridge.agent.service.CartridgeAgentService
+ </parameter>
+ <parameter name="enableMTOM">true</parameter>
+ <parameter name="adminService" locked="true">false</parameter>
+ <parameter name="hiddenService" locked="true">false</parameter>
+ <parameter name="AuthorizationAction" locked="true">
+ /permission/admin/manage/modify/webapp </parameter>
+ <parameter name="DoAuthentication" locked="true">true</parameter>
+ </service>
+</serviceGroup>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/pom.xml b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/pom.xml
new file mode 100644
index 0000000..72ff502
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/pom.xml
@@ -0,0 +1,77 @@
+<?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>cartridge-agent-parent</artifactId>
+ <version>2.0.0</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.cartridge.messages</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.1.1</version>
+ <name>Apache Stratos Cartridge Agent - Messages</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.axis2.wso2</groupId>
+ <artifactId>axis2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </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>
+ <Export-Package>
+ org.apache.startos.cartridge.messages.*
+ </Export-Package>
+ <Import-Package>
+ !org.apache.commons.logging,
+ org.apache.commons.logging; version=0.0.0,
+ *; resolution:=optional
+ </Import-Package>
+ <DynamicImport-Package>*</DynamicImport-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomain.java
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomain.java b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomain.java
new file mode 100644
index 0000000..d70d131
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomain.java
@@ -0,0 +1,117 @@
+/**
+ * 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.cartridge.messages;
+
+public class ClusterDomain {
+
+ private String domain;
+ private String subDomain;
+ private String hostName;
+ //private int tenantId;
+ private String tenantRange;
+ private int minInstances;
+ private int maxInstances;
+ private String serviceName;
+ private int maxRequestsPerSecond;
+ private int roundsToAverage;
+ private double alarmingUpperRate;
+ private double alarmingLowerRate;
+ private double scaleDownFactor;
+
+ public String getDomain() {
+ return domain;
+ }
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+ public String getSubDomain() {
+ return subDomain;
+ }
+ public void setSubDomain(String subDomain) {
+ this.subDomain = subDomain;
+ }
+ public String getHostName() {
+ return hostName;
+ }
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+ /*public int getTenantId() {
+ return tenantId;
+ }
+ public void setTenantId(int tenantId) {
+ this.tenantId = tenantId;
+ }*/
+ public int getMinInstances() {
+ return minInstances;
+ }
+ public void setMinInstances(int minInstances) {
+ this.minInstances = minInstances;
+ }
+ public int getMaxInstances() {
+ return maxInstances;
+ }
+ public void setMaxInstances(int maxInstances) {
+ this.maxInstances = maxInstances;
+ }
+ public String getServiceName() {
+ return serviceName;
+ }
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+ public String getTenantRange() {
+ return tenantRange;
+ }
+ public void setTenantRange(String tenantRange) {
+ this.tenantRange = tenantRange;
+ }
+ public int getMaxRequestsPerSecond() {
+ return maxRequestsPerSecond;
+ }
+ public void setMaxRequestsPerSecond(int maxRequestsPerSecond) {
+ this.maxRequestsPerSecond = maxRequestsPerSecond;
+ }
+ public int getRoundsToAverage() {
+ return roundsToAverage;
+ }
+ public void setRoundsToAverage(int roundsToAverage) {
+ this.roundsToAverage = roundsToAverage;
+ }
+ public double getAlarmingUpperRate() {
+ return alarmingUpperRate;
+ }
+ public void setAlarmingUpperRate(double alarmingUpperRate) {
+ this.alarmingUpperRate = alarmingUpperRate;
+ }
+ public double getAlarmingLowerRate() {
+ return alarmingLowerRate;
+ }
+ public void setAlarmingLowerRate(double alarmingLowerRate) {
+ this.alarmingLowerRate = alarmingLowerRate;
+ }
+ public double getScaleDownFactor() {
+ return scaleDownFactor;
+ }
+ public void setScaleDownFactor(double scaleDownFactor) {
+ this.scaleDownFactor = scaleDownFactor;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomainManager.java
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomainManager.java b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomainManager.java
new file mode 100644
index 0000000..cdea820
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/ClusterDomainManager.java
@@ -0,0 +1,35 @@
+/**
+ * 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.cartridge.messages;
+
+/**
+ * TODO: class description
+ */
+public interface ClusterDomainManager {
+
+ void addClusterDomain(ClusterDomain clusterDomain);
+
+ /**
+ * This will remove the corresponding ServiceConfiguration.
+ * @param domain
+ * @param subDomain
+ * @param hostName
+ */
+ void removeClusterDomain(String domain, String subDomain, String hostName);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateClusterDomainMessage.java
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateClusterDomainMessage.java b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateClusterDomainMessage.java
new file mode 100644
index 0000000..7c54a8d
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateClusterDomainMessage.java
@@ -0,0 +1,129 @@
+/**
+ * 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.cartridge.messages;
+
+import org.apache.axis2.clustering.ClusteringCommand;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.ClusteringMessage;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * TODO: class description
+ */
+public class CreateClusterDomainMessage extends ClusteringMessage {
+ private static final Log log = LogFactory.getLog(CreateClusterDomainMessage.class);
+ public static final String CLUSTER_DOMAIN_MANAGER = "cluster.domain.manager";
+ private String service;
+ private String clusterDomain;
+ private String hostName;
+ //private int tenantId;
+ private String tenantRange;
+ private int minInstances;
+ private int maxInstances;
+ private int maxRequestsPerSecond;
+ private int roundsToAverage;
+ private double alarmingUpperRate;
+ private double alarmingLowerRate;
+ private double scaleDownFactor;
+
+
+ public CreateClusterDomainMessage(String service, String clusterDomain,
+ String hostName, String tenantRange,
+ int minInstances, int maxInstances,
+ int maxRequestsPerSecond, int roundsToAverage,
+ double alarmingUpperRate, double alarmingLowerRate,
+ double scaleDownFactor) {
+ this.service = service;
+ this.clusterDomain = clusterDomain;
+ this.hostName = hostName;
+ this.tenantRange = tenantRange;
+ this.minInstances = minInstances;
+ this.maxInstances = maxInstances;
+ this.maxRequestsPerSecond = maxRequestsPerSecond;
+ this.roundsToAverage = roundsToAverage;
+ this.alarmingUpperRate = alarmingUpperRate;
+ this.alarmingLowerRate = alarmingLowerRate;
+ this.scaleDownFactor = scaleDownFactor;
+ }
+
+ @Override
+ public ClusteringCommand getResponse() {
+ return new ClusteringCommand() {
+ @Override
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ log.info("Received response to CreateClusterDomainMessage");
+ }
+ };
+ }
+
+ @Override
+ public void execute(final ConfigurationContext configurationContext) throws ClusteringFault {
+ log.info("Received ***" + this);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ ClusterDomainManager clusterDomainManager =
+ (ClusterDomainManager) configurationContext.getProperty(CLUSTER_DOMAIN_MANAGER);
+ if (clusterDomainManager != null) {
+ clusterDomainManager.addClusterDomain(createClusterDomain());
+ } else {
+ log.warn(CLUSTER_DOMAIN_MANAGER + " has not been defined in ConfigurationContext");
+ }
+ }
+
+ private ClusterDomain createClusterDomain() {
+
+ ClusterDomain clusterDomainObj = new ClusterDomain();
+ clusterDomainObj.setDomain(clusterDomain);
+ clusterDomainObj.setHostName(hostName);
+ clusterDomainObj.setMaxInstances(maxInstances);
+ clusterDomainObj.setMinInstances(minInstances);
+ clusterDomainObj.setSubDomain(null); // TODO subdomain
+ clusterDomainObj.setTenantRange(tenantRange);
+ clusterDomainObj.setServiceName(service);
+ clusterDomainObj.setMaxRequestsPerSecond(maxRequestsPerSecond);
+ clusterDomainObj.setRoundsToAverage(roundsToAverage);
+ clusterDomainObj.setAlarmingUpperRate(alarmingUpperRate);
+ clusterDomainObj.setAlarmingLowerRate(alarmingLowerRate);
+ clusterDomainObj.setScaleDownFactor(scaleDownFactor);
+
+ if(log.isDebugEnabled())
+ log.debug("Cluster Domain is created with minInstances:" + minInstances + ", maxInstances: " + maxInstances);
+
+ return clusterDomainObj;
+ }
+ };
+ new Thread(runnable).start();
+ }
+
+ @Override
+ public String toString() {
+ return "CreateClusterDomainMessage{" +
+ "service='" + service + '\'' +
+ ", clusterDomain='" + clusterDomain + '\'' +
+ ", hostName='" + hostName + '\'' +
+ ", tenantId=" + tenantRange +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/091701b3/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateRemoveClusterDomainMessage.java
----------------------------------------------------------------------
diff --git a/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateRemoveClusterDomainMessage.java b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateRemoveClusterDomainMessage.java
new file mode 100644
index 0000000..b154424
--- /dev/null
+++ b/components/stratos/cartridge-agent/org.apache.stratos.cartridge.messages/2.1.1/src/main/java/org/apache/stratos/cartridge/messages/CreateRemoveClusterDomainMessage.java
@@ -0,0 +1,77 @@
+/**
+ * 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.cartridge.messages;
+
+import org.apache.axis2.clustering.ClusteringCommand;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.ClusteringMessage;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CreateRemoveClusterDomainMessage extends ClusteringMessage{
+
+ private static final Log log = LogFactory.getLog(CreateClusterDomainMessage.class);
+ public static final String CLUSTER_DOMAIN_MANAGER = "cluster.domain.manager";
+ private String domain;
+ private String subDomain;
+ private String hostName;
+
+
+
+ public CreateRemoveClusterDomainMessage(String domain, String subDomain, String hostName) {
+ this.domain = domain;
+ this.subDomain = subDomain;
+ this.hostName = hostName;
+ }
+
+ @Override
+ public ClusteringCommand getResponse() {
+ return new ClusteringCommand() {
+ @Override
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ log.info("Received response to CreateRemoveClusterDomainMessage");
+ }
+ };
+ }
+
+ @Override
+ public void execute(final ConfigurationContext configurationContext) throws ClusteringFault {
+
+ log.info("Received ***" + this);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) {
+ }
+ ClusterDomainManager clusterDomainManager =
+ (ClusterDomainManager) configurationContext.getProperty(CLUSTER_DOMAIN_MANAGER);
+ log.info(" ***** Received clusterDomain Manager ** " + clusterDomainManager);
+ if (clusterDomainManager != null) {
+ clusterDomainManager.removeClusterDomain(domain, subDomain, hostName);
+ } else {
+ log.warn(CLUSTER_DOMAIN_MANAGER + " has not been defined in ConfigurationContext");
+ }
+ }
+ };
+ new Thread(runnable).start();
+ }
+
+}