tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r462592 - in /tomcat/tc6.0.x/trunk/java/org/apache/catalina: ha/tcp/SimpleTcpCluster.java tribes/membership/McastServiceImpl.java tribes/tipis/AbstractReplicatedMap.java
Date Tue, 10 Oct 2006 21:50:44 GMT
Author: fhanik
Date: Tue Oct 10 14:50:43 2006
New Revision: 462592

URL: http://svn.apache.org/viewvc?view=rev&rev=462592
Log:
Fixes and improvements

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java?view=diff&rev=462592&r1=462591&r2=462592
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java Tue Oct 10
14:50:43 2006
@@ -555,12 +555,13 @@
      */
     public String getManagerName(String name, Manager manager) {
         String clusterName = name ;
+        if ( clusterName == null ) clusterName = manager.getContainer().getName();
         if(getContainer() instanceof Engine) {
             Container context = manager.getContainer() ;
             if(context != null && context instanceof Context) {
                 Container host = ((Context)context).getParent();
                 if(host != null && host instanceof Host)
-                    clusterName = host.getName()  + name ;
+                    clusterName = host.getName() +"#" + name ;
             }
         }
         return clusterName;

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java?view=diff&rev=462592&r1=462591&r2=462592
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
Tue Oct 10 14:50:43 2006
@@ -163,6 +163,7 @@
     protected void setupSocket() throws IOException {
         if (mcastBindAddress != null) socket = new MulticastSocket(new InetSocketAddress(mcastBindAddress,
port));
         else socket = new MulticastSocket(port);
+        socket.setLoopbackMode(false); //hint that we don't need loop back messages
         if (mcastBindAddress != null) {
 			if(log.isInfoEnabled())
                 log.info("Setting multihome multicast interface to:" +mcastBindAddress);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?view=diff&rev=462592&r1=462591&r2=462592
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
Tue Oct 10 14:50:43 2006
@@ -45,6 +45,7 @@
 import org.apache.catalina.tribes.util.Arrays;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import java.util.ConcurrentModificationException;
 
 /**
  *
@@ -760,57 +761,63 @@
     }
     
     public Object get(Object key) {
-            MapEntry entry = (MapEntry)super.get(key);
-            if (log.isTraceEnabled()) log.trace("Requesting id:"+key+" entry:"+entry);
-            if ( entry == null ) return null;
-            if ( !entry.isPrimary() ) {
-                //if the message is not primary, we need to retrieve the latest value
-                try {
-                    Member[] backup = null;
-                    MapMessage msg = null;
-                    if ( !entry.isBackup() ) {
-                        //make sure we don't retrieve from ourselves
-                        msg = new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP,
false,
-                                             (Serializable) key, null, null, null);
-                        Response[] resp = getRpcChannel().send(entry.getBackupNodes(),msg,
this.getRpcChannel().FIRST_REPLY, Channel.SEND_OPTIONS_DEFAULT, getRpcTimeout());
-                        if (resp == null || resp.length == 0) {
-                            //no responses
-                            log.warn("Unable to retrieve remote object for key:" + key);
-                            return null;
-                        }
-                        msg = (MapMessage) resp[0].getMessage();
-                        msg.deserialize(getExternalLoaders());
-                        backup = entry.getBackupNodes();
-                        if ( entry.getValue() instanceof ReplicatedMapEntry ) {
-                            ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
-                            val.setOwner(getMapOwner());
-                        }
-                        if ( msg.getValue()!=null ) entry.setValue(msg.getValue());
+        MapEntry entry = (MapEntry)super.get(key);
+        if (log.isTraceEnabled()) log.trace("Requesting id:"+key+" entry:"+entry);
+        if ( entry == null ) return null;
+        if ( !entry.isPrimary() ) {
+            //if the message is not primary, we need to retrieve the latest value
+            try {
+                Member[] backup = null;
+                MapMessage msg = null;
+                if ( !entry.isBackup() ) {
+                    //make sure we don't retrieve from ourselves
+                    msg = new MapMessage(getMapContextName(), MapMessage.MSG_RETRIEVE_BACKUP,
false,
+                                         (Serializable) key, null, null, null);
+                    Response[] resp = getRpcChannel().send(entry.getBackupNodes(),msg, this.getRpcChannel().FIRST_REPLY,
Channel.SEND_OPTIONS_DEFAULT, getRpcTimeout());
+                    if (resp == null || resp.length == 0) {
+                        //no responses
+                        log.warn("Unable to retrieve remote object for key:" + key);
+                        return null;
                     }
-                    if (entry.isBackup()) {
-                        //select a new backup node
-                        backup = publishEntryInfo(key, entry.getValue());
-                    } else if ( entry.isProxy() ) {
-                        //invalidate the previous primary
-                        msg = new MapMessage(getMapContextName(),MapMessage.MSG_PROXY,false,(Serializable)key,null,null,backup);
-                        Member[] dest = getMapMembersExcl(backup);
-                        if ( dest!=null && dest.length >0) {
-                            getChannel().send(dest, msg, getChannelSendOptions());
-                        }
+                    msg = (MapMessage) resp[0].getMessage();
+                    msg.deserialize(getExternalLoaders());
+                    backup = entry.getBackupNodes();
+                    if ( entry.getValue() instanceof ReplicatedMapEntry ) {
+                        ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
+                        val.setOwner(getMapOwner());
                     }
-    
-                    entry.setBackupNodes(backup);
-                    entry.setBackup(false);
-                    entry.setProxy(false);
-    
-    
-                } catch (Exception x) {
-                    log.error("Unable to replicate out data for a LazyReplicatedMap.get operation",
x);
-                    return null;
+                    if ( msg.getValue()!=null ) entry.setValue(msg.getValue());
                 }
+                if (entry.isBackup()) {
+                    //select a new backup node
+                    backup = publishEntryInfo(key, entry.getValue());
+                } else if ( entry.isProxy() ) {
+                    //invalidate the previous primary
+                    msg = new MapMessage(getMapContextName(),MapMessage.MSG_PROXY,false,(Serializable)key,null,null,backup);
+                    Member[] dest = getMapMembersExcl(backup);
+                    if ( dest!=null && dest.length >0) {
+                        getChannel().send(dest, msg, getChannelSendOptions());
+                    }
+                }
+
+                entry.setBackupNodes(backup);
+                entry.setBackup(false);
+                entry.setProxy(false);
+
+
+            } catch (Exception x) {
+                log.error("Unable to replicate out data for a LazyReplicatedMap.get operation",
x);
+                return null;
             }
-            if (log.isTraceEnabled()) log.trace("Requesting id:"+key+" result:"+entry.getValue());
-            return entry.getValue();
+        }
+        if (log.isTraceEnabled()) log.trace("Requesting id:"+key+" result:"+entry.getValue());
+        if ( entry.getValue() != null && entry.getValue() instanceof ReplicatedMapEntry
) {
+            ReplicatedMapEntry val = (ReplicatedMapEntry)entry.getValue();
+            //hack, somehow this is not being set above
+            val.setOwner(getMapOwner());
+            
+        }
+        return entry.getValue();
     }    
 
     
@@ -950,7 +957,7 @@
             //todo, implement a counter variable instead
             //only count active members in this node
             int counter = 0;
-            Iterator it = super.entrySet().iterator();
+            Iterator it = Collections.unmodifiableSet(super.entrySet()).iterator();
             while (it.hasNext() ) {
                 Map.Entry e = (Map.Entry) it.next();
                 if ( e != null ) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message