org.apache.hama.bsp
Class GroomServer

java.lang.Object
  extended by org.apache.hama.bsp.GroomServer
All Implemented Interfaces:
java.io.Closeable, java.lang.Runnable, org.apache.hadoop.ipc.VersionedProtocol, BSPPeerInterface, BSPPeerProtocol, BSPRPCProtocolVersion, Constants, HamaRPCProtocolVersion, WorkerProtocol

public class GroomServer
extends java.lang.Object
implements java.lang.Runnable, WorkerProtocol, BSPPeerProtocol

A Groom Server (shortly referred to as groom) is a process that performs bsp tasks assigned by BSPMaster. Each groom contacts the BSPMaster, and it takes assigned tasks and reports its status by means of periodical piggybacks with BSPMaster. Each groom is designed to run with HDFS or other distributed storages. Basically, a groom server and a data node should be run on one physical node.


Nested Class Summary
static class GroomServer.Child
          The main() for child processes.
 
Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from interface org.apache.hama.ipc.HamaRPCProtocolVersion
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_CLIENT_PORT, DEFAULT_ZOOKEEPER_PAUSE, DEFAULT_ZOOKEEPER_RETRIES, DEFAULT_ZOOKEEPER_ROOT, DEFAULT_ZOOKEEPER_SERVER_ADDR, EMPTY_BYTE_ARRAY, GROOM_RPC_HOST, GROOM_RPC_PORT, GROOM_SERVER_IMPL, PEER_HOST, PEER_ID, PEER_PORT, UTF8_ENCODING, ZOOKEEPER_CLIENT_PORT, ZOOKEEPER_CONFIG_NAME, ZOOKEEPER_PAUSE, ZOOKEEPER_QUORUM, ZOOKEEPER_RETRIES, ZOOKEEPER_ROOT, ZOOKEEPER_SERVER_ADDRS, ZOOKEEPER_SESSION_TIMEOUT
 
Constructor Summary
GroomServer(org.apache.hadoop.conf.Configuration conf)
           
 
Method Summary
 void cleanupStorage()
           
 void clear()
          Clears all queues entries.
 void close()
           
static GroomServer constructGroomServer(java.lang.Class<? extends GroomServer> groomServerClass, org.apache.hadoop.conf.Configuration conf2)
           
 void deleteLocalFiles()
           
 void deleteLocalFiles(java.lang.String subdir)
           
 void dispatch(Directive directive)
          Instruct GroomServer performaning tasks.
 void done(TaskAttemptID taskid, boolean shouldBePromoted)
          Report that the task is successfully completed.
 void doReport(org.apache.hama.bsp.TaskStatus taskStatus)
          Update and report refresh status back to BSPMaster.
 void fsError(TaskAttemptID taskId, java.lang.String message)
          Report that the task encounted a local filesystem error.
 java.lang.String[] getAllPeerNames()
           
 java.lang.String getBspPeerName()
          GroomServer address information.
 BSPMessage getCurrentMessage()
           
 java.lang.String[] getLocalDirs()
           
 int getNumCurrentMessages()
           
 java.lang.String getPeerName()
           
 long getProtocolVersion(java.lang.String protocol, long clientVersion)
           
 long getSuperstepCount()
           
 Task getTask(TaskAttemptID taskid)
          Called when a child task process starts, to get its task.
 java.net.InetSocketAddress getTaskTrackerReportAddress()
          Return the port at which the tasktracker bound to
 void initialize()
           
 boolean isRunning()
           
 org.apache.hama.bsp.GroomServer.State offerService()
           
 boolean ping(TaskAttemptID taskid)
          Periodically called by child to check if parent is still alive.
 void put(BSPMessage msg)
          Puts a message to local queue.
 void put(BSPMessageBundle messages)
          Puts a bundle of messages to local queue.
 void run()
           
 void send(java.lang.String peerName, BSPMessage msg)
          Send a data with a tag to another BSPSlave corresponding to hostname.
 void shutdown()
           
static java.lang.Thread startGroomServer(GroomServer hrs)
           
static java.lang.Thread startGroomServer(GroomServer hrs, java.lang.String name)
           
 void sync()
          Barrier Synchronization.
 java.util.List<org.apache.hama.bsp.TaskStatus> updateTaskStatus(org.apache.hama.bsp.TaskStatus taskStatus)
           
 
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

GroomServer

public GroomServer(org.apache.hadoop.conf.Configuration conf)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

initialize

public void initialize()
                throws java.io.IOException
Throws:
java.io.IOException

getTaskTrackerReportAddress

public java.net.InetSocketAddress getTaskTrackerReportAddress()
Return the port at which the tasktracker bound to


dispatch

public void dispatch(Directive directive)
              throws java.io.IOException
Description copied from interface: WorkerProtocol
Instruct GroomServer performaning tasks.

Specified by:
dispatch in interface WorkerProtocol
Parameters:
directive - instructs a GroomServer performing necessary execution.
Throws:
java.io.IOException

getLocalDirs

public java.lang.String[] getLocalDirs()

deleteLocalFiles

public void deleteLocalFiles()
                      throws java.io.IOException
Throws:
java.io.IOException

deleteLocalFiles

public void deleteLocalFiles(java.lang.String subdir)
                      throws java.io.IOException
Throws:
java.io.IOException

cleanupStorage

public void cleanupStorage()
                    throws java.io.IOException
Throws:
java.io.IOException

offerService

public org.apache.hama.bsp.GroomServer.State offerService()
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

doReport

public void doReport(org.apache.hama.bsp.TaskStatus taskStatus)
Update and report refresh status back to BSPMaster.


updateTaskStatus

public java.util.List<org.apache.hama.bsp.TaskStatus> updateTaskStatus(org.apache.hama.bsp.TaskStatus taskStatus)

run

public void run()
Specified by:
run in interface java.lang.Runnable

shutdown

public void shutdown()
              throws java.io.IOException
Throws:
java.io.IOException

close

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

startGroomServer

public static java.lang.Thread startGroomServer(GroomServer hrs)

startGroomServer

public static java.lang.Thread startGroomServer(GroomServer hrs,
                                                java.lang.String name)

isRunning

public boolean isRunning()

constructGroomServer

public static GroomServer constructGroomServer(java.lang.Class<? extends GroomServer> groomServerClass,
                                               org.apache.hadoop.conf.Configuration conf2)

getProtocolVersion

public long getProtocolVersion(java.lang.String protocol,
                               long clientVersion)
                        throws java.io.IOException
Specified by:
getProtocolVersion in interface org.apache.hadoop.ipc.VersionedProtocol
Throws:
java.io.IOException

getBspPeerName

public java.lang.String getBspPeerName()
GroomServer address information.

Returns:
bsp peer information in the form of "address:port".

getTask

public Task getTask(TaskAttemptID taskid)
             throws java.io.IOException
Description copied from interface: BSPPeerProtocol
Called when a child task process starts, to get its task.

Specified by:
getTask in interface BSPPeerProtocol
Throws:
java.io.IOException

ping

public boolean ping(TaskAttemptID taskid)
             throws java.io.IOException
Description copied from interface: BSPPeerProtocol
Periodically called by child to check if parent is still alive.

Specified by:
ping in interface BSPPeerProtocol
Returns:
True if the task is known
Throws:
java.io.IOException

done

public void done(TaskAttemptID taskid,
                 boolean shouldBePromoted)
          throws java.io.IOException
Description copied from interface: BSPPeerProtocol
Report that the task is successfully completed. Failure is assumed if the task process exits without calling this.

Specified by:
done in interface BSPPeerProtocol
Parameters:
taskid - task's id
shouldBePromoted - whether to promote the task's output or not
Throws:
java.io.IOException

fsError

public void fsError(TaskAttemptID taskId,
                    java.lang.String message)
             throws java.io.IOException
Description copied from interface: BSPPeerProtocol
Report that the task encounted a local filesystem error.

Specified by:
fsError in interface BSPPeerProtocol
Throws:
java.io.IOException

send

public void send(java.lang.String peerName,
                 BSPMessage msg)
          throws java.io.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:
java.io.IOException

put

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

Specified by:
put in interface BSPPeerInterface
Throws:
java.io.IOException

put

public void put(BSPMessageBundle messages)
         throws java.io.IOException
Description copied from interface: BSPPeerInterface
Puts a bundle of messages to local queue.

Specified by:
put in interface BSPPeerInterface
Throws:
java.io.IOException

getCurrentMessage

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

getNumCurrentMessages

public int getNumCurrentMessages()
Specified by:
getNumCurrentMessages in interface BSPPeerInterface
Returns:
The number of messages in the peer's received messages queue.

sync

public void sync()
          throws java.io.IOException,
                 org.apache.zookeeper.KeeperException,
                 java.lang.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
java.lang.InterruptedException
java.io.IOException

getSuperstepCount

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

getPeerName

public java.lang.String getPeerName()
Specified by:
getPeerName in interface BSPPeerInterface
Returns:
The name of this peer in the format "hostname:port".

getAllPeerNames

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

clear

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

Specified by:
clear in interface BSPPeerInterface


Copyright © 2008-2011 The Apache Software Foundation. All Rights Reserved.