/** * Helper method to create a Message with given parameters and invoke {@link #send(Message)}. * @param dst destination address for the message. If null, the message will be sent to all cluster members * @param obj a serializable object. Will be marshalled into the byte buffer of the message. If it * is <em>not</em> serializable, an exception will be thrown * @throws Exception exception thrown if message sending was not successful */ public JChannel send(Address dst, Object obj) throws Exception { return send(new Message(dst, obj)); }
/** * Enables access to event mechanism of a channel and is normally not used by clients directly. * * @param evt sends an Event to a specific protocol layer and receives a response. * @return a response from a particular protocol layer targeted by Event parameter */ public Object down(Event evt) { if(evt.type() == 1) // MSG return ch.down((Message)evt.getArg()); return ch.down(evt); }
public Draw(JChannel channel) throws Exception { this.channel=channel; channel.setReceiver(this); channel.addChannelListener(this); }
/** Returns true if all mbrs are elements of this view, false otherwise */ public boolean containsMembers(Address ... mbrs) { if(mbrs == null || members == null) return false; for(Address mbr: mbrs) { if(!containsMember(mbr)) return false; } return true; }
/** * Establishes an order between 2 ViewIds. The comparison is done on the IDs, if they are equal, we use the creator. * * @return 0 for equality, value less than 0 if smaller, greater than 0 if greater. */ public int compareTo(ViewId other) { return id > other.id ? 1 : id < other.id ? -1 : creator.compareTo(other.creator); }
protected JChannel notifyChannelClosed(JChannel c) { return notifyListeners(l -> l.channelClosed(c), "channelClosed()"); }
/** * Removes a ChannelListener previously installed * * @param listener to be removed */ public synchronized void removeChannelListener(ChannelListener listener) { ch.removeChannelListener(listener); }
public Membership add(Address ... mbrs) { for(Address mbr: mbrs) add(mbr); return this; }
/** * Constructs a JChannel with the protocol stack configuration contained by the protocol stack configurator parameter. * <p> * All of the public constructors of this class eventually delegate to this method. * @param configurator A protocol stack configurator containing a JGroups protocol stack configuration. */ public JChannel(ProtocolStackConfigurator configurator) throws Exception { init(configurator); }
/** * Sends a message. See {@link #send(Address,byte[],int,int)} for details * @param dst destination address for the message. If null, the message will be sent to all cluster members * @param buf buffer message payload * @throws Exception exception thrown if the message sending was not successful */ public JChannel send(Address dst, byte[] buf) throws Exception { return send(new Message(dst, buf)); }
/** * Sends a message to a destination. * * @param dst the destination address. If null, the message will be sent to all cluster nodes (= cluster members) * @param buf the buffer to be sent * @param offset the offset into the buffer * @param length the length of the data to be sent. Has to be <= buf.length - offset. This will send * {@code length} bytes starting at {@code offset} * @throws Exception thrown if send() failed */ public JChannel send(Address dst, byte[] buf, int offset, int length) throws Exception { return send(new Message(dst, buf, offset, length)); }