org.objectweb.cjdbc.scenario.tools.components
Class ComponentManager

java.lang.Object
  extended byorg.objectweb.cjdbc.scenario.tools.components.ComponentManager
All Implemented Interfaces:
ComponentManagerInterface
Direct Known Subclasses:
ControllerManager, DatabaseManager

public abstract class ComponentManager
extends java.lang.Object
implements ComponentManagerInterface

This class defines a ComponentManager

Version:
1.0
Author:
Nicolas Modrzyk

Field Summary
protected  java.util.Hashtable processes
           
 
Constructor Summary
ComponentManager()
           
 
Method Summary
abstract  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
abstract  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 loaddatabase(java.lang.String port, java.lang.String templateName, java.lang.String target)
          Load the database with a given input file
 void release()
          release files locked 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 database
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processes

protected java.util.Hashtable processes
Constructor Detail

ComponentManager

public ComponentManager()
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

Specified by:
instanciateProcess in interface ComponentManagerInterface
Parameters:
port - port to start the process on
Returns:
a reference to the newly started component
Throws:
java.lang.Exception - if fails

instanciateProcess

public abstract 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

Specified by:
instanciateProcess in interface ComponentManagerInterface
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 abstract java.lang.String getDefaultConfigurationFile()
The default configuration file to use with this component manager. This should be specific to each component manager

Specified by:
getDefaultConfigurationFile in interface ComponentManagerInterface
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

Specified by:
startComponent in interface ComponentManagerInterface
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

Specified by:
startComponent in interface ComponentManagerInterface
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

Specified by:
waitForStarted in interface ComponentManagerInterface
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

Specified by:
waitForStopped in interface ComponentManagerInterface
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

Specified by:
isStarted in interface ComponentManagerInterface
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

Specified by:
loaddatabase in interface ComponentManagerInterface
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

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

loaddatabase

public void loaddatabase(java.lang.String port,
                         java.lang.String templateName,
                         java.lang.String target)
                  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!)
target - the target database to load
Throws:
java.lang.Exception - if fails

stop

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

Specified by:
stop in interface ComponentManagerInterface
Parameters:
process - to stop

stop

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

Specified by:
stop in interface ComponentManagerInterface
Parameters:
componentOnPort - port number of the component to stop

stop

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

Specified by:
stop in interface ComponentManagerInterface
Parameters:
port - port number

stopAll

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

Specified by:
stopAll in interface ComponentManagerInterface

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

Specified by:
start in interface ComponentManagerInterface
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 database

Specified by:
start in interface ComponentManagerInterface
Parameters:
port - to run component on
Returns:
created process
Throws:
java.lang.Exception - if fails to create process

release

public void release()
release files locked by manager

Specified by:
release in interface ComponentManagerInterface

simulateFailure

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

Specified by:
simulateFailure in interface ComponentManagerInterface
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
See Also:
ComponentManagerInterface.simulateFailure(int, long, boolean)

simulateFailure

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

Specified by:
simulateFailure in interface ComponentManagerInterface
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
See Also:
ComponentManagerInterface.simulateFailure(java.lang.String, long, boolean)


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