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 2007/05/24 17:09:18 UTC

svn commit: r541316 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/clustering/control/ clustering/src/org/apache/axis2/clustering/handlers/ clustering/src/org/apache/axis2/clustering/tribes/ kernel/src/org/apache/axis2/clus...

Author: azeez
Date: Thu May 24 08:09:17 2007
New Revision: 541316

URL: http://svn.apache.org/viewvc?view=rev&rev=541316
Log:
Functionality for sending control messages between axis2 nodes in a cluster

At the moment, I've identified 2 control messages;
1. GetStateCommand - Sent by a node which is joining a cluster which already has one or more members. In such a case, it will send a request for the latest
node to a randomly selected member, and will wait till a reply is reveived. If such a reply is not received, it will retry by sending the same request to
another member, or until there are no members in the cluster. Unless a GetStateResponseCommand message is received, a node cannot start successfuly and join a
cluster, unless it is the very first node which is joining the cluster.

2. GetStateResponseCommand - Sent by the node which receives the GetStateCommand. It will populate this message with the latest state and send it out to the
requester.


Added:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/ControlCommand.java
    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/TribesControlCommandProcessor.java
Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/handlers/ReplicationHandler.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/TribesClusterManager.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/kernel/src/org/apache/axis2/clustering/ClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/ControlCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/ControlCommand.java?view=auto&rev=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/ControlCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/ControlCommand.java Thu May 24 08:09:17 2007
@@ -0,0 +1,32 @@
+/*                                                                             
+ * 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.control;
+
+import org.apache.axis2.clustering.ClusteringCommand;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ * 
+ */
+public abstract class ControlCommand extends ClusteringCommand {
+    public int getCommandType() {
+        //TODO: Method implementation
+        return 0;
+    }
+
+    public abstract void execute(ConfigurationContext configurationContext) throws ClusteringFault;
+}

Added: 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?view=auto&rev=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateCommand.java Thu May 24 08:09:17 2007
@@ -0,0 +1,30 @@
+/*                                                                             
+ * 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.control;
+
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ * 
+ */
+public class GetStateCommand extends ControlCommand {
+
+    public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+        //TODO: Method implementation
+        System.err.println("####### Going to send state to Member");
+    }
+}

Added: 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?view=auto&rev=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetStateResponseCommand.java Thu May 24 08:09:17 2007
@@ -0,0 +1,32 @@
+/*                                                                             
+ * 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.control;
+
+import org.apache.axis2.clustering.ClusteringConstants;
+import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.context.ConfigurationContext;
+
+/**
+ * 
+ */
+public class GetStateResponseCommand extends ControlCommand {
+
+    public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
+        //TODO: Method implementation
+        configurationContext.
+                setNonReplicableProperty(ClusteringConstants.GET_STATE_RESPONSE_RECEIVED, "true");
+    }
+}

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/handlers/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/handlers/ReplicationHandler.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/handlers/ReplicationHandler.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/handlers/ReplicationHandler.java Thu May 24 08:09:17 2007
@@ -34,11 +34,13 @@
     private static final Log log = LogFactory.getLog(ReplicationHandler.class);
 
     public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+        log.debug("Going to replicate state on invoke");
         replicateState(msgContext);
         return InvocationResponse.CONTINUE;
     }
 
     public void flowComplete(MessageContext msgContext) {
+        log.debug("Going to replicate state on flowComplete");
         try {
             replicateState(msgContext);
         } catch (Exception e) {

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?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- 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 Thu May 24 08:09:17 2007
@@ -17,6 +17,9 @@
 package org.apache.axis2.clustering.tribes;
 
 import org.apache.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.control.ControlCommand;
+import org.apache.axis2.clustering.control.GetStateCommand;
+import org.apache.axis2.clustering.control.GetStateResponseCommand;
 import org.apache.axis2.clustering.configuration.ConfigurationClusteringCommand;
 import org.apache.axis2.clustering.configuration.DefaultConfigurationManager;
 import org.apache.axis2.clustering.context.ContextClusteringCommand;
@@ -31,13 +34,16 @@
 public class ChannelListener implements org.apache.catalina.tribes.ChannelListener {
     private static final Log log = LogFactory.getLog(ChannelListener.class);
     
-    private DefaultContextManager contextManager = null;
-    private DefaultConfigurationManager configurationManager = null;
+    private DefaultContextManager contextManager;
+    private DefaultConfigurationManager configurationManager;
+    private TribesControlCommandProcessor controlCommandProcessor;
 
     public ChannelListener(DefaultConfigurationManager configurationManager,
-                           DefaultContextManager contextManager) {
+                           DefaultContextManager contextManager,
+                           TribesControlCommandProcessor controlCommandProcessor) {
         this.configurationManager = configurationManager;
         this.contextManager = contextManager;
+        this.controlCommandProcessor = controlCommandProcessor;
     }
 
     public void setContextManager(DefaultContextManager contextManager) {
@@ -56,17 +62,21 @@
         log.debug("Message received : " + msg);
         if (msg instanceof ContextClusteringCommand) {
             try {
-                ContextClusteringCommand comMsg = (ContextClusteringCommand) msg;
-                contextManager.notifyListener(comMsg);
+                contextManager.notifyListener((ContextClusteringCommand) msg);
             } catch (ClusteringFault e) {
                 log.error("Could not process ContextCommand", e);
             }
         } else if (msg instanceof ConfigurationClusteringCommand) {
-            ConfigurationClusteringCommand command = (ConfigurationClusteringCommand) msg;
             try {
-                configurationManager.notifyListener(command);
+                configurationManager.notifyListener((ConfigurationClusteringCommand) msg);
             } catch (ClusteringFault e) {
                 log.error("Could not process ConfigurationCommand", e);
+            }
+        } else if(msg instanceof ControlCommand){
+            try {
+                controlCommandProcessor.process((ControlCommand) msg, sender);
+            } catch (ClusteringFault e) {
+                log.error("Could not process ControlCommand", e);
             }
         }
     }

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?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- 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 Thu May 24 08:09:17 2007
@@ -33,17 +33,12 @@
 
     public void sendToGroup(ClusteringCommand msg) throws ClusteringFault {
         if(channel == null) return;
-        Member[] group = channel.getMembers();
-        log.debug("Group size " + group.length);
-        // send the message
-
-//        for (int i = 0; i < group.length; i++) {
-//            printMember(group[i]);
-//        }
+        Member[] members = channel.getMembers();
 
-        if (group.length > 0) {
+        // send the message
+        if (members.length > 0) {
             try {
-                channel.send(group, msg, 0);
+                channel.send(members, msg, 0);
             } catch (ChannelException e) {
                 log.error("" + msg, e);
                 String message = "Error sending command message : " + msg;
@@ -69,9 +64,9 @@
         log.debug("Group size " + group.length);
         // send the message
 
-        for (int i = 0; i < group.length; i++) {
+        /*for (int i = 0; i < group.length; i++) {
             printMember(group[i]);
-        }
+        }*/
 
         if (group.length > 0) {
             try {
@@ -81,6 +76,14 @@
                 String message = "Error sending exception message : " + throwable;
                 throw new ClusteringFault(message, e);
             }
+        }
+    }
+
+    public void sendToMember(ClusteringCommand cmd, Member member) throws ClusteringFault {
+        try {
+            channel.send(new Member[]{member}, cmd, Channel.SEND_OPTIONS_USE_ACK);
+        } catch (ChannelException e) {
+            throw new ClusteringFault(e);
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java Thu May 24 08:09:17 2007
@@ -18,13 +18,15 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.clustering.ClusterManager;
-import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.clustering.ClusteringConstants;
+import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.clustering.configuration.ConfigurationManager;
 import org.apache.axis2.clustering.configuration.DefaultConfigurationManager;
 import org.apache.axis2.clustering.context.ContextManager;
 import org.apache.axis2.clustering.context.DefaultContextManager;
+import org.apache.axis2.clustering.control.GetStateCommand;
 import org.apache.axis2.clustering.tribes.info.TransientTribesChannelInfo;
 import org.apache.axis2.clustering.tribes.info.TransientTribesMemberInfo;
 import org.apache.axis2.description.Parameter;
@@ -48,10 +50,14 @@
     private DefaultContextManager contextManager;
 
     private HashMap parameters;
-    private Channel channel;
+    private ManagedChannel channel;
+    private TribesMembershipListener membershipListener;
+    private ConfigurationContext configurationContext;
+    private TribesControlCommandProcessor controlCmdProcessor;
 
     public TribesClusterManager() {
         parameters = new HashMap();
+        controlCmdProcessor = new TribesControlCommandProcessor(configurationContext);
     }
 
     public ContextManager getContextManager() {
@@ -63,29 +69,28 @@
     }
 
     public void init() throws ClusteringFault {
-        if (log.isDebugEnabled()) {
-            log.debug("Enter: TribesClusterManager::init");
-        }
-
         ChannelSender sender = new ChannelSender();
 
-        ChannelListener listener = new ChannelListener(configurationManager, contextManager);
+        ChannelListener listener = new ChannelListener(configurationManager,
+                                                       contextManager,
+                                                       controlCmdProcessor);
 
         TransientTribesChannelInfo channelInfo = new TransientTribesChannelInfo();
         TransientTribesMemberInfo memberInfo = new TransientTribesMemberInfo();
 
         contextManager.setSender(sender);
         configurationManager.setSender(sender);
+        controlCmdProcessor.setChannelSender(sender);
 
         try {
 
-            ManagedChannel channel = new GroupChannel();
+            channel = new GroupChannel();
 
             // Set the domain for this Node
             Parameter domainParam = getParameter(ClusteringConstants.DOMAIN);
             byte[] domain;
             if (domainParam != null) {
-                domain = ((String)domainParam.getValue()).getBytes();
+                domain = ((String) domainParam.getValue()).getBytes();
                 channel.getMembershipService().setDomain(domain);
             } else {
                 domain = "apache.axis2.domain".getBytes();
@@ -95,35 +100,63 @@
             dfi.setDomain(domain);
             channel.addInterceptor(dfi);
 
-            this.channel = channel;
+            // Add the NonBlockingCoordinator. This is used for leader election
+            /*nbc = new NonBlockingCoordinator() {
+                public void fireInterceptorEvent(InterceptorEvent event) {
+                    String status = event.getEventTypeDesc();
+                    System.err.println("$$$$$$$$$$$$ NBC status=" + status);
+                    int type = event.getEventType();
+                }
+            };
+            nbc.setPrevious(dfi);
+            channel.addInterceptor(nbc);*/
+
+//            TcpFailureDetector tcpFailureDetector = new TcpFailureDetector();
+//            tcpFailureDetector.setPrevious(nbc);
+//            channel.addInterceptor(tcpFailureDetector);
 
             channel.addChannelListener(listener);
             channel.addChannelListener(channelInfo);
             channel.addMembershipListener(memberInfo);
-            channel.addMembershipListener(new TribesMembershipListener());
+            membershipListener = new TribesMembershipListener();
+//            membershipListener.setConfigContext(configurationManager);  //TODO: set the config ctx here and when config context is switched
+            channel.addMembershipListener(membershipListener);
             channel.start(Channel.DEFAULT);
             sender.setChannel(channel);
             contextManager.setSender(sender);
             configurationManager.setSender(sender);
 
-            Member[] members = channel.getMembers();
-            TribesUtil.printMembers(members);
-
             listener.setContextManager(contextManager);
 
-        } catch (ChannelException e) {
+            Member[] members = channel.getMembers();
+            TribesUtil.printMembers(members);
 
-            if (log.isDebugEnabled()) {
-                log.debug("Exit: TribesClusterManager::init");
+            // If there is at least one member in the Tribe, get the current state from a member
+            /*while (members.length > 0 &&
+                   configurationContext.
+                           getProperty(ClusteringConstants.GET_STATE_RESPONSE_RECEIVED) == null) {
+
+                // While there are members and GetStateResponseCommand is not received do the following
+                try {
+                    members = channel.getMembers();
+
+                    //TODO: select a random member and send the request to it. Otherwise the same member will
+                    // get overloaded
+                    sender.sendToMember(new GetStateCommand(), members[0]);
+                    System.out.println("### WAITING FOR STATE UPDATE");
+                    Thread.sleep(200);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    break;
+                }
             }
+            configurationContext.
+                    removePropertyNonReplicable(ClusteringConstants.GET_STATE_RESPONSE_RECEIVED);*/
 
+        } catch (ChannelException e) {
             String message = "Error starting Tribes channel";
             throw new ClusteringFault(message, e);
         }
-
-        if (log.isDebugEnabled()) {
-            log.debug("Exit: TribesClusterManager::init");
-        }
     }
 
     public void setConfigurationManager(ConfigurationManager configurationManager) {
@@ -190,5 +223,10 @@
         if (log.isDebugEnabled()) {
             log.debug("Exit: TribesClusterManager::shutdown");
         }
+    }
+
+    public void setConfigurationContext(ConfigurationContext configurationContext) {
+        this.configurationContext = configurationContext;
+        controlCmdProcessor.setConfigurationContext(configurationContext);
     }
 }

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java?view=auto&rev=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java Thu May 24 08:09:17 2007
@@ -0,0 +1,52 @@
+/*                                                                             
+ * 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.axis2.clustering.ClusteringFault;
+import org.apache.axis2.clustering.control.ControlCommand;
+import org.apache.axis2.clustering.control.GetStateCommand;
+import org.apache.axis2.clustering.control.GetStateResponseCommand;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.catalina.tribes.Member;
+
+/**
+ * 
+ */
+public class TribesControlCommandProcessor {
+    private ConfigurationContext configurationContext;
+
+    private ChannelSender channelSender;
+
+    public void setChannelSender(ChannelSender channelSender) {
+        this.channelSender = channelSender;
+    }
+
+    public TribesControlCommandProcessor(ConfigurationContext configurationContext) {
+        this.configurationContext = configurationContext;
+    }
+
+    public void setConfigurationContext(ConfigurationContext configurationContext) {
+        this.configurationContext = configurationContext;
+    }
+
+    public void process(ControlCommand command, Member sender) throws ClusteringFault {
+        command.execute(configurationContext);
+        if(command instanceof GetStateCommand){
+            channelSender.sendToMember(new GetStateResponseCommand(),
+                                       sender);
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java Thu May 24 08:09:17 2007
@@ -17,8 +17,10 @@
 
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.MembershipListener;
+import org.apache.catalina.tribes.group.interceptors.NonBlockingCoordinator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.context.ConfigurationContext;
 
 /**
  * 
@@ -26,13 +28,20 @@
 public class TribesMembershipListener implements MembershipListener {
 
     private static Log log = LogFactory.getLog(TribesMembershipListener.class);
+//    private ConfigurationContext configContext;
 
     public void memberAdded(Member member) {
         log.info("New member " + getHostSocket(member) + " added to Tribes group.");
+        /* TODO: Send state information to this member.
+        But if all of the members start sending these messages, there is
+        it is going to be messy. Need to ensure that only one node send this message*/
+
+//        System.err.println("++++++ IS COORD="+TribesClusterManager.nbc.isCoordinator());
     }
 
     public void memberDisappeared(Member member) {
         log.info("Member " + getHostSocket(member) + " left Tribes group");
+//        System.err.println("++++++ IS COORD="+TribesClusterManager.nbc.isCoordinator());
     }
 
     private String getHostSocket(Member member) {
@@ -42,5 +51,9 @@
             host = (host == null) ? ("" + hostBytes[i]) : (host + "." + hostBytes[i]);
         }
         return host + ":" + member.getPort();
-    }
+    }/*
+
+    public void setConfigContext(ConfigurationContext configContext) {
+        this.configContext = configContext;
+    }*/
 }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java Thu May 24 08:09:17 2007
@@ -26,23 +26,27 @@
 
     public static void printMembers(Member[] members) {
 
-        log.info("MEMBERS OF THE CURRENT TRIBES GROUP...");
 
         if (members != null) {
             int length = members.length;
-            for (int i = 0; i < length; i++) {
-                byte[] hostBts = members[i].getHost();
-                String host = null;
-                if (hostBts != null) {
-                    for (int j = 0; j < hostBts.length; j++) {
-                        host = host == null ? ("" + hostBts[j]) : (host + "." + hostBts[j]);
+            if (length > 0) {
+                log.info("Members of current Tribes...");
+                for (int i = 0; i < length; i++) {
+                    byte[] hostBts = members[i].getHost();
+                    String host = null;
+                    if (hostBts != null) {
+                        for (int j = 0; j < hostBts.length; j++) {
+                            host = host == null ? ("" + hostBts[j]) : (host + "." + hostBts[j]);
+                        }
                     }
-                }
 
-                String port = "" + members[i].getPort();
-                log.info("Member " + (i + 1) + " NAME:" + members[i].getName() + " HOST:"
-                         + host + "  PORT:" + port);
+                    String port = "" + members[i].getPort();
+                    log.info("Member " + (i + 1) + " NAME:" + members[i].getName() + " HOST:"
+                             + host + "  PORT:" + port);
 
+                }
+            } else {
+                log.info("No members in current Tribe");
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusterManager.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusterManager.java Thu May 24 08:09:17 2007
@@ -19,14 +19,21 @@
 import org.apache.axis2.clustering.configuration.ConfigurationManager;
 import org.apache.axis2.clustering.context.ContextManager;
 import org.apache.axis2.description.ParameterInclude;
+import org.apache.axis2.context.ConfigurationContext;
 
 public interface ClusterManager extends ParameterInclude {
-	
+
     public void init() throws ClusteringFault;
     public ContextManager getContextManager ();
     public ConfigurationManager getConfigurationManager ();
     public void setContextManager (ContextManager contextManager);
     public void setConfigurationManager (ConfigurationManager configurationManager);
     public void shutdown () throws ClusteringFault;
-    
+
+    /**
+     * Set the configuration context
+     *
+     * @param configurationContext
+     */
+    void setConfigurationContext(ConfigurationContext configurationContext);
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java Thu May 24 08:09:17 2007
@@ -17,7 +17,11 @@
 
 package org.apache.axis2.clustering;
 
-public class ClusteringConstants {
-	public static final String AVOID_INITIATION_KEY = "AvoidInitiation";
-	public static final String DOMAIN = "domain";
+public final class ClusteringConstants {
+    private ClusteringConstants() {
+    }
+
+    public static final String AVOID_INITIATION_KEY = "AvoidInitiation";
+    public static final String DOMAIN = "domain";
+    public static final String GET_STATE_RESPONSE_RECEIVED = "local_get.state.response.recd";
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java Thu May 24 08:09:17 2007
@@ -94,6 +94,7 @@
                 configManager.setConfigurationContext(this);
             }
             if (shouldClusterBeInitiated(clusterManager)) {
+                clusterManager.setConfigurationContext(this);
                 clusterManager.init();
             }
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java?view=diff&rev=541316&r1=541315&r2=541316
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java Thu May 24 08:09:17 2007
@@ -66,6 +66,8 @@
             Class clazz = Class.forName(className);
             clusterManager = (ClusterManager) clazz.newInstance();
 
+            clusterManager.setConfigurationContext(configCtx);
+
             //loading the parameters.
             processParameters(clusterElement.getChildrenWithName(new QName(TAG_PARAMETER)),
                               clusterManager,



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org