Package org.apache.derby.impl.drda
Class NetworkServerControlImpl
- java.lang.Object
-
- org.apache.derby.impl.drda.NetworkServerControlImpl
-
public final class NetworkServerControlImpl extends java.lang.ObjectNetworkServerControlImpl does all the work for NetworkServerControl- See Also:
for description
-
-
Field Summary
Fields Modifier and Type Field Description private intallowOnlySecurityMechanismprivate java.util.Hashtable<java.lang.String,AppRequester>appRequesterTableprivate static java.lang.Stringatt_extnamprivate static java.lang.Stringatt_srvclsnmprotected static java.lang.StringATT_SRVNAMprivate static java.lang.Stringatt_srvrlslvprivate java.lang.StringbootPasswordArgprivate static java.lang.StringbuildNumberprivate java.io.ByteArrayOutputStreambyteArrayOsprotected static intCCSIDMBCprotected static intCCSIDSBCprivate booleancleanupOnStartprivate java.io.InputStreamclientIsprivate java.lang.StringclientLocaleprivate java.io.OutputStreamclientOsprivate java.net.SocketclientSocketprivate static java.lang.StringCLOUDSCAPE_DRIVERprivate static java.sql.DrivercloudscapeDriverprivate java.io.PrintWritercloudscapeLogWriterprivate static int[]COMMAND_ARGSprivate static java.lang.StringCOMMAND_HEADERstatic intCOMMAND_LOGCONNECTIONSstatic intCOMMAND_MAXTHREADSstatic intCOMMAND_PROPERTIESstatic intCOMMAND_RUNTIME_INFOstatic intCOMMAND_SHUTDOWNstatic intCOMMAND_STARTstatic intCOMMAND_SYSINFOstatic intCOMMAND_TESTCONNECTIONstatic intCOMMAND_TIMESLICEstatic intCOMMAND_TRACEstatic intCOMMAND_TRACEDIRECTORYstatic intCOMMAND_UNKNOWNprivate java.util.Vector<java.lang.String>commandArgsprivate java.io.DataOutputStreamcommandOsprivate static java.lang.String[]COMMANDSprivate intconnNumprivate SessioncurrentSessionstatic intDASHARG_BOOTPASSWORDstatic intDASHARG_DATABASEstatic intDASHARG_ENCALGstatic intDASHARG_ENCPRVstatic intDASHARG_HOSTstatic intDASHARG_LOADSYSIBMstatic intDASHARG_PASSWORDstatic intDASHARG_PORTstatic intDASHARG_SESSIONprivate static intDASHARG_SSLstatic intDASHARG_UNSECUREstatic intDASHARG_USERprivate static java.lang.String[]DASHARGSprivate java.lang.StringdatabaseArgprivate booleandebugOutputprotected static intDEFAULT_CCSID(package private) static java.nio.charset.CharsetDEFAULT_CHARSETprotected static java.lang.StringDEFAULT_ENCODINGprivate static java.lang.StringDEFAULT_HOSTprivate static java.lang.StringDEFAULT_LOCALEprivate static java.lang.StringDEFAULT_LOCALE_COUNTRYprivate static intDEFAULT_MAXTHREADSprivate static intDEFAULT_PROTOCOL_VERSIONprivate static intDEFAULT_TIMESLICEprivate static java.lang.StringDRDA_MSG_PREFIXprivate static java.lang.StringDRDA_PROP_DEBUGprivate static java.lang.StringDRDA_PROP_MESSAGESprivate java.lang.StringencAlgArgprivate java.lang.StringencPrvArgprivate static intERRORprivate static intERRTYPE_INFOprivate static intERRTYPE_SEVEREprivate static intERRTYPE_UNKNOWNprivate static intERRTYPE_USERprivate intfreeThreadsprivate java.net.InetAddresshostAddressprivate java.lang.StringhostArgprotected static intINVALID_OR_NOTSET_SECURITYMECHANISMprivate booleankeepAliveprivate LocalizedResourcelangUtil(package private) java.util.ArrayList<java.net.InetAddress>localAddressesList of local addresses for checking admin commands.private booleanlogConnectionsprivate java.lang.ObjectlogConnectionsSyncprivate java.io.PrintWriterlogWriterprivate static intMAX_ALLOWED_PROTOCOL_VERSIONprivate intmaxPoolSizeprivate static intMAXREPLYMaximum reply size.private intmaxThreadsprivate memCheckmcprivate static int[]MGR_LEVELSprivate static intMIN_MAXTHREADSprivate static intMIN_TIMESLICEprivate intminPoolSizeprivate intminThreadsprivate static java.util.concurrent.atomic.AtomicIntegernextThreadNumberHolds the sequence number to be assigned to the next thread that callsgetUniqueThreadName(String).private static intNO_USAGE_MSGSprivate static intOKprivate java.lang.StringpasswordArgprivate java.lang.ObjectpoolSyncprivate intportNumberprivate static java.lang.StringprdIdprivate static byte[]prdIdBytes_private java.lang.StringpropertyFileNameprivate static java.lang.StringREPLY_HEADERprivate static intREPLY_HEADER_LENGTHprivate byte[]replyBufferprivate intreplyBufferCountprivate intreplyBufferPosprivate booleanrestartFlagprivate java.util.Vector<Session>runQueueprivate NetworkServerControlImplserverInstanceprivate java.net.ServerSocketserverSocketprivate java.lang.ObjectserverStartSyncprivate intsessionArgprivate java.util.Hashtable<java.lang.Integer,Session>sessionTableprivate booleanshutdownprivate static intSHUTDOWN_CHECK_ATTEMPTSprivate static intSHUTDOWN_CHECK_INTERVALprivate static intSHUTDOWN_WITH_CREDENTIAL_PROTOCOL_VERSIONprivate booleanshutdownDatabasesOnShutdownprivate java.lang.ObjectshutdownSyncprotected static byteSPACE_CHARprivate static intSQLERRORprivate static intSQLWARNINGprivate static intSSL_BASICprivate static intSSL_OFFprivate static intSSL_PEER_AUTHENTICATIONprivate intsslModeprivate static booleanSUPPORTS_EUSRIDPWDCan EUSRIDPWD security mechanism be used with the current JVMprivate NetworkServerControlImplthisControlprivate java.util.Vector<DRDAConnThread>threadListprivate java.lang.ObjectthreadsSyncprivate inttimeSliceprivate java.lang.ObjecttimeSliceSyncprivate booleantraceAllprivate java.lang.ObjecttraceAllSyncprivate java.lang.StringtraceDirectoryprivate java.lang.ObjecttraceDirectorySyncstatic java.lang.StringUNEXPECTED_ERRprivate booleanunsecureArgprivate static intUSE_DEFAULTprivate java.lang.StringuserArgprivate static java.lang.StringversionStringprivate static intWARNING
-
Constructor Summary
Constructors Constructor Description NetworkServerControlImpl()NetworkServerControlImpl(java.lang.String userName, java.lang.String password)Internal constructor for NetworkServerControl API.NetworkServerControlImpl(java.net.InetAddress address, int portNumber)Internal constructor for NetworkServerControl API.NetworkServerControlImpl(java.net.InetAddress address, int portNumber, java.lang.String userName, java.lang.String password)Internal constructor for NetworkServerControl API.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddSession(java.net.Socket clientSocket)Add a session - for use byClientThread.static java.lang.Stringatt_extnam()Return the att_extnam server attributestatic java.lang.Stringatt_srvclsnm()Return the att_srvclsnm server attributestatic java.lang.Stringatt_srvrlslv()Return the att_srvrlslv server attributevoidblockingStart(java.io.PrintWriter consoleWriter)Start a network serverprivate voidbuildLocalAddressList(java.net.InetAddress bindAddr)Build local address list to allow admin commands.java.lang.StringbuildRuntimeInfo(LocalizedResource locallangUtil)private voidcheckAddressIsLocal(java.net.InetAddress inetAddr)voidcheckShutdownPrivileges()private voidclientSocketError(java.io.IOException e)Stream error writing to client socketprivate voidcloseSocket()Close the resources associated with the opened socket.voidconsoleError(java.lang.String msg)Write an error message to console output stream and throw an exception for this errorvoidconsoleExceptionPrint(java.lang.Exception e)Write an exception to console output stream, but only if debugOutput is true.voidconsoleExceptionPrintTrace(java.lang.Throwable e)Write an exception (with trace) to console output stream.voidconsoleMessage(java.lang.String msg, boolean printTimeStamp)Write a message to console output streamprivate voidconsolePrintAndIgnore(java.lang.String msgProp, java.lang.Exception e, boolean printTimeStamp)protected voidconsolePropertyMessage(java.lang.String msgProp, boolean printTimeStamp)Put property message on consoleprotected voidconsolePropertyMessage(java.lang.String msgProp, java.lang.String arg)Put property message on consoleprotected voidconsolePropertyMessage(java.lang.String msgProp, java.lang.String[] args)Put property message on consoleprivate voidconsolePropertyMessageWork(java.lang.String messageKey, java.lang.String[] args, boolean printTimeStamp)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 messageprivate voidconsoleTraceMessage(int connNum, boolean on)Print trace change message to consoleprivate java.net.ServerSocketcreateServerSocket()Create the right kind of server socketbooleandebugOutput()Return the debug statevoiddirectShutdown()(package private) voiddirectShutdownInternal()private voidensureDataInBuffer(int minimumBytesNeeded, boolean failOnEOS)Ensure the reply buffer is large enough to hold all the data; don't just rely on OS level defaultsvoidexecuteWork(int command)Execute the command given on the command lineprivate voidfillReplyBuffer()Fill the reply buffer with the reply allocates a reply buffer if one doesn't existprivate intfindCommand(java.lang.String[] args)Go through the arguments and find the command and save the dash arguments and arguments to the command.private static java.lang.ObjectfindService(java.lang.String factoryInterface, java.lang.String serviceName)Privileged service lookup.(package private) intgetActiveSessions()protected AppRequestergetAppRequester(AppRequester appRequester)Get the stored application requester or store if we haven't seen it yet(package private) longgetBytesRead()(package private) longgetBytesWritten()private java.lang.StringgetCLSSysInfo()Get Derby information(package private) intgetConnectionNumber()java.util.PropertiesgetCurrentProperties()Get current propertiesprotected static java.sql.DrivergetDriver()private java.lang.StringgetEnabledProtocols(javax.net.ssl.SSLServerSocket sslServerSocket)java.lang.StringgetHost()Get the host where we listen for connections.private intgetIntPropVal(java.lang.String propName, java.lang.String propVal)Get integer property valuesprotected booleangetKeepAlive()Get the current value of keepAlive to configure how long the server should keep the socket alive for a disconnected clientbooleangetLogConnections()Get the current value of logging connectionsprotected intgetManagerLevel(int manager)Get the server manager level for a given managerprivate intgetMaxThreads()Get the current value of maximum number of threads to createprivate intgetMessageType(java.lang.String msg)Determine type of messageprivate intgetMinThreads()Get the current value of minimum number of threads to create at startprivate ProductVersionHoldergetNetProductVersionHolder()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.private java.lang.StringgetNetSysInfo()Get Net Server informationprotected SessiongetNextSession(Session currentSession)Get the next session for the thread to work on Called from DRDAConnThread after session completes or timeslice exceeded.intgetPort()Get the port where we listen for connections.private voidgetPropertyInfo()Initialize fields from system properties(package private) java.util.PropertiesgetPropertyValues()Constructs an object containing network server related properties and their values.(package private) intgetRunQueueSize()private java.lang.StringgetRuntimeInfo()private intgetSecMecValue(java.lang.String s)Retrieve the SECMEC integer value from the user friendly security mechanism nameprotected intgetSecurityMechanism()get the security mechanism (secmec value) that the server will accept connections from.protected booleangetShutdown()protected java.lang.ObjectgetShutdownSync()protected intgetSSLMode()private java.lang.StringgetSSLModeString(int i)Get the string value of the SSL-mode.private intgetSSLModeValue(java.lang.String s)Get the SSL-mode from a string.private java.lang.StringgetStringValueForSecMec(int secmecVal)Retrieve the string name for the integer secmec valueprivate static java.lang.ObjectgetSystemModule(java.lang.String factoryInterface)Privileged module lookup.(package private) intgetThreadListSize()protected intgetTimeSlice()Get the current value of the time sliceprotected booleangetTraceAll()Get the current value of whether to trace all the sessionsprotected java.lang.StringgetTraceDirectory()Get the current value of trace directory(package private) static java.lang.StringgetUniqueThreadName(java.lang.String base)Get a thread name that is both meaningful and unique (primarily for debugging purposes).private voidinit()protected static booleanisCmd(java.lang.String val)Is this the command protocolprivate booleanisMsgProperty(java.lang.String msg)Determine whether string is a property key or not property keys start with DRDA_MSG_PREFIXprivate booleanisOn(java.lang.String arg)Is string "on" or "off"booleanisServerStarted()java.lang.StringlocalizeMessage(java.lang.String msgProp, java.lang.String[] args)Convenience routine so that NetworkServerControl can localize messages.private java.lang.StringlocalizeMessage(java.lang.String msgProp, LocalizedResource localLangUtil, java.lang.String[] args)Localize a message given a particular AppUIvoidlogConnections(boolean on)Turn logging connections on or off.private voidlogConnectionsChange(boolean on)Record a change to the connection logging modejava.io.PrintWriterlogWriter()Get the log writer we're usingprivate java.io.PrintWritermakePrintWriter(java.io.OutputStream out)voidnetSetMaxThreads(int max)Connect to network server and set connection maxthread parametervoidnetSetTimeSlice(int timeslice)Set network server connection timeslice parameterintparseArgs(java.lang.String[] args)Parse the command-line arguments.voidping()Ping opening an new socket and close it.private voidpingWithNoOpen()Ping the server using the client socket that is already open.static java.lang.StringprdId()Return the product idstatic byte[]prdIdBytes()Return the bytes of the product idprotected voidprocessCommands(DDMReader reader, DDMWriter writer, Session session)processCommands reads and processes NetworkServerControlImpl commands sent to the network server over the socket.private intprocessDashArg(int pos, java.lang.String[] args)Get the dash argument.private byte[]readBytesReply(java.lang.String msgKey)Read Bytes replyprivate voidreadCommandReplyHeader()Read the command reply header from the serverprivate intreadInt()Read int from bufferprivate byte[]readLDBytes()Read length delimited bytes from a bufferprivate java.lang.StringreadLDString()Read length delimited string from a bufferprivate voidreadResult()Read result from sending client message to serverprivate intreadShort()Read short from bufferprivate java.lang.StringreadStringReply(java.lang.String msgKey)Read String replyprotected voidremoveFromSessionTable(int sessionid)Remove session from session tableprivate java.lang.String[]removeSSLv3andSSLv2Hello(java.lang.String[] enabledProtocols)(package private) voidremoveThread(DRDAConnThread thread)Remove a thread from the thread list.booleanrunningUnsecure()Return true if the customer forcibly overrode our decision to install a default SecurityManager.private voidrunQueueAdd(Session clientSession)Add session to the run queuejava.lang.StringruntimeInfo()private voidsend()Send client message to serverprivate voidsendMessage(DDMWriter writer, int messageType, java.lang.String message)Send Error or Warning from server to client after processing a commandprivate voidsendOK(DDMWriter writer)Send OK from server to client after processing a commandprivate voidsendOKInt(DDMWriter writer, int val)Send OK and int valueprivate voidsendPropInfo(DDMWriter writer)Send property information from server to clientprivate voidsendRuntimeInfo(DDMWriter writer)Send RuntimeInfo information from server to clientvoidsendSetTraceDirectory(java.lang.String traceDirectory)private voidsendSQLMessage(DDMWriter writer, java.sql.SQLException se, int type)Send SQL Exception from server to client after processing a commandprivate voidsendSysInfo(DDMWriter writer)Send SysInfo information from server to clientvoidsetClientLocale(java.lang.String locale)private voidsetLogConnections(boolean value)Set the current value of logging connectionsvoidsetLogWriter(java.io.PrintWriter outWriter)Set the output stream for console messages If this is set to null, no messages will be written to the consoleprivate voidsetMaxThreads(int value)Set the current value of maximum number of threads to createprivate voidsetMinThreads(int value)Set the current value of minimum number of threads to create at startprivate voidsetSecurityMechanism(java.lang.String s)Set the security mechanism for derby.drda.securityMechanism If this property is set, server will only allow connections from client with this security mechanism.protected voidsetSSLMode(int mode)private voidsetTimeSlice(int value)Set the current value of time sliceprivate booleansetTrace(boolean on)Set the trace on/off for all sessions, or one session, depending on whether we got -s argument.private voidsetTraceAll(boolean value)Set the current value of whether to trace all the sessionsprivate voidsetTraceDirectory(java.lang.String value)Set the current value of trace directoryprivate voidsetUpSocket()Set up client socket to send a command to the network servervoidshutdown()Shutdown a network servervoidstart(java.io.PrintWriter consoleWriter)Start a network server.protected voidstartNetworkServer()Load Derby and save driver for future use.protected booleansupportsCCSID(int ccsid)Check whether a CCSID code page is supported(package private) booleansupportsEUSRIDPWD()This method returns whether EUSRIDPWD security mechanism is supported or not.java.lang.Stringsysinfo()private voidthrowSQLException(java.lang.String msg)Throw a SQL Exception which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized messageprivate voidthrowSQLWarning(java.lang.String msg)Throw a SQL Warning which was sent over by a server Format of the msg is SQLSTATE:localized message\nSQLSTATE:next localized messageprivate voidthrowUnexpectedException(java.lang.Exception e)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).voidtrace(boolean on)Turn tracing on or off for all sessionsvoidtrace(int connNum, boolean on)Turn tracing on or off for one session or all sessionsprivate voidunknownHostException(java.lang.Throwable t)voidusage()Display usage informationprivate voidwrapSQLError(java.lang.String messageKey)Wrap SQL Error - display to console and raise exceptionprivate voidwrapSQLWarning(java.lang.String messageKey)Wrap SQL Warning - display to console and raise exceptionprivate voidwriteByte(int value)Write byteprivate voidwriteCommandHeader(int command)Write command header consisting of command header string and default protocol version and command.private voidwriteCommandHeader(int command, int protocol_version_for_command)Write command header consisting of command header string and passed protocol version and command.private voidwriteCommandReplyHeader(DDMWriter writer)Write Command replyprivate voidwriteLDString(java.lang.String msg)Write length delimited string stringprivate voidwriteShort(int value)Write shortprotected voidwriteString(java.lang.String msg)Write string
-
-
-
Field Detail
-
NO_USAGE_MSGS
private static final int NO_USAGE_MSGS
- See Also:
- Constant Field Values
-
COMMANDS
private static final java.lang.String[] COMMANDS
-
COMMAND_ARGS
private static final int[] COMMAND_ARGS
-
COMMAND_START
public static final int COMMAND_START
- See Also:
- Constant Field Values
-
COMMAND_SHUTDOWN
public static final int COMMAND_SHUTDOWN
- See Also:
- Constant Field Values
-
COMMAND_TRACE
public static final int COMMAND_TRACE
- See Also:
- Constant Field Values
-
COMMAND_TRACEDIRECTORY
public static final int COMMAND_TRACEDIRECTORY
- See Also:
- Constant Field Values
-
COMMAND_TESTCONNECTION
public static final int COMMAND_TESTCONNECTION
- See Also:
- Constant Field Values
-
COMMAND_LOGCONNECTIONS
public static final int COMMAND_LOGCONNECTIONS
- See Also:
- Constant Field Values
-
COMMAND_SYSINFO
public static final int COMMAND_SYSINFO
- See Also:
- Constant Field Values
-
COMMAND_RUNTIME_INFO
public static final int COMMAND_RUNTIME_INFO
- See Also:
- Constant Field Values
-
COMMAND_MAXTHREADS
public static final int COMMAND_MAXTHREADS
- See Also:
- Constant Field Values
-
COMMAND_TIMESLICE
public static final int COMMAND_TIMESLICE
- See Also:
- Constant Field Values
-
COMMAND_PROPERTIES
public static final int COMMAND_PROPERTIES
- See Also:
- Constant Field Values
-
COMMAND_UNKNOWN
public static final int COMMAND_UNKNOWN
- See Also:
- Constant Field Values
-
DASHARGS
private static final java.lang.String[] DASHARGS
-
DASHARG_PORT
public static final int DASHARG_PORT
- See Also:
- Constant Field Values
-
DASHARG_DATABASE
public static final int DASHARG_DATABASE
- See Also:
- Constant Field Values
-
DASHARG_USER
public static final int DASHARG_USER
- See Also:
- Constant Field Values
-
DASHARG_PASSWORD
public static final int DASHARG_PASSWORD
- See Also:
- Constant Field Values
-
DASHARG_LOADSYSIBM
public static final int DASHARG_LOADSYSIBM
- See Also:
- Constant Field Values
-
DASHARG_ENCALG
public static final int DASHARG_ENCALG
- See Also:
- Constant Field Values
-
DASHARG_ENCPRV
public static final int DASHARG_ENCPRV
- See Also:
- Constant Field Values
-
DASHARG_BOOTPASSWORD
public static final int DASHARG_BOOTPASSWORD
- See Also:
- Constant Field Values
-
DASHARG_HOST
public static final int DASHARG_HOST
- See Also:
- Constant Field Values
-
DASHARG_SESSION
public static final int DASHARG_SESSION
- See Also:
- Constant Field Values
-
DASHARG_UNSECURE
public static final int DASHARG_UNSECURE
- See Also:
- Constant Field Values
-
DASHARG_SSL
private static final int DASHARG_SSL
- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL_VERSION
private static final int DEFAULT_PROTOCOL_VERSION
- See Also:
- Constant Field Values
-
SHUTDOWN_WITH_CREDENTIAL_PROTOCOL_VERSION
private static final int SHUTDOWN_WITH_CREDENTIAL_PROTOCOL_VERSION
- See Also:
- Constant Field Values
-
MAX_ALLOWED_PROTOCOL_VERSION
private static final int MAX_ALLOWED_PROTOCOL_VERSION
- See Also:
- Constant Field Values
-
COMMAND_HEADER
private static final java.lang.String COMMAND_HEADER
- See Also:
- Constant Field Values
-
REPLY_HEADER
private static final java.lang.String REPLY_HEADER
- See Also:
- Constant Field Values
-
REPLY_HEADER_LENGTH
private static final int REPLY_HEADER_LENGTH
-
OK
private static final int OK
- See Also:
- Constant Field Values
-
WARNING
private static final int WARNING
- See Also:
- Constant Field Values
-
ERROR
private static final int ERROR
- See Also:
- Constant Field Values
-
SQLERROR
private static final int SQLERROR
- See Also:
- Constant Field Values
-
SQLWARNING
private static final int SQLWARNING
- See Also:
- Constant Field Values
-
DRDA_PROP_MESSAGES
private static final java.lang.String DRDA_PROP_MESSAGES
- See Also:
- Constant Field Values
-
DRDA_PROP_DEBUG
private static final java.lang.String DRDA_PROP_DEBUG
- See Also:
- Constant Field Values
-
CLOUDSCAPE_DRIVER
private static final java.lang.String CLOUDSCAPE_DRIVER
- See Also:
- Constant Field Values
-
UNEXPECTED_ERR
public static final java.lang.String UNEXPECTED_ERR
- See Also:
- Constant Field Values
-
MIN_MAXTHREADS
private static final int MIN_MAXTHREADS
- See Also:
- Constant Field Values
-
MIN_TIMESLICE
private static final int MIN_TIMESLICE
- See Also:
- Constant Field Values
-
USE_DEFAULT
private static final int USE_DEFAULT
- See Also:
- Constant Field Values
-
DEFAULT_MAXTHREADS
private static final int DEFAULT_MAXTHREADS
- See Also:
- Constant Field Values
-
DEFAULT_TIMESLICE
private static final int DEFAULT_TIMESLICE
- See Also:
- Constant Field Values
-
DEFAULT_HOST
private static final java.lang.String DEFAULT_HOST
- See Also:
- Constant Field Values
-
DRDA_MSG_PREFIX
private static final java.lang.String DRDA_MSG_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_LOCALE
private static final java.lang.String DEFAULT_LOCALE
- See Also:
- Constant Field Values
-
DEFAULT_LOCALE_COUNTRY
private static final java.lang.String DEFAULT_LOCALE_COUNTRY
- See Also:
- Constant Field Values
-
SHUTDOWN_CHECK_ATTEMPTS
private static final int SHUTDOWN_CHECK_ATTEMPTS
- See Also:
- Constant Field Values
-
SHUTDOWN_CHECK_INTERVAL
private static final int SHUTDOWN_CHECK_INTERVAL
- See Also:
- Constant Field Values
-
MAXREPLY
private static final int MAXREPLY
Maximum reply size. The reply buffer must be large enough to hold the largest reply thatreadBytesReply(String)andreadStringReply(String)can receive. That is, a reply header (4 bytes), a status byte (1 byte), a length field (2 bytes) and the longest value (in bytes) that could be written byDDMWriter.writeLDBytes(byte[])orDDMWriter.writeLDString(String).
-
att_srvclsnm
private static java.lang.String att_srvclsnm
-
ATT_SRVNAM
protected static final java.lang.String ATT_SRVNAM
- See Also:
- Constant Field Values
-
att_extnam
private static java.lang.String att_extnam
-
att_srvrlslv
private static java.lang.String att_srvrlslv
-
prdId
private static java.lang.String prdId
-
prdIdBytes_
private static byte[] prdIdBytes_
-
buildNumber
private static java.lang.String buildNumber
-
versionString
private static java.lang.String versionString
-
CCSIDSBC
protected static final int CCSIDSBC
- See Also:
- Constant Field Values
-
CCSIDMBC
protected static final int CCSIDMBC
- See Also:
- Constant Field Values
-
DEFAULT_ENCODING
protected static final java.lang.String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
DEFAULT_CHARSET
static final java.nio.charset.Charset DEFAULT_CHARSET
-
DEFAULT_CCSID
protected static final int DEFAULT_CCSID
- See Also:
- Constant Field Values
-
SPACE_CHAR
protected static final byte SPACE_CHAR
- See Also:
- Constant Field Values
-
MGR_LEVELS
private static final int[] MGR_LEVELS
-
logWriter
private java.io.PrintWriter logWriter
-
cloudscapeLogWriter
private java.io.PrintWriter cloudscapeLogWriter
-
cloudscapeDriver
private static java.sql.Driver cloudscapeDriver
-
ERRTYPE_SEVERE
private static final int ERRTYPE_SEVERE
- See Also:
- Constant Field Values
-
ERRTYPE_USER
private static final int ERRTYPE_USER
- See Also:
- Constant Field Values
-
ERRTYPE_INFO
private static final int ERRTYPE_INFO
- See Also:
- Constant Field Values
-
ERRTYPE_UNKNOWN
private static final int ERRTYPE_UNKNOWN
- See Also:
- Constant Field Values
-
commandArgs
private java.util.Vector<java.lang.String> commandArgs
-
databaseArg
private java.lang.String databaseArg
-
userArg
private java.lang.String userArg
-
passwordArg
private java.lang.String passwordArg
-
bootPasswordArg
private java.lang.String bootPasswordArg
-
encAlgArg
private java.lang.String encAlgArg
-
encPrvArg
private java.lang.String encPrvArg
-
hostArg
private java.lang.String hostArg
-
hostAddress
private java.net.InetAddress hostAddress
-
sessionArg
private int sessionArg
-
unsecureArg
private boolean unsecureArg
-
mc
private memCheck mc
-
replyBuffer
private byte[] replyBuffer
-
replyBufferCount
private int replyBufferCount
-
replyBufferPos
private int replyBufferPos
-
portNumber
private int portNumber
-
traceDirectory
private java.lang.String traceDirectory
-
traceDirectorySync
private java.lang.Object traceDirectorySync
-
traceAll
private boolean traceAll
-
traceAllSync
private java.lang.Object traceAllSync
-
serverStartSync
private java.lang.Object serverStartSync
-
logConnections
private boolean logConnections
-
logConnectionsSync
private java.lang.Object logConnectionsSync
-
minThreads
private int minThreads
-
maxThreads
private int maxThreads
-
threadsSync
private java.lang.Object threadsSync
-
timeSlice
private int timeSlice
-
timeSliceSync
private java.lang.Object timeSliceSync
-
keepAlive
private boolean keepAlive
-
minPoolSize
private int minPoolSize
-
maxPoolSize
private int maxPoolSize
-
poolSync
private java.lang.Object poolSync
-
debugOutput
private boolean debugOutput
-
cleanupOnStart
private boolean cleanupOnStart
-
restartFlag
private boolean restartFlag
-
INVALID_OR_NOTSET_SECURITYMECHANISM
protected static final int INVALID_OR_NOTSET_SECURITYMECHANISM
- See Also:
- Constant Field Values
-
allowOnlySecurityMechanism
private int allowOnlySecurityMechanism
-
clientSocket
private java.net.Socket clientSocket
-
clientIs
private java.io.InputStream clientIs
-
clientOs
private java.io.OutputStream clientOs
-
byteArrayOs
private java.io.ByteArrayOutputStream byteArrayOs
-
commandOs
private java.io.DataOutputStream commandOs
-
shutdownSync
private java.lang.Object shutdownSync
-
shutdown
private boolean shutdown
-
connNum
private int connNum
-
serverSocket
private java.net.ServerSocket serverSocket
-
serverInstance
private NetworkServerControlImpl serverInstance
-
langUtil
private LocalizedResource langUtil
-
clientLocale
private java.lang.String clientLocale
-
localAddresses
java.util.ArrayList<java.net.InetAddress> localAddresses
List of local addresses for checking admin commands.
-
sessionTable
private java.util.Hashtable<java.lang.Integer,Session> sessionTable
-
currentSession
private Session currentSession
-
threadList
private java.util.Vector<DRDAConnThread> threadList
-
runQueue
private java.util.Vector<Session> runQueue
-
freeThreads
private int freeThreads
-
appRequesterTable
private java.util.Hashtable<java.lang.String,AppRequester> appRequesterTable
-
propertyFileName
private java.lang.String propertyFileName
-
thisControl
private NetworkServerControlImpl thisControl
-
shutdownDatabasesOnShutdown
private boolean shutdownDatabasesOnShutdown
-
SSL_OFF
private static final int SSL_OFF
- See Also:
- Constant Field Values
-
SSL_BASIC
private static final int SSL_BASIC
- See Also:
- Constant Field Values
-
SSL_PEER_AUTHENTICATION
private static final int SSL_PEER_AUTHENTICATION
- See Also:
- Constant Field Values
-
sslMode
private int sslMode
-
SUPPORTS_EUSRIDPWD
private static boolean SUPPORTS_EUSRIDPWD
Can EUSRIDPWD security mechanism be used with the current JVM
-
nextThreadNumber
private static final java.util.concurrent.atomic.AtomicInteger nextThreadNumber
Holds the sequence number to be assigned to the next thread that callsgetUniqueThreadName(String).
-
-
Constructor Detail
-
NetworkServerControlImpl
public NetworkServerControlImpl() throws java.lang.Exception- Throws:
java.lang.Exception
-
NetworkServerControlImpl
public NetworkServerControlImpl(java.net.InetAddress address, int portNumber) throws java.lang.ExceptionInternal constructor for NetworkServerControl API.- Parameters:
address- InetAddress to listen on, throws NPE if nullportNumber- portNumber to listen on, -1 use property or default- Throws:
java.lang.Exception- on error- See Also:
NetworkServerControl
-
NetworkServerControlImpl
public NetworkServerControlImpl(java.lang.String userName, java.lang.String password) throws java.lang.ExceptionInternal constructor for NetworkServerControl API.- Parameters:
userName- the user name for actions requiring authorizationpassword- the password for actions requiring authorization- Throws:
java.lang.Exception- on error- See Also:
NetworkServerControl
-
NetworkServerControlImpl
public NetworkServerControlImpl(java.net.InetAddress address, int portNumber, java.lang.String userName, java.lang.String password) throws java.lang.ExceptionInternal constructor for NetworkServerControl API.- Parameters:
address- InetAddress to listen on, throws NPE if nullportNumber- portNumber to listen on, -1 use property or defaultuserName- the user name for actions requiring authorizationpassword- the password for actions requiring authorization- Throws:
java.lang.Exception- on error- See Also:
NetworkServerControl
-
-
Method Detail
-
logWriter
public java.io.PrintWriter logWriter()
Get the log writer we're using
-
getHost
public java.lang.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 java.lang.Exception- Throws:
java.lang.Exception
-
makePrintWriter
private java.io.PrintWriter makePrintWriter(java.io.OutputStream out)
-
getDriver
protected static java.sql.Driver getDriver()
-
setLogWriter
public void setLogWriter(java.io.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(java.lang.String msg) throws java.lang.ExceptionWrite an error message to console output stream and throw an exception for this error- Parameters:
msg- error message- Throws:
java.lang.Exception
-
debugOutput
public boolean debugOutput()
Return the debug state
-
att_extnam
public static java.lang.String att_extnam()
Return the att_extnam server attribute
-
att_srvclsnm
public static java.lang.String att_srvclsnm()
Return the att_srvclsnm server attribute
-
att_srvrlslv
public static java.lang.String att_srvrlslv()
Return the att_srvrlslv server attribute
-
prdId
public static java.lang.String prdId()
Return the product id
-
prdIdBytes
public static byte[] prdIdBytes()
Return the bytes of the product id
-
consoleExceptionPrint
public void consoleExceptionPrint(java.lang.Exception e)
Write an exception to console output stream, but only if debugOutput is true.- Parameters:
e- exception
-
consoleExceptionPrintTrace
public void consoleExceptionPrintTrace(java.lang.Throwable e)
Write an exception (with trace) to console output stream.- Parameters:
e- exception
-
consoleMessage
public void consoleMessage(java.lang.String msg, boolean printTimeStamp)Write a message to console output stream- Parameters:
msg- messageprintTimeStamp- Whether to prepend a timestamp to the message or not
-
start
public void start(java.io.PrintWriter consoleWriter) throws java.lang.ExceptionStart 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:
java.lang.Exception- throws an exception if an error occurs
-
createServerSocket
private java.net.ServerSocket createServerSocket() throws java.io.IOExceptionCreate the right kind of server socket- Throws:
java.io.IOException
-
getEnabledProtocols
private java.lang.String getEnabledProtocols(javax.net.ssl.SSLServerSocket sslServerSocket)
-
blockingStart
public void blockingStart(java.io.PrintWriter consoleWriter) throws java.lang.ExceptionStart a network server- Parameters:
consoleWriter- PrintWriter to which server console will be output. Null will disable console output.- Throws:
java.lang.Exception- throws an exception if an error occurs
-
consolePrintAndIgnore
private void consolePrintAndIgnore(java.lang.String msgProp, java.lang.Exception e, boolean printTimeStamp)
-
startNetworkServer
protected void startNetworkServer() throws java.lang.ExceptionLoad 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:
java.lang.Exception
-
shutdown
public void shutdown() throws java.lang.ExceptionShutdown a network server- Throws:
java.lang.Exception- throws an exception if an error occurs
-
checkShutdownPrivileges
public void checkShutdownPrivileges() throws java.sql.SQLException- Throws:
java.sql.SQLException- if authentication or privileges check fails
-
directShutdown
public void directShutdown() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
directShutdownInternal
void directShutdownInternal()
-
isServerStarted
public boolean isServerStarted() throws java.lang.Exception- Throws:
java.lang.Exception
-
ping
public void ping() throws java.lang.ExceptionPing opening an new socket and close it.- Throws:
java.lang.Exception
-
pingWithNoOpen
private void pingWithNoOpen() throws java.lang.ExceptionPing the server using the client socket that is already open.- Throws:
java.lang.Exception
-
trace
public void trace(boolean on) throws java.lang.ExceptionTurn tracing on or off for all sessions- Parameters:
on- true to turn tracing on, false to turn tracing off- Throws:
java.lang.Exception- throws an exception if an error occurs
-
trace
public void trace(int connNum, boolean on) throws java.lang.ExceptionTurn tracing on or off for one session or all sessions- Parameters:
connNum- the connNum of the session, 0 if all sessionson- true to turn tracing on, false to turn tracing off- Throws:
java.lang.Exception- throws an exception if an error occurs
-
consoleTraceMessage
private void consoleTraceMessage(int connNum, boolean on) throws java.lang.ExceptionPrint trace change message to console- Parameters:
on- true to print tracing on, false to print tracing off- Throws:
java.lang.Exception- throws an exception if an error occurs
-
logConnections
public void logConnections(boolean on) throws java.lang.ExceptionTurn 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:
java.lang.Exception- throws an exception if an error occurs
-
sendSetTraceDirectory
public void sendSetTraceDirectory(java.lang.String traceDirectory) throws java.lang.Exception- Throws:
java.lang.Exception- See Also:
NetworkServerControl.setTraceDirectory(java.lang.String)
-
sysinfo
public java.lang.String sysinfo() throws java.lang.Exception- Throws:
java.lang.Exception- See Also:
NetworkServerControl.getSysinfo()
-
runtimeInfo
public java.lang.String runtimeInfo() throws java.lang.Exception- Throws:
java.lang.Exception- See Also:
NetworkServerControl.getRuntimeInfo()
-
usage
public void usage()
Display usage information
-
netSetMaxThreads
public void netSetMaxThreads(int max) throws java.lang.ExceptionConnect 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:
java.lang.Exception- throws an exception if an error occurs
-
netSetTimeSlice
public void netSetTimeSlice(int timeslice) throws java.lang.ExceptionSet 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:
java.lang.Exception- throws an exception if an error occurs
-
getCurrentProperties
public java.util.Properties getCurrentProperties() throws java.lang.ExceptionGet current properties- Returns:
- Properties object containing properties
- Throws:
java.lang.Exception- throws an exception if an error occurs
-
getUniqueThreadName
static java.lang.String getUniqueThreadName(java.lang.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
baseand 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 java.lang.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 commandwriter- output writer for commandsession- session information- Throws:
java.lang.Throwable- throws an exception if an error occurs
-
logConnectionsChange
private void logConnectionsChange(boolean on) throws java.lang.ExceptionRecord a change to the connection logging mode- Throws:
java.lang.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(java.lang.String msgProp, boolean printTimeStamp) throws java.lang.ExceptionPut property message on console- Parameters:
msgProp- message property keyprintTimeStamp- whether to prepend a timestamp to the message- Throws:
java.lang.Exception- if an error occurs
-
consolePropertyMessage
protected void consolePropertyMessage(java.lang.String msgProp, java.lang.String arg) throws java.lang.ExceptionPut property message on console- Parameters:
msgProp- message property keyarg- argument for message- Throws:
java.lang.Exception- if an error occurs
-
consolePropertyMessage
protected void consolePropertyMessage(java.lang.String msgProp, java.lang.String[] args) throws java.lang.ExceptionPut property message on console- Parameters:
msgProp- message property keyargs- argument array for message- Throws:
java.lang.Exception- if an error occurs
-
isCmd
protected static boolean isCmd(java.lang.String val)
Is this the command protocol- Parameters:
val-
-
writeCommandReplyHeader
private void writeCommandReplyHeader(DDMWriter writer) throws java.lang.Exception
Write Command reply- Parameters:
writer- writer to use- Throws:
java.lang.Exception- if a problem occurs sending OK
-
sendOK
private void sendOK(DDMWriter writer) throws java.lang.Exception
Send OK from server to client after processing a command- Parameters:
writer- writer to use for sending OK- Throws:
java.lang.Exception- if a problem occurs sending OK
-
sendOKInt
private void sendOKInt(DDMWriter writer, int val) throws java.lang.Exception
Send OK and int value- Parameters:
writer- writer to use for sendingval- int val to send- Throws:
java.lang.Exception- if a problem occurs
-
sendMessage
private void sendMessage(DDMWriter writer, int messageType, java.lang.String message) throws java.lang.Exception
Send Error or Warning from server to client after processing a command- Parameters:
writer- writer to use for sending messagemessageType- 1 for Warning, 2 for Error 3 for SQLErrormessage- message- Throws:
java.lang.Exception- if a problem occurs sending message
-
sendSQLMessage
private void sendSQLMessage(DDMWriter writer, java.sql.SQLException se, int type) throws java.lang.Exception
Send SQL Exception from server to client after processing a command- Parameters:
writer- writer to use for sending messagese- Derby exceptiontype- type of exception, SQLERROR or SQLWARNING- Throws:
java.lang.Exception- if a problem occurs sending message
-
sendSysInfo
private void sendSysInfo(DDMWriter writer) throws java.lang.Exception
Send SysInfo information from server to client- Parameters:
writer- writer to use for sending sysinfo- Throws:
java.lang.Exception- if a problem occurs sending value
-
sendRuntimeInfo
private void sendRuntimeInfo(DDMWriter writer) throws java.lang.Exception
Send RuntimeInfo information from server to client- Parameters:
writer- writer to use for sending sysinfo- Throws:
java.lang.Exception- if a problem occurs sending value
-
sendPropInfo
private void sendPropInfo(DDMWriter writer) throws java.lang.Exception
Send property information from server to client- Parameters:
writer- writer to use for sending sysinfo- Throws:
java.lang.Exception- if a problem occurs sending value
-
getNetSysInfo
private java.lang.String getNetSysInfo()
Get Net Server information- Returns:
- system information for the Network Server
-
getRuntimeInfo
private java.lang.String getRuntimeInfo()
- See Also:
NetworkServerControl.getRuntimeInfo()
-
getCLSSysInfo
private java.lang.String getCLSSysInfo() throws java.io.IOExceptionGet Derby information- Returns:
- system information for Derby
- Throws:
java.io.IOException- if a problem occurs encoding string
-
parseArgs
public int parseArgs(java.lang.String[] args) throws java.lang.ExceptionParse 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:
java.lang.Exception
-
executeWork
public void executeWork(int command) throws java.lang.ExceptionExecute 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:
java.lang.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(java.lang.String[] args) throws java.lang.ExceptionGo 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:
java.lang.Exception
-
processDashArg
private int processDashArg(int pos, java.lang.String[] args) throws java.lang.ExceptionGet the dash argument. Optional arguments are formated as -x value.- Parameters:
pos- starting pointargs- arguments to search- Returns:
- command
- Throws:
java.lang.Exception- thrown if an error occurs
-
isOn
private boolean isOn(java.lang.String arg) throws java.lang.ExceptionIs string "on" or "off"- Parameters:
arg- string to check- Returns:
- true if string is "on", false if string is "off"
- Throws:
java.lang.Exception- thrown if string is not one of "on" or "off"
-
closeSocket
private void closeSocket() throws java.io.IOExceptionClose the resources associated with the opened socket.- Throws:
java.io.IOException
-
setUpSocket
private void setUpSocket() throws java.lang.ExceptionSet up client socket to send a command to the network server- Throws:
java.lang.Exception- thrown if exception encountered
-
removeSSLv3andSSLv2Hello
private java.lang.String[] removeSSLv3andSSLv2Hello(java.lang.String[] enabledProtocols)
-
checkAddressIsLocal
private void checkAddressIsLocal(java.net.InetAddress inetAddr) throws java.net.UnknownHostException, java.lang.Exception- Throws:
java.net.UnknownHostExceptionjava.lang.Exception
-
buildLocalAddressList
private void buildLocalAddressList(java.net.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(java.lang.Throwable t)
-
writeCommandHeader
private void writeCommandHeader(int command) throws java.lang.ExceptionWrite 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:
java.lang.Exception- throws an exception if an error occurs
-
writeCommandHeader
private void writeCommandHeader(int command, int protocol_version_for_command) throws java.lang.ExceptionWrite 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 writtenprotocol_version_for_command- protocol version to be used for the given command- Throws:
java.lang.Exception- throws an exception if an error occurs
-
writeLDString
private void writeLDString(java.lang.String msg) throws java.lang.ExceptionWrite length delimited string string- Parameters:
msg- string to be written- Throws:
java.lang.Exception- throws an exception if an error occurs
-
writeString
protected void writeString(java.lang.String msg) throws java.lang.ExceptionWrite string- Parameters:
msg- String to write- Throws:
java.lang.Exception
-
writeShort
private void writeShort(int value) throws java.lang.ExceptionWrite short- Parameters:
value- value to be written- Throws:
java.lang.Exception- throws an exception if an error occurs
-
writeByte
private void writeByte(int value) throws java.lang.ExceptionWrite byte- Parameters:
value- value to be written- Throws:
java.lang.Exception- throws an exception if an error occurs
-
send
private void send() throws java.lang.ExceptionSend client message to server- Throws:
java.lang.Exception- throws an exception if an error occurs
-
clientSocketError
private void clientSocketError(java.io.IOException e) throws java.io.IOExceptionStream error writing to client socket- Throws:
java.io.IOException
-
readResult
private void readResult() throws java.lang.ExceptionRead result from sending client message to server- Throws:
java.lang.Exception- throws an exception if an error occurs
-
ensureDataInBuffer
private void ensureDataInBuffer(int minimumBytesNeeded, boolean failOnEOS) throws java.lang.ExceptionEnsure the reply buffer is large enough to hold all the data; don't just rely on OS level defaults- Parameters:
minimumBytesNeeded- size of buffer requiredfailOnEOS- 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:
java.lang.Exception- throws an exception if a problem reading the reply
-
fillReplyBuffer
private void fillReplyBuffer() throws java.lang.ExceptionFill the reply buffer with the reply allocates a reply buffer if one doesn't exist- Throws:
java.lang.Exception- throws an exception if a problem reading the reply
-
readCommandReplyHeader
private void readCommandReplyHeader() throws java.lang.ExceptionRead the command reply header from the server- Throws:
java.lang.Exception- throws an exception if an error occurs
-
readShort
private int readShort() throws java.lang.ExceptionRead short from buffer- Throws:
java.lang.Exception- throws an exception if an error occurs
-
readInt
private int readInt() throws java.lang.ExceptionRead int from buffer- Throws:
java.lang.Exception- throws an exception if an error occurs
-
readStringReply
private java.lang.String readStringReply(java.lang.String msgKey) throws java.lang.ExceptionRead String reply- Parameters:
msgKey- error message key- Returns:
- string value or null
- Throws:
java.lang.Exception- throws an error if problems reading reply
-
readLDString
private java.lang.String readLDString() throws java.lang.ExceptionRead length delimited string from a buffer- Returns:
- string value from buffer
- Throws:
java.lang.Exception- throws an error if problems reading reply
-
readBytesReply
private byte[] readBytesReply(java.lang.String msgKey) throws java.lang.ExceptionRead Bytes reply- Parameters:
msgKey- error message key- Returns:
- string value or null
- Throws:
java.lang.Exception- throws an error if problems reading reply
-
readLDBytes
private byte[] readLDBytes() throws java.lang.ExceptionRead length delimited bytes from a buffer- Returns:
- byte array from buffer
- Throws:
java.lang.Exception- throws an error if problems reading reply
-
getPropertyInfo
private void getPropertyInfo() throws java.lang.ExceptionInitialize fields from system properties- Throws:
java.lang.Exception
-
getSecMecValue
private int getSecMecValue(java.lang.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 java.lang.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(java.lang.String s) throws java.lang.ExceptionGet 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:
java.lang.Exception
-
getSSLModeString
private java.lang.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(java.lang.String propName, java.lang.String propVal) throws java.lang.ExceptionGet integer property values- Parameters:
propName- property namepropVal- string property value- Returns:
- integer value
- Throws:
java.lang.Exception- if not a valid integer
-
consolePropertyMessageWork
private void consolePropertyMessageWork(java.lang.String messageKey, java.lang.String[] args, boolean printTimeStamp) throws java.lang.ExceptionHandle 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 keyargs- arguments to messageprintTimeStamp- whether to prepend a timestamp to the message- Throws:
java.lang.Exception- if an error occurs
-
throwSQLException
private void throwSQLException(java.lang.String msg) throws java.sql.SQLExceptionThrow 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:
java.sql.SQLException
-
throwSQLWarning
private void throwSQLWarning(java.lang.String msg) throws java.sql.SQLWarningThrow 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:
java.sql.SQLWarning
-
throwUnexpectedException
private void throwUnexpectedException(java.lang.Exception e) throws java.lang.ExceptionPrint 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:
java.lang.Exception- with message UNEXPECTED_ERR.
-
localizeMessage
public java.lang.String localizeMessage(java.lang.String msgProp, java.lang.String[] args)Convenience routine so that NetworkServerControl can localize messages.- Parameters:
msgProp- message keyargs- arguments to message
-
localizeMessage
private java.lang.String localizeMessage(java.lang.String msgProp, LocalizedResource localLangUtil, java.lang.String[] args)Localize a message given a particular AppUI- Parameters:
msgProp- message keylocalLangUtil- LocalizedResource to use to localize messageargs- arguments to message
-
getMessageType
private int getMessageType(java.lang.String msg)
Determine type of message- Parameters:
msg- message- Returns:
- message type
-
isMsgProperty
private boolean isMsgProperty(java.lang.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(java.lang.String s) throws java.lang.ExceptionSet 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:
java.lang.Exception- if value to set is invalid- See Also:
Property.DRDA_PROP_SECURITYMECHANISM
-
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:
Property.DRDA_PROP_SECURITYMECHANISM
-
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 java.lang.ExceptionSet the current value of time slice- Parameters:
value- time slice value- Throws:
java.lang.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 java.lang.ExceptionSet the current value of maximum number of threads to create- Parameters:
value- value of maximum number of threads- Throws:
java.lang.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 java.lang.String getTraceDirectory()
Get the current value of trace directory- Returns:
- trace directory
-
setTraceDirectory
private void setTraceDirectory(java.lang.String value)
Set the current value of trace directory- Parameters:
value- trace directory
-
wrapSQLError
private void wrapSQLError(java.lang.String messageKey) throws java.lang.ExceptionWrap SQL Error - display to console and raise exception- Parameters:
messageKey- Derby SQL Exception message id- Throws:
java.lang.Exception- raises exception for message
-
wrapSQLWarning
private void wrapSQLWarning(java.lang.String messageKey) throws java.lang.ExceptionWrap SQL Warning - display to console and raise exception- Parameters:
messageKey- Derby SQL Exception message id- Throws:
java.lang.Exception- raises exception for message
-
getPropertyValues
java.util.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(java.net.Socket clientSocket) throws java.lang.ExceptionAdd a session - for use byClientThread. Put the session into the session table and the run queue. Start a newDRDAConnThreadif 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:
java.lang.Exception
-
removeThread
void removeThread(DRDAConnThread thread)
Remove a thread from the thread list. Should be called when aDRDAConnThreadhas been closed.- Parameters:
thread- the closed thread
-
getShutdownSync
protected java.lang.Object getShutdownSync()
-
getShutdown
protected boolean getShutdown()
-
buildRuntimeInfo
public java.lang.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(java.lang.String locale)
-
getNetProductVersionHolder
private ProductVersionHolder getNetProductVersionHolder() throws java.lang.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:
java.lang.Exception
-
getSystemModule
private static java.lang.Object getSystemModule(java.lang.String factoryInterface)
Privileged module lookup. Must be private so that user code can't call this entry point.
-
findService
private static java.lang.Object findService(java.lang.String factoryInterface, java.lang.String serviceName)Privileged service lookup. Must be private so that user code can't call this entry point.
-
-