Kieker 1.12

kieker.monitoring.writer
Class AbstractAsyncThread

java.lang.Object
  extended by java.lang.Thread
      extended by kieker.monitoring.writer.AbstractAsyncThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
AbstractFsWriterThread, AbstractZipWriterThread

public abstract class AbstractAsyncThread
extends java.lang.Thread

Since:
1.3
Author:
Andre van Hoorn, Jan Waller

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  IMonitoringController monitoringController
          The monitoring controller for the current monitoring session.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AbstractAsyncThread(IMonitoringController monitoringController, java.util.concurrent.BlockingQueue<IMonitoringRecord> writeQueue)
          Creates a new instance of this class using the given parameters.
 
Method Summary
protected abstract  void cleanup()
          Inheriting classes should implement this method to do some cleanup work like, for example, closing open connections.
protected abstract  void consume(IMonitoringRecord monitoringRecord)
          Inheriting classes should implement this method to consume the given record by, for example, sending it to a JMS client or by writing it to the file sysytem.
 void initShutdown(java.util.concurrent.CountDownLatch cdl)
          Initializes the shutdown of this thread if necessary.
 boolean isFinished()
          Can be used to determine whether the thread is in the finished state or not.
 void run()
           
 java.lang.String toString()
          Returns a human-readable information string about the writer's configuration and state.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

monitoringController

protected final IMonitoringController monitoringController
The monitoring controller for the current monitoring session.

Constructor Detail

AbstractAsyncThread

public AbstractAsyncThread(IMonitoringController monitoringController,
                           java.util.concurrent.BlockingQueue<IMonitoringRecord> writeQueue)
Creates a new instance of this class using the given parameters.

Parameters:
monitoringController - The monitoring controller for the current monitoring session.
writeQueue - The queue containing the records (and the potential end of monitoring marker).
Method Detail

initShutdown

public final void initShutdown(java.util.concurrent.CountDownLatch cdl)
Initializes the shutdown of this thread if necessary. The method returns immediately in every case and counts the latch down eventually (assuming that no exception occurs).

Parameters:
cdl - The latch which will be count down once the thread has been terminated.

isFinished

public final boolean isFinished()
Can be used to determine whether the thread is in the finished state or not.

Returns:
true iff the thread has set the finished flag.

run

public final void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

toString

public java.lang.String toString()
Returns a human-readable information string about the writer's configuration and state.

Overrides:
toString in class java.lang.Thread
Returns:
the information string.

consume

protected abstract void consume(IMonitoringRecord monitoringRecord)
                         throws java.lang.Exception
Inheriting classes should implement this method to consume the given record by, for example, sending it to a JMS client or by writing it to the file sysytem.

Parameters:
monitoringRecord - The record to consume.
Throws:
java.lang.Exception - Indicates that something went wrong during the consumption.

cleanup

protected abstract void cleanup()
Inheriting classes should implement this method to do some cleanup work like, for example, closing open connections.


Kieker 1.12

Copyright 2015 Kieker Project, http://kieker-monitoring.net