public class ServerController
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BASEDIR_KEY
Where is the server installed?
|
static java.lang.String |
DATADIR_KEY
Where are the databases installed?
|
static java.lang.String |
DEFAULTS_FILE_KEY
Where is the config file located?
|
static java.lang.String |
EXECUTABLE_NAME_KEY
What is the name of the executable to run?
|
static java.lang.String |
EXECUTABLE_PATH_KEY
What is the path to the mysql server executable (if not standard?)
|
private java.lang.Process |
serverProcess
The process representing the MySQL server
|
private java.util.Properties |
serverProps
The list of properties for this server
|
| Constructor and Description |
|---|
ServerController(java.lang.String baseDir)
Creates a ServerController with the directory for the MySQL server.
|
ServerController(java.lang.String basedir,
java.lang.String datadir)
Creates a server controller for the MySQL server with the given basedir
and datadir.
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
buildOptionalCommandLine()
Builds the list of command-line arguments that will be passed to the
mysql server to be started.
|
void |
forceStop()
Forcefully terminates the server process (if started).
|
private java.lang.String |
getCommandLine()
Returns the full commandline used to start the mysql server, including
and arguments to be passed to the server process.
|
private java.lang.String |
getFullExecutablePath()
Returns the fully-qualifed path to the 'mysqld' executable
|
java.util.Properties |
getServerProps()
Returns the list of properties that will be used to start/control the
server.
|
private boolean |
isNonCommandLineArgument(java.lang.String propName)
Returns true if the property does not belong as a command-line argument
|
private boolean |
runningOnWindows()
Is this ServerController running on a Windows operating system?
|
void |
setBaseDir(java.lang.String baseDir)
Sets the basedir to use when starting MySQL.
|
void |
setDataDir(java.lang.String dataDir)
Sets the data to use when starting MySQL.
|
java.lang.Process |
start()
Starts the server, returning a java.lang.Process instance that represents
the mysql server.
|
void |
stop(boolean forceIfNecessary)
Stops the server (if started)
|
public static final java.lang.String BASEDIR_KEY
public static final java.lang.String DATADIR_KEY
public static final java.lang.String DEFAULTS_FILE_KEY
public static final java.lang.String EXECUTABLE_NAME_KEY
public static final java.lang.String EXECUTABLE_PATH_KEY
private java.lang.Process serverProcess
private java.util.Properties serverProps
public ServerController(java.lang.String baseDir)
baseDir - the base directory for the MySQL server.public ServerController(java.lang.String basedir,
java.lang.String datadir)
basedir - the basedir to use when starting MySQL.datadir - the datadir to use when starting MySQL.public void setBaseDir(java.lang.String baseDir)
baseDir - the basedir to use when starting MySQL.public void setDataDir(java.lang.String dataDir)
dataDir - the basedir to use when starting MySQL.public java.lang.Process start()
throws java.io.IOException
java.io.IOException - if an error occurs while starting the mysql server.public void stop(boolean forceIfNecessary)
throws java.io.IOException
forceIfNecessary - use forceStop if mysqladmin doesn't shut the server downjava.io.IOException - if an error occurs while stopping the serverpublic void forceStop()
public java.util.Properties getServerProps()
private java.lang.String getCommandLine()
private java.lang.String getFullExecutablePath()
private java.lang.String buildOptionalCommandLine()
private boolean isNonCommandLineArgument(java.lang.String propName)
propName - property nameprivate boolean runningOnWindows()