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

java.lang.Object
  extended by org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent

public class ChukwaAgent
extends Object

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
           
 
Constructor Summary
ChukwaAgent()
           
ChukwaAgent(org.apache.hadoop.conf.Configuration conf)
           
 
Method Summary
 int adaptorCount()
           
 Map<Long,Adaptor> getAdaptorList()
           
static ChukwaAgent getAgent()
           
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 Connector getConnector()
           
 int getControllerPort()
           
 long getOffset(Adaptor a)
          Returns the last offset at which a given adaptor was checkpointed
static void main(String[] args)
           
 long processCommand(String cmd)
           
protected static org.apache.hadoop.conf.Configuration readConfig()
           
 void reportCommit(Adaptor src, long uuid)
           
 boolean restoreFromCheckpoint()
          Tries to restore from a checkpoint file in checkpointDir.
 void shutdown()
           
 void shutdown(boolean exit)
          Triggers agent shutdown.
 long stopAdaptor(long number, boolean gracefully)
          Stop the adaptor with given ID number.
 void writeCheckpoint()
          Called periodically to write checkpoints
 
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()
Returns:
the number of running adaptors inside this local agent

processCommand

public long processCommand(String cmd)

restoreFromCheckpoint

public boolean restoreFromCheckpoint()
                              throws IOException
Tries to restore from a checkpoint file in checkpointDir. There should usually only be one checkpoint present -- two checkpoints present implies a crash during writing the higher-numbered one. As a result, this method chooses the lowest-numbered file present. Lines in the checkpoint file are processed one at a time with processCommand();

Returns:
true if the restore succeeded
Throws:
IOException

writeCheckpoint

public void writeCheckpoint()
                     throws IOException
Called periodically to write checkpoints

Throws:
IOException

reportCommit

public void reportCommit(Adaptor src,
                         long uuid)

getAdaptorList

public Map<Long,Adaptor> getAdaptorList()

stopAdaptor

public long stopAdaptor(long number,
                        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.

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()

getConnector

public Connector getConnector()

readConfig

protected static org.apache.hadoop.conf.Configuration readConfig()

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.


getOffset

public long getOffset(Adaptor a)
Returns the last offset at which a given adaptor was checkpointed

Parameters:
a - the adaptor in question
Returns:
that adaptor's last-checkpointed offset


Copyright © ${year} The Apache Software Foundation