* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import org.apache.tomcat.util.threads.TaskThreadFactory;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
/**
- *
+ *
* @author fhanik
* @author Mladen Turk
* @author Remy Maucherat
*/
public abstract class AbstractEndpoint {
-
+
// -------------------------------------------------------------- Constants
protected static final StringManager sm = StringManager.getManager("org.apache.tomcat.util.net.res");
* This one is a Tomcat extension to the Servlet spec.
*/
public static final String SESSION_MGR = "javax.servlet.request.ssl_session_mgr";
-
+
/**
* Different types of socket states to react upon
*/
OPEN, CLOSED, LONG, ASYNC_END
}
}
-
+
// Standard SSL Configuration attributes
// JSSE
// Standard configuration attribute names
* Track the initialization state of the endpoint.
*/
protected boolean initialized = false;
-
+
/**
* Are we using an internal executor
*/
protected volatile boolean internalExecutor = false;
-
+
/**
* Socket properties
*/
return socketProperties;
}
-
+
// ----------------------------------------------------------------- Properties
private int maxConnections = 10000;
* External Executor based thread pool.
*/
private Executor executor = null;
- public void setExecutor(Executor executor) {
+ public void setExecutor(Executor executor) {
this.executor = executor;
this.internalExecutor = (executor==null);
}
public Executor getExecutor() { return executor; }
-
+
/**
* Server socket port.
*/
private InetAddress address;
public InetAddress getAddress() { return address; }
public void setAddress(InetAddress address) { this.address = address; }
-
+
/**
* Allows the server developer to specify the backlog that
* should be used for server sockets. By default, this value
* Socket linger.
*/
public int getSoLinger() { return socketProperties.getSoLingerTime(); }
- public void setSoLinger(int soLinger) {
+ public void setSoLinger(int soLinger) {
socketProperties.setSoLingerTime(soLinger);
socketProperties.setSoLingerOn(soLinger>=0);
}
}
}
}
-
+
/**
* Maximum amount of worker threads.
*/
}
/**
- * Max keep alive requests
+ * Max keep alive requests
*/
private int maxKeepAliveRequests=100; // as in Apache HTTPD server
public int getMaxKeepAliveRequests() {
public void setMaxKeepAliveRequests(int maxKeepAliveRequests) {
this.maxKeepAliveRequests = maxKeepAliveRequests;
}
-
+
/**
* Name of the thread pool, which will be used for naming child threads.
*/
public int getThreadPriority() { return threadPriority; }
protected abstract boolean getDeferAccept();
-
+
/**
* Generic properties, introspected
*/
}
/**
- * Return the amount of threads that are in use
+ * Return the amount of threads that are in use
*
* @return the amount of threads that are in use
*/
public boolean isRunning() {
return running;
}
-
+
public boolean isPaused() {
return paused;
}
-
+
public void createExecutor() {
internalExecutor = true;
executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
taskqueue.setParent( (ThreadPoolExecutor) executor);
}
-
+
public void shutdownExecutor() {
if ( executor!=null && internalExecutor ) {
if ( executor instanceof ThreadPoolExecutor ) {
saddr = new InetSocketAddress(address,getPort());
}
s = new java.net.Socket();
- s.setSoTimeout(getSocketProperties().getSoTimeout());
+ int stmo = 2 * 1000;
+ int utmo = 2 * 1000;
+ if (getSocketProperties().getSoTimeout() > stmo)
+ stmo = getSocketProperties().getSoTimeout();
+ if (getSocketProperties().getUnlockTimeout() > utmo)
+ utmo = getSocketProperties().getUnlockTimeout();
+ s.setSoTimeout(stmo);
// TODO Consider hard-coding to s.setSoLinger(true,0)
s.setSoLinger(getSocketProperties().getSoLingerOn(),getSocketProperties().getSoLingerTime());
if (getLog().isDebugEnabled()) {
getLog().debug("About to unlock socket for:"+saddr);
}
- s.connect(saddr,getSocketProperties().getUnlockTimeout());
+ s.connect(saddr,utmo);
if (getDeferAccept()) {
/*
* In the case of a deferred accept / accept filters we need to
}
}
}
- }
-
-
+ }
+
+
public abstract void init() throws Exception;
public abstract void start() throws Exception;
-
+
/**
* Pause the endpoint, which will stop it accepting new connections.
*/
}
}
}
-
+
/**
* Resume the endpoint, which will make it start accepting new connections
* again.
paused = false;
}
}
-
+
public abstract void stop() throws Exception;
public abstract void destroy() throws Exception;
-
+
public String adjustRelativePath(String path, String relativeTo) {
String newPath = path;
File f = new File(newPath);
}
return newPath;
}
-
+
protected abstract Log getLog();
public abstract boolean getUseSendfile();
private String clientAuth = "false";
public String getClientAuth() { return clientAuth;}
public void setClientAuth(String s ) { this.clientAuth = s;}
-
+
private String keystoreFile = System.getProperty("user.home")+"/.keystore";
public String getKeystoreFile() { return keystoreFile;}
- public void setKeystoreFile(String s ) {
+ public void setKeystoreFile(String s ) {
String file = adjustRelativePath(s, System.getProperty(Globals.CATALINA_BASE_PROP));
- this.keystoreFile = file;
+ this.keystoreFile = file;
}
private String keystorePass = null;
public String getKeystorePass() { return keystorePass;}
public void setKeystorePass(String s ) { this.keystorePass = s;}
-
+
private String keystoreType = "JKS";
public String getKeystoreType() { return keystoreType;}
public void setKeystoreType(String s ) { this.keystoreType = s;}
public String getKeystoreProvider() { return keystoreProvider;}
public void setKeystoreProvider(String s ) { this.keystoreProvider = s;}
- private String sslProtocol = "TLS";
+ private String sslProtocol = "TLS";
public String getSslProtocol() { return sslProtocol;}
public void setSslProtocol(String s) { sslProtocol = s;}
-
+
// Note: Some implementations use the comma separated string, some use
// the array
private String ciphers = null;
private String[] ciphersarr = new String[0];
public String[] getCiphersArray() { return this.ciphersarr;}
public String getCiphers() { return ciphers;}
- public void setCiphers(String s) {
+ public void setCiphers(String s) {
ciphers = s;
if ( s == null ) ciphersarr = new String[0];
else {
private String keyAlias = null;
public String getKeyAlias() { return keyAlias;}
public void setKeyAlias(String s ) { keyAlias = s;}
-
+
private String keyPass = JSSESocketFactory.DEFAULT_KEY_PASS;
public String getKeyPass() { return keyPass;}
public void setKeyPass(String s ) { this.keyPass = s;}
public void setTruststorePass(String truststorePass) {
this.truststorePass = truststorePass;
}
-
+
private String truststoreType =
System.getProperty("javax.net.ssl.trustStoreType");
public String getTruststoreType() {return truststoreType;}
sslEnabledProtocolsarr = new String[t.countTokens()];
for (int i=0; i<sslEnabledProtocolsarr.length; i++ ) sslEnabledProtocolsarr[i] = t.nextToken();
}
-
+
}