Top Description Fields Constructors Methods
org.apache.derby.drda

public Class NetworkServerControl

extends Object
Class Inheritance
Imports
java.io.File, .PrintWriter, java.net.Inet6Address, .InetAddress, .URL, java.security.CodeSource, .ProtectionDomain, java.util.Properties, org.apache.derby.shared.common.reference.Property, org.apache.derby.iapi.services.property.PropertyUtil, org.apache.derby.impl.drda.NetworkServerControlImpl

NetworkServerControl provides the ability to start a Network Server or connect to a running Network Server to shutdown, configure or retrieve diagnostic information. With the exception of ping, these commands can only be performed from the machine on which the server is running. Commands can be performed from the command line with the following arguments:

Properties can be set in the derby.properties file or on the command line. Properties on the command line take precedence over properties in the derby.properties file. Arguments on the command line take precedence over properties. The following is a list of properties that can be set for NetworkServerControl:

Examples.

This is an example of shutting down the server on port 1621.

 
    java org.apache.derby.drda.NetworkServerControl shutdown -p 1621
    

This is an example of turning tracing on for session 3

    java org.apache.derby.drda.NetworkServerControl  trace on -s 3 
    

This is an example of starting and then shutting down the Network Server on port 1621 on machine myhost

    java org.apache.derby.drda.NetworkServerControl  start -h myhost -p 1621
    java org.apache.derby.drda.NetworkServerControl  shutdown -h myhost -p 1621
    

This is an example of starting and shutting down the Network Server in the example above with the API.


    NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621)

    serverControl.shutdown();
    

Field Summary

Modifier and TypeField and Description
public static final int
private static final String
private static final String
private static final String
private NetworkServerControlImpl
private static final String

Constructor Summary

AccessConstructor and Description
public
NetworkServerControl(InetAddress
The IP address of the Network Server host. address cannot be null.
address
,
int
port number server is to used. If <= 0, default port number is used
portNumber
,
String
The user name for actions requiring authorization.
userName
,
String
The password for actions requiring authorization.
password
)

Creates a NetworkServerControl object that is configured to control a Network Server on a specified port and InetAddress with given user credentials.

public
NetworkServerControl(String
The user name for actions requiring authorization.
userName
,
String
The password for actions requiring authorization.
password
)

Creates a NetworkServerControl object that is configured to control a Network Server on the default host and the default port with given user credentials.

public
NetworkServerControl(InetAddress
The IP address of the Network Server host. address cannot be null.
address
,
int
port number server is to used. If <= 0, default port number is used
portNumber
)

Creates a NetworkServerControl object that is configured to control a Network Server on a specified port and InetAddress.

public
NetworkServerControl()

Creates a NetworkServerControl object that is configured to control a Network Server on the default host(localhost) and the default port(1527) unless derby.drda.portNumber and derby.drda.host are set.

Method Summary

Modifier and TypeMethod and Description
public Properties

Returns:

Properties object containing Network server properties
getCurrentProperties
()

Get current Network server properties

public int

Returns:

maxThreads setting
getMaxThreads
()

Returns the current maxThreads setting for the running Network Server

public String

Returns:

run time information
getRuntimeInfo
()

Return detailed session runtime information about sessions, prepared statements, and memory usage for the running Network Server.

public String

Returns:

sysinfo output
getSysinfo
()

Return classpath and version information about the running Network Server.

public int

Returns:

timeSlice setting
getTimeSlice
()

Return the current timeSlice setting for the running Network Server

private static boolean
private static boolean
public void
logConnections(boolean
true to turn on, false to turn off
on
)

Turn logging connections on or off.

public static void
main(String[]
array of arguments indicating command to be executed. See class comments for more information
args
)

main routine for NetworkServerControl

public void
ping()

Check if the Network Server is started.

protected void
setClientLocale(String
Locale to use
locale
)

set the client locale.

public void
setMaxThreads(int
maximum number of connection threads. If <= 0, connection threads will be created when there are no free connection threads.
max
)

Set Network Server maxthread parameter.

public void
setTimeSlice(int
number of milliseconds given to each session before yielding to another session, if <=0, never yield.
timeslice
)

Set Network Server connection time slice parameter.

public void
setTraceDirectory(String
directory for trace files on machine where server is running
traceDirectory
)

Set directory for trace files.

public void
shutdown()

Shutdown a Network Server.

public void
start(PrintWriter
PrintWriter to which server console will be output. Null will disable console output.
consoleWriter
)

Start a Network Server.

public void
trace(boolean
true to turn tracing on, false to turn tracing off.
on
)

Turn tracing on or off for the specified connection on the Network Server.

public void
trace(int
connection number.

Note

Connection numbers will print in the Derby error log if logConnections is on

connNum
,
boolean
true to turn tracing on, false to turn tracing off.
on
)

Turn tracing on or off for all connections on the Network Server.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_PORTNUMBERback to summary
public static final int DEFAULT_PORTNUMBER
DERBY_HOSTNAME_WILDCARDback to summary
private static final String DERBY_HOSTNAME_WILDCARD
DERBYNET_JARback to summary
private static final String DERBYNET_JAR
IPV6_HOSTNAME_WILDCARDback to summary
private static final String IPV6_HOSTNAME_WILDCARD
serverImplback to summary
private NetworkServerControlImpl serverImpl
SOCKET_PERMISSION_HOSTNAME_WILDCARDback to summary
private static final String SOCKET_PERMISSION_HOSTNAME_WILDCARD

Constructor Detail

NetworkServerControlback to summary
public NetworkServerControl(InetAddress address, int portNumber, String userName, String password) throws Exception

Creates a NetworkServerControl object that is configured to control a Network Server on a specified port and InetAddress with given user credentials.

Parameters
address:InetAddress

The IP address of the Network Server host. address cannot be null.

portNumber:int

port number server is to used. If <= 0, default port number is used

userName:String

The user name for actions requiring authorization.

password:String

The password for actions requiring authorization.

Exceptions
Exception:
on error
NetworkServerControlback to summary
public NetworkServerControl(String userName, String password) throws Exception

Creates a NetworkServerControl object that is configured to control a Network Server on the default host and the default port with given user credentials.

Parameters
userName:String

The user name for actions requiring authorization.

password:String

The password for actions requiring authorization.

Exceptions
Exception:
on error
NetworkServerControlback to summary
public NetworkServerControl(InetAddress address, int portNumber) throws Exception

Creates a NetworkServerControl object that is configured to control a Network Server on a specified port and InetAddress.

Examples:

To configure for port 1621 and listen on the loopback address:

  NetworkServerControl  util = new
 NetworkServerControl(InetAddress.getByName("localhost"), 1621);
 
Parameters
address:InetAddress

The IP address of the Network Server host. address cannot be null.

portNumber:int

port number server is to used. If <= 0, default port number is used

Exceptions
Exception:
on error
NetworkServerControlback to summary
public NetworkServerControl() throws Exception

Creates a NetworkServerControl object that is configured to control a Network Server on the default host(localhost) and the default port(1527) unless derby.drda.portNumber and derby.drda.host are set.

 new NetworkServerControl() 

 is equivalent to calling

 new NetworkServerControl(InetAddress.getByName("localhost"),1527);
 
Exceptions
Exception:
on error

Method Detail

getCurrentPropertiesback to summary
public Properties getCurrentProperties() throws Exception

Get current Network server properties

Returns:Properties

Properties object containing Network server properties

Exceptions
Exception:
throws an exception if an error occurs
getMaxThreadsback to summary
public int getMaxThreads() throws Exception

Returns the current maxThreads setting for the running Network Server

Returns:int

maxThreads setting

Exceptions
Exception:
throws an exception if an error occurs
See Also
setMaxThreads
getRuntimeInfoback to summary
public String getRuntimeInfo() throws Exception

Return detailed session runtime information about sessions, prepared statements, and memory usage for the running Network Server.

Returns:String

run time information

Exceptions
Exception:
throws an exception if an error occurs
getSysinfoback to summary
public String getSysinfo() throws Exception

Return classpath and version information about the running Network Server.

Returns:String

sysinfo output

Exceptions
Exception:
throws an exception if an error occurs
getTimeSliceback to summary
public int getTimeSlice() throws Exception

Return the current timeSlice setting for the running Network Server

Returns:int

timeSlice setting

Exceptions
Exception:
throws an exception if an error occurs
See Also
setTimeSlice
hostnamesEqualback to summary
private static boolean hostnamesEqual(String left, String right)
isIPV6Addressback to summary
private static boolean isIPV6Address(String hostname)
logConnectionsback to summary
public void logConnections(boolean on) throws Exception

Turn logging connections on or off. When logging is turned on a message is written to the Derby error log each time a connection is made.

Parameters
on:boolean

true to turn on, false to turn off

Exceptions
Exception:
throws an exception if an error occurs
mainback to summary
public static void main(String[] args)

main routine for NetworkServerControl

Parameters
args:String[]

array of arguments indicating command to be executed. See class comments for more information

pingback to summary
public void ping() throws Exception

Check if the Network Server is started. Excecutes and returns without error if the server has started

Exceptions
Exception:
throws an exception if an error occurs
setClientLocaleback to summary
protected void setClientLocale(String locale)

set the client locale. Used by servlet for localization

Parameters
locale:String

Locale to use

setMaxThreadsback to summary
public void setMaxThreads(int max) throws Exception

Set Network Server maxthread parameter. This is the maximum number of threads that will be used for JDBC client connections. setTimeSlice should also be set so that clients will yield appropriately.

Parameters
max:int

maximum number of connection threads. If <= 0, connection threads will be created when there are no free connection threads.

Exceptions
Exception:
throws an exception if an error occurs
See Also
setTimeSlice
setTimeSliceback to summary
public void setTimeSlice(int timeslice) throws Exception

Set Network Server connection time slice parameter. This should be set and is only relevant if setMaxThreads > 0.

Parameters
timeslice:int

number of milliseconds given to each session before yielding to another session, if <=0, never yield.

Exceptions
Exception:
throws an exception if an error occurs
See Also
setMaxThreads
setTraceDirectoryback to summary
public void setTraceDirectory(String traceDirectory) throws Exception

Set directory for trace files. The directory must be on the machine where the server is running.

Parameters
traceDirectory:String

directory for trace files on machine where server is running

Exceptions
Exception:
throws an exception if an error occurs
shutdownback to summary
public void shutdown() throws Exception

Shutdown a Network Server. Shuts down the Network Server listening on the port and InetAddress specified in the constructor for this NetworkServerControl object.

Exceptions
Exception:
throws an exception if an error occurs
startback to summary
public void start(PrintWriter consoleWriter) throws Exception

Start a Network Server. This method will launch a separate thread and start a Network Server. This method may return before the server is ready to accept connections. Use the ping method to verify that the server has started.

Note

an alternate method to starting the Network Server with the API, is to use the derby.drda.startNetworkServer property in derby.properties.

Parameters
consoleWriter:PrintWriter

PrintWriter to which server console will be output. Null will disable console output.

Exceptions
Exception:
if there is an error starting the server.
See Also
shutdown
traceback to summary
public void trace(boolean on) throws Exception

Turn tracing on or off for the specified connection on the Network Server.

Parameters
on:boolean

true to turn tracing on, false to turn tracing off.

Exceptions
Exception:
throws an exception if an error occurs
traceback to summary
public void trace(int connNum, boolean on) throws Exception

Turn tracing on or off for all connections on the Network Server.

Parameters
connNum:int

connection number.

Note

Connection numbers will print in the Derby error log if logConnections is on

on:boolean

true to turn tracing on, false to turn tracing off.

Exceptions
Exception:
throws an exception if an error occurs