org.apache.hadoop.chukwa.datacollection.agent
Class ChukwaAgent

java.lang.Object
  extended by org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent
All Implemented Interfaces:
AdaptorManager

public class ChukwaAgent
extends Object
implements AdaptorManager

The local agent daemon that runs on each machine. This class is designed to be embeddable, for use in testing.


Nested Class Summary
static class ChukwaAgent.AlreadyRunningException
           
static class ChukwaAgent.Offset
           
 
Field Summary
 
Fields inherited from interface org.apache.hadoop.chukwa.datacollection.agent.AdaptorManager
NULL
 
Constructor Summary
ChukwaAgent()
           
ChukwaAgent(org.apache.hadoop.conf.Configuration conf)
           
 
Method Summary
 int adaptorCount()
           
 Adaptor getAdaptor(String name)
           
 Map<String,String> getAdaptorList()
          Expose the adaptor list.
 String getAdaptorName(Adaptor initiator)
           
static ChukwaAgent getAgent()
           
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 int getControllerPort()
           
static void main(String[] args)
           
 ChukwaAgent.Offset offset(Adaptor a)
           
 String processAddCommand(String cmd)
          Most of the Chukwa wire protocol is implemented in @link{AgentControlSocketListener} Unlike the rest of the chukwa wire protocol, add commands can appear in initial_adaptors and checkpoint files.
 String reportCommit(Adaptor src, long uuid)
          Called to update the Agent status table.
 void shutdown()
           
 void shutdown(boolean exit)
          Triggers agent shutdown.
 long stopAdaptor(String name, boolean gracefully)
          Stop the adaptor with given ID number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChukwaAgent

public ChukwaAgent()
            throws ChukwaAgent.AlreadyRunningException
Throws:
ChukwaAgent.AlreadyRunningException

ChukwaAgent

public ChukwaAgent(org.apache.hadoop.conf.Configuration conf)
            throws ChukwaAgent.AlreadyRunningException
Throws:
ChukwaAgent.AlreadyRunningException
Method Detail

getAgent

public static ChukwaAgent getAgent()

getControllerPort

public int getControllerPort()

main

public static void main(String[] args)
                 throws AdaptorException
Parameters:
args -
Throws:
AdaptorException

adaptorCount

public int adaptorCount()
Specified by:
adaptorCount in interface AdaptorManager
Returns:
the number of running adaptors inside this local agent

processAddCommand

public String processAddCommand(String cmd)
Most of the Chukwa wire protocol is implemented in @link{AgentControlSocketListener} Unlike the rest of the chukwa wire protocol, add commands can appear in initial_adaptors and checkpoint files. So it makes sense to handle them here.

Specified by:
processAddCommand in interface AdaptorManager

reportCommit

public String reportCommit(Adaptor src,
                           long uuid)
Description copied from interface: AdaptorManager
Called to update the Agent status table. Most adaptors should not call this. It is designed for adaptors that do some sort of local operation that needs checkpointing, but that doesn't emit chunks. For instance, DirTailingAdaptor uses it to track sweeps.

Specified by:
reportCommit in interface AdaptorManager
Parameters:
src - the adaptor in question
uuid - the number to record as checkpoint. Must be monotonically increasing.
Returns:
the adaptor ID of the associated adaptor, or null if not running.

getAdaptorList

public Map<String,String> getAdaptorList()
Expose the adaptor list. Keys are adaptor ID numbers, values are the adaptor status strings.

Specified by:
getAdaptorList in interface AdaptorManager
Returns:

stopAdaptor

public long stopAdaptor(String name,
                        boolean gracefully)
Stop the adaptor with given ID number. Takes a parameter to indicate whether the adaptor should force out all remaining data, or just exit abruptly. If the adaptor is written correctly, its offset won't change after returning from shutdown.

Specified by:
stopAdaptor in interface AdaptorManager
Parameters:
number - the adaptor to stop
gracefully - if true, shutdown, if false, hardStop
Returns:
the number of bytes synched at stop. -1 on error

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Specified by:
getConfiguration in interface AdaptorManager

getAdaptor

public Adaptor getAdaptor(String name)
Specified by:
getAdaptor in interface AdaptorManager

offset

public ChukwaAgent.Offset offset(Adaptor a)

shutdown

public void shutdown()

shutdown

public void shutdown(boolean exit)
Triggers agent shutdown. For now, this method doesn't shut down adaptors explicitly. It probably should.


getAdaptorName

public String getAdaptorName(Adaptor initiator)


Copyright © ${year} The Apache Software Foundation