Re: [javagroups-users] view synchrony guarantees?
Brought to you by:
belaban
From: Bela B. <be...@ya...> - 2007-11-30 08:25:19
|
I modified and added your demo to JGroups: tests/other/org//jgroups/tests/ViewDeliveryDemo. I get the violation too. Vladimir and I will investigate Robert Newson wrote: > Hi, > > I'm running a test where I have eight machines each sending batches of > messages, leaving and joining a channel at random. The messages > contain the current ViewId. On receipt that ViewId is compared to the > local ViewId. My stack is the "udp" one in stacks.xml, though not over > a multiplexed channel. > > Given the presence of the FLUSH protocol and its description in its > Javadoc, I was not expecting to see a message arrive in a later view > than which it was sent in. As it happens, it does. It's a low rate, my > batches are up to 5000 messages and I sent 1 or 2 such messages every > few seconds, but I expected none. > > FLUSH states this; > > "Before installing a new view V2, flushing would ensure that all > messages *sent* in the current view V1 are indeed *delivered* in V1, > rather than in V2 (in all non-faulty members). This is essentially > Virtual Synchrony." > > This appears not to be the case with 2.6.1 at least. > > here's a sample violation which shows message sent in view 21 arriving > in view 22 (the coordinator of the views is the same). > > VIOLATION: message sent in view [192.168.164.227:33198|21] received in > [192.168.164.227:33198|22] > > The full source code for the demo is below; > > > import java.security.SecureRandom; > import java.util.Random ; > > import org.jgroups.Address; > import org.jgroups.Channel; > import org.jgroups.Message; > import org.jgroups.Receiver; > import org.jgroups.View; > import org.jgroups.ViewId; > > /** > * Verify that all messages are delivered in the view they are sent in > * regardless of members joining, leaving or crashing. > * > * @author rnewson > * > */ > public final class ViewDeliveryDemo { > > private static class MyReceiver implements Receiver { > > @Override > public byte[] getState() { > // Ignored. > return null; > } > > @Override > public void receive(final Message msg) { > final Object obj = msg.getObject (); > if (obj instanceof ViewId) { > final ViewId sent_in_vid = (ViewId) obj; > final ViewId arrived_in_vid = channel.getView().getVid(); > if (!sent_in_vid.equals(arrived_in_vid)) { > System.out > .printf( > "VIOLATION: message sent in view > %s received in %s\n", > sent_in_vid, arrived_in_vid); > } > } else { > System.out.println("ERROR: unexpected payload: " + obj); > } > } > > @Override > public void setState(byte[] state) { > // Ignored. > } > > @Override > public void block() { > > } > > @Override > public void suspect(Address suspected_mbr) { > > } > > @Override > public void viewAccepted(View new_view) { > > } > > } > > private static final int SEND = 0; > private static final int REOPEN = 1; > private static final int RECONNECT = 2; > > private static Channel channel; > private static final Random random = new SecureRandom(); > > public static void main(final String[] args) throws Exception { > connect(); > while (true) { > switch (random.nextInt(3)) { > case SEND: > send(); > break; > case REOPEN: > reopen(); > break; > case RECONNECT: > reconnect(); > break; > default: > assert false; > } > Thread.sleep(random.nextInt(2000)); > } > } > > private static void send() throws Exception { > System.out.println("Sending batch of messages."); > for (int i = 0, max = random.nextInt(1000); i < max; i++) { > channel.send(null, null, channel.getView().getVid()); > } > } > > private static void reopen() throws Exception { > System.out.println("closing and reopening."); > channel.close(); > Thread.sleep(random.nextInt(5000)); > channel.open(); > connect(); > } > > private static void reconnect() throws Exception { > System.out.println("disconnecting and reconnecting."); > channel.disconnect(); > Thread.sleep(random.nextInt(5000)); > connect(); > } > > private static void connect() throws Exception { > if (channel == null) { > channel = DemoUtils.getChannel(null); > } > channel.setReceiver(new MyReceiver()); > channel.connect("view_test"); > } > } > > note: DemoUtils.getChannel(null) calls createChannel() on a > JChannelFactory for which setMultiplexerConfig(" stacks.xml") has been > called. Also, AUTO_RECONNECT has been set to true. > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > ------------------------------------------------------------------------ > > _______________________________________________ > javagroups-users mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/javagroups-users > -- Bela Ban Lead JGroups / Clustering Team JBoss - a division of Red Hat |