org.objectweb.cjdbc.scenario.tools.components
Interface ComponentManagerInterface

All Known Implementing Classes:
ComponentManager

public interface ComponentManagerInterface

This class defines a ComponentManagerInterface. This class is used to start, stop, management configuration of classes that implements the ComponentInterface interface.
Typically, this will be used to start database backends and controller, load database configuration (virtual or not) and simulate failure by stopping the component straight away or after a given time.

Version:
1.0
Author:
Nicolas Modrzyk

Method Summary
 java.lang.String getDefaultConfigurationFile()
          The default configuration file to use with this component manager.
 ComponentInterface instanciateProcess(java.lang.String port)
          Instaciate a process managed by this component manager on the given port This used the default configuration file returned by the getDefaultConfigurationFile method
 ComponentInterface instanciateProcess(java.lang.String port, java.lang.String configurationFile)
          Instaciate a process managed by this component manager on the given port
 boolean isStarted(java.lang.String port)
          Check if can open a connection on localhost on the given port
 void loaddatabase(java.lang.String port)
          fill the database with raidb1 default configuration
 void loaddatabase(java.lang.String port, java.lang.String templateName)
          Load the database with a given input file
 void release()
          release files and processes owned by manager
 void simulateFailure(int port, long wait, boolean rand)
          Simulate a failure of the component by stopping it after the given time.
 void simulateFailure(java.lang.String port, long wait, boolean rand)
          Simulate a failure of the component by stopping it after the given time.
 ComponentInterface start(java.lang.String port)
          Starts database component on the given port with the default configuration
 ComponentInterface start(java.lang.String port, java.lang.String database)
          Starts database component on the given port with the given database
 ComponentInterface startComponent(java.lang.String port)
          Starts component on the given port
 ComponentInterface startComponent(java.lang.String port, java.lang.String database)
          Starts component on the given port with the given database
 void stop(ComponentInterface process)
          Stop Hsql.
 void stop(int port)
          Same as stop(String)
 void stop(java.lang.String componentOnPort)
          Stop a component from its unique port number
 void stopAll()
          Stops all process contained in this manager
 void waitForStarted(java.lang.String port)
          Check if can open a connection on localhost on the given port
 void waitForStopped(java.lang.String port)
          Wait for the component to stop
 

Method Detail

instanciateProcess

public ComponentInterface instanciateProcess(java.lang.String port)
                                      throws java.lang.Exception
Instaciate a process managed by this component manager on the given port This used the default configuration file returned by the getDefaultConfigurationFile method

Parameters:
port - port to start the process on
Returns:
a reference to the newly started component
Throws:
java.lang.Exception - if fails

instanciateProcess

public ComponentInterface instanciateProcess(java.lang.String port,
                                             java.lang.String configurationFile)
                                      throws java.lang.Exception
Instaciate a process managed by this component manager on the given port

Parameters:
port - port to start the process on
configurationFile - used to instanciate the process
Returns:
a reference to the newly started component
Throws:
java.lang.Exception - if fails

getDefaultConfigurationFile

public java.lang.String getDefaultConfigurationFile()
The default configuration file to use with this component manager. This should be specific to each component manager

Returns:
the default filename

startComponent

public ComponentInterface startComponent(java.lang.String port,
                                         java.lang.String database)
                                  throws java.lang.Exception
Starts component on the given port with the given database

Parameters:
port - to run hsql on
database - to load component with
Returns:
created process
Throws:
java.lang.Exception - if fails to create process

startComponent

public ComponentInterface startComponent(java.lang.String port)
                                  throws java.lang.Exception
Starts component on the given port

Parameters:
port - to run component on
Returns:
created process
Throws:
java.lang.Exception - if fails to create process

waitForStarted

public void waitForStarted(java.lang.String port)
                    throws java.lang.Exception
Check if can open a connection on localhost on the given port

Parameters:
port - to open a socket for check
Throws:
java.lang.Exception - if fails

waitForStopped

public void waitForStopped(java.lang.String port)
                    throws java.lang.Exception
Wait for the component to stop

Parameters:
port - to check the connection on
Throws:
java.lang.Exception - if fails

isStarted

public boolean isStarted(java.lang.String port)
Check if can open a connection on localhost on the given port

Parameters:
port - to open a socket for check
Returns:
true if can connect, false if exception or can't connect

loaddatabase

public void loaddatabase(java.lang.String port)
                  throws java.lang.Exception
fill the database with raidb1 default configuration

Parameters:
port - of the database
Throws:
java.lang.Exception - if fails

loaddatabase

public void loaddatabase(java.lang.String port,
                         java.lang.String templateName)
                  throws java.lang.Exception
Load the database with a given input file

Parameters:
port - of the database to load
templateName - name of the file to load(NO PATH!)
Throws:
java.lang.Exception - if fails

stop

public void stop(ComponentInterface process)
Stop Hsql. Destroy the process so it looks like a failure.

Parameters:
process - to stop

stop

public void stop(java.lang.String componentOnPort)
Stop a component from its unique port number

Parameters:
componentOnPort - port number of the component to stop

stop

public void stop(int port)
Same as stop(String)

Parameters:
port - port number

simulateFailure

public void simulateFailure(java.lang.String port,
                            long wait,
                            boolean rand)
Simulate a failure of the component by stopping it after the given time.

Parameters:
port - the port of the component to stop
wait - the wait time before stopping it
rand - should we use a random time, if so, the previous argument is used as a range

simulateFailure

public void simulateFailure(int port,
                            long wait,
                            boolean rand)
Simulate a failure of the component by stopping it after the given time.

Parameters:
port - the port of the component to stop
wait - the wait time before stopping it
rand - should we use a random time, if so, the previous argument is used as a range

stopAll

public void stopAll()
Stops all process contained in this manager


start

public ComponentInterface start(java.lang.String port,
                                java.lang.String database)
                         throws java.lang.Exception
Starts database component on the given port with the given database

Parameters:
port - to run component on
database - to load component with
Returns:
created process
Throws:
java.lang.Exception - if fails to create process

start

public ComponentInterface start(java.lang.String port)
                         throws java.lang.Exception
Starts database component on the given port with the default configuration

Parameters:
port - to run component on
Returns:
created process
Throws:
java.lang.Exception - if fails to create process

release

public void release()
release files and processes owned by manager



Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.