org.apache.hama.bsp
Class BSPPeer

java.lang.Object
  extended by org.apache.hama.bsp.BSPPeer
All Implemented Interfaces:
Closeable, org.apache.hadoop.ipc.VersionedProtocol, BSPPeerInterface, BSPRPCProtocolVersion, Constants, org.apache.zookeeper.Watcher

public class BSPPeer
extends Object
implements org.apache.zookeeper.Watcher, BSPPeerInterface

This class represents a BSP peer.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from interface org.apache.hama.bsp.BSPRPCProtocolVersion
versionID
 
Fields inherited from interface org.apache.hama.Constants
CLUSTER_DISTRIBUTED, CLUSTER_IS_DISTRIBUTED, DEFAULT_GROOM_RPC_HOST, DEFAULT_GROOM_RPC_PORT, DEFAULT_PEER_HOST, DEFAULT_PEER_PORT, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, DEFAULT_ZOOKEEPER_ROOT, DEFAULT_ZOOKEEPER_SERVER_ADDR, DEFAULT_ZOOKEPER_CLIENT_PORT, EMPTY_BYTE_ARRAY, GROOM_RPC_HOST, GROOM_RPC_PORT, GROOM_SERVER_IMPL, PEER_HOST, PEER_ID, PEER_PORT, UTF8_ENCODING, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES, ZOOKEEPER_ROOT, ZOOKEEPER_SERVER_ADDRS, ZOOKEPER_CLIENT_PORT
 
Constructor Summary
BSPPeer(org.apache.hadoop.conf.Configuration conf)
          Constructor
 
Method Summary
 void clear()
          Clears all queues entries.
 void clearLocalQueue()
          Clears local queue
 void clearOutgoingQueues()
          Clears outgoing queues
 void close()
           
protected  boolean enterBarrier()
           
 String[] getAllPeerNames()
           
protected  BSPPeerInterface getBSPPeerConnection(InetSocketAddress addr)
           
 BSPMessage getCurrentMessage()
           
 int getLocalQueueSize()
           
 int getNumCurrentMessages()
           
 int getOutgoingQueueSize()
           
 String getPeerName()
           
 long getProtocolVersion(String arg0, long arg1)
           
 long getSuperstepCount()
           
protected  boolean leaveBarrier()
           
 void process(org.apache.zookeeper.WatchedEvent event)
           
 void put(BSPMessage msg)
          Puts a message to local queue.
 void reinitialize()
           
 void send(String peerName, BSPMessage msg)
          Send a data with a tag to another BSPSlave corresponding to hostname.
 void setCurrentTaskStatus(org.apache.hama.bsp.TaskStatus currentTaskStatus)
          Sets the current status
 void setJobConf(BSPJob jobConf)
          Sets the job configuration
 void sync()
          Barrier Synchronization.
protected  boolean waitForSync()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Constructor Detail

BSPPeer

public BSPPeer(org.apache.hadoop.conf.Configuration conf)
        throws IOException
Constructor

Throws:
IOException
Method Detail

reinitialize

public void reinitialize()

getCurrentMessage

public BSPMessage getCurrentMessage()
                             throws IOException
Specified by:
getCurrentMessage in interface BSPPeerInterface
Returns:
A message from the peer's received messages queue (a FIFO).
Throws:
IOException

send

public void send(String peerName,
                 BSPMessage msg)
          throws IOException
Description copied from interface: BSPPeerInterface
Send a data with a tag to another BSPSlave corresponding to hostname. Messages sent by this method are not guaranteed to be received in a sent order.

Specified by:
send in interface BSPPeerInterface
Throws:
IOException

sync

public void sync()
          throws IOException,
                 org.apache.zookeeper.KeeperException,
                 InterruptedException
Description copied from interface: BSPPeerInterface
Barrier Synchronization. Sends all the messages in the outgoing message queues to the corresponding remote peers.

Specified by:
sync in interface BSPPeerInterface
Throws:
org.apache.zookeeper.KeeperException
InterruptedException
IOException

enterBarrier

protected boolean enterBarrier()
                        throws org.apache.zookeeper.KeeperException,
                               InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

waitForSync

protected boolean waitForSync()
                       throws org.apache.zookeeper.KeeperException,
                              InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

leaveBarrier

protected boolean leaveBarrier()
                        throws org.apache.zookeeper.KeeperException,
                               InterruptedException
Throws:
org.apache.zookeeper.KeeperException
InterruptedException

process

public void process(org.apache.zookeeper.WatchedEvent event)
Specified by:
process in interface org.apache.zookeeper.Watcher

clear

public void clear()
Description copied from interface: BSPPeerInterface
Clears all queues entries.

Specified by:
clear in interface BSPPeerInterface

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

put

public void put(BSPMessage msg)
         throws IOException
Description copied from interface: BSPPeerInterface
Puts a message to local queue.

Specified by:
put in interface BSPPeerInterface
Throws:
IOException

getProtocolVersion

public long getProtocolVersion(String arg0,
                               long arg1)
                        throws IOException
Specified by:
getProtocolVersion in interface org.apache.hadoop.ipc.VersionedProtocol
Throws:
IOException

getBSPPeerConnection

protected BSPPeerInterface getBSPPeerConnection(InetSocketAddress addr)

getPeerName

public String getPeerName()
Specified by:
getPeerName in interface BSPPeerInterface
Returns:
the string as host:port of this Peer

getAllPeerNames

public String[] getAllPeerNames()
Specified by:
getAllPeerNames in interface BSPPeerInterface
Returns:
The names of all the peers executing tasks from the same job (including this peer).

getNumCurrentMessages

public int getNumCurrentMessages()
Specified by:
getNumCurrentMessages in interface BSPPeerInterface
Returns:
the number of messages

setCurrentTaskStatus

public void setCurrentTaskStatus(org.apache.hama.bsp.TaskStatus currentTaskStatus)
Sets the current status

Parameters:
currentTaskStatus -

getSuperstepCount

public long getSuperstepCount()
Specified by:
getSuperstepCount in interface BSPPeerInterface
Returns:
the count of current super-step

setJobConf

public void setJobConf(BSPJob jobConf)
Sets the job configuration

Parameters:
jobConf -

getLocalQueueSize

public int getLocalQueueSize()
Returns:
the size of local queue

getOutgoingQueueSize

public int getOutgoingQueueSize()
Returns:
the size of outgoing queue

clearLocalQueue

public void clearLocalQueue()
Clears local queue


clearOutgoingQueues

public void clearOutgoingQueues()
Clears outgoing queues



Copyright © 2011 The Apache Software Foundation