Package com.mckoi.database.jdbcserver
Class MultiThreadedConnectionPoolServer
- java.lang.Object
-
- com.mckoi.database.jdbcserver.MultiThreadedConnectionPoolServer
-
- All Implemented Interfaces:
ConnectionPoolServer
final class MultiThreadedConnectionPoolServer extends java.lang.Object implements ConnectionPoolServer
A multi-threaded implementation of a connection pool server. This starts a new thread for each connection made and processes each command as they arrive.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
MultiThreadedConnectionPoolServer.ClientThread
This thread blocks waiting for a complete command to arrive from the client it is connected to.
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList
client_threads
The list of all threads that were created to deal with incoming commands.private Database
database
The Database parent.private static boolean
DISPLAY_STATS
If this is set to true then the server periodically outputs statistics about the connections.
-
Constructor Summary
Constructors Constructor Description MultiThreadedConnectionPoolServer(Database database)
The Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnection(ServerConnection connection)
Connects a new ServerConnection into the pool of connections to clients that this server maintains.void
close()
Closes this connection pool server down.DebugLogger
Debug()
Returns a DebugLogger object that we can log debug messages to.
-
-
-
Field Detail
-
DISPLAY_STATS
private static final boolean DISPLAY_STATS
If this is set to true then the server periodically outputs statistics about the connections.- See Also:
- Constant Field Values
-
database
private Database database
The Database parent.
-
client_threads
private java.util.ArrayList client_threads
The list of all threads that were created to deal with incoming commands.
-
-
Constructor Detail
-
MultiThreadedConnectionPoolServer
MultiThreadedConnectionPoolServer(Database database)
The Constructor. The argument is the configuration file.
-
-
Method Detail
-
Debug
public final DebugLogger Debug()
Returns a DebugLogger object that we can log debug messages to.
-
addConnection
public void addConnection(ServerConnection connection)
Connects a new ServerConnection into the pool of connections to clients that this server maintains. We then cycle through these connections determining whether any commands are pending. If a command is pending we spawn off a worker thread to do the task.- Specified by:
addConnection
in interfaceConnectionPoolServer
-
close
public void close()
Closes this connection pool server down.- Specified by:
close
in interfaceConnectionPoolServer
-
-