r9561 - helma/extensions/helmaswarm/trunk/src/helma/swarm

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090401131338.957503D0D6@mia>
Author: hannes
Date: 2009-04-01 15:13:38 +0200 (Wed, 01 Apr 2009)
New Revision: 9561

Modified:
   helma/extensions/helmaswarm/trunk/src/helma/swarm/SwarmIDGenerator.java
Log:
Catch and log TimeoutException in generateID loop. Increase message timeout to 20 seconds as it is just a safety net that shouldn't be used as long as a suspicion service is available.

Details at http://dev.helma.org/trac/helma/changeset/9561

Modified: helma/extensions/helmaswarm/trunk/src/helma/swarm/SwarmIDGenerator.java
===================================================================
--- helma/extensions/helmaswarm/trunk/src/helma/swarm/SwarmIDGenerator.java	2009-03-31 20:20:13 UTC (rev 9560)
+++ helma/extensions/helmaswarm/trunk/src/helma/swarm/SwarmIDGenerator.java	2009-04-01 13:13:38 UTC (rev 9561)
@@ -68,7 +68,7 @@
     public String generateID(DbMapping dbmap) throws Exception {
         String typeName = dbmap == null ? null : dbmap.getTypeName();
         // try three times to get id from group coordinator
-        for (int i=0; i<3; i++) {
+        for (int i = 0; i < 3; i++) {
             // if we are the coordinator, create id locally
             Address coordinator = (Address) view.getMembers().firstElement();
             if (coordinator == null) {
@@ -80,8 +80,15 @@
                 return nmgr.doGenerateID(dbmap);
             }
             Message msg = new Message(coordinator, address, typeName);
-            Object response = dispatcher.sendMessage(msg, GroupRequest.GET_FIRST, 8000);
-            log.info("SwarmIDGenerator: Received ID " + response + " for " + dbmap);
+            Object response = null;
+            try {
+                // Note: message timeout should not be used if suspicion service is available.
+                // It's more of a safety net/last ressort here.
+                response = dispatcher.sendMessage(msg, GroupRequest.GET_FIRST, 20000);
+                log.info("SwarmIDGenerator: Received ID " + response + " for " + dbmap);
+            } catch (TimeoutException timeout) {
+                log.info("SwarmIDGenerator: Message to " + coordinator + " timed out");
+            }
             if (response != null) {
                 return (String) response;
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.