Skip to content
Browse files

changed signature of Channel.down() from Object back to void (http://…

  • Loading branch information...
1 parent e573e0f commit 3b36e9cf69b7c25c79201b23fc1e0e8dd1f92a78 @belaban committed Apr 2, 2007
View
14 src/org/jgroups/Channel.java
@@ -1,4 +1,4 @@
-// $Id: Channel.java,v 1.30 2007/01/18 15:18:19 belaban Exp $
+// $Id: Channel.java,v 1.31 2007/04/02 07:10:16 belaban Exp $
package org.jgroups;
@@ -198,10 +198,18 @@ abstract public void send(Address dst, Address src, Serializable obj) throws Cha
blocks to communicate with (building block) specific protocol layers. Currently useful only
with JChannel.
*/
- public Object down(Event evt) {
- return null;
+ public void down(Event evt) {
}
+ /**
+ * Can be used instead of down() when a return value is expected. This will be removed in 3.0 when we change
+ * the signature of down() to return Object rather than void
+ * @param evt
+ * @return
+ */
+ public Object downcall(Event evt) {
+ return null;
+ }
/** Receives a message, a view change or a block event. By using <code>setOpt</code>, the
View
35 src/org/jgroups/JChannel.java
@@ -68,7 +68,7 @@
* the construction of the stack will be aborted.
*
* @author Bela Ban
- * @version $Id: JChannel.java,v 1.126 2007/02/16 07:32:07 belaban Exp $
+ * @version $Id: JChannel.java,v 1.127 2007/04/02 07:10:16 belaban Exp $
*/
public class JChannel extends Channel {
@@ -393,7 +393,7 @@ public synchronized void connect(String cluster_name) throws ChannelException {
flush_unblock_promise.reset();
Event connect_event=new Event(Event.CONNECT, cluster_name);
- Object res=down(connect_event); // waits forever until connected (or channel is closed)
+ Object res=downcall(connect_event); // waits forever until connected (or channel is closed)
if(res != null && res instanceof Exception) { // the JOIN was rejected by the coordinator
throw new ChannelException("connect() failed", (Throwable)res);
}
@@ -1169,7 +1169,33 @@ public Object up(Event evt) {
* Sends a message through the protocol stack if the stack is available
* @param evt the message to send down, encapsulated in an event
*/
- public Object down(Event evt) {
+ public void down(Event evt) {
+ if(evt == null) return;
+
+ switch(evt.getType()) {
+ case Event.CONFIG: // handle setting of additional data (kludge, will be removed soon)
+ try {
+ Map m=(Map)evt.getArg();
+ if(m != null && m.containsKey("additional_data")) {
+ additional_data=(byte[])m.get("additional_data");
+ if(local_addr instanceof IpAddress)
+ ((IpAddress)local_addr).setAdditionalData(additional_data);
+ }
+ }
+ catch(Throwable t) {
+ if(log.isErrorEnabled()) log.error("CONFIG event did not contain a hashmap: " + t);
+ }
+ break;
+ case Event.STATE_TRANSFER_INPUTSTREAM_CLOSED:
+ state_promise.setResult(Boolean.TRUE);
+ break;
+ }
+
+ prot_stack.down(evt);
+ }
+
+
+ public Object downcall(Event evt) {
if(evt == null) return null;
switch(evt.getType()) {
@@ -1448,7 +1474,6 @@ public boolean flushSupported() {
*
*
* @param timeout
- * @param numberOfAttempts if flush was unsuccessful attempt again until numberOfAttempts is 0
* @param automatic_resume Call {@link #stopFlush()} after the flush
* @return true if FLUSH completed within the timeout
*/
@@ -1457,7 +1482,7 @@ public boolean startFlush(long timeout, boolean automatic_resume) {
throw new IllegalStateException("Flush is not supported, add pbcast.FLUSH protocol to your configuration");
}
boolean successfulFlush = false;
- successfulFlush = (Boolean) down(new Event(Event.SUSPEND));
+ successfulFlush = (Boolean) downcall(new Event(Event.SUSPEND));
if(automatic_resume)
stopFlush();
View
4 src/org/jgroups/blocks/MessageDispatcher.java
@@ -35,7 +35,7 @@
* the application instead of protocol level.
*
* @author Bela Ban
- * @version $Id: MessageDispatcher.java,v 1.69 2007/01/12 14:22:04 belaban Exp $
+ * @version $Id: MessageDispatcher.java,v 1.70 2007/04/02 07:10:17 belaban Exp $
*/
public class MessageDispatcher implements RequestHandler {
protected Channel channel=null;
@@ -734,7 +734,7 @@ public Object up(Event evt) {
public Object down(Event evt) {
if(channel != null) {
- return channel.down(evt);
+ return channel.downcall(evt);
}
else
if(this.log.isWarnEnabled()) {
View
15 src/org/jgroups/mux/MuxChannel.java
@@ -11,7 +11,7 @@
* {@link org.jgroups.ChannelFactory#createMultiplexerChannel(String,String,boolean,String)}. Maintains the multiplexer
* ID, which is used to add a header to each message, so that the message can be demultiplexed at the receiver
* @author Bela Ban
- * @version $Id: MuxChannel.java,v 1.30 2007/01/22 18:05:24 vlada Exp $
+ * @version $Id: MuxChannel.java,v 1.31 2007/04/02 07:10:15 belaban Exp $
*/
public class MuxChannel extends JChannel {
@@ -196,14 +196,23 @@ public void send(Address dst, Address src, Serializable obj) throws ChannelNotCo
}
- public Object down(Event evt) {
+ public void down(Event evt) {
if(evt.getType() == Event.MSG) {
Message msg=(Message)evt.getArg();
msg.putHeader(name, hdr);
}
- return ch.down(evt);
+ ch.down(evt);
}
+ public Object downcall(Event evt) {
+ if(evt.getType() == Event.MSG) {
+ Message msg=(Message)evt.getArg();
+ msg.putHeader(name, hdr);
+ }
+ return ch.downcall(evt);
+ }
+
+
public boolean getState(Address target, long timeout) throws ChannelNotConnectedException, ChannelClosedException {
return getState(target, null, timeout);
}

0 comments on commit 3b36e9c

Please sign in to comment.
Something went wrong with that request. Please try again.