eclipse-ee4j / glassfish-shoal

Shoal
Other
5 stars 9 forks source link

messages received not in same order as when sent #36

Open glassfishrobot opened 16 years ago

glassfishrobot commented 16 years ago

I did some extensive testing to see if the messages that are sent, get received by the other instances in the same order.

I wrote a simple test for testing point to point message send - receive : tests/com/sun/enterprise/ee/ cms/tests/p2pmessagesend/P2PMessageSendAndReceive.java

This test uses the MessageAction Signal to receive messages. I started 2 instances (one is the sender while the other is the receiver). 10 messages are sent by instance A in sequence. The receiver i.e. instance B does not receive the messages in the same order that they were sent in. The logs show that the same thread takes care of calling the processNotification() method for each message received. So its not a threading issue.

The main line of code is ClusterManager.send(id, message) which then calls outputPipe.send(message).

Here are the logs :

Sender : INFO: Sending messages... Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 0 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 1 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 2 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 3 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 4 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 5 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 6 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 7 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 8 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 9 sent from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive sendMessages INFO: Message 10 sent from C1 to Group

Receiver : Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 0 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 1 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 3 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 5 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 4 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 7 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 2 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 8 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 6 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 10 from C1 to Group Jan 29, 2008 2:28:26 PM com.sun.enterprise.ee.cms.tests.p2pmessagesend.P2PMessageSendAndReceive processNotification INFO: Message: P2PMsgSendReceive : message 9 from C1 to Group

I also tried another test. I added some code to ClusterManager.main() to send and receive messages using the ClusterMessageListener model. The ClusterMessageListener's handleClusterMessage() method is implemented in GroupCommunicationProviderImpl which puts the incoming message into MessageQueue which is a FIFO order queue. The MessageWindow then takes the message and goes through MessageAction API which is a single thread. In this case, the logs are showing a different thread calling the ClusterManager.pipeMsgEvent() every time. So looks like the PipeMsgListener is spawning a new thread every time it calls pipeMsgEvent().

I tried checking the order of the messages received via the Listener model in the 1st case as well, as mentioned above . The sequence of messages received by ClusterMessageListener.handlerClusterMessage() and the MessageAction signal API is the same. So the underlying Jxta layer seems to be sending the messages out of order.

main method changes to ClusterManager :

public static void main(final String[] argv) { JxtaUtil.setupLogHandler(); LOG.setLevel(Level.INFO); final String name = System.getProperty("INAME", "instanceName"); final String groupName = System.getProperty("GNAME", "groupName"); LOG.log(Level.INFO, "Instance Name :" + name); final Map props = getPropsForTest(); final Map<String, String> idMap = getIdMap(); final List vListeners = new ArrayList(); final List mListeners = new ArrayList(); vListeners.add( new ClusterViewEventListener() { public void clusterViewEvent( final ClusterViewEvent event, final ClusterView view) { //LOG.log(Level.INFO, "event.message", new Object[]

{event.getEvent().toString()}

); //LOG.log(Level.INFO, "peer.involved", new Object[]

{event.getAdvertisement().toString ()}

); //LOG.log(Level.INFO, "view.message", new Object[]

{view.getPeerNamesInView().toString ()}

); } }); mListeners.add( new ClusterMessageListener() { public void handleClusterMessage( final SystemAdvertisement id, final Object message)

{ LOG.log(Level.INFO, id.getName()); LOG.log(Level.INFO, "SHEETAL : message received = " + new String(((GMSMessage) message).getMessage())); }

} ); final ClusterManager manager = new ClusterManager(groupName, name, idMap, props, vListeners, mListeners); manager.start(); //manager.waitForClose(); if (System.getProperty("TYPE").equals("sender")) { final Object waitLock = new Object(); LOG.log(Level.INFO, "wait 10 secs to shutdown"); synchronized (waitLock) { try

{ waitLock.wait(10000); }

catch (InterruptedException e)

{ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } LOG.log(Level.INFO, "Sending messages..."); final ID id = manager.getID("client2"); for (int i = 0; i <= 10; i++) { final GMSMessage gMsg = new GMSMessage(name, MessageFormat.format("P2PMsgSendReceive : message {0} from {1} to {2}", i, name, groupName).getBytes(), groupName, Long.getLong("10")); try { manager.send(id, gMsg); LOG.info("Message " + i + " sent from " + name + " to " + groupName); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }

} manager.waitForClose(); } else if (System.getProperty("TYPE").equals("receiver")) { final Object waitLock = new Object(); LOG.log(Level.INFO, "wait 30 secs to shutdown"); synchronized (waitLock) { try

{ waitLock.wait(30000); }

catch (InterruptedException e)

{ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }

} manager.waitForClose(); } System.exit(0); }

run_client.sh :

java Dcom.sun.management.jmxremote -DINAME=client$1 -DTYPE=$2 -cp ./lib/jxta.jar:dist/shoal gms.jar com.sun.enterprise.jxtamgmt.ClusterManager

Environment

Operating System: All Platform: All

Affected Versions

[current]

glassfishrobot commented 6 years ago
glassfishrobot commented 16 years ago

@glassfishrobot Commented Reported by sheetalv

glassfishrobot commented 16 years ago

@glassfishrobot Commented sheetalv said: NA for Sailfin 1.0

glassfishrobot commented 16 years ago

@glassfishrobot Commented sheetalv said: Requires more input from the JXTA team.

glassfishrobot commented 16 years ago

@glassfishrobot Commented Was assigned to hamada

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA SHOAL-36