Class NetworkServerControlImpl

java.lang.Object
org.apache.derby.impl.drda.NetworkServerControlImpl

public final class NetworkServerControlImpl extends Object
NetworkServerControlImpl does all the work for NetworkServerControl
See Also:
  • Field Details

  • Constructor Details

    • NetworkServerControlImpl

      public NetworkServerControlImpl() throws Exception
      Throws:
      Exception
    • NetworkServerControlImpl

      public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception
      Internal constructor for NetworkServerControl API.
      Parameters:
      address - InetAddress to listen on, throws NPE if null
      portNumber - portNumber to listen on, -1 use property or default
      Throws:
      Exception - on error
      See Also:
    • NetworkServerControlImpl

      public NetworkServerControlImpl(String userName, String password) throws Exception
      Internal constructor for NetworkServerControl API.
      Parameters:
      userName - the user name for actions requiring authorization
      password - the password for actions requiring authorization
      Throws:
      Exception - on error
      See Also:
    • NetworkServerControlImpl

      public NetworkServerControlImpl(InetAddress address, int portNumber, String userName, String password) throws Exception
      Internal constructor for NetworkServerControl API.
      Parameters:
      address - InetAddress to listen on, throws NPE if null
      portNumber - portNumber to listen on, -1 use property or default
      userName - the user name for actions requiring authorization
      password - the password for actions requiring authorization
      Throws:
      Exception - on error
      See Also:
  • Method Details

    • logWriter

      public PrintWriter logWriter()
      Get the log writer we're using
    • getHost

      public String getHost()
      Get the host where we listen for connections.
    • getPort

      public int getPort()
      Get the port where we listen for connections.
      Returns:
      the port number
    • runningUnsecure

      public boolean runningUnsecure()
      Return true if the customer forcibly overrode our decision to install a default SecurityManager.
    • init

      private void init() throws Exception
      Throws:
      Exception
    • makePrintWriter

      private PrintWriter makePrintWriter(OutputStream out)
    • getDriver

      protected static Driver getDriver()
    • setLogWriter

      public void setLogWriter(PrintWriter outWriter)
      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
    • consoleError

      public void consoleError(String msg) throws Exception
      Write an error message to console output stream and throw an exception for this error
      Parameters:
      msg - error message
      Throws:
      Exception
    • debugOutput

      public boolean debugOutput()
      Return the debug state
    • att_extnam

      public static String att_extnam()
      Return the att_extnam server attribute
    • att_srvclsnm

      public static String att_srvclsnm()
      Return the att_srvclsnm server attribute
    • att_srvrlslv

      public static String att_srvrlslv()
      Return the att_srvrlslv server attribute
    • prdId

      public static String prdId()
      Return the product id
    • prdIdBytes

      public static byte[] prdIdBytes()
      Return the bytes of the product id
    • consoleExceptionPrint

      public void consoleExceptionPrint(Exception e)
      Write an exception to console output stream, but only if debugOutput is true.
      Parameters:
      e - exception
    • consoleExceptionPrintTrace

      public void consoleExceptionPrintTrace(Throwable e)
      Write an exception (with trace) to console output stream.
      Parameters:
      e - exception
    • consoleMessage

      public void consoleMessage(String msg, boolean printTimeStamp)
      Write a message to console output stream
      Parameters:
      msg - message
      printTimeStamp - Whether to prepend a timestamp to the message or not
    • start

      public void start(PrintWriter consoleWriter) throws Exception
      Start a network server. Launches a separate thread with DRDAServerStarter. Want to use Monitor.startModule, so it can all get shutdown when Derby 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.
      Throws:
      Exception - throws an exception if an error occurs
    • createServerSocket

      private ServerSocket createServerSocket() throws IOException
      Create the right kind of server socket
      Throws:
      IOException
    • getEnabledProtocols

      private String getEnabledProtocols(SSLServerSocket sslServerSocket)
    • blockingStart

      public void blockingStart(PrintWriter consoleWriter) throws Exception
      Start a network server
      Parameters:
      consoleWriter - PrintWriter to which server console will be output. Null will disable console output.
      Throws:
      Exception - throws an exception if an error occurs
    • consolePrintAndIgnore

      private void consolePrintAndIgnore(String msgProp, Exception e, boolean printTimeStamp)
    • startNetworkServer

      protected void startNetworkServer() throws Exception
      Load Derby and save driver for future use. We can't call Driver Manager when the client connects, because they might be holding the DriverManager lock.
      Throws:
      Exception
    • shutdown

      public void shutdown() throws Exception
      Shutdown a network server
      Throws:
      Exception - throws an exception if an error occurs
    • checkShutdownPrivileges

      public void checkShutdownPrivileges() throws SQLException
      Throws:
      SQLException - if authentication or privileges check fails
    • directShutdown

      public void directShutdown() throws SQLException
      Throws:
      SQLException
    • directShutdownInternal

      void directShutdownInternal()
    • isServerStarted

      public boolean isServerStarted() throws Exception
      Throws:
      Exception
    • ping

      public void ping() throws Exception
      Ping opening an new socket and close it.
      Throws:
      Exception
    • pingWithNoOpen

      private void pingWithNoOpen() throws Exception
      Ping the server using the client socket that is already open.
      Throws:
      Exception
    • trace

      public void trace(boolean on) throws Exception
      Turn tracing on or off for all sessions
      Parameters:
      on - true to turn tracing on, false to turn tracing off
      Throws:
      Exception - throws an exception if an error occurs
    • trace

      public void trace(int connNum, boolean on) throws Exception
      Turn tracing on or off for one session or all sessions
      Parameters:
      connNum - the connNum of the session, 0 if all sessions
      on - true to turn tracing on, false to turn tracing off
      Throws:
      Exception - throws an exception if an error occurs
    • consoleTraceMessage

      private void consoleTraceMessage(int connNum, boolean on) throws Exception
      Print trace change message to console
      Parameters:
      on - true to print tracing on, false to print tracing off
      Throws:
      Exception - throws an exception if an error occurs
    • logConnections

      public void logConnections(boolean on) throws Exception
      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
      Throws:
      Exception - throws an exception if an error occurs
    • sendSetTraceDirectory

      public void sendSetTraceDirectory(String traceDirectory) throws Exception
      Throws:
      Exception
      See Also:
    • sysinfo

      public String sysinfo() throws Exception
      Throws:
      Exception
      See Also:
    • runtimeInfo

      public String runtimeInfo() throws Exception
      Throws:
      Exception
      See Also:
    • usage

      public void usage()
      Display usage information
    • netSetMaxThreads

      public void netSetMaxThreads(int max) throws Exception
      Connect to network server and set connection maxthread parameter
      Parameters:
      max - maximum number of connections, if 0, connections created when no free connection available if -1, use default
      Throws:
      Exception - throws an exception if an error occurs
    • netSetTimeSlice

      public void netSetTimeSlice(int timeslice) throws Exception
      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.
      Throws:
      Exception - throws an exception if an error occurs
    • getCurrentProperties

      public Properties getCurrentProperties() throws Exception
      Get current properties
      Returns:
      Properties object containing properties
      Throws:
      Exception - throws an exception if an error occurs
    • getUniqueThreadName

      static String getUniqueThreadName(String base)
      Get a thread name that is both meaningful and unique (primarily for debugging purposes).
      Parameters:
      base - the first part of the thread name (the meaningful part)
      Returns:
      a unique thread name that starts with base and is followed by an underscore and a unique sequence number
    • removeFromSessionTable

      protected void removeFromSessionTable(int sessionid)
      Remove session from session table
      Parameters:
      sessionid - id of session to be removed
    • processCommands

      protected void processCommands(DDMReader reader, DDMWriter writer, Session session) throws Throwable
      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 // DERBY-2109: transmit user credentials for System Privileges check 2 bytes - length of user name n bytes - user name 2 bytes - length of password n bytes - password 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
      writer - output writer for command
      session - session information
      Throws:
      Throwable - throws an exception if an error occurs
    • logConnectionsChange

      private void logConnectionsChange(boolean on) throws Exception
      Record a change to the connection logging mode
      Throws:
      Exception
    • getNextSession

      protected Session getNextSession(Session currentSession)
      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
      Returns:
      next session to work on, could be same as current session
    • getAppRequester

      protected AppRequester getAppRequester(AppRequester appRequester)
      Get the stored application requester or store if we haven't seen it yet
      Parameters:
      appRequester - Application Requester to look for
      Returns:
      stored application requester
    • getManagerLevel

      protected int getManagerLevel(int manager)
      Get the server manager level for a given manager
      Parameters:
      manager - codepoint for manager
      Returns:
      manager level
    • supportsCCSID

      protected boolean supportsCCSID(int ccsid)
      Check whether a CCSID code page is supported
      Parameters:
      ccsid - CCSID to check
      Returns:
      true if supported; false otherwise
    • consolePropertyMessage

      protected void consolePropertyMessage(String msgProp, boolean printTimeStamp) throws Exception
      Put property message on console
      Parameters:
      msgProp - message property key
      printTimeStamp - whether to prepend a timestamp to the message
      Throws:
      Exception - if an error occurs
    • consolePropertyMessage

      protected void consolePropertyMessage(String msgProp, String arg) throws Exception
      Put property message on console
      Parameters:
      msgProp - message property key
      arg - argument for message
      Throws:
      Exception - if an error occurs
    • consolePropertyMessage

      protected void consolePropertyMessage(String msgProp, String[] args) throws Exception
      Put property message on console
      Parameters:
      msgProp - message property key
      args - argument array for message
      Throws:
      Exception - if an error occurs
    • isCmd

      protected static boolean isCmd(String val)
      Is this the command protocol
      Parameters:
      val -
    • writeCommandReplyHeader

      private void writeCommandReplyHeader(DDMWriter writer) throws Exception
      Write Command reply
      Parameters:
      writer - writer to use
      Throws:
      Exception - if a problem occurs sending OK
    • sendOK

      private void sendOK(DDMWriter writer) throws Exception
      Send OK from server to client after processing a command
      Parameters:
      writer - writer to use for sending OK
      Throws:
      Exception - if a problem occurs sending OK
    • sendOKInt

      private void sendOKInt(DDMWriter writer, int val) throws Exception
      Send OK and int value
      Parameters:
      writer - writer to use for sending
      val - int val to send
      Throws:
      Exception - if a problem occurs
    • sendMessage

      private void sendMessage(DDMWriter writer, int messageType, String message) throws Exception
      Send Error or Warning from server to client after processing a command
      Parameters:
      writer - writer to use for sending message
      messageType - 1 for Warning, 2 for Error 3 for SQLError
      message - message
      Throws:
      Exception - if a problem occurs sending message
    • sendSQLMessage

      private void sendSQLMessage(DDMWriter writer, SQLException se, int type) throws Exception
      Send SQL Exception from server to client after processing a command
      Parameters:
      writer - writer to use for sending message
      se - Derby exception
      type - type of exception, SQLERROR or SQLWARNING
      Throws:
      Exception - if a problem occurs sending message
    • sendSysInfo

      private void sendSysInfo(DDMWriter writer) throws Exception
      Send SysInfo information from server to client
      Parameters:
      writer - writer to use for sending sysinfo
      Throws:
      Exception - if a problem occurs sending value
    • sendRuntimeInfo

      private void sendRuntimeInfo(DDMWriter writer) throws Exception
      Send RuntimeInfo information from server to client
      Parameters:
      writer - writer to use for sending sysinfo
      Throws:
      Exception - if a problem occurs sending value
    • sendPropInfo

      private void sendPropInfo(DDMWriter writer) throws Exception
      Send property information from server to client
      Parameters:
      writer - writer to use for sending sysinfo
      Throws:
      Exception - if a problem occurs sending value
    • getNetSysInfo

      private String getNetSysInfo()
      Get Net Server information
      Returns:
      system information for the Network Server
    • getRuntimeInfo

      private String getRuntimeInfo()
      See Also:
    • getCLSSysInfo

      private String getCLSSysInfo() throws IOException
      Get Derby information
      Returns:
      system information for Derby
      Throws:
      IOException - if a problem occurs encoding string
    • parseArgs

      public int parseArgs(String[] args) throws Exception
      Parse the command-line arguments. As a side-effect, fills in various instance fields. This method was carved out of executeWork() so that NetworkServerControl can figure out whether to install a security manager before the server actually comes up. This is part of the work for DERBY-2196.
      Parameters:
      args - array of arguments indicating command to be executed
      Returns:
      the command to be executed
      Throws:
      Exception
    • executeWork

      public void executeWork(int command) throws Exception
      Execute the command given on the command line
      Parameters:
      command - The command to execute. The command itself was determined by an earlier call to parseArgs().
      Throws:
      Exception - throws an exception if an error occurs see class comments for more information
    • runQueueAdd

      private void runQueueAdd(Session clientSession)
      Add session to the run queue
      Parameters:
      clientSession - session needing work
    • findCommand

      private int findCommand(String[] args) throws Exception
      Go through the arguments and find the command and save the dash arguments and arguments to the command. Only one command is allowed in the argument list.
      Parameters:
      args - arguments to search
      Returns:
      command
      Throws:
      Exception
    • processDashArg

      private int processDashArg(int pos, String[] args) throws Exception
      Get the dash argument. Optional arguments are formated as -x value.
      Parameters:
      pos - starting point
      args - arguments to search
      Returns:
      command
      Throws:
      Exception - thrown if an error occurs
    • isOn

      private boolean isOn(String arg) throws Exception
      Is string "on" or "off"
      Parameters:
      arg - string to check
      Returns:
      true if string is "on", false if string is "off"
      Throws:
      Exception - thrown if string is not one of "on" or "off"
    • closeSocket

      private void closeSocket() throws IOException
      Close the resources associated with the opened socket.
      Throws:
      IOException
    • setUpSocket

      private void setUpSocket() throws Exception
      Set up client socket to send a command to the network server
      Throws:
      Exception - thrown if exception encountered
    • removeSSLv3andSSLv2Hello

      private String[] removeSSLv3andSSLv2Hello(String[] enabledProtocols)
    • checkAddressIsLocal

      private void checkAddressIsLocal(InetAddress inetAddr) throws UnknownHostException, Exception
      Throws:
      UnknownHostException
      Exception
    • buildLocalAddressList

      private void buildLocalAddressList(InetAddress bindAddr)
      Build local address list to allow admin commands.
      Parameters:
      bindAddr - Address on which server was started Note: Some systems may not support localhost. In that case a console message will print for the localhost entries, but the server will continue to start.
    • unknownHostException

      private void unknownHostException(Throwable t)
    • writeCommandHeader

      private void writeCommandHeader(int command) throws Exception
      Write command header consisting of command header string and default protocol version and command. At this point, all the commands except shutdown with username/passwrod use default protocol version.
      Parameters:
      command - command to be written
      Throws:
      Exception - throws an exception if an error occurs
    • writeCommandHeader

      private void writeCommandHeader(int command, int protocol_version_for_command) throws Exception
      Write command header consisting of command header string and passed protocol version and command. At this point, all the commands except shutdown with username/passwrod use default protocol version.
      Parameters:
      command - command to be written
      protocol_version_for_command - protocol version to be used for the given command
      Throws:
      Exception - throws an exception if an error occurs
    • writeLDString

      private void writeLDString(String msg) throws Exception
      Write length delimited string string
      Parameters:
      msg - string to be written
      Throws:
      Exception - throws an exception if an error occurs
    • writeString

      protected void writeString(String msg) throws Exception
      Write string
      Parameters:
      msg - String to write
      Throws:
      Exception
    • writeShort

      private void writeShort(int value) throws Exception
      Write short
      Parameters:
      value - value to be written
      Throws:
      Exception - throws an exception if an error occurs
    • writeByte

      private void writeByte(int value) throws Exception
      Write byte
      Parameters:
      value - value to be written
      Throws:
      Exception - throws an exception if an error occurs
    • send

      private void send() throws Exception
      Send client message to server
      Throws:
      Exception - throws an exception if an error occurs
    • clientSocketError

      private void clientSocketError(IOException e) throws IOException
      Stream error writing to client socket
      Throws:
      IOException
    • readResult

      private void readResult() throws Exception
      Read result from sending client message to server
      Throws:
      Exception - throws an exception if an error occurs
    • ensureDataInBuffer

      private void ensureDataInBuffer(int minimumBytesNeeded, boolean failOnEOS) throws Exception
      Ensure the reply buffer is large enough to hold all the data; don't just rely on OS level defaults
      Parameters:
      minimumBytesNeeded - size of buffer required
      failOnEOS - tells whether or not an error should be raised if end-of-stream is reached before the requested amount of bytes could be read
      Throws:
      Exception - throws an exception if a problem reading the reply
    • fillReplyBuffer

      private void fillReplyBuffer() throws Exception
      Fill the reply buffer with the reply allocates a reply buffer if one doesn't exist
      Throws:
      Exception - throws an exception if a problem reading the reply
    • readCommandReplyHeader

      private void readCommandReplyHeader() throws Exception
      Read the command reply header from the server
      Throws:
      Exception - throws an exception if an error occurs
    • readShort

      private int readShort() throws Exception
      Read short from buffer
      Throws:
      Exception - throws an exception if an error occurs
    • readInt

      private int readInt() throws Exception
      Read int from buffer
      Throws:
      Exception - throws an exception if an error occurs
    • readStringReply

      private String readStringReply(String msgKey) throws Exception
      Read String reply
      Parameters:
      msgKey - error message key
      Returns:
      string value or null
      Throws:
      Exception - throws an error if problems reading reply
    • readLDString

      private String readLDString() throws Exception
      Read length delimited string from a buffer
      Returns:
      string value from buffer
      Throws:
      Exception - throws an error if problems reading reply
    • readBytesReply

      private byte[] readBytesReply(String msgKey) throws Exception
      Read Bytes reply
      Parameters:
      msgKey - error message key
      Returns:
      string value or null
      Throws:
      Exception - throws an error if problems reading reply
    • readLDBytes

      private byte[] readLDBytes() throws Exception
      Read length delimited bytes from a buffer
      Returns:
      byte array from buffer
      Throws:
      Exception - throws an error if problems reading reply
    • getPropertyInfo

      private void getPropertyInfo() throws Exception
      Initialize fields from system properties
      Throws:
      Exception
    • getSecMecValue

      private int getSecMecValue(String s)
      Retrieve the SECMEC integer value from the user friendly security mechanism name
      Parameters:
      s - security mechanism name
      Returns:
      integer value , return the SECMEC value for the security mechanism as defined by DRDA spec or INVALID_OR_NOTSET_SECURITYMECHANISM if 's' passed is invalid or not supported security mechanism
    • getStringValueForSecMec

      private String getStringValueForSecMec(int secmecVal)
      Retrieve the string name for the integer secmec value
      Parameters:
      secmecVal - secmec value
      Returns:
      String - return the string name corresponding to the secmec value if recognized else returns null
    • supportsEUSRIDPWD

      boolean supportsEUSRIDPWD()
      This method returns whether EUSRIDPWD security mechanism is supported or not. See class static block for more info.
      Returns:
      true if EUSRIDPWD is supported, false otherwise
    • getSSLModeValue

      private int getSSLModeValue(String s) throws Exception
      Get the SSL-mode from a string.
      Parameters:
      s - the SSL-mode string ("off"/"false", "on"/"true" or "authenticate"/"auth"
      Returns:
      SSL_OFF, SSL_BASIC or SSL_PEER_AUTHENTICATION. Will default to SSL_OFF if the input does not match one of the four listed above.
      Throws:
      Exception
    • getSSLModeString

      private String getSSLModeString(int i)
      Get the string value of the SSL-mode. This is the inverse of getSSLModeValue.
      Parameters:
      i - The SSL-mode value (SSL_OFF, SSL_BASIC or SSL_PEER_AUTHENTICATION)
      Returns:
      The string representation ("off","on" or "autneticate"). Will default to SSL_OFF for other values than those listed above.
    • getIntPropVal

      private int getIntPropVal(String propName, String propVal) throws Exception
      Get integer property values
      Parameters:
      propName - property name
      propVal - string property value
      Returns:
      integer value
      Throws:
      Exception - if not a valid integer
    • consolePropertyMessageWork

      private void consolePropertyMessageWork(String messageKey, String[] args, boolean printTimeStamp) throws Exception
      Handle console error message - display on console and if it is a user error, display usage - if user error or severe error, throw exception with message key and message
      Parameters:
      messageKey - message key
      args - arguments to message
      printTimeStamp - whether to prepend a timestamp to the message
      Throws:
      Exception - if an error occurs
    • throwSQLException

      private void throwSQLException(String msg) throws SQLException
      Throw a SQL Exception which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
      Parameters:
      msg - msg containing SQL Exception
      Throws:
      SQLException
    • throwSQLWarning

      private void throwSQLWarning(String msg) throws SQLWarning
      Throw a SQL Warning which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized message
      Parameters:
      msg - msg containing SQL Warning
      Throws:
      SQLWarning
    • throwUnexpectedException

      private void throwUnexpectedException(Exception e) throws Exception
      Print a trace for the (unexpected) exception received, then throw a generic exception indicating that 1) an unexpected exception was thrown, and 2) we've already printed the trace (so don't do it again).
      Parameters:
      e - An unexpected exception.
      Throws:
      Exception - with message UNEXPECTED_ERR.
    • localizeMessage

      public String localizeMessage(String msgProp, String[] args)
      Convenience routine so that NetworkServerControl can localize messages.
      Parameters:
      msgProp - message key
      args - arguments to message
    • localizeMessage

      private String localizeMessage(String msgProp, LocalizedResource localLangUtil, String[] args)
      Localize a message given a particular AppUI
      Parameters:
      msgProp - message key
      localLangUtil - LocalizedResource to use to localize message
      args - arguments to message
    • getMessageType

      private int getMessageType(String msg)
      Determine type of message
      Parameters:
      msg - message
      Returns:
      message type
    • isMsgProperty

      private boolean isMsgProperty(String msg)
      Determine whether string is a property key or not property keys start with DRDA_MSG_PREFIX
      Parameters:
      msg - message
      Returns:
      true if it is a property key; false otherwise
    • getLogConnections

      public boolean getLogConnections()
      Get the current value of logging connections
      Returns:
      true if logging connections is on; false otherwise
    • setLogConnections

      private void setLogConnections(boolean value)
      Set the current value of logging connections
      Parameters:
      value - true to turn logging connections on; false to turn it off
    • setSecurityMechanism

      private void setSecurityMechanism(String s) throws Exception
      Set the security mechanism for derby.drda.securityMechanism If this property is set, server will only allow connections from client with this security mechanism. This method will map the user friendly string representing the security mechanism to the corresponding drda secmec value
      Parameters:
      s - security mechanism string value
      Throws:
      Exception - if value to set is invalid
      See Also:
    • getSecurityMechanism

      protected int getSecurityMechanism()
      get the security mechanism (secmec value) that the server will accept connections from.
      Returns:
      the securitymechanism value. It is value that the derby.drda.securityMechanism was set to, if it is not set, then it is equal to INVALID_OR_NOTSET_SECURITYMECHANISM
      See Also:
    • setTrace

      private boolean setTrace(boolean on)
      Set the trace on/off for all sessions, or one session, depending on whether we got -s argument.
      Parameters:
      on - true to turn trace on; false to turn it off
      Returns:
      true if set false if an error occurred
    • getTimeSlice

      protected int getTimeSlice()
      Get the current value of the time slice
      Returns:
      time slice value
    • setTimeSlice

      private void setTimeSlice(int value) throws Exception
      Set the current value of time slice
      Parameters:
      value - time slice value
      Throws:
      Exception - if value is < 0
    • getKeepAlive

      protected boolean getKeepAlive()
      Get the current value of keepAlive to configure how long the server should keep the socket alive for a disconnected client
    • getMinThreads

      private int getMinThreads()
      Get the current value of minimum number of threads to create at start
      Returns:
      value of minimum number of threads
    • setMinThreads

      private void setMinThreads(int value)
      Set the current value of minimum number of threads to create at start
      Parameters:
      value - value of minimum number of threads
    • getMaxThreads

      private int getMaxThreads()
      Get the current value of maximum number of threads to create
      Returns:
      value of maximum number of threads
    • setMaxThreads

      private void setMaxThreads(int value) throws Exception
      Set the current value of maximum number of threads to create
      Parameters:
      value - value of maximum number of threads
      Throws:
      Exception - if value is less than 0
    • setSSLMode

      protected void setSSLMode(int mode)
    • getSSLMode

      protected int getSSLMode()
    • getTraceAll

      protected boolean getTraceAll()
      Get the current value of whether to trace all the sessions
      Returns:
      true if tracing is on for all sessions; false otherwise
    • setTraceAll

      private void setTraceAll(boolean value)
      Set the current value of whether to trace all the sessions
      Parameters:
      value - true if tracing is on for all sessions; false otherwise
    • getTraceDirectory

      protected String getTraceDirectory()
      Get the current value of trace directory
      Returns:
      trace directory
    • setTraceDirectory

      private void setTraceDirectory(String value)
      Set the current value of trace directory
      Parameters:
      value - trace directory
    • wrapSQLError

      private void wrapSQLError(String messageKey) throws Exception
      Wrap SQL Error - display to console and raise exception
      Parameters:
      messageKey - Derby SQL Exception message id
      Throws:
      Exception - raises exception for message
    • wrapSQLWarning

      private void wrapSQLWarning(String messageKey) throws Exception
      Wrap SQL Warning - display to console and raise exception
      Parameters:
      messageKey - Derby SQL Exception message id
      Throws:
      Exception - raises exception for message
    • getPropertyValues

      Properties getPropertyValues()

      Constructs an object containing network server related properties and their values. Some properties are only included if set. Some other properties are included with a default value if not set.

      This method is accessing the local JVM in which the network server instance is actually running (i.e. no networking).

      This method is package private to allow access from relevant MBean implementations in the same package.

      Returns:
      a collection of network server properties and their current values
    • addSession

      void addSession(Socket clientSocket) throws Exception
      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
      Throws:
      Exception
    • removeThread

      void removeThread(DRDAConnThread thread)
      Remove a thread from the thread list. Should be called when a DRDAConnThread has been closed.
      Parameters:
      thread - the closed thread
    • getShutdownSync

      protected Object getShutdownSync()
    • getShutdown

      protected boolean getShutdown()
    • buildRuntimeInfo

      public String buildRuntimeInfo(LocalizedResource locallangUtil)
    • getBytesRead

      long getBytesRead()
    • getBytesWritten

      long getBytesWritten()
    • getActiveSessions

      int getActiveSessions()
    • getRunQueueSize

      int getRunQueueSize()
    • getThreadListSize

      int getThreadListSize()
    • getConnectionNumber

      int getConnectionNumber()
    • setClientLocale

      public void setClientLocale(String locale)
    • getNetProductVersionHolder

      private ProductVersionHolder getNetProductVersionHolder() throws Exception
      Retrieve product version information We need to make sure that this method gets the stream and passes it to ProductVersionHolder, because it lives in the Network Server jar and won't be readily available to ProductVersionHolder when running under security manager.
      Throws:
      Exception
    • getSystemModule

      private static Object getSystemModule(String factoryInterface)
      Privileged module lookup. Must be private so that user code can't call this entry point.
    • findService

      private static Object findService(String factoryInterface, String serviceName)
      Privileged service lookup. Must be private so that user code can't call this entry point.