/** Start the protocol */ public void init() throws Exception { endpoint.setName(getName()); endpoint.setHandler(cHandler); try { endpoint.init(); } catch (Exception ex) { CoyoteLogger.AJP_LOGGER.errorInitializingEndpoint(ex); throw ex; } }
public InetAddress getAddress() { return endpoint.getAddress(); } public void setAddress(InetAddress ia) { endpoint.setAddress(ia); }
public int getBacklog() { return endpoint.getBacklog(); } public void setBacklog(int backlog) { endpoint.setBacklog(backlog); }
@Override public void stopInternal() { releaseConnectionLatch(); if (!paused) { pause(); } if (running) { running = false; unlockAccept(); } shutdownExecutor(); }
@Override public void startInternal() throws Exception { if (!running) { running = true; paused = false; // Create worker collection if (getExecutor() == null) { createExecutor(); } initializeConnectionLatch(); startAcceptorThreads(); // Start async timeout thread Thread timeoutThread = new Thread(new AsyncTimeout(), getName() + "-AsyncTimeout"); timeoutThread.setPriority(threadPriority); timeoutThread.setDaemon(true); timeoutThread.start(); } }
if (getMaxConnections() == 0) { setMaxConnections(getMaxThreads()); if (isSSLEnabled()) { serverSocketFactory = handler.getSslImplementation().getServerSocketFactory(this); if (getAddress() == null) { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog()); } else { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog(), getAddress()); if (getAddress() == null) msg = orig.getMessage() + " <null>:" + getPort(); else msg = orig.getMessage() + " " + getAddress().toString() + ":" + getPort(); BindException be = new BindException(msg); be.initCause(orig);
if (getMaxConnections() == 0) { setMaxConnections(getMaxThreadsExecutor(true)); if (isSSLEnabled()) { serverSocketFactory = handler.getSslImplementation().getServerSocketFactory(this); if (getAddress() == null) { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog()); } else { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog(), getAddress()); if (getAddress() == null) msg = orig.getMessage() + " <null>:" + getPort(); else msg = orig.getMessage() + " " + getAddress().toString() + ":" + getPort(); BindException be = new BindException(msg); be.initCause(orig);
countUpOrAwaitConnection(); countDownConnection(); errorDelay = handleExceptionWithDelay(errorDelay); if (running && !paused && setSocketOptions(socket)) { if (!processSocket(socket)) { countDownConnection(); countDownConnection();
public SpdyProxyProtocol() { endpoint = new JIoEndpoint(); ((JIoEndpoint) endpoint).setHandler(cHandler); setSoLinger(Constants.DEFAULT_CONNECTION_LINGER); setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT); setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY); }
if (isSSLEnabled()) { serverSocketFactory = handler.getSslImplementation().getServerSocketFactory(this); if (getAddress() == null) { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog()); } else { serverSocket = serverSocketFactory.createSocket(getPort(), getBacklog(), getAddress()); if (getAddress() == null) msg = orig.getMessage() + " <null>:" + getPort(); else msg = orig.getMessage() + " " + getAddress().toString() + ":" + getPort(); BindException be = new BindException(msg); be.initCause(orig);
@Override public void startInternal() throws Exception { if (!running) { running = true; paused = false; // Create worker collection if (getExecutor() == null) { createExecutor(); } initializeConnectionLatch(); // Start acceptor threads for (int i = 0; i < acceptorThreadCount; i++) { Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i); acceptorThread.setPriority(threadPriority); acceptorThread.setDaemon(getDaemon()); acceptorThread.start(); } // Start async timeout thread Thread timeoutThread = new Thread(new AsyncTimeout(), getName() + "-AsyncTimeout"); timeoutThread.setPriority(threadPriority); timeoutThread.setDaemon(true); timeoutThread.start(); } }
public int getPort() { return endpoint.getPort(); } public void setPort(int port) { endpoint.setPort(port); }
if (!processSocket(socket, SocketStatus.ERROR)) { try { socket.close(); } catch (IOException e) { }
public void init() throws Exception { endpoint.setName(getName()); endpoint.setHandler(cHandler); (JSSEImplementation) SSLImplementation.getInstance(sslImplementationName); socketFactory = sslImplementation.getServerSocketFactory(); endpoint.setServerSocketFactory(socketFactory); } else if (socketFactoryName != null) { socketFactory = (ServerSocketFactory) Class.forName(socketFactoryName).newInstance(); endpoint.setServerSocketFactory(socketFactory); endpoint.init(); } catch (Exception ex) { CoyoteLogger.HTTP_BIO_LOGGER.errorInitializingEndpoint(ex);
@Override public Executor getExecutor() { return endpoint.getExecutor(); } }
awaitConnection(); if (setSocketOptions(socket)) { if (!processSocket(socket)) { countUpConnection();
/** * Deallocate APR memory pools, and close server socket. */ public void destroy() throws Exception { if (running) { stop(); } if (serverSocket != null) { try { if (serverSocket != null) serverSocket.close(); } catch (Exception e) { CoyoteLogger.UTIL_LOGGER.errorClosingSocket(e); } serverSocket = null; } initialized = false ; }
public void start() throws Exception { // Initialize socket if not done before if (!initialized) { init(); } if (!running) { running = true; paused = false; // Create worker collection if (executor == null) { workers = new WorkerStack(maxThreads); } // Start acceptor threads for (int i = 0; i < acceptorThreadCount; i++) { Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i); acceptorThread.setPriority(threadPriority); acceptorThread.setDaemon(daemon); acceptorThread.start(); } } }
/** * The background thread that listens for incoming TCP/IP connections and * hands them off to an appropriate processor. */ public void run() { // Process requests until we receive a shutdown signal while (running) { // Wait for the next socket to be assigned Socket socket = await(); if (socket == null) continue; // Process the request from this socket if (!setSocketOptions(socket) || !handler.process(socket)) { // Close socket try { socket.close(); } catch (IOException e) { } } // Finish up this request socket = null; recycleWorkerThread(this); } }
public void pause() throws Exception { try { endpoint.pause(); } catch (Exception ex) { log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex); throw ex; } // Wait for a while until all the processors are idle RequestInfo[] states = cHandler.global.getRequestProcessors(); int retry = 0; boolean done = false; while (!done && retry < 20) { retry++; for (int i = 0; i < states.length; i++) { if (states[i].getStage() == org.apache.coyote.Constants.STAGE_SERVICE) { try { Thread.sleep(1000); } catch (InterruptedException e) { ; } continue; } } done = true; } if (log.isInfoEnabled()) log.info(sm.getString("ajpprotocol.pause", getName())); }