Package com.mckoi.database.jdbcserver
Interface ServerConnection
-
- All Known Implementing Classes:
StreamJDBCServerConnection
,TCPJDBCServerConnection
interface ServerConnection
A server side connection with a client. Each client that is connected to the database has a ServerConnection object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
blockForRequest()
Blocks until a complete command is available to be processed.void
close()
Closes this connection.void
ping()
Pings the connection.void
processRequest()
Processes a pending command on the connection.boolean
requestPending()
This should return true if it has been determined that there is an entire command waiting to be serviced on this connection.
-
-
-
Method Detail
-
requestPending
boolean requestPending() throws java.io.IOException
This should return true if it has been determined that there is an entire command waiting to be serviced on this connection. This method is always run on the same thread for all connections. It is called many times a second by the connection pool server so it must execute extremely fast.ISSUE: Method is polled! Unfortunately can't get around this because of the limitation in Java that TCP connections must block on a thread, and we can't block if we are to be servicing 100+ connections.
- Throws:
java.io.IOException
-
processRequest
void processRequest() throws java.io.IOException
Processes a pending command on the connection. This method is called from a database worker thread. The method will block until a request has been received and processed. Note, it is not desirable is some cases to allow this method to block. If a call to 'requestPending' returns true then then method is guarenteed not to block.The first call to this method will handle the hand shaking protocol between the client and server.
While this method is doing something, it can not be called again even if another request arrives from the client. All calls to this method are sequential. This method will only be called if the 'ping' method is not currently being processed.
- Throws:
java.io.IOException
-
blockForRequest
void blockForRequest() throws java.io.IOException
Blocks until a complete command is available to be processed. This is used for a blocking implementation. As soon as this method returns then a call to 'processRequest' will process the incoming command.- Throws:
java.io.IOException
-
ping
void ping() throws java.io.IOException
Pings the connection. This is used to determine if the connection is alive or not. If it's not, we should throw an IOException.This method will only be called if the 'processRequest' method is not being processed.
- Throws:
java.io.IOException
-
close
void close() throws java.io.IOException
Closes this connection.- Throws:
java.io.IOException
-
-