You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by az...@apache.org on 2009/02/16 13:03:45 UTC
svn commit: r744900 [1/3] - in /webservices/axis2/trunk/java/modules:
clustering/src/org/apache/axis2/clustering/
clustering/src/org/apache/axis2/clustering/configuration/
clustering/src/org/apache/axis2/clustering/context/
clustering/src/org/apache/ax...
Author: azeez
Date: Mon Feb 16 12:02:42 2009
New Revision: 744900
URL: http://svn.apache.org/viewvc?rev=744900&view=rev
Log:
There are 3 interfaces in the Axis2 clustering implementation.
1. ClusterManager
2. ContextManager
3. ConfigurationManager
Now I realize that these names are wrong. So we need to;
1. s/ClusterManager/NodeInitializer
2. s/ContextManager/StateReplicationManager
3. s/ConfigurationManager/NodeManager
ClusterManagement actually refers to management of an entire cluster,
which again can constitute several groups.
We can safely rename these interfaces since there is only a
single implementation at the moment.
We will also need to change the cluster config section in the axis2.xml
file. This will simply be changes to the element tag names. The
latest axis2.xml cluster configuration is very much different to that
shipped with axis2 1.4.1 since I've introduced several parameters to
give more cluster parameter configuration control to the user.
Added:
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultGroupManagementAgent.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultNodeManager.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/NodeManagementCommandFactory.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/RestartMemberCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/ShutdownMemberCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/ClusteringContextListener.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/DefaultStateManager.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/PropertyUpdater.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/StateClusteringCommandFactory.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceGroupStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/StateClusteringCommandCollection.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateConfigurationStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceGroupStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementInterceptor.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementMode.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusteringAgent.java
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/management/
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/management/ConfigurationManagerTestCase.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringAgent.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/management/
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/management/GroupManagementAgent.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/management/GroupManagementCommand.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/management/NodeManagementCommand.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/management/NodeManager.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/state/
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/state/Replicator.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/state/StateClusteringCommand.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/state/StateManager.java
Removed:
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/DefaultLoadBalanceEventHandler.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/configuration/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusterManager.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/LoadBalanceEventHandler.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/configuration/
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/
Modified:
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ClusterManagerTestCase.java
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/ContextReplicationTest.java
webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/ConfigurationManagerTest.java
webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringCommand.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisServer.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java?rev=744900&r1=744899&r2=744900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java Mon Feb 16 12:02:42 2009
@@ -19,11 +19,11 @@
package org.apache.axis2.clustering.control;
-import org.apache.axis2.clustering.ClusterManager;
+import org.apache.axis2.clustering.ClusteringAgent;
import org.apache.axis2.clustering.ClusteringFault;
-import org.apache.axis2.clustering.context.ContextClusteringCommand;
-import org.apache.axis2.clustering.context.ContextClusteringCommandFactory;
-import org.apache.axis2.clustering.context.ContextManager;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.clustering.state.StateClusteringCommandFactory;
+import org.apache.axis2.clustering.state.StateManager;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.context.ServiceGroupContext;
@@ -38,24 +38,24 @@
*/
public class GetStateCommand extends ControlCommand {
- private ContextClusteringCommand[] commands;
+ private StateClusteringCommand[] commands;
public void execute(ConfigurationContext configCtx) throws ClusteringFault {
- ClusterManager clusterManager = configCtx.getAxisConfiguration().getClusterManager();
- if(clusterManager == null){
+ ClusteringAgent clusteringAgent = configCtx.getAxisConfiguration().getClusteringAgent();
+ if(clusteringAgent == null){
return;
}
- ContextManager contextManager = clusterManager.getContextManager();
- if (contextManager != null) {
- Map excludedPropPatterns = contextManager.getReplicationExcludePatterns();
- List<ContextClusteringCommand> cmdList = new ArrayList<ContextClusteringCommand>();
+ StateManager stateManager = clusteringAgent.getStateManager();
+ if (stateManager != null) {
+ Map excludedPropPatterns = stateManager.getReplicationExcludePatterns();
+ List<StateClusteringCommand> cmdList = new ArrayList<StateClusteringCommand>();
// Add the service group contexts, service contexts & their respective properties
String[] sgCtxIDs = configCtx.getServiceGroupContextIDs();
for (String sgCtxID : sgCtxIDs) {
ServiceGroupContext sgCtx = configCtx.getServiceGroupContext(sgCtxID);
- ContextClusteringCommand updateServiceGroupCtxCmd =
- ContextClusteringCommandFactory.getUpdateCommand(sgCtx,
+ StateClusteringCommand updateServiceGroupCtxCmd =
+ StateClusteringCommandFactory.getUpdateCommand(sgCtx,
excludedPropPatterns,
true);
if (updateServiceGroupCtxCmd != null) {
@@ -64,8 +64,8 @@
if (sgCtx.getServiceContexts() != null) {
for (Iterator iter2 = sgCtx.getServiceContexts(); iter2.hasNext();) {
ServiceContext serviceCtx = (ServiceContext) iter2.next();
- ContextClusteringCommand updateServiceCtxCmd =
- ContextClusteringCommandFactory.getUpdateCommand(serviceCtx,
+ StateClusteringCommand updateServiceCtxCmd =
+ StateClusteringCommandFactory.getUpdateCommand(serviceCtx,
excludedPropPatterns,
true);
if (updateServiceCtxCmd != null) {
@@ -75,20 +75,20 @@
}
}
- ContextClusteringCommand updateCmd =
- ContextClusteringCommandFactory.getUpdateCommand(configCtx,
+ StateClusteringCommand updateCmd =
+ StateClusteringCommandFactory.getUpdateCommand(configCtx,
excludedPropPatterns,
true);
if (updateCmd != null) {
cmdList.add(updateCmd);
}
if (!cmdList.isEmpty()) {
- commands = cmdList.toArray(new ContextClusteringCommand[cmdList.size()]);
+ commands = cmdList.toArray(new StateClusteringCommand[cmdList.size()]);
}
}
}
- public ContextClusteringCommand[] getCommands() {
+ public StateClusteringCommand[] getCommands() {
return commands;
}
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java?rev=744900&r1=744899&r2=744900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java Mon Feb 16 12:02:42 2009
@@ -21,7 +21,7 @@
import org.apache.axis2.clustering.ClusteringConstants;
import org.apache.axis2.clustering.ClusteringFault;
-import org.apache.axis2.clustering.context.ContextClusteringCommand;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,7 +33,7 @@
private static final Log log = LogFactory.getLog(GetStateResponseCommand.class);
- private ContextClusteringCommand[] commands;
+ private StateClusteringCommand[] commands;
public void execute(ConfigurationContext configContext) throws ClusteringFault {
log.info("Received state initialization message");
@@ -52,7 +52,7 @@
}
}
- public void setCommands(ContextClusteringCommand[] commands) {
+ public void setCommands(StateClusteringCommand[] commands) {
this.commands = commands;
}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultGroupManagementAgent.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultGroupManagementAgent.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultGroupManagementAgent.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultGroupManagementAgent.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.clustering.management;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.clustering.management.GroupManagementAgent;
+import org.apache.axis2.clustering.management.GroupManagementCommand;
+import org.apache.axis2.clustering.Member;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.tribes.ChannelSender;
+import org.apache.axis2.clustering.tribes.TribesConstants;
+import org.apache.axis2.clustering.tribes.MembershipManager;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.group.RpcChannel;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The default implementation of {@link GroupManagementAgent}
+ */
+public class DefaultGroupManagementAgent implements GroupManagementAgent {
+
+ private static final Log log = LogFactory.getLog(DefaultGroupManagementAgent.class);
+ private List<Member> members = new ArrayList<Member>();
+ private ChannelSender sender;
+ private MembershipManager membershipManager;
+ private RpcChannel rpcChannel; //TODO
+ private String description;
+
+ public void setSender(ChannelSender sender) {
+ this.sender = sender;
+ }
+
+ public void setMembershipManager(MembershipManager membershipManager) {
+ this.membershipManager = membershipManager;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void applicationMemberAdded(Member member) {
+ Thread th = new Thread(new MemberAdder(member));
+ th.setPriority(Thread.MAX_PRIORITY);
+ th.start();
+ }
+
+ public void applicationMemberRemoved(Member member) {
+ log.info("Application member " + member + " left cluster.");
+ members.remove(member);
+ }
+
+ public List<Member> getMembers() {
+ return members;
+ }
+
+ public void send(GroupManagementCommand command) throws ClusteringFault {
+ sender.sendToGroup(command,
+ membershipManager,
+ Channel.SEND_OPTIONS_ASYNCHRONOUS |
+ TribesConstants.MEMBERSHIP_MSG_OPTION);
+ }
+
+ private class MemberAdder implements Runnable {
+
+ private final Member member;
+
+ private MemberAdder(Member member) {
+ this.member = member;
+ }
+
+ public void run() {
+ if (members.contains(member)) {
+ return;
+ }
+ if (canConnect(member)) {
+ // try
+ // Thread.sleep(10000); // Sleep for sometime to allow complete initialization of the node
+ // } catch (InterruptedException e) {
+ // e.printStackTrace();
+ // }
+ if (!members.contains(member)) {
+ members.add(member);
+ }
+ log.info("Application member " + member + " joined application cluster");
+ } else {
+ log.error("Could not add application member " + member);
+ }
+ }
+
+ /**
+ * Before adding a member, we will try to verify whether we can connect to it
+ *
+ * @param member The member whose connectvity needs to be verified
+ * @return true, if the member can be contacted; false, otherwise.
+ */
+ private boolean canConnect(Member member) {
+ if (log.isDebugEnabled()) {
+ log.debug("Trying to connect to member " + member + "...");
+ }
+ for (int retries = 30; retries > 0; retries--) {
+ try {
+ InetAddress addr = InetAddress.getByName(member.getHostName());
+ int httpPort = member.getHttpPort();
+ if (log.isDebugEnabled()) {
+ log.debug("HTTP Port=" + httpPort);
+ }
+ if (httpPort != -1) {
+ SocketAddress httpSockaddr = new InetSocketAddress(addr, httpPort);
+ new Socket().connect(httpSockaddr, 10000);
+ }
+ int httpsPort = member.getHttpsPort();
+ if (log.isDebugEnabled()) {
+ log.debug("HTTPS Port=" + httpsPort);
+ }
+ if (httpsPort != -1) {
+ SocketAddress httpsSockaddr = new InetSocketAddress(addr, httpsPort);
+ new Socket().connect(httpsSockaddr, 10000);
+ }
+ return true;
+ } catch (IOException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("", e);
+ }
+ String msg = e.getMessage();
+ if (msg.indexOf("Connection refused") == -1 && msg.indexOf("connect timed out") == -1) {
+ log.error("Cannot connect to member " + member, e);
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ }
+ return false;
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultNodeManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultNodeManager.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultNodeManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/DefaultNodeManager.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,116 @@
+/*
+ * 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.axis2.clustering.management;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.MessageSender;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+public class DefaultNodeManager implements NodeManager {
+ private static final Log log = LogFactory.getLog(DefaultNodeManager.class);
+
+ private MessageSender sender;
+ private ConfigurationContext configurationContext;
+ private Map<String, Parameter> parameters = new HashMap<String, Parameter>();
+
+ public DefaultNodeManager() {
+ }
+
+ public void commit() throws ClusteringFault {
+ }
+
+ public void exceptionOccurred(Throwable throwable) throws ClusteringFault {
+ }
+
+ public void prepare() throws ClusteringFault {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: DefaultNodeManager::prepare");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: DefaultNodeManager::prepare");
+ }
+ }
+ public void rollback() throws ClusteringFault {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: DefaultNodeManager::rollback");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: DefaultNodeManager::rollback");
+ }
+ }
+
+ protected void send(Throwable throwable) throws ClusteringFault {
+// sender.sendToGroup(new ExceptionCommand(throwable));
+ }
+
+ public void sendMessage(NodeManagementCommand command) throws ClusteringFault {
+ sender.sendToGroup(command);
+ }
+
+ public void setSender(MessageSender sender) {
+ this.sender = sender;
+ }
+
+ public void setConfigurationContext(ConfigurationContext configurationContext) {
+ this.configurationContext = configurationContext;
+ }
+
+ public void addParameter(Parameter param) throws AxisFault {
+ parameters.put(param.getName(), param);
+ }
+
+ public void removeParameter(Parameter param) throws AxisFault {
+ parameters.remove(param.getName());
+ }
+
+ public Parameter getParameter(String name) {
+ return parameters.get(name);
+ }
+
+ public ArrayList getParameters() {
+ ArrayList<Parameter> list = new ArrayList<Parameter>();
+ for (Iterator iter = parameters.keySet().iterator(); iter.hasNext();) {
+ list.add(parameters.get(iter.next()));
+ }
+ return list;
+ }
+
+ public boolean isParameterLocked(String parameterName) {
+ return getParameter(parameterName).isLocked();
+ }
+
+ public void deserializeParameters(OMElement parameterElement) throws AxisFault {
+ throw new UnsupportedOperationException();
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/NodeManagementCommandFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/NodeManagementCommandFactory.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/NodeManagementCommandFactory.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/NodeManagementCommandFactory.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,26 @@
+/*
+ * 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.axis2.clustering.management;
+
+/**
+ *
+ */
+public final class NodeManagementCommandFactory {
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/RestartMemberCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/RestartMemberCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/RestartMemberCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/RestartMemberCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.clustering.management.commands;
+
+/**
+ *
+ */
+public class RestartMemberCommand {
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/ShutdownMemberCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/ShutdownMemberCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/ShutdownMemberCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/management/commands/ShutdownMemberCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.clustering.management.commands;
+
+import org.apache.axis2.clustering.management.GroupManagementCommand;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ *
+ */
+public class ShutdownMemberCommand extends GroupManagementCommand {
+ public void execute(ConfigurationContext configContext) throws ClusteringFault{
+ System.exit(0);
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/ClusteringContextListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/ClusteringContextListener.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/ClusteringContextListener.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/ClusteringContextListener.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.axis2.clustering.state;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.MessageSender;
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ContextListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ */
+public class ClusteringContextListener implements ContextListener {
+ private static final Log log = LogFactory.getLog(ClusteringContextListener.class);
+
+ private MessageSender sender;
+
+ public ClusteringContextListener(MessageSender sender) {
+ this.sender = sender;
+ }
+
+ public void contextCreated(AbstractContext context) {
+ }
+
+ public void contextRemoved(AbstractContext context) {
+ StateClusteringCommand command =
+ StateClusteringCommandFactory.getRemoveCommand(context);
+ if(command != null){
+ try {
+ sender.sendToGroup(command);
+ } catch (ClusteringFault e) {
+ log.error("Cannot send context removed message to cluster", e);
+ }
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/DefaultStateManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/DefaultStateManager.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/DefaultStateManager.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/DefaultStateManager.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,134 @@
+/*
+ * 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.axis2.clustering.state;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.state.commands.StateClusteringCommandCollection;
+import org.apache.axis2.clustering.tribes.ChannelSender;
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.Parameter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DefaultStateManager implements StateManager {
+
+ private ConfigurationContext configContext;
+
+ private Map<String, Parameter> parameters = new HashMap<String, Parameter>();
+
+ private ChannelSender sender;
+
+ private Map<String, List> excludedReplicationPatterns = new HashMap<String, List>();
+
+ //TODO: Try to use an interface
+ public void setSender(ChannelSender sender) {
+ this.sender = sender;
+ }
+
+ public DefaultStateManager() {
+ }
+
+ public void updateContext(AbstractContext context) throws ClusteringFault {
+ StateClusteringCommand cmd =
+ StateClusteringCommandFactory.getUpdateCommand(context,
+ excludedReplicationPatterns,
+ false);
+ if (cmd != null) {
+ sender.sendToGroup(cmd);
+ }
+ }
+
+ public void updateContext(AbstractContext context,
+ String[] propertyNames) throws ClusteringFault {
+ StateClusteringCommand cmd =
+ StateClusteringCommandFactory.getUpdateCommand(context, propertyNames);
+ if (cmd != null) {
+ sender.sendToGroup(cmd);
+ }
+ }
+
+ public void updateContexts(AbstractContext[] contexts) throws ClusteringFault {
+ StateClusteringCommandCollection cmd =
+ StateClusteringCommandFactory.getCommandCollection(contexts,
+ excludedReplicationPatterns);
+ sender.sendToGroup(cmd);
+ }
+
+ public void removeContext(AbstractContext context) throws ClusteringFault {
+ StateClusteringCommand cmd = StateClusteringCommandFactory.getRemoveCommand(context);
+ sender.sendToGroup(cmd);
+ }
+
+ public boolean isContextClusterable(AbstractContext context) {
+ return (context instanceof ConfigurationContext) ||
+ (context instanceof ServiceContext) ||
+ (context instanceof ServiceGroupContext);
+ }
+
+ public void setConfigurationContext(ConfigurationContext configurationContext) {
+ this.configContext = configurationContext;
+ }
+
+ public void setReplicationExcludePatterns(String contextType, List patterns) {
+ excludedReplicationPatterns.put(contextType, patterns);
+ }
+
+ public Map getReplicationExcludePatterns() {
+ return excludedReplicationPatterns;
+ }
+
+ // ---------------------- Methods from ParameterInclude ----------------------------------------
+ public void addParameter(Parameter param) throws AxisFault {
+ parameters.put(param.getName(), param);
+ }
+
+ public void removeParameter(Parameter param) throws AxisFault {
+ parameters.remove(param.getName());
+ }
+
+ public Parameter getParameter(String name) {
+ return parameters.get(name);
+ }
+
+ public ArrayList getParameters() {
+ ArrayList<Parameter> list = new ArrayList<Parameter>();
+ for (String msg : parameters.keySet()) {
+ list.add(parameters.get(msg));
+ }
+ return list;
+ }
+
+ public boolean isParameterLocked(String parameterName) {
+ return getParameter(parameterName).isLocked();
+ }
+
+ public void deserializeParameters(OMElement parameterElement) throws AxisFault {
+ throw new UnsupportedOperationException();
+ }
+ // ---------------------------------------------------------------------------------------------
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/PropertyUpdater.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/PropertyUpdater.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/PropertyUpdater.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/PropertyUpdater.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.axis2.clustering.state;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.PropertyDifference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ *
+ */
+public class PropertyUpdater implements Serializable {
+ private static final Log log = LogFactory.getLog(PropertyUpdater.class);
+
+ private Map properties;
+
+ public void updateProperties(AbstractContext abstractContext) {
+ if (log.isDebugEnabled()) {
+ log.debug("Updating props in " + abstractContext);
+ }
+ if (abstractContext != null) {
+ for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ PropertyDifference propDiff =
+ (PropertyDifference) properties.get(key);
+ if (propDiff.isRemoved()) {
+ abstractContext.removePropertyNonReplicable(key);
+ } else { // it is updated/added
+ abstractContext.setNonReplicableProperty(key, propDiff.getValue());
+ if (log.isDebugEnabled()) {
+ log.debug("Added prop=" + key + ", value=" + propDiff.getValue() +
+ " to context " + abstractContext);
+ }
+ }
+ }
+ }
+ }
+
+ public void addContextProperty(PropertyDifference diff) {
+ properties.put(diff.getKey(), diff);
+ }
+
+ public void setProperties(Map properties) {
+ this.properties = properties;
+ }
+
+ public Map getProperties() {
+ return properties;
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/StateClusteringCommandFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/StateClusteringCommandFactory.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/StateClusteringCommandFactory.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/StateClusteringCommandFactory.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,280 @@
+/*
+ * 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.axis2.clustering.state;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.state.commands.StateClusteringCommandCollection;
+import org.apache.axis2.clustering.state.commands.DeleteServiceGroupStateCommand;
+import org.apache.axis2.clustering.state.commands.UpdateConfigurationStateCommand;
+import org.apache.axis2.clustering.state.commands.UpdateStateCommand;
+import org.apache.axis2.clustering.state.commands.UpdateServiceStateCommand;
+import org.apache.axis2.clustering.state.commands.UpdateServiceGroupStateCommand;
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.PropertyDifference;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ */
+public final class StateClusteringCommandFactory {
+
+ private static final Log log = LogFactory.getLog(StateClusteringCommandFactory.class);
+
+ public static StateClusteringCommandCollection
+ getCommandCollection(AbstractContext[] contexts,
+ Map excludedReplicationPatterns) {
+
+ ArrayList<StateClusteringCommand> commands = new ArrayList<StateClusteringCommand>(contexts.length);
+ StateClusteringCommandCollection collection =
+ new StateClusteringCommandCollection(commands);
+ for (AbstractContext context : contexts) {
+ StateClusteringCommand cmd = getUpdateCommand(context,
+ excludedReplicationPatterns,
+ false);
+ if (cmd != null) {
+ commands.add(cmd);
+ }
+ }
+ return collection;
+ }
+
+ /**
+ * @param context The context
+ * @param excludedPropertyPatterns The property patterns to be excluded
+ * @param includeAllProperties True - Include all properties,
+ * False - Include only property differences
+ * @return ContextClusteringCommand
+ */
+ public static StateClusteringCommand getUpdateCommand(AbstractContext context,
+ Map excludedPropertyPatterns,
+ boolean includeAllProperties) {
+
+ UpdateStateCommand cmd = toUpdateContextCommand(context);
+ if (cmd != null) {
+ fillProperties(cmd,
+ context,
+ excludedPropertyPatterns,
+ includeAllProperties);
+ if (cmd.isPropertiesEmpty()) {
+ cmd = null;
+ }
+ }
+ return cmd;
+ }
+
+
+ public static StateClusteringCommand getUpdateCommand(AbstractContext context,
+ String[] propertyNames)
+ throws ClusteringFault {
+
+ UpdateStateCommand cmd = toUpdateContextCommand(context);
+ if (cmd != null) {
+ fillProperties(cmd, context, propertyNames);
+ if (cmd.isPropertiesEmpty()) {
+ cmd = null;
+ }
+ }
+ return cmd;
+ }
+
+ private static UpdateStateCommand toUpdateContextCommand(AbstractContext context) {
+ UpdateStateCommand cmd = null;
+ if (context instanceof ConfigurationContext) {
+ cmd = new UpdateConfigurationStateCommand();
+ } else if (context instanceof ServiceGroupContext) {
+ ServiceGroupContext sgCtx = (ServiceGroupContext) context;
+ cmd = new UpdateServiceGroupStateCommand();
+ UpdateServiceGroupStateCommand updateSgCmd = (UpdateServiceGroupStateCommand) cmd;
+ updateSgCmd.setServiceGroupName(sgCtx.getDescription().getServiceGroupName());
+ updateSgCmd.setServiceGroupContextId(sgCtx.getId());
+ } else if (context instanceof ServiceContext) {
+ ServiceContext serviceCtx = (ServiceContext) context;
+ cmd = new UpdateServiceStateCommand();
+ UpdateServiceStateCommand updateServiceCmd = (UpdateServiceStateCommand) cmd;
+ String sgName =
+ serviceCtx.getServiceGroupContext().getDescription().getServiceGroupName();
+ updateServiceCmd.setServiceGroupName(sgName);
+ updateServiceCmd.setServiceGroupContextId(serviceCtx.getServiceGroupContext().getId());
+ updateServiceCmd.setServiceName(serviceCtx.getAxisService().getName());
+ }
+ return cmd;
+ }
+
+ /**
+ * @param updateCmd The command
+ * @param context The context
+ * @param excludedPropertyPatterns The property patterns to be excluded from replication
+ * @param includeAllProperties True - Include all properties,
+ * False - Include only property differences
+ */
+ private static void fillProperties(UpdateStateCommand updateCmd,
+ AbstractContext context,
+ Map excludedPropertyPatterns,
+ boolean includeAllProperties) {
+ if (!includeAllProperties) {
+ synchronized (context) {
+ Map diffs = context.getPropertyDifferences();
+ for (Object o : diffs.keySet()) {
+ String key = (String) o;
+ PropertyDifference diff = (PropertyDifference) diffs.get(key);
+ Object value = diff.getValue();
+ if (isSerializable(value)) {
+
+ // Next check whether it matches an excluded pattern
+ if (!isExcluded(key,
+ context.getClass().getName(),
+ excludedPropertyPatterns)) {
+ if (log.isDebugEnabled()) {
+ log.debug("sending property =" + key + "-" + value);
+ }
+ updateCmd.addProperty(diff);
+ }
+ }
+ }
+ }
+ } else {
+ synchronized (context) {
+ for (Iterator iter = context.getPropertyNames(); iter.hasNext();) {
+ String key = (String) iter.next();
+ Object value = context.getPropertyNonReplicable(key);
+ if (isSerializable(value)) {
+
+ // Next check whether it matches an excluded pattern
+ if (!isExcluded(key, context.getClass().getName(), excludedPropertyPatterns)) {
+ if (log.isDebugEnabled()) {
+ log.debug("sending property =" + key + "-" + value);
+ }
+ PropertyDifference diff = new PropertyDifference(key, value, false);
+ updateCmd.addProperty(diff);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static void fillProperties(UpdateStateCommand updateCmd,
+ AbstractContext context,
+ String[] propertyNames) throws ClusteringFault {
+ Map diffs = context.getPropertyDifferences();
+ for (String key : propertyNames) {
+ Object prop = context.getPropertyNonReplicable(key);
+
+ // First check whether it is serializable
+ if (isSerializable(prop)) {
+ if (log.isDebugEnabled()) {
+ log.debug("sending property =" + key + "-" + prop);
+ }
+ PropertyDifference diff = (PropertyDifference) diffs.get(key);
+ if (diff != null) {
+ diff.setValue(prop);
+ updateCmd.addProperty(diff);
+
+ // Remove the diff?
+ diffs.remove(key);
+ }
+ } else {
+ String msg =
+ "Trying to replicate non-serializable property " + key +
+ " in context " + context;
+ throw new ClusteringFault(msg);
+ }
+ }
+ }
+
+ private static boolean isExcluded(String propertyName,
+ String ctxClassName,
+ Map excludedPropertyPatterns) {
+
+ // Check in the excludes list specific to the context
+ List specificExcludes =
+ (List) excludedPropertyPatterns.get(ctxClassName);
+ boolean isExcluded = false;
+ if (specificExcludes != null) {
+ isExcluded = isExcluded(specificExcludes, propertyName);
+ }
+ if (!isExcluded) {
+ // check in the default excludes
+ List defaultExcludes =
+ (List) excludedPropertyPatterns.get(DeploymentConstants.TAG_DEFAULTS);
+ if (defaultExcludes != null) {
+ isExcluded = isExcluded(defaultExcludes, propertyName);
+ }
+ }
+ return isExcluded;
+ }
+
+ private static boolean isExcluded(List list, String propertyName) {
+ for (Object aList : list) {
+ String pattern = (String) aList;
+ if (pattern.startsWith("*")) {
+ pattern = pattern.replaceAll("\\*", "");
+ if (propertyName.endsWith(pattern)) {
+ return true;
+ }
+ } else if (pattern.endsWith("*")) {
+ pattern = pattern.replaceAll("\\*", "");
+ if (propertyName.startsWith(pattern)) {
+ return true;
+ }
+ } else if (pattern.equals(propertyName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static StateClusteringCommand getRemoveCommand(AbstractContext abstractContext) {
+ if (abstractContext instanceof ServiceGroupContext) {
+ ServiceGroupContext sgCtx = (ServiceGroupContext) abstractContext;
+ DeleteServiceGroupStateCommand cmd = new DeleteServiceGroupStateCommand();
+ cmd.setServiceGroupContextId(sgCtx.getId());
+
+ return cmd;
+ }
+ return null;
+ }
+
+ private static boolean isSerializable(Object obj) {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(out);
+ oos.writeObject(obj);
+ oos.close();
+ return out.toByteArray().length > 0;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceGroupStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceGroupStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceGroupStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceGroupStateCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ *
+ */
+public class DeleteServiceGroupStateCommand extends StateClusteringCommand {
+ private String serviceGroupContextId;
+
+ public void setServiceGroupContextId(String serviceGroupContextId) {
+ this.serviceGroupContextId = serviceGroupContextId;
+ }
+
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ configurationContext.removeServiceGroupContext(serviceGroupContextId);
+ }
+}
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/DeleteServiceStateCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ *
+ */
+public class DeleteServiceStateCommand extends StateClusteringCommand {
+ protected String serviceGroupName;
+ protected String serviceGroupContextId;
+ protected String serviceName;
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public void setServiceGroupContextId(String serviceGroupContextId) {
+ this.serviceGroupContextId = serviceGroupContextId;
+ }
+
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ // TODO: Implementation
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/StateClusteringCommandCollection.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/StateClusteringCommandCollection.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/StateClusteringCommandCollection.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/StateClusteringCommandCollection.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,51 @@
+/*
+ * 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.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.context.ConfigurationContext;
+
+import java.util.ArrayList;
+
+/**
+ *
+ */
+public class StateClusteringCommandCollection extends StateClusteringCommand {
+
+ private ArrayList commands;
+
+ public StateClusteringCommandCollection(ArrayList commands) {
+ this.commands = commands;
+ }
+
+ public void execute(ConfigurationContext configContext) throws ClusteringFault {
+ for (int i = 0; i < commands.size(); i++) {
+ StateClusteringCommand cmd = (StateClusteringCommand) commands.get(i);
+ if (cmd != null) {
+ cmd.execute(configContext);
+ }
+ }
+ }
+
+ public String toString() {
+ return "StateClusteringCommandCollection";
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateConfigurationStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateConfigurationStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateConfigurationStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateConfigurationStateCommand.java Mon Feb 16 12:02:42 2009
@@ -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.
+ */
+
+package org.apache.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ *
+ */
+public class UpdateConfigurationStateCommand extends UpdateStateCommand {
+
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ propertyUpdater.updateProperties(configurationContext);
+ }
+
+ public String toString() {
+ return "UpdateConfigurationStateCommand";
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceGroupStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceGroupStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceGroupStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceGroupStateCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ */
+public class UpdateServiceGroupStateCommand extends UpdateStateCommand {
+
+ private static Log log = LogFactory.getLog(UpdateServiceGroupStateCommand.class);
+
+ protected String serviceGroupName;
+ protected String serviceGroupContextId;
+
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
+ public String getServiceGroupContextId() {
+ return serviceGroupContextId;
+ }
+
+ public void setServiceGroupContextId(String serviceGroupContextId) {
+ this.serviceGroupContextId = serviceGroupContextId;
+ }
+
+ public void execute(ConfigurationContext configContext) throws ClusteringFault {
+ ServiceGroupContext sgCtx =
+ configContext.getServiceGroupContext(serviceGroupContextId);
+
+ // If the ServiceGroupContext is not found, create it
+ if (sgCtx == null) {
+ AxisServiceGroup axisServiceGroup =
+ configContext.getAxisConfiguration().getServiceGroup(serviceGroupName);
+ if(axisServiceGroup == null){
+ return;
+ }
+ sgCtx = new ServiceGroupContext(configContext, axisServiceGroup);
+ sgCtx.setId(serviceGroupContextId);
+ configContext.addServiceGroupContextIntoSoapSessionTable(sgCtx); // TODO: Check this
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Gonna update SG prop in " + serviceGroupContextId + "===" + sgCtx);
+ }
+ propertyUpdater.updateProperties(sgCtx);
+ }
+
+ public String toString() {
+ return "UpdateServiceGroupStateCommand";
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateServiceStateCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,108 @@
+/*
+ * 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.axis2.clustering.state.commands;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ */
+public class UpdateServiceStateCommand extends UpdateStateCommand {
+
+ private static final Log log = LogFactory.getLog(UpdateServiceStateCommand.class);
+
+ protected String serviceGroupName;
+ protected String serviceGroupContextId;
+ protected String serviceName;
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public void setServiceGroupContextId(String serviceGroupContextId) {
+ this.serviceGroupContextId = serviceGroupContextId;
+ }
+
+ public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+ if (log.isDebugEnabled()) {
+ log.debug("Updating service context properties...");
+ }
+ ServiceGroupContext sgCtx =
+ configurationContext.getServiceGroupContext(serviceGroupContextId);
+ if (sgCtx != null) {
+ try {
+ AxisService axisService =
+ configurationContext.getAxisConfiguration().getService(serviceName);
+ ServiceContext serviceContext = sgCtx.getServiceContext(axisService);
+ propertyUpdater.updateProperties(serviceContext);
+ } catch (AxisFault e) {
+ throw new ClusteringFault(e);
+ }
+ } else {
+ sgCtx = configurationContext.getServiceGroupContext(serviceGroupContextId);
+ AxisService axisService;
+ try {
+ axisService = configurationContext.getAxisConfiguration().getService(serviceName);
+ } catch (AxisFault axisFault) {
+ throw new ClusteringFault(axisFault);
+ }
+ String scope = axisService.getScope();
+ if (sgCtx == null) {
+ AxisServiceGroup serviceGroup =
+ configurationContext.getAxisConfiguration().getServiceGroup(serviceGroupName);
+ if(serviceGroup == null){
+ return;
+ }
+ sgCtx = new ServiceGroupContext(configurationContext, serviceGroup);
+ sgCtx.setId(serviceGroupContextId);
+ if (scope.equals(Constants.SCOPE_APPLICATION)) {
+ configurationContext.
+ addServiceGroupContextIntoApplicationScopeTable(sgCtx);
+ } else if (scope.equals(Constants.SCOPE_SOAP_SESSION)) {
+ configurationContext.
+ addServiceGroupContextIntoSoapSessionTable(sgCtx);
+ }
+ }
+ try {
+ ServiceContext serviceContext = sgCtx.getServiceContext(axisService);
+ propertyUpdater.updateProperties(serviceContext);
+ } catch (AxisFault axisFault) {
+ throw new ClusteringFault(axisFault);
+ }
+ }
+ }
+
+ public String toString() {
+ return "UpdateServiceStateCommand";
+ }
+}
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateStateCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateStateCommand.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/state/commands/UpdateStateCommand.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.clustering.state.commands;
+
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.clustering.state.PropertyUpdater;
+import org.apache.axis2.context.PropertyDifference;
+
+import java.util.HashMap;
+
+/**
+ *
+ */
+public abstract class UpdateStateCommand extends StateClusteringCommand {
+
+ protected PropertyUpdater propertyUpdater = new PropertyUpdater();
+
+ public boolean isPropertiesEmpty() {
+ if (propertyUpdater.getProperties() == null) {
+ propertyUpdater.setProperties(new HashMap());
+ return true;
+ }
+ return propertyUpdater.getProperties().isEmpty();
+ }
+
+ public void addProperty(PropertyDifference diff) {
+ if (propertyUpdater.getProperties() == null) {
+ propertyUpdater.setProperties(new HashMap());
+ }
+ propertyUpdater.addContextProperty(diff);
+ }
+}
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java?rev=744900&r1=744899&r2=744900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java Mon Feb 16 12:02:42 2009
@@ -29,20 +29,20 @@
*/
public class ApplicationMode implements OperationMode {
- private static final Log log = LogFactory.getLog(LoadBalancerMode.class);
+ private static final Log log = LogFactory.getLog(ClusterManagementMode.class);
- private byte[] loadBalancerDomain;
+ private byte[] domain;
private MembershipManager membershipManager;
- public ApplicationMode(byte[] loadBalancerDomain, MembershipManager membershipManager) {
- this.loadBalancerDomain = loadBalancerDomain;
+ public ApplicationMode(byte[] domain, MembershipManager membershipManager) {
+ this.domain = domain;
this.membershipManager = membershipManager;
}
public void addInterceptors(Channel channel) {
DomainFilterInterceptor dfi = new DomainFilterInterceptor();
dfi.setOptionFlag(TribesConstants.MEMBERSHIP_MSG_OPTION);
- dfi.setDomain(loadBalancerDomain);
+ dfi.setDomain(domain);
channel.addInterceptor(dfi);
if (log.isDebugEnabled()) {
log.debug("Added Domain Filter Interceptor");
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java?rev=744900&r1=744899&r2=744900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java Mon Feb 16 12:02:42 2009
@@ -21,10 +21,11 @@
import org.apache.axis2.clustering.ClusteringConstants;
import org.apache.axis2.clustering.ClusteringFault;
-import org.apache.axis2.clustering.configuration.ConfigurationClusteringCommand;
-import org.apache.axis2.clustering.configuration.DefaultConfigurationManager;
-import org.apache.axis2.clustering.context.ContextClusteringCommand;
-import org.apache.axis2.clustering.context.DefaultContextManager;
+import org.apache.axis2.clustering.management.NodeManagementCommand;
+import org.apache.axis2.clustering.management.DefaultNodeManager;
+import org.apache.axis2.clustering.management.GroupManagementCommand;
+import org.apache.axis2.clustering.state.StateClusteringCommand;
+import org.apache.axis2.clustering.state.DefaultStateManager;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisServiceGroup;
@@ -45,25 +46,25 @@
public class ChannelListener implements org.apache.catalina.tribes.ChannelListener {
private static final Log log = LogFactory.getLog(ChannelListener.class);
- private DefaultContextManager contextManager;
- private DefaultConfigurationManager configurationManager;
+ private DefaultStateManager stateManager;
+ private DefaultNodeManager nodeManager;
private ConfigurationContext configurationContext;
public ChannelListener(ConfigurationContext configurationContext,
- DefaultConfigurationManager configurationManager,
- DefaultContextManager contextManager) {
- this.configurationManager = configurationManager;
- this.contextManager = contextManager;
+ DefaultNodeManager nodeManager,
+ DefaultStateManager stateManager) {
+ this.nodeManager = nodeManager;
+ this.stateManager = stateManager;
this.configurationContext = configurationContext;
}
- public void setContextManager(DefaultContextManager contextManager) {
- this.contextManager = contextManager;
+ public void setStateManager(DefaultStateManager stateManager) {
+ this.stateManager = stateManager;
}
- public void setConfigurationManager(DefaultConfigurationManager configurationManager) {
- this.configurationManager = configurationManager;
+ public void setNodeManager(DefaultNodeManager nodeManager) {
+ this.nodeManager = nodeManager;
}
public void setConfigurationContext(ConfigurationContext configurationContext) {
@@ -133,11 +134,13 @@
}
private void processMessage(Serializable msg) throws ClusteringFault {
- if (msg instanceof ContextClusteringCommand && contextManager != null) {
- ContextClusteringCommand ctxCmd = (ContextClusteringCommand) msg;
+ if (msg instanceof StateClusteringCommand && stateManager != null) {
+ StateClusteringCommand ctxCmd = (StateClusteringCommand) msg;
ctxCmd.execute(configurationContext);
- } else if (msg instanceof ConfigurationClusteringCommand && configurationManager != null) {
- configurationManager.process((ConfigurationClusteringCommand) msg);
- }
+ } else if (msg instanceof NodeManagementCommand && nodeManager != null) {
+ ((NodeManagementCommand) msg).execute(configurationContext);
+ } else if (msg instanceof GroupManagementCommand){
+ ((GroupManagementCommand) msg).execute(configurationContext);
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java?rev=744900&r1=744899&r2=744900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java Mon Feb 16 12:02:42 2009
@@ -49,7 +49,9 @@
this.synchronizeAllMembers = synchronizeAllMembers;
}
- public void sendToGroup(ClusteringCommand msg) throws ClusteringFault {
+ public void sendToGroup(ClusteringCommand msg,
+ MembershipManager membershipManager,
+ int additionalOptions) throws ClusteringFault {
if (channel == null) {
return;
}
@@ -64,12 +66,14 @@
Channel.SEND_OPTIONS_USE_ACK |
Channel.SEND_OPTIONS_SYNCHRONIZED_ACK |
TribesConstants.MSG_ORDER_OPTION |
- TribesConstants.AT_MOST_ONCE_OPTION);
+ TribesConstants.AT_MOST_ONCE_OPTION |
+ additionalOptions);
} else {
channel.send(members, toByteMessage(msg),
Channel.SEND_OPTIONS_ASYNCHRONOUS |
TribesConstants.MSG_ORDER_OPTION |
- TribesConstants.AT_MOST_ONCE_OPTION);
+ TribesConstants.AT_MOST_ONCE_OPTION |
+ additionalOptions);
}
if (log.isDebugEnabled()) {
log.debug("Sent " + msg + " to group");
@@ -95,6 +99,10 @@
}
}
+ public void sendToGroup(ClusteringCommand msg) throws ClusteringFault {
+ sendToGroup(msg, this.membershipManager, 0);
+ }
+
private ByteMessage toByteMessage(ClusteringCommand msg) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos);
Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementInterceptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementInterceptor.java?rev=744900&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementInterceptor.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ClusterManagementInterceptor.java Mon Feb 16 12:02:42 2009
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.clustering.tribes;
+
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.group.ChannelInterceptorBase;
+import org.apache.catalina.tribes.membership.Membership;
+
+/**
+ * This interceptor is used when this member acts as a ClusterManager.
+ */
+public class ClusterManagementInterceptor extends ChannelInterceptorBase {
+
+ /**
+ * Represents the load balancer group
+ */
+ protected Membership clusterMgtMembership = null;
+
+ /**
+ * Represents the cluster manager's group
+ */
+ protected byte[] clusterManagerDomain = new byte[0];
+
+ public ClusterManagementInterceptor(byte[] clusterManagerDomain) {
+ this.clusterManagerDomain = clusterManagerDomain;
+ }
+
+ public void messageReceived(ChannelMessage msg) {
+ // Ignore all messages which are not intended for the cluster manager group or which are not
+ // membership messages
+ if (okToProcess(msg.getOptions()) ||
+ TribesUtil.isInDomain(msg.getAddress(), clusterManagerDomain)) {
+ super.messageReceived(msg);
+ }
+ }
+}