Class TCPServer


  • public final class TCPServer
    extends java.lang.Object
    A TCP/IP socket server that opens a single port and allows JDBC clients to connect through the port to talk with the database.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.InetAddress address
      The InetAddress the JDBC server is bound to.
      private ConnectionPoolServer connection_pool
      The ConnectionPoolServer that polls the ServerConnection for new commands to process.
      private java.lang.String connection_pool_model
      The connection pool model used for this server.
      private Database database
      The parent Database object that describes everything about the database this TCP server is for.
      private int port
      The port the JDBC server is on.
      private java.net.ServerSocket server_socket
      The ServerSocket object where the database server is bound.
    • Constructor Summary

      Constructors 
      Constructor Description
      TCPServer​(Database database)
      Constructs the TCPServer over the given DatabaseSystem configuration.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkAvailable​(java.net.InetAddress bind_address, int tcp_port)
      Checks to see if there's already something listening on the jdbc port.
      void close()
      Closes the JDBC Server.
      DebugLogger Debug()
      Returns a DebugLogger object that we can log debug messages to.
      int getJDBCPort()
      Returns the port the JDBC server is on.
      private void portConnection​(java.net.Socket socket)
      Called whenever a new connection has been received on the port.
      void start​(java.net.InetAddress bind_address, int tcp_port, java.lang.String connection_pool_model)
      Starts the server running.
      java.lang.String toString()
      Returns human understandable information about the server.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • database

        private Database database
        The parent Database object that describes everything about the database this TCP server is for.
      • connection_pool

        private ConnectionPoolServer connection_pool
        The ConnectionPoolServer that polls the ServerConnection for new commands to process.
      • server_socket

        private java.net.ServerSocket server_socket
        The ServerSocket object where the database server is bound.
      • address

        private java.net.InetAddress address
        The InetAddress the JDBC server is bound to.
      • port

        private int port
        The port the JDBC server is on.
      • connection_pool_model

        private java.lang.String connection_pool_model
        The connection pool model used for this server.
    • Constructor Detail

      • TCPServer

        public TCPServer​(Database database)
        Constructs the TCPServer over the given DatabaseSystem configuration.
    • Method Detail

      • Debug

        public final DebugLogger Debug()
        Returns a DebugLogger object that we can log debug messages to.
      • getJDBCPort

        public int getJDBCPort()
        Returns the port the JDBC server is on.
      • checkAvailable

        public boolean checkAvailable​(java.net.InetAddress bind_address,
                                      int tcp_port)
        Checks to see if there's already something listening on the jdbc port. Returns true if the jdbc port in the configuration is available, otherwise returns false.
      • start

        public void start​(java.net.InetAddress bind_address,
                          int tcp_port,
                          java.lang.String connection_pool_model)
        Starts the server running. This method returns immediately but spawns its own thread.
      • portConnection

        private void portConnection​(java.net.Socket socket)
                             throws java.io.IOException
        Called whenever a new connection has been received on the port.
        Throws:
        java.io.IOException
      • close

        public void close()
        Closes the JDBC Server.
      • toString

        public java.lang.String toString()
        Returns human understandable information about the server.
        Overrides:
        toString in class java.lang.Object