Пример #1
0
        internal JvmBridge(int portNumber)
        {
            if (portNumber == 0)
            {
                throw new Exception("Port number is not set.");
            }

            _portNumber = portNumber;
            _logger.LogInfo($"JvMBridge port is {portNumber}");

            _jvmThreadPoolGC = new JvmThreadPoolGC(
                _logger, this, SparkEnvironment.ConfigurationService.JvmThreadGCInterval, _processId);

            _isRunningRepl = SparkEnvironment.ConfigurationService.IsRunningRepl();

            int numBackendThreads = SparkEnvironment.ConfigurationService.GetNumBackendThreads();
            int maxNumSockets     = numBackendThreads;

            if (numBackendThreads >= (2 * SocketBufferThreshold))
            {
                // Set the max number of concurrent sockets to be less than the number of
                // JVM backend threads to allow some buffer.
                maxNumSockets -= SocketBufferThreshold;
            }
            _logger.LogInfo($"The number of JVM backend thread is set to {numBackendThreads}. " +
                            $"The max number of concurrent sockets in JvmBridge is set to {maxNumSockets}.");
            _socketSemaphore = new SemaphoreSlim(maxNumSockets, maxNumSockets);
        }