Hi Walker, seems the contract is broken and the array is not sorted anymore.
Try to use: String[] names = peer.getAllPeerNames(); Arrays.sort(names); int index = Arrays.binarySearch(names, peer.getPeerName()); Sorry for the inconvenience, we have replaced it with the task id in the latest trunk, so this will be fixed in the next release. 2012/9/18 顾荣 <[email protected]>: > Hi, > > I have a Hama cluster of 3 nodes. The host name of the nodes are slave019, > slave020, slave021. I wirte a simple program to test the PeerIndex and > PeerName info in Hama. > > In setup function, I choose a peer as master, and the in bsp function each > peer get its PeerIndex and its PeerName by peer.getPeerIndex() and > peer.getPeerName() API and send it to the master peer. Lastly, in cleanup > function of the master peer, it write out the messages in its queue. The > result is below: > > peerName: slave020:61001 peerIndex: -7 > peerName: slave019:61002 peerIndex: 4 > peerName: slave021:61001 peerIndex: 6 > peerName: slave019:61001 peerIndex: -1 > peerName: slave021:61002 peerIndex: -8 > peerName: slave020:61002 peerIndex: -7 > peerName: slave019:61003 peerIndex: 5 > peerName: slave021:61003 peerIndex: 7 > peerName: slave020:61003 peerIndex: -7 > > The peerNames are reasonable, but I am confused with the peerIndex > information. What does they mean? According to the source code of > BSPPeer.java, the comment message is below > /** > * @return the index of this peer from sorted array by name. > */ > public int getPeerIndex(); > > However, the peerIndex messages I got seem not to be so....Can you give me > a hint? > > Thanks in advance. > > Walker
