Package py4j

Class ClientServerConnection

    • Field Detail

      • socket

        protected java.net.Socket socket
      • writer

        protected java.io.BufferedWriter writer
      • reader

        protected java.io.BufferedReader reader
      • commands

        protected final java.util.Map<java.lang.String,​Command> commands
      • logger

        protected final java.util.logging.Logger logger
      • blockingReadTimeout

        protected final int blockingReadTimeout
      • nonBlockingReadTimeout

        protected final int nonBlockingReadTimeout
      • authToken

        protected final java.lang.String authToken
    • Constructor Detail

      • ClientServerConnection

        public ClientServerConnection​(Gateway gateway,
                                      java.net.Socket socket,
                                      java.util.List<java.lang.Class<? extends Command>> customCommands,
                                      Py4JPythonClientPerThread pythonClient,
                                      Py4JJavaServer javaServer,
                                      int readTimeout)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • ClientServerConnection

        public ClientServerConnection​(Gateway gateway,
                                      java.net.Socket socket,
                                      java.util.List<java.lang.Class<? extends Command>> customCommands,
                                      Py4JPythonClientPerThread pythonClient,
                                      Py4JJavaServer javaServer,
                                      int readTimeout,
                                      java.lang.String authToken)
                               throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • startServerConnection

        public void startServerConnection()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • initCommands

        protected void initCommands​(Gateway gateway,
                                    java.util.List<java.lang.Class<? extends Command>> commandsClazz)

        Override this method to initialize custom commands.

        Parameters:
        gateway -
        commandsClazz -
      • fireConnectionStopped

        protected void fireConnectionStopped()
      • quietSendFatalError

        protected void quietSendFatalError​(java.io.BufferedWriter writer,
                                           java.lang.Throwable exception)
      • getSocket

        public java.net.Socket getSocket()
        Specified by:
        getSocket in interface Py4JServerConnection
        Returns:
        The socket used by this gateway connection.
      • waitForCommands

        public void waitForCommands()
      • sendCommand

        public java.lang.String sendCommand​(java.lang.String command,
                                            boolean blocking)
        Specified by:
        sendCommand in interface Py4JClientConnection
      • start

        public void start()
                   throws java.io.IOException
        Specified by:
        start in interface Py4JClientConnection
        Throws:
        java.io.IOException
      • isInitiatedFromClient

        public boolean isInitiatedFromClient()
      • setInitiatedFromClient

        public void setInitiatedFromClient​(boolean initiatedFromClient)
      • readBlockingResponse

        protected java.lang.String readBlockingResponse​(java.io.BufferedReader reader)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • readNonBlockingResponse

        protected java.lang.String readNonBlockingResponse​(java.net.Socket socket,
                                                           java.io.BufferedReader reader)
                                                    throws java.io.IOException
        Throws:
        java.io.IOException