org.apache.hadoop.chukwa.datacollection.controller
Class ChukwaAgentController

java.lang.Object
  extended by org.apache.hadoop.chukwa.datacollection.controller.ChukwaAgentController

public class ChukwaAgentController
extends Object

A convenience library for applications to communicate to the ChukwaAgent. Can be used to register and unregister new Adaptors. Also contains functions for applications to use for handling log rations.


Nested Class Summary
 class ChukwaAgentController.AddAdaptorTask
           
 
Field Summary
static String CharFileTailUTF8
           
static String CharFileTailUTF8NewLineEscaped
           
 
Constructor Summary
ChukwaAgentController()
           
ChukwaAgentController(String hostname, int portno)
           
 
Method Summary
 String add(String adaptorName, String type, String params, long offset)
          Registers a new adaptor.
 String addByName(String adaptorID, String adaptorName, String type, String params, long offset, long numRetries, long retryInterval)
          Registers a new adaptor.
 String addFile(String appType, String filename)
           
 String addFile(String appType, String filename, long numRetries, long retryInterval)
          Registers a new "LineFileTailUTF8" adaptor and starts it at offset 0.
 boolean isFilePaused(String appType, String filename)
           
static void main(String[] args)
           
 Collection<String> pauseFile(String appType, String filename)
          Pause all active adaptors of the default file tailing type who are tailing this file This means we actually stop the adaptor and it goes away forever, but we store it state so that we can re-launch a new adaptor with the same state later.
 org.apache.hadoop.chukwa.datacollection.controller.ChukwaAgentController.Adaptor remove(String adaptorID)
           
 void remove(String className, String appType, String filename)
           
 void removeAll()
           
 void removeFile(String appType, String filename)
           
 void removeInstanceAdaptors()
           
 Collection<String> resumeFile(String appType, String filename)
          Resume all adaptors for this filename that have been paused
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CharFileTailUTF8

public static final String CharFileTailUTF8
See Also:
Constant Field Values

CharFileTailUTF8NewLineEscaped

public static final String CharFileTailUTF8NewLineEscaped
See Also:
Constant Field Values
Constructor Detail

ChukwaAgentController

public ChukwaAgentController()

ChukwaAgentController

public ChukwaAgentController(String hostname,
                             int portno)
Method Detail

add

public String add(String adaptorName,
                  String type,
                  String params,
                  long offset)
Registers a new adaptor. Makes no guarantee about success. On failure, we print a message to stderr and ignore silently so that an application doesn't crash if it's attempt to register an adaptor fails. This call does not retry a conection. for that use the overloaded version of this which accepts a time interval and number of retries

Returns:
the id number of the adaptor, generated by the agent

addByName

public String addByName(String adaptorID,
                        String adaptorName,
                        String type,
                        String params,
                        long offset,
                        long numRetries,
                        long retryInterval)
Registers a new adaptor. Makes no guarantee about success. On failure, to connect to server, will retry numRetries times, every retryInterval milliseconds.

Returns:
the id number of the adaptor, generated by the agent

remove

public org.apache.hadoop.chukwa.datacollection.controller.ChukwaAgentController.Adaptor remove(String adaptorID)
                                                                                        throws IOException
Throws:
IOException

remove

public void remove(String className,
                   String appType,
                   String filename)
            throws IOException
Throws:
IOException

removeAll

public void removeAll()

removeInstanceAdaptors

public void removeInstanceAdaptors()

addFile

public String addFile(String appType,
                      String filename,
                      long numRetries,
                      long retryInterval)
Registers a new "LineFileTailUTF8" adaptor and starts it at offset 0. Checks to see if the file is being watched already, if so, won't register another adaptor with the agent. If you have run the tail adaptor on this file before and rotated or emptied the file you should use pauseFile(String, String) and resumeFile(String, String) which will store the adaptors metadata and re-use them to pick up where it left off.

Parameters:
type - the datatype associated with the file to pass through
filename - of the file for the tail adaptor to start monitoring
Returns:
the id number of the adaptor, generated by the agent

addFile

public String addFile(String appType,
                      String filename)

pauseFile

public Collection<String> pauseFile(String appType,
                                    String filename)
                             throws IOException
Pause all active adaptors of the default file tailing type who are tailing this file This means we actually stop the adaptor and it goes away forever, but we store it state so that we can re-launch a new adaptor with the same state later.

Parameters:
appType -
filename -
Returns:
array of adaptorID numbers which have been created and assigned the state of the formerly paused adaptors
Throws:
IOException

isFilePaused

public boolean isFilePaused(String appType,
                            String filename)

resumeFile

public Collection<String> resumeFile(String appType,
                                     String filename)
                              throws IOException
Resume all adaptors for this filename that have been paused

Parameters:
appType - the appType
filename - filename by which to lookup adaptors which are paused (and tailing this file)
Returns:
an array of the new adaptor ID numbers which have resumed where the old adaptors left off
Throws:
IOException

removeFile

public void removeFile(String appType,
                       String filename)
                throws IOException
Throws:
IOException

main

public static void main(String[] args)


Copyright © ${year} The Apache Software Foundation