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

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.hadoop.chukwa.datacollection.agent.AgentControlSocketListener
All Implemented Interfaces:
Runnable

public class AgentControlSocketListener
extends Thread

Class to handle the agent control protocol. This is a simple line-oriented ASCII protocol, that is designed to be easy to work with both programmatically and via telnet. The port to bind to can be specified by setting option chukwaAgent.agent.control.port. A port of 0 creates a socket on any free port.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  ChukwaAgent agent
           
 boolean ALLOW_REMOTE
           
protected  int portno
           
static String REMOTE_ACCESS_OPT
           
protected  ServerSocket s
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AgentControlSocketListener(ChukwaAgent agent)
          Initializes listener, but does not bind to socket.
 
Method Summary
 int getPort()
           
 String getStatusLine()
           
 boolean isBound()
           
 void run()
          Binds to socket, starts looping listening for commands
 void shutdown()
          Close the control socket, and exit.
 void tryToBind()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

agent

protected ChukwaAgent agent

portno

protected int portno

s

protected ServerSocket s

ALLOW_REMOTE

public boolean ALLOW_REMOTE

REMOTE_ACCESS_OPT

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

AgentControlSocketListener

public AgentControlSocketListener(ChukwaAgent agent)
Initializes listener, but does not bind to socket.

Parameters:
a - the agent to control
Method Detail

run

public void run()
Binds to socket, starts looping listening for commands

Specified by:
run in interface Runnable
Overrides:
run in class Thread

shutdown

public void shutdown()
Close the control socket, and exit. Triggers graceful thread shutdown.


isBound

public boolean isBound()

tryToBind

public void tryToBind()
               throws IOException
Throws:
IOException

getPort

public int getPort()

getStatusLine

public String getStatusLine()


Copyright © ${year} The Apache Software Foundation