tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1296020 - in /openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery: MultipointDiscoveryAgent.java MultipointServer.java
Date Fri, 02 Mar 2012 01:38:07 GMT
Author: dblevins
Date: Fri Mar  2 01:38:07 2012
New Revision: 1296020

URL: http://svn.apache.org/viewvc?rev=1296020&view=rev
Log:
OPENEJB-1789: Multipoint.discoveryHost allows for "bind" of 0.0.0.0

Modified:
    openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
    openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java

Modified: openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java?rev=1296020&r1=1296019&r2=1296020&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
(original)
+++ openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointDiscoveryAgent.java
Fri Mar  2 01:38:07 2012
@@ -31,6 +31,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.net.URI;
+import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -55,6 +56,7 @@ public class MultipointDiscoveryAgent im
     private MultipointServer multipointServer;
     private boolean debug = true;
     private String name;
+    private String discoveryHost;
 
     public MultipointDiscoveryAgent() {
     }
@@ -73,6 +75,8 @@ public class MultipointDiscoveryAgent im
         port = options.get("port", port);
         initialServers = options.get("initialServers", initialServers);
         heartRate = options.get("heart_rate", heartRate);
+        discoveryHost = options.get("discoveryHost", host);
+        name = options.get("discoveryName", MultipointServer.randomColor());
 
 
         Tracker.Builder builder = new Tracker.Builder();
@@ -132,7 +136,7 @@ public class MultipointDiscoveryAgent im
         try {
             if (running.compareAndSet(false, true)) {
 
-                multipointServer = new MultipointServer(host, port, tracker, name, debug).start();
+                multipointServer = new MultipointServer(host, discoveryHost, port, tracker,
name, debug).start();
 
                 this.port = multipointServer.getPort();
                 

Modified: openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java?rev=1296020&r1=1296019&r2=1296020&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
(original)
+++ openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
Fri Mar  2 01:38:07 2012
@@ -56,7 +56,6 @@ public class MultipointServer {
 
     private static final URI END_LIST = URI.create("end:list");
 
-    private final String host;
     private final int port;
     private final Selector selector;
     private final URI me;
@@ -86,30 +85,35 @@ public class MultipointServer {
     }
 
     public MultipointServer(String host, int port, Tracker tracker, String name, boolean
debug) throws IOException {
+        this(host, host, port, tracker, name, debug);
+    }
+
+    public MultipointServer(String bindHost, String broadcastHost, int port, Tracker tracker,
String name, boolean debug) throws IOException {
         if (tracker == null) throw new NullPointerException("tracker cannot be null");
-        this.host = host;
         this.tracker = tracker;
         this.name = name;
         this.debug = debug;
+        String format = String.format("MultipointServer(bindHost=%s, discoveryHost=%s, port=%s,
name=%s, debug=%s)", bindHost, broadcastHost, port, name, debug);
+        log.debug(format);
         ServerSocketChannel serverChannel = ServerSocketChannel.open();
 
         ServerSocket serverSocket = serverChannel.socket();
-        InetSocketAddress address = new InetSocketAddress(host, port);
+        InetSocketAddress address = new InetSocketAddress(bindHost, port);
         serverSocket.bind(address);
         serverChannel.configureBlocking(false);
 
         this.port = serverSocket.getLocalPort();
         if (name != null) {
-            me = URI.create("conn://" + this.host + ":" + this.port + "/" + name);
+            me = URI.create("conn://" + broadcastHost + ":" + this.port + "/" + name);
         } else {
-            me = URI.create("conn://" + this.host + ":" + this.port);
+            me = URI.create("conn://" + broadcastHost + ":" + this.port);
         }
 
         selector = Selector.open();
 
         serverChannel.register(selector, SelectionKey.OP_ACCEPT);
 
-        println("Broadcasting ");
+        println("Broadcasting");
     }
 
     public int getPort() {
@@ -773,12 +777,15 @@ public class MultipointServer {
                 session = sessions[0];
                 duplicate = sessions[1];
 
-                session.info(session + "@" + session.hashCode() + " KEEP");
-                duplicate.info(duplicate + "@" + duplicate.hashCode() + " KILL");
+                session.trace(session + "@" + session.hashCode() + " KEEP");
+                duplicate.trace(duplicate + "@" + duplicate.hashCode() + " KILL");
 
                 duplicate.hangup = true;
             }
 
+            if (session.state == State.GREETING) {
+                session.info(session + "@" + session.hashCode() + " DISCOVERED");
+            }
             connections.put(session.uri, session);
         }
     }
@@ -797,7 +804,7 @@ public class MultipointServer {
                 '}';
     }
 
-    private static String randomColor() {
+    public static String randomColor() {
         String[] colors = {
                 "almond",
                 "amber",



Mime
View raw message