Kieker 1.5

kieker.analysis
Class AnalysisController

java.lang.Object
  extended by kieker.analysis.AnalysisController

public final class AnalysisController
extends Object

The AnalysisController can be used to configure and control an analysis instance. It is responsible for the life cycle of the readers, filters and repositories.

Author:
Andre van Hoorn, Matthias Rohr, Nils Christian Ehmke, Jan Waller

Nested Class Summary
static interface AnalysisController.IStateObserver
          This interface can be used for observers which want to get notified about state changes of an analysis controller.
static class AnalysisController.STATE
          An enumeration used to describe the state of an AnalysisController.
 
Constructor Summary
AnalysisController()
          Constructs an AnalysisController instance.
AnalysisController(File file)
          This constructors creates an AnalysisController instance, using the given file to load an analysis model.
AnalysisController(File file, ClassLoader classLoader)
          This constructors creates an AnalysisController instance, using the given file to load an analysis model and the given classloader to initialize the objects.
AnalysisController(MIProject project)
          Creates a new instance of the class AnalysisController but uses the given instance of MIProject to construct the analysis.
AnalysisController(MIProject project, ClassLoader classLoader)
          Creates a new instance of the class AnalysisController but uses the given instance of @link{Project} to construct the analysis.
AnalysisController(String projectName)
          Constructs an AnalysisController instance using the given parameter.
 
Method Summary
 void connect(AbstractPlugin src, String outputPortName, AbstractPlugin dst, String inputPortName)
          This method should be used to connect two plugins.
 void connect(AbstractPlugin plugin, String repositoryPort, AbstractRepository repository)
          Connects the given repository to this plugin via the given name.
 MIProject getCurrentConfiguration()
          This method delivers the current configuration of this instance as an instance of MIProject.
 Collection<AbstractFilterPlugin> getFilters()
          Delivers an unmodifiable collection of all filters.
 String getProjectName()
          Delivers the current name of the project.
 Collection<AbstractReaderPlugin> getReaders()
          Delivers an unmodifiable collection of all readers.
 Collection<AbstractRepository> getRepositories()
          Delivers an unmodifiable collection of all repositories.
 AnalysisController.STATE getState()
          Delivers the current state of the analysis controller.
static MIProject loadFromFile(File file)
          This method can be used to load a meta model instance from a given file.
 void registerFilter(AbstractFilterPlugin filter)
          Registers the passed plugin.
 void registerReader(AbstractReaderPlugin reader)
          Registers a log reader used as a source for monitoring records.
 void registerRepository(AbstractRepository repository)
          Registers the passed repository.
 void registerStateObserver(AnalysisController.IStateObserver stateObserver)
          Registers the given instance as a new state observer.
 void run()
          Starts an AnalysisController instance.
 void saveToFile(File file)
          This method can be used to store the current configuration of this analysis controller in a specified file.
static void saveToFile(File file, MIProject project)
          This method can be used to save the given instance of MIProject within a given file.
 void terminate()
          Initiates a termination of the analysis.
 void terminate(boolean error)
          Initiates a termination of the analysis.
 void unregisterStateObserver(AnalysisController.IStateObserver stateObserver)
          Unregisters the given instance from the state observers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnalysisController

public AnalysisController()
Constructs an AnalysisController instance.


AnalysisController

public AnalysisController(String projectName)
Constructs an AnalysisController instance using the given parameter.

Parameters:
projectName - The name of the project.

AnalysisController

public AnalysisController(File file)
                   throws IOException,
                          AnalysisConfigurationException
This constructors creates an AnalysisController instance, using the given file to load an analysis model. The given file should therefore be an instance of the analysis meta model.

Parameters:
file - The configuration file for the analysis.
Throws:
IOException - If the given file could not be loaded or is not a valid kax-configuration file.
AnalysisConfigurationException - If one or more plugins or repositories could not be created, one or more properties of the plugins are invalid or if a connection between two filters is not allowed.

AnalysisController

public AnalysisController(File file,
                          ClassLoader classLoader)
                   throws IOException,
                          AnalysisConfigurationException
This constructors creates an AnalysisController instance, using the given file to load an analysis model and the given classloader to initialize the objects. The given file should therefore be an instance of the analysis meta model.

Parameters:
file - The configuration file for the analysis.
classLoader - The classloader used to initialize the plugins etc.
Throws:
IOException - If the given file could not be loaded or is not a valid kax-configuration file.
AnalysisConfigurationException - If one or more plugins or repositories could not be created, one or more properties of the plugins are invalid or if a connection between two filters is not allowed.

AnalysisController

public AnalysisController(MIProject project)
                   throws NullPointerException,
                          AnalysisConfigurationException
Creates a new instance of the class AnalysisController but uses the given instance of MIProject to construct the analysis.

Parameters:
project - The project instance for the analysis.
Throws:
AnalysisConfigurationException - If the given project could not be loaded.
NullPointerException - If the project is null.

AnalysisController

public AnalysisController(MIProject project,
                          ClassLoader classLoader)
                   throws NullPointerException,
                          AnalysisConfigurationException
Creates a new instance of the class AnalysisController but uses the given instance of @link{Project} to construct the analysis.

Parameters:
project - The project instance for the analysis.
classLoader - The class loader used for the initializing.
Throws:
NullPointerException - If the project is null.
AnalysisConfigurationException - If the given project could not be loaded.
Method Detail

registerStateObserver

public final void registerStateObserver(AnalysisController.IStateObserver stateObserver)
Registers the given instance as a new state observer. All instances are informed when the state (Running, Terminated etc) changes and get the new state as an object.

Parameters:
stateObserver - The observer to be registered.

unregisterStateObserver

public final void unregisterStateObserver(AnalysisController.IStateObserver stateObserver)
Unregisters the given instance from the state observers.

Parameters:
stateObserver - The observer to be unregistered.

saveToFile

public final void saveToFile(File file)
                      throws IOException,
                             AnalysisConfigurationException
This method can be used to store the current configuration of this analysis controller in a specified file. The file can later be used to initialize the analysis controller.

Parameters:
file - The file in which the configuration will be stored.
Throws:
IOException - If an exception during the storage occurred.
AnalysisConfigurationException - If the current configuration is somehow invalid.

connect

public void connect(AbstractPlugin src,
                    String outputPortName,
                    AbstractPlugin dst,
                    String inputPortName)
             throws IllegalStateException,
                    AnalysisConfigurationException
This method should be used to connect two plugins. The plugins have to be registered within this controller instance.

Parameters:
src - The source plugin.
outputPortName - The output port of the source plugin.
dst - The destination plugin.
inputPortName - The input port of the destination port.
Throws:
IllegalStateException - If this instance has already been started or has already been terminated.
AnalysisConfigurationException - If the port names or the given plugins are invalid or not compatible.

connect

public void connect(AbstractPlugin plugin,
                    String repositoryPort,
                    AbstractRepository repository)
             throws IllegalStateException,
                    AnalysisConfigurationException
Connects the given repository to this plugin via the given name.

Parameters:
plugin - The plugin to be connected.
repositoryPort - The name of the port to connect the repository.
repository - The repository which should be used.
Throws:
IllegalStateException - If this instance has already been started or has already been terminated.
AnalysisConfigurationException - If the port names or the given objects are invalid or not compatible.

getCurrentConfiguration

public final MIProject getCurrentConfiguration()
                                        throws AnalysisConfigurationException
This method delivers the current configuration of this instance as an instance of MIProject.

Returns:
A filled meta model instance.
Throws:
AnalysisConfigurationException - If the current configuration is somehow invalid.

run

public final void run()
               throws IllegalStateException,
                      AnalysisConfigurationException
Starts an AnalysisController instance. The method returns after all configured readers finished reading and all analysis plug-ins terminated On errors during the initialization, Exceptions are thrown.

Throws:
IllegalStateException - If the current instance has already been started or already been terminated.
AnalysisConfigurationException - If plugins with mandatory repositories have not been connected properly or couldn't be initialized.

terminate

public final void terminate()
Initiates a termination of the analysis.


terminate

public final void terminate(boolean error)
Initiates a termination of the analysis.

Parameters:
error - Determines whether this is a normal termination or an termination due to an error during the analysis.

registerReader

public final void registerReader(AbstractReaderPlugin reader)
                          throws IllegalStateException
Registers a log reader used as a source for monitoring records.

Parameters:
reader - The reader to be registered.
Throws:
IllegalStateException - If the controller is already running or has already been terminated.

registerFilter

public final void registerFilter(AbstractFilterPlugin filter)
                          throws IllegalStateException
Registers the passed plugin. All plugins which have been registered before calling the run-method, will be started once the analysis is started.

Parameters:
filter - The filter to be registered.
Throws:
IllegalStateException - If the controller is already running or has already been terminated.

registerRepository

public final void registerRepository(AbstractRepository repository)
                              throws IllegalStateException
Registers the passed repository.

Parameters:
repository - The repository to be registered.
Throws:
IllegalStateException - If the controller is already running or has already been terminated.

getProjectName

public final String getProjectName()
Delivers the current name of the project.

Returns:
The current project name.

getReaders

public final Collection<AbstractReaderPlugin> getReaders()
Delivers an unmodifiable collection of all readers.

Returns:
All registered readers.

getFilters

public final Collection<AbstractFilterPlugin> getFilters()
Delivers an unmodifiable collection of all filters.

Returns:
All registered filters.

getRepositories

public final Collection<AbstractRepository> getRepositories()
Delivers an unmodifiable collection of all repositories.

Returns:
All registered repositories.

getState

public final AnalysisController.STATE getState()
Delivers the current state of the analysis controller.

Returns:
The current state.

loadFromFile

public static final MIProject loadFromFile(File file)
                                    throws IOException
This method can be used to load a meta model instance from a given file.

Parameters:
file - The file to be loaded.
Returns:
An instance of MIProject if everything went well.
Throws:
IOException - If something during loading went wrong.

saveToFile

public static final void saveToFile(File file,
                                    MIProject project)
                             throws IOException
This method can be used to save the given instance of MIProject within a given file.

Parameters:
file - The file to be used for the storage.
project - The project to be stored.
Throws:
IOException - In case of errors.

Kieker 1.5

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