Package com.mckoi.database.jdbcserver
Class StreamJDBCServerConnection
- java.lang.Object
-
- com.mckoi.database.jdbcserver.JDBCProcessor
-
- com.mckoi.database.jdbcserver.StreamJDBCServerConnection
-
- All Implemented Interfaces:
ProtocolConstants,ServerConnection
- Direct Known Subclasses:
TCPJDBCServerConnection
abstract class StreamJDBCServerConnection extends JDBCProcessor implements ServerConnection
A generic JDBC stream protocol server that reads JDBC commands from a stream from each connection and dispatches the commands appropriately.
-
-
Field Summary
Fields Modifier and Type Field Description private static intINPUT_BUFFER_SIZEThe size in bytes of the buffer used for reading information from the input stream from the client.private LengthMarkedBufferedInputStreammarked_inputThe LengthMarkedBufferedInputStream we use to poll for commands from the client.private java.io.DataOutputStreamoutThe output stream to the client formatted as a DataOutputStream.private static intOUTPUT_BUFFER_SIZEThe size in bytes of the buffer used for writing information onto the output stream to the client.-
Fields inherited from interface com.mckoi.database.jdbc.ProtocolConstants
ACKNOWLEDGEMENT, AUTHENTICATION_ERROR, CLOSE, DATABASE_EVENT, DISPOSE_RESULT, DISPOSE_STREAMABLE_OBJECT, EXCEPTION, FAILED, PING, PUSH_STREAMABLE_OBJECT_PART, QUERY, RESULT_SECTION, SERVER_REQUEST, STREAMABLE_OBJECT_SECTION, SUCCESS, USER_AUTHENTICATION_FAILED, USER_AUTHENTICATION_PASSED
-
-
Constructor Summary
Constructors Constructor Description StreamJDBCServerConnection(DatabaseInterface db_interface, java.io.InputStream in, java.io.OutputStream out, DebugLogger logger)Sets up the protocol connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblockForRequest()Block waiting for a complete command to become available.voidping()Pings the client to check it's still alive.voidprocessRequest()Processes a request from this connection.booleanrequestPending()Inspects the input stream and determines in there's a command pending to be processed.voidsendEvent(byte[] event_msg)Sends an event to the client.-
Methods inherited from class com.mckoi.database.jdbcserver.JDBCProcessor
close, dispose, finalize, getState, isClosed, printByteArray, processJDBCCommand
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.mckoi.database.jdbcserver.ServerConnection
close
-
-
-
-
Field Detail
-
OUTPUT_BUFFER_SIZE
private static final int OUTPUT_BUFFER_SIZE
The size in bytes of the buffer used for writing information onto the output stream to the client.- See Also:
- Constant Field Values
-
INPUT_BUFFER_SIZE
private static final int INPUT_BUFFER_SIZE
The size in bytes of the buffer used for reading information from the input stream from the client.- See Also:
- Constant Field Values
-
marked_input
private LengthMarkedBufferedInputStream marked_input
The LengthMarkedBufferedInputStream we use to poll for commands from the client.
-
out
private java.io.DataOutputStream out
The output stream to the client formatted as a DataOutputStream.
-
-
Constructor Detail
-
StreamJDBCServerConnection
StreamJDBCServerConnection(DatabaseInterface db_interface, java.io.InputStream in, java.io.OutputStream out, DebugLogger logger) throws java.io.IOException
Sets up the protocol connection.- Throws:
java.io.IOException
-
-
Method Detail
-
sendEvent
public void sendEvent(byte[] event_msg) throws java.io.IOExceptionDescription copied from class:JDBCProcessorSends an event to the client. This is used to notify the client of trigger events, etc.SECURITY ISSUE: This is always invoked by the DatabaseDispatcher. We have to be careful that this method isn't allowed to block. Otherwise the DatabaseDispatcher thread will be out of operation. Unfortunately assuring this may not be possible until Java has non-blocking IO, or we use datagrams for transmission. I know for sure that the TCP implementation is vunrable. If the client doesn't 'read' what we are sending then this'll block when the buffers become full.
- Specified by:
sendEventin classJDBCProcessor- Throws:
java.io.IOException
-
requestPending
public boolean requestPending() throws java.io.IOExceptionInspects the input stream and determines in there's a command pending to be processed.- Specified by:
requestPendingin interfaceServerConnection- Throws:
java.io.IOException
-
processRequest
public void processRequest() throws java.io.IOExceptionProcesses a request from this connection.- Specified by:
processRequestin interfaceServerConnection- Throws:
java.io.IOException
-
blockForRequest
public void blockForRequest() throws java.io.IOExceptionBlock waiting for a complete command to become available.- Specified by:
blockForRequestin interfaceServerConnection- Throws:
java.io.IOException
-
ping
public void ping() throws java.io.IOExceptionPings the client to check it's still alive.- Specified by:
pingin interfaceServerConnection- Throws:
java.io.IOException
-
-