| java.lang.Object org.apache.derby.impl.drda.NetworkServerControlImpl
NetworkServerControlImpl | final public class NetworkServerControlImpl (Code) | | NetworkServerControlImpl does all the work for NetworkServerControl
See Also: NetworkServerControl See Also: for description |
Method Summary | |
void | addSession(Socket clientSocket) Add a session - for use by ClientThread . | public void | blockingStart(PrintWriter consoleWriter) Start a network server
Parameters: consoleWriter - PrintWriter to which server console will be output. | public String | buildRuntimeInfo(LocalizedResource locallangUtil) | public void | consoleError(String msg) | public void | consoleExceptionPrint(Exception e) Write an exception to console output stream,
but only if debugOutput is true. | public void | consoleExceptionPrintTrace(Throwable e) Write an exception (with trace) to console
output stream. | public void | consoleMessage(String msg) | protected void | consolePropertyMessage(String msgProp) | protected void | consolePropertyMessage(String msgProp, String arg) | protected void | consolePropertyMessage(String msgProp, String[] args) | public void | directShutdown() | public void | executeWork(String args) | protected AppRequester | getAppRequester(AppRequester appRequester) | public Properties | getCurrentProperties() | protected static Driver | getDriver() | protected boolean | getKeepAlive() | public boolean | getLogConnections() | protected int | getManagerLevel(int manager) | protected Session | getNextSession(Session currentSession) Get the next session for the thread to work on
Called from DRDAConnThread after session completes or timeslice
exceeded. | protected int | getSecurityMechanism() get the security mechanism (secmec value) that the server
will accept connections from.
the securitymechanism value. | protected boolean | getShutdown() | protected Object | getShutdownSync() | protected int | getTimeSlice() | protected boolean | getTraceAll() | protected String | getTraceDirectory() | protected static boolean | isCmd(String val) | public boolean | isServerStarted() | public void | logConnections(boolean on) Turn logging connections on or off. | public void | netSetMaxThreads(int max) | public void | netSetTimeSlice(int timeslice) Set network server connection timeslice parameter
Parameters: timeslice - amount of time given to each session before yielding to another session, if 0, never yield. | public void | ping() | protected synchronized void | processCommands(DDMReader reader, DDMWriter writer, Session session) processCommands reads and processes NetworkServerControlImpl commands sent
to the network server over the socket. | protected void | removeFromSessionTable(int sessionid) | void | removeThread(DRDAConnThread thread) Remove a thread from the thread list. | public String | runtimeInfo() | public void | sendSetTraceDirectory(String traceDirectory) | protected void | setClientLocale(String locale) | public void | setLogWriter(PrintWriter outWriter) | public static void | setUniqueThreadName(Thread thrd, String newName) Set a thread name to be something that is both meaningful and unique (primarily
for debugging purposes).
The received thread's name is set to a new string of the form
[newName + "_n"], where 'n' is a unique thread id originally generated
by the jvm Thread constructor. | public void | shutdown() | public void | start(PrintWriter consoleWriter) Start a network server. | protected void | startNetworkServer() Load Cloudscape and save driver for future use. | protected boolean | supportsCCSID(int ccsid) | boolean | supportsEUSRIDPWD() This method returns whether EUSRIDPWD security mechanism
is supported or not. | public String | sysinfo() | public void | trace(boolean on) | public void | trace(int connNum, boolean on) | public void | usage() | protected void | writeString(String msg) |
CCSIDMBC | final protected static int CCSIDMBC(Code) | | |
CCSIDSBC | final protected static int CCSIDSBC(Code) | | |
DEFAULT_CCSID | final protected static int DEFAULT_CCSID(Code) | | |
DEFAULT_ENCODING | final protected static String DEFAULT_ENCODING(Code) | | |
INVALID_OR_NOTSET_SECURITYMECHANISM | final protected static int INVALID_OR_NOTSET_SECURITYMECHANISM(Code) | | |
MGR_LEVELS | final protected static int[] MGR_LEVELS(Code) | | |
SPACE_CHAR | final protected static byte SPACE_CHAR(Code) | | |
UNEXPECTED_ERR | final public static String UNEXPECTED_ERR(Code) | | |
debugOutput | protected boolean debugOutput(Code) | | |
prdIdBytes_ | protected static byte[] prdIdBytes_(Code) | | |
NetworkServerControlImpl | public NetworkServerControlImpl() throws Exception(Code) | | |
NetworkServerControlImpl | public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception(Code) | | Internal constructor for NetworkServerControl API.
Parameters: address - - InetAddress to listen on, May not be null. Throws NPE if null Parameters: portNumber - - portNumber to listen on, -1 use propert or default. throws: Exception - on error See Also: NetworkServerControl |
addSession | void addSession(Socket clientSocket) throws Exception(Code) | | Add a session - for use by ClientThread . Put the session
into the session table and the run queue. Start a new
DRDAConnThread if there are more sessions waiting than
there are free threads, and the maximum number of threads is not
exceeded.
addSession() should only be called from one thread at a
time.
Parameters: clientSocket - the socket to read from and write to
|
blockingStart | public void blockingStart(PrintWriter consoleWriter) throws Exception(Code) | | Start a network server
Parameters: consoleWriter - PrintWriter to which server console will be output. Null will disable console output. exception: Exception - throws an exception if an error occurs |
consoleError | public void consoleError(String msg) throws Exception(Code) | | Write an error message to console output stream
and throw an exception for this error
Parameters: msg - error message exception: Exception - |
consoleExceptionPrint | public void consoleExceptionPrint(Exception e)(Code) | | Write an exception to console output stream,
but only if debugOutput is true.
Parameters: e - exception |
consoleExceptionPrintTrace | public void consoleExceptionPrintTrace(Throwable e)(Code) | | Write an exception (with trace) to console
output stream.
Parameters: e - exception |
consoleMessage | public void consoleMessage(String msg)(Code) | | Write a message to console output stream
Parameters: msg - message |
consolePropertyMessage | protected void consolePropertyMessage(String msgProp) throws Exception(Code) | | Put property message on console
Parameters: msgProp - message property key throws: Exception - if an error occurs |
consolePropertyMessage | protected void consolePropertyMessage(String msgProp, String arg) throws Exception(Code) | | Put property message on console
Parameters: msgProp - message property key Parameters: arg - argument for message throws: Exception - if an error occurs |
consolePropertyMessage | protected void consolePropertyMessage(String msgProp, String[] args) throws Exception(Code) | | Put property message on console
Parameters: msgProp - message property key Parameters: args - argument array for message throws: Exception - if an error occurs |
directShutdown | public void directShutdown()(Code) | | |
executeWork | public void executeWork(String args) throws Exception(Code) | | Execute the command given on the command line
Parameters: args - array of arguments indicating command to be executed exception: Exception - throws an exception if an error occurssee class comments for more information |
getAppRequester | protected AppRequester getAppRequester(AppRequester appRequester)(Code) | | Get the stored application requester or store if we haven't seen it yet
Parameters: appRequester - Application Requester to look for stored application requester |
getCurrentProperties | public Properties getCurrentProperties() throws Exception(Code) | | Get current properties
Properties object containing properties exception: Exception - throws an exception if an error occurs |
getKeepAlive | protected boolean getKeepAlive()(Code) | | Get the current value of keepAlive to configure how long the server
should keep the socket alive for a disconnected client
|
getLogConnections | public boolean getLogConnections()(Code) | | Get the current value of logging connections
true if logging connections is on; false otherwise |
getManagerLevel | protected int getManagerLevel(int manager)(Code) | | Get the server manager level for a given manager
Parameters: manager - codepoint for manager manager level |
getNextSession | protected Session getNextSession(Session currentSession)(Code) | | Get the next session for the thread to work on
Called from DRDAConnThread after session completes or timeslice
exceeded.
If there is a waiting session, pick it up and put currentSession
at the back of the queue if there is one.
Parameters: currentSession - session thread is currently working on next session to work on, could be same as current session |
getSecurityMechanism | protected int getSecurityMechanism()(Code) | | get the security mechanism (secmec value) that the server
will accept connections from.
the securitymechanism value. It is value that the derby.drda.securityMechanism was set to, if it is not set, thenit is equal to INVALID_OR_NOTSET_SECURITYMECHANISM See Also: Property.DRDA_PROP_SECURITYMECHANISM See Also: |
getShutdown | protected boolean getShutdown()(Code) | | |
getTimeSlice | protected int getTimeSlice()(Code) | | Get the current value of the time slice
time slice value |
getTraceAll | protected boolean getTraceAll()(Code) | | Get the current value of whether to trace all the sessions
true if tracing is on for all sessions; false otherwise |
getTraceDirectory | protected String getTraceDirectory()(Code) | | Get the current value of trace directory
trace directory |
isCmd | protected static boolean isCmd(String val)(Code) | | Is this the command protocol
Parameters: val - |
logConnections | public void logConnections(boolean on) throws Exception(Code) | | Turn logging connections on or off. When logging is turned on a message is
written to derby.log each time a connection is made.
Parameters: on - true to turn on, false to turn off exception: Exception - throws an exception if an error occurs |
netSetMaxThreads | public void netSetMaxThreads(int max) throws Exception(Code) | | Connect to network server and set connection maxthread parameter
Parameters: max - maximum number of connections, if 0, connections created when no free connection availableif -1, use default exception: Exception - throws an exception if an error occurs |
netSetTimeSlice | public void netSetTimeSlice(int timeslice) throws Exception(Code) | | Set network server connection timeslice parameter
Parameters: timeslice - amount of time given to each session before yielding to another session, if 0, never yield. if -1, use default. exception: Exception - throws an exception if an error occurs |
processCommands | protected synchronized void processCommands(DDMReader reader, DDMWriter writer, Session session) throws Throwable(Code) | | processCommands reads and processes NetworkServerControlImpl commands sent
to the network server over the socket. The protocol used is
4 bytes - String CMD:
2 bytes - Protocol version
1 byte - length of locale (0 for default)
n bytes - locale
1 byte - length of codeset (0 for default)
n bytes - codeset
1 byte - command
n bytes - parameters for the command
The server returns
4 bytes - String RPY:
for most commands
1 byte - command result, 0 - OK, 1 - warning, 2 - error
if warning or error
1 bytes - length of message key
n bytes - message key
1 byte - number of parameters to message
{2 bytes - length of parameter
n bytes - parameter} for each parameter
for sysinfo
1 byte - command result, 0 - OK, 1 - warning, 2 - error
if OK
2 bytes - length of sysinfo
n bytes - sysinfo
Note, the 3rd byte of the command must not be 'D0' to distinquish it
from DSS structures.
The protocol for the parameters for each command follows:
Command: trace {on | off}
Protocol:
4 bytes - connection id - connection id of 0 means all sessions
1 byte - 0 off, 1 on
Command: logConnections {on | off}
Protocol:
1 byte - 0 off, 1 on
Command: shutdown
No parameters
Command: sysinfo
No parameters
Command: dbstart
Protocol:
2 bytes - length of database name
n bytes - database name
2 bytes - length of boot password
n bytes - boot password
2 bytes - length of encryption algorithm
n bytes - encryption algorithm
2 bytes - length of encryption provider
n bytes - encryption provider
2 bytes - length of user name
n bytes - user name
2 bytes - length of password
n bytes - password
Command: dbshutdown
Protocol:
2 bytes - length of database name
n bytes - database name
2 bytes - length of user name
n bytes - user name
2 bytes - length of password
n bytes - password
Command: connpool
Protocol:
2 bytes - length of database name, if 0, default for all databases
is set
n bytes - database name
2 bytes - minimum number of connections, if 0, connection pool not used
if value is -1 use default
2 bytes - maximum number of connections, if 0, connections are created
as needed, if value is -1 use default
Command: maxthreads
Protocol:
2 bytes - maximum number of threads
Command: timeslice
Protocol:
4 bytes - timeslice value
Command: tracedirectory
Protocol:
2 bytes - length of directory name
n bytes - directory name
Command: test connection
Protocol:
2 bytes - length of database name if 0, just the connection
to the network server is tested and user name and
password aren't sent
n bytes - database name
2 bytes - length of user name (optional)
n bytes - user name
2 bytes - length of password (optional)
n bytes - password
The calling routine is synchronized so that multiple threads don't clobber each
other. This means that configuration commands will be serialized.
This shouldn't be a problem since they should be fairly rare.
Parameters: reader - input reader for command Parameters: writer - output writer for command Parameters: session - session information exception: Throwable - throws an exception if an error occurs |
removeFromSessionTable | protected void removeFromSessionTable(int sessionid)(Code) | | Remove session from session table
Parameters: sessionid - id of session to be removed |
removeThread | void removeThread(DRDAConnThread thread)(Code) | | Remove a thread from the thread list. Should be called when a
DRDAConnThread has been closed.
Parameters: thread - the closed thread |
setClientLocale | protected void setClientLocale(String locale)(Code) | | |
setLogWriter | public void setLogWriter(PrintWriter outWriter)(Code) | | Set the output stream for console messages
If this is set to null, no messages will be written to the console
Parameters: outWriter - output stream for console messages |
setUniqueThreadName | public static void setUniqueThreadName(Thread thrd, String newName)(Code) | | Set a thread name to be something that is both meaningful and unique (primarily
for debugging purposes).
The received thread's name is set to a new string of the form
[newName + "_n"], where 'n' is a unique thread id originally generated
by the jvm Thread constructor. If the default name of the thread has
been changed before getting here, then nothing is done.
Parameters: thrd - An instance of a Thread object that still has its defaultthread name (as generated by the jvm Thread constructor). This shouldalways be of the form "Thread-N", where N is a unique thread idgenerated by the jvm. Ex. "Thread-0", "Thread-1", etc. |
shutdown | public void shutdown() throws Exception(Code) | | Shutdown a network server
exception: Exception - throws an exception if an error occurs |
start | public void start(PrintWriter consoleWriter) throws Exception(Code) | | Start a network server. Launches a separate thread with
DRDAServerStarter. Want to use Monitor.startModule,
so it can all get shutdown when cloudscape shuts down, but
can't get it working right now.
Parameters: consoleWriter - PrintWriter to which server console will be output. Null will disable console output. exception: Exception - throws an exception if an error occurs |
startNetworkServer | protected void startNetworkServer() throws Exception(Code) | | Load Cloudscape and save driver for future use.
We can't call Driver Manager when the client connects,
because they might be holding the DriverManager lock.
|
supportsCCSID | protected boolean supportsCCSID(int ccsid)(Code) | | Check whether a CCSID code page is supported
Parameters: ccsid - CCSID to check true if supported; false otherwise |
supportsEUSRIDPWD | boolean supportsEUSRIDPWD()(Code) | | This method returns whether EUSRIDPWD security mechanism
is supported or not. See class static block for more
info.
true if EUSRIDPWD is supported, false otherwise |
trace | public void trace(boolean on) throws Exception(Code) | | Turn tracing on or off for all sessions
Parameters: on - true to turn tracing on, false to turn tracing off exception: Exception - throws an exception if an error occurs |
trace | public void trace(int connNum, boolean on) throws Exception(Code) | | Turn tracing on or off for one session or all sessions
Parameters: connNum - the connNum of the session, 0 if all sessions Parameters: on - true to turn tracing on, false to turn tracing off exception: Exception - throws an exception if an error occurs |
usage | public void usage()(Code) | | Display usage information
|
writeString | protected void writeString(String msg) throws Exception(Code) | | Write string
Parameters: msg - String to write |
|
|