Hamam Study Notes-Communication

Source: Internet
Author: User

At present, the hamam documentation is not detailed yet. I have no instructions on how to send messages to Hamam, so I have to experiment with myself. According to the BSP model, each superstep should have three clear steps: computing-> communication-> synchronization, but in the Hamana, before the node enters the synchronization status, can I send and receive messages in real time with other nodes? If yes, it will undoubtedly make the bsp program more flexible, but this will also bring unnecessary trouble: If the bsp program is improperly designed, arbitrary communication between nodes may lead to poor program performance. In order to understand the communication situation, we did the following experiment: Open the PI calculation example and call peer in the bsp method of MyEstimator. the breakpoint is set before sending. In fact, the Comment document of the send method already tells us some useful information: * send a data with a tag to another BSPSlave corresponding to hostname. * Messages sent by this method are not guaranteed to be stored ed in a sent * order. it can be seen that the hama bsp does not strictly ensure that the message receiving and sending order are consistent. Start debug in eclipse (Click mode. At this time, hamn uses multiple threads to simulate computing on multiple nodes). It is found that the following code is finally executed by calling send: [java] InetSocketAddress targetPeerAddress = null; // Get socket for target peer. if (peerSocketCache. containsKey (peerName) {targetPeerAddress = peerSocketCache. get (peerName);} else {targetPeerAddress = BSPNetUtils. getAddress (peerName); peerSocketCache. put (peerName, targetPeerAddress);} MessageQueue <M> queue = outgoingQueues. ge T (targetPeerAddress); if (queue = null) {queue = getQueue ();} queue. add (msg); peer. incrementCounter (BSPPeerImpl. peerCounter. TOTAL_MESSAGES_SENT, 1L); outgoingQueues. put (targetPeerAddress, queue); notifySentMessage (peerName, msg); it can be seen that the message to be sent is added to the queue and the message is not sent. Continue debugging and find that the following code is executed by calling the sync method: [java] // normally all messages shoshould been send now, finalizing the send phase messenger. finishSendPhase (); Iterator <Entry <InetSocketAddress, MessageQueue <M> it = messenger. getMessageIterator (); while (it. hasNext () {Entry <InetSocketAddress, MessageQueue <M> entry = it. next (); final InetSocketAddress addr = entry. getKey (); final Iterable <M> messages = entry. getValu E (); final BSPMessageBundle <M> bundle = combineMessages (messages); // remove this message during runtime to save a bit of memory it. remove (); try {messenger. transfer (addr, bundle);} catch (Exception e) {LOG. error ("Error while sending messages", e) ;}} if (this. faultToleranceService! = Null) {try {this. faultToleranceService. beforeBarrier ();} catch (Exception e) {throw new IOException (e);} long startBarrier = System. currentTimeMillis (); enterBarrier (); if (this. faultToleranceService! = Null) {try {this. faultToleranceService. duringBarrier ();} catch (Exception e) {throw new IOException (e) ;}// Clear outgoing queues. messenger. clearOutgoingQueues (); leaveBarrier (); incrementCounter (PeerCounter. TIME_IN_SYNC_MS, (System. currentTimeMillis ()-startBarrier); incrementCounter (PeerCounter. SUPERSTEP_SUM, 1L); currentTaskStatus. setCounters (counters); if (this. faultToleranceService! = Null) {try {this. faultToleranceService. afterBarrier ();} catch (Exception e) {throw new IOException (e);} umbilical. statusUpdate (taskId, currentTaskStatus); from the comments on the first line, we can see that the messages sent before sending will be actually sent when synchronization starts. In addition, it seems that in [java] view plaincopymessenger. clearOutgoingQueues (); will prepare a local message queue before you can read the messages sent from other nodes, after the experiment, it seems that only messages sent from other nodes can be received after sync is returned. The messages obtained by getCurrentMessage () before sync are always null. The conclusion is as follows: In a superstep, the hama bsp can only send messages or process messages received in the previous superstep.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.