Update of /var/cvs/applications/clustering/src/org/mmbase/clustering/unicast
In directory 
james.mmbase.org:/tmp/cvs-serv2657/applications/clustering/src/org/mmbase/clustering/unicast

Modified Files:
        Unicast.java ChangesSender.java ChangesReceiver.java 
Log Message:
 mmbase unicast host configurable
 Added javadoc



See also: 
http://cvs.mmbase.org/viewcvs/applications/clustering/src/org/mmbase/clustering/unicast


Index: Unicast.java
===================================================================
RCS file: 
/var/cvs/applications/clustering/src/org/mmbase/clustering/unicast/Unicast.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Unicast.java        21 Jun 2007 15:50:25 -0000      1.11
+++ Unicast.java        9 May 2008 11:33:54 -0000       1.12
@@ -11,18 +11,20 @@
 
 import java.util.Map;
 
-import org.mmbase.core.event.NodeEvent;
 import org.mmbase.clustering.ClusterManager;
+import org.mmbase.module.core.MMBase;
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
 import org.mmbase.util.xml.UtilReader;
 
 
 /**
- * @javadoc
+ * Unicast implementation for the mmbase cluster. This implemenetation
+ * opens a direct network connection to each host mentioned in the mmservers
+ * as active. 
  *
  * @author Nico Klasens
- * @version $Id: Unicast.java,v 1.11 2007/06/21 15:50:25 nklasens Exp $
+ * @version $Id: Unicast.java,v 1.12 2008/05/09 11:33:54 nklasens Exp $
  */
 public class Unicast extends ClusterManager {
 
@@ -30,6 +32,9 @@
 
     public static final String CONFIG_FILE = "unicast.xml";
 
+    /** Host on which the server socket is bound.*/
+    private String unicastHost;
+    
     /** Port on which the talking between nodes take place.*/
     private int unicastPort = 4243;
 
@@ -79,13 +84,25 @@
             } catch (Exception e) {}
         }
 
-        tmp = configuration.get("unicasttimeout");
-        if (tmp != null && !tmp.equals("")) {
+        unicastHost = MMBase.getMMBase().getHost();
+        
+        String tmpHost = configuration.get("unicasthost");
+        if (tmpHost != null && !tmpHost.equals("")) {
+            unicastHost = tmpHost;
+        }
+        tmpHost = 
configuration.get(org.mmbase.module.core.MMBase.getMMBase().getMachineName() + 
".unicasthost");
+        if (tmpHost != null && !tmpHost.equals("")) {
+            unicastHost = tmpHost;
+        }
+        
+        String tmpTimeout = configuration.get("unicasttimeout");
+        if (tmpTimeout != null && !tmpTimeout.equals("")) {
             try {
-                unicastTimeout = Integer.parseInt(tmp);
+                unicastTimeout = Integer.parseInt(tmpTimeout);
             } catch (Exception e) {}
         }
 
+        log.info("unicast host: "    + unicastHost);
         log.info("unicast port: "    + unicastPort);
         log.info("unicast timeout: " + unicastTimeout);
 
@@ -97,7 +114,7 @@
     protected synchronized void startCommunicationThreads() {
         ucs = new ChangesSender(reader.getProperties(), unicastPort, 
unicastTimeout, nodesToSend, send);
         try {
-            ucr = new ChangesReceiver(unicastPort, nodesToSpawn);
+            ucr = new ChangesReceiver(unicastHost, unicastPort, nodesToSpawn);
         } catch (java.io.IOException ioe) {
             log.error(ioe);
         }
@@ -119,16 +136,4 @@
         }
     }
 
-    // javadoc inherited
-    public void changedNode(NodeEvent event) {
-        byte[] message = createMessage(event);
-        nodesToSend.offer(message);
-        //Multicast receives his own message. Unicast now too.
-        nodesToSpawn.offer(message);
-        if (log.isDebugEnabled()) {
-            log.debug("message: " + event);
-        }
-        return;
-    }
-
 }


Index: ChangesSender.java
===================================================================
RCS file: 
/var/cvs/applications/clustering/src/org/mmbase/clustering/unicast/ChangesSender.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ChangesSender.java  21 Jun 2007 15:50:25 -0000      1.15
+++ ChangesSender.java  9 May 2008 11:33:54 -0000       1.16
@@ -28,7 +28,7 @@
  * sending queue over unicast connections
  *
  * @author Nico Klasens
- * @version $Id: ChangesSender.java,v 1.15 2007/06/21 15:50:25 nklasens Exp $
+ * @version $Id: ChangesSender.java,v 1.16 2008/05/09 11:33:54 nklasens Exp $
  */
 public class ChangesSender implements Runnable {
 
@@ -58,10 +58,11 @@
 
     /**
      * Construct UniCast Sender
+     * @param configuration configuration of unicast
      * @param unicastPort port of the unicast connections
      * @param unicastTimeout timeout on the connections
      * @param nodesToSend Queue of messages to send
-     * @param mmbase MMBase instance
+     * @param send Statistics
      */
     ChangesSender(Map<String,String> configuration, int unicastPort, int 
unicastTimeout, BlockingQueue<byte[]> nodesToSend, Statistics send) {
         this.nodesToSend = nodesToSend;


Index: ChangesReceiver.java
===================================================================
RCS file: 
/var/cvs/applications/clustering/src/org/mmbase/clustering/unicast/ChangesReceiver.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ChangesReceiver.java        21 Jun 2007 15:50:25 -0000      1.9
+++ ChangesReceiver.java        9 May 2008 11:33:54 -0000       1.10
@@ -14,7 +14,6 @@
 import java.util.concurrent.BlockingQueue;
 
 import org.mmbase.core.util.DaemonThread;
-import org.mmbase.module.core.MMBase;
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
 
@@ -24,7 +23,7 @@
  * to receive changes from other MMBase Servers.
  *
  * @author Nico Klasens
- * @version $Id: ChangesReceiver.java,v 1.9 2007/06/21 15:50:25 nklasens Exp $
+ * @version $Id: ChangesReceiver.java,v 1.10 2008/05/09 11:33:54 nklasens Exp $
  */
 public class ChangesReceiver implements Runnable {
 
@@ -40,13 +39,15 @@
 
     /**
      * Construct UniCast Receiver
+     * @param unicastHost host of unicast connection
      * @param unicastPort port of the unicast connections
      * @param nodesToSpawn Queue of received messages
+     * @throws IOException when server socket failrf to listen
      */
-    ChangesReceiver(int unicastPort, BlockingQueue<byte[]> nodesToSpawn) 
throws IOException {
+    ChangesReceiver(String unicastHost, int unicastPort, BlockingQueue<byte[]> 
nodesToSpawn) throws IOException {
         this.nodesToSpawn = nodesToSpawn;
         this.serverSocket = new ServerSocket();
-        SocketAddress address = new 
InetSocketAddress(MMBase.getMMBase().getHost(), unicastPort);
+        SocketAddress address = new InetSocketAddress(unicastHost, 
unicastPort);
         serverSocket.bind(address);
         log.info("Listening to " + address);
         this.start();
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to