CVS update: JGroups/src/org/jgroups/protocols STOMP.java
"Bela Ban" <[email protected]> Tue, 26 Oct 2010 16:08:43 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/10/26 16:08:43
Modified: src/org/jgroups/protocols STOMP.java
Log:
ns
Revision Changes Path
1.18 +24 -6 JGroups/src/org/jgroups/protocols/STOMP.java
Index: STOMP.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/protocols/STOMP.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- STOMP.java 26 Oct 2010 12:30:14 -0000 1.17
+++ STOMP.java 26 Oct 2010 16:08:43 -0000 1.18
@@ -22,13 +22,14 @@
* Protocol which provides STOMP (http://stomp.codehaus.org/) support. Very simple implementation, with a
* one-thread-per-connection model. Use for a few hundred clients max.<p/>
* The intended use for this protocol is pub-sub with clients which handle text messages, e.g. stock updates,
- * SMS messages to mobile clients, SNMP traps etc.
+ * SMS messages to mobile clients, SNMP traps etc.<p/>
+ * Note that the full STOMP protocol has not yet been implemented, e.g. transactions are not supported.
* todo: use a thread pool to handle incoming frames and to send messages to clients
* <p/>
* todo: add PING to test health of client connections
* <p/>
* @author Bela Ban
- * @version $Id: STOMP.java,v 1.17 2010/10/26 12:30:14 belaban Exp $
+ * @version $Id: STOMP.java,v 1.18 2010/10/26 16:08:43 belaban Exp $
* @since 2.11
*/
@MBean
@@ -69,6 +70,8 @@
protected final List<Connection> connections=new LinkedList<Connection>();
protected final Map<Address,String> endpoints=new HashMap<Address,String>();
+ protected View view;
+
// Subscriptions and connections which are subscribed
protected final ConcurrentMap<String,Set<Connection>> subscriptions=Util.createConcurrentMap(20);
@@ -137,6 +140,7 @@
connections.add(conn);
}
thread.start();
+ conn.sendInfo();
}
catch(IOException io_ex) {
break;
@@ -207,6 +211,7 @@
throw new EOFException("reading verb");
if(verb.length() == 0)
return null;
+ verb=verb.trim();
Map<String,String> headers=new HashMap<String,String>();
byte[] body=null;
@@ -266,6 +271,8 @@
protected void handleView(View view) {
broadcastEndpoint();
List<Address> mbrs=view.getMembers();
+ this.view=view;
+
synchronized(endpoints) {
endpoints.keySet().retainAll(mbrs);
}
@@ -474,6 +481,17 @@
}
}
+ public void sendInfo() {
+ synchronized(connections) {
+ for(Connection conn: connections) {
+ if(send_info)
+ conn.writeResponse(ServerVerb.INFO, "view", view.toString(), "endpoints", getAllEndpoints());
+ else
+ conn.writeResponse(ServerVerb.INFO, "view", view.toString());
+ }
+ }
+ }
+
/**
* Sends back a response. The keys_and_values vararg array needs to have an even number of elements
* @param response
@@ -495,7 +513,7 @@
out.flush();
}
catch(IOException ex) {
- log.error("failed writing response " + response, ex);
+ log.error("failed writing response " + response + ": " + ex);
}
}
@@ -505,11 +523,11 @@
out.flush();
}
catch(IOException ex) {
- log.error("failed writing response", ex);
+ log.error("failed writing response: " + ex);
}
}
}
-
+
public static class Frame {
final String verb;
@@ -544,7 +562,7 @@
if(body != null && body.length > 0) {
sb.append("body: ");
if(body.length < 50)
- sb.append(": " + new String(body)).append(body.length).append(" bytes");
+ sb.append(": " + new String(body)).append(" (").append(body.length).append(" bytes)");
else
sb.append(body.length).append(" bytes");
}
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev