org.apache.hadoop.chukwa.util
Class ConstRateAdaptor

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.hadoop.chukwa.util.ConstRateAdaptor
All Implemented Interfaces:
Runnable, Adaptor

public class ConstRateAdaptor
extends Thread
implements Adaptor

Emits chunks at a roughly constant data rate. Chunks are in a very particular format: the output data is verifiable, but sufficiently non-deterministic that two different instances of this adaptor are very likely to have distinct outputs. Each chunk is full of random bytes; the randomness comes from an instance of java.util.Random seeded with the offset xored with the time-of-generation. The time of generation is stored, big-endian, in the first eight bytes of each chunk.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ConstRateAdaptor()
           
 
Method Summary
static boolean checkChunk(Chunk chunk)
           
 String getCurrentStatus()
          Return the adaptor's state Should not include class name or byte offset, which are written by caller.
 String getType()
           
 void hardStop()
          Deprecated. 
 ChunkImpl nextChunk(int arraySize)
           
 String parseArgs(String bytesPerSecParam)
          Parse args, return stream name.
 void run()
           
 long shutdown()
          Deprecated. 
 long shutdown(AdaptorShutdownPolicy shutdownPolicy)
          Signals this adaptor to come to an orderly stop.
 void start(String adaptorID, String type, long offset, ChunkReceiver dest, AdaptorManager c)
          Start this adaptor
 String toString()
           
 
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, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstRateAdaptor

public ConstRateAdaptor()
Method Detail

getCurrentStatus

public String getCurrentStatus()
Description copied from interface: Adaptor
Return the adaptor's state Should not include class name or byte offset, which are written by caller. The datatype should, however, be written by this method.

Specified by:
getCurrentStatus in interface Adaptor
Returns:
the adaptor state as a string

start

public void start(String adaptorID,
                  String type,
                  long offset,
                  ChunkReceiver dest,
                  AdaptorManager c)
           throws AdaptorException
Description copied from interface: Adaptor
Start this adaptor

Specified by:
start in interface Adaptor
type - the application type, who is starting this adaptor
offset - the stream offset of the first byte sent by this adaptor
Throws:
AdaptorException

parseArgs

public String parseArgs(String bytesPerSecParam)
Description copied from interface: Adaptor
Parse args, return stream name. Do not start running. Return the stream name, given params. The stream name is the part of the Adaptor status that's used to determine uniqueness.

Specified by:
parseArgs in interface Adaptor
Returns:
Stream name as a string, null if params are malformed

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

nextChunk

public ChunkImpl nextChunk(int arraySize)

toString

public String toString()
Overrides:
toString in class Thread

hardStop

@Deprecated
public void hardStop()
              throws AdaptorException
Deprecated. 

Description copied from interface: Adaptor
Signals this adaptor to come to an abrupt stop, as quickly as it can. The use case here is "Whups, I didn't mean to start that adaptor tailing a gigabyte file, stop it now". Adaptors might need to do something nontrivial here, e.g., in the case in which they have registered periodic timer interrupts, or use a shared worker thread from which they need to disengage. This method is synchronous: In other words, after shutdown() returns, no new data should be written.

Specified by:
hardStop in interface Adaptor
Throws:
AdaptorException

shutdown

@Deprecated
public long shutdown()
              throws AdaptorException
Deprecated. 

Description copied from interface: Adaptor
Signals this adaptor to come to an orderly stop. The adaptor ought to push out all the data it can before exiting. This method is synchronous up to 60 seconds

Specified by:
shutdown in interface Adaptor
Returns:
the logical offset at which the adaptor stops
Throws:
AdaptorException

getType

public String getType()
Specified by:
getType in interface Adaptor

shutdown

public long shutdown(AdaptorShutdownPolicy shutdownPolicy)
Description copied from interface: Adaptor
Signals this adaptor to come to an orderly stop. The adaptor ought to push out all the data it can before exiting depending of the shutdown policy

Specified by:
shutdown in interface Adaptor
Returns:
the logical offset at which the adaptor was when the method return

checkChunk

public static boolean checkChunk(Chunk chunk)


Copyright © ${year} The Apache Software Foundation