/** * Register a <code>SelectionKey</code> to this <code>Selector</code> * running of this thread. */ @Override public void registerKey(SelectionKey key){ if (key == null) return; if (keepAlivePipeline.dropConnection()) { cancelKey(key); return; } if (enableNioLogging){ logger.log(Level.INFO, "Registering SocketChannel for keep alive " + key.channel()); } getKeysToEnable().add(key); selector.wakeup(); }
/** * Create <code>SSLProcessorTask</code> objects and configure it to be ready * to proceed request. */ @Override protected ProcessorTask newProcessorTask(boolean initialize){ SSLProcessorTask task = null; if (!asyncExecution) { task = new SSLProcessorTask(initialize, isBufferResponse()); } else { task = new SSLAsyncProcessorTask(initialize, isBufferResponse()); } return configureProcessorTask(task); }
/** * Initialize <code>SSLSelectorReadThread</code> used to process * OP_READ operations. */ @Override protected void initMultiSelectors() throws IOException, InstantiationException { for (int i = 0; i < readThreads.length; i++) { readThreads[i] = new SSLSelectorReadThread(){ public ReadTask getReadTask(SelectionKey key) throws IOException{ ReadTask readTask = SSLSelectorThread.this.getReadTask(key); readTask.setSelectorThread(this); return readTask; } }; ((SSLSelectorReadThread)readThreads[i]).countName = i; configureReadThread((SSLSelectorReadThread)readThreads[i]); } }
Pipeline pipeline = null; try{ className = Class.forName(getPipelineClassName()); pipeline = (Pipeline)className.newInstance(); } catch (ClassNotFoundException ex){ getLogger().log(Level.WARNING, "Unable to load Pipeline: " + getPipelineClassName()); pipeline = new SSLPipeline(); } catch (InstantiationException ex){ getLogger().log(Level.WARNING, "Unable to instantiate Pipeline: " + getPipelineClassName()); pipeline = new SSLPipeline(); } catch (IllegalAccessException ex){ getLogger().log(Level.WARNING, "Unable to instantiate Pipeline: " + getPipelineClassName()); pipeline = new SSLPipeline(); if (getLogger().isLoggable(Level.FINE)){ getLogger().log(Level.FINE, "http-listener " + port + " uses pipeline: " + pipeline.getClass().getName()); pipeline.setPort(port); pipeline.setPriority(priority); pipeline.setQueueSizeInBytes(getMaxQueueSizeInBytes()); pipeline.setThreadsIncrement(getThreadsIncrement()); pipeline.setThreadsTimeout(getThreadsTimeout());
if (enabledCipherSuites != null){ if (!isCipherConfigured) { enabledCipherSuites = configureEnabledCiphers(sslEngine, enabledCipherSuites); isCipherConfigured = true; enabledProtocols = configureEnabledProtocols(sslEngine, enabledProtocols); isProtocolConfigured = true; sslEngine.setUseClientMode(isClientMode()); if (isNeedClientAuth()) { sslEngine.setNeedClientAuth(true); } else if (isWantClientAuth()) { sslEngine.setWantClientAuth(true); } else {
long current = System.currentTimeMillis(); if (current < getNextKeysExpiration()) { return; setNextKeysExpiration(current + getKaTimeout()); if (current - expire >= getKaTimeout()) { cancelKey(key); } else if (expire + getKaTimeout() < getNextKeysExpiration()){ setNextKeysExpiration(expire + getKaTimeout());
/** * Disable gathering of monitoring datas. */ @Override public void disableMonitoring(){ disablePipelineStats(); if (readThreads != null) { for (int i = 0; i < readThreads.length; i++) { ((SSLSelectorReadThread)readThreads[i]).isMonitoringEnabled = false; } } fileCacheFactory.setIsMonitoringEnabled(isMonitoringEnabled); }
/** * Enable gathering of monitoring datas. */ @Override public void enableMonitoring(){ isMonitoringEnabled = true; enablePipelineStats(); if (readThreads != null) { for (int i = 0; i < readThreads.length; i++) { ((SSLSelectorReadThread)readThreads[i]).isMonitoringEnabled = true; } } fileCacheFactory.setIsMonitoringEnabled(isMonitoringEnabled); }
/** * Enable all registered interestOps. Due a a NIO bug, all interestOps * invocation needs to occurs on the same thread as the selector thread. */ @Override public void enableSelectionKeys(){ SelectionKey selectionKey; int size = getKeysToEnable().size(); long currentTime = System.currentTimeMillis(); for (int i=0; i < size; i++) { selectionKey = (SelectionKey)getKeysToEnable().poll(); selectionKey.interestOps( selectionKey.interestOps() | SelectionKey.OP_READ); if ( selectionKey.attachment() != null){ ((SSLEngine)selectionKey .attachment()).getSession().putValue (String.valueOf(selectionKey.hashCode()), System.currentTimeMillis()); } keepAlivePipeline.trap(selectionKey); } }