[prev in list] [next in list] [prev in thread] [next in thread]
List: httpcomponents-commits
Subject: svn commit: r1208523 - in /httpcomponents/httpcore/trunk:
From: olegk () apache ! org
Date: 2011-11-30 17:09:41
Message-ID: 20111130170942.21CF7238897F () eris ! apache ! org
[Download RAW message or body]
Author: olegk
Date: Wed Nov 30 17:09:39 2011
New Revision: 1208523
URL: http://svn.apache.org/viewvc?rev=1208523&view=rev
Log:
HTTPCORE-277: SO_KEEPALIVE parameter
Modified:
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/CoreConnectionPNames.java
httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/ \
java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java \
Wed Nov 30 17:09:39 2011 @@ -197,6 +197,7 @@ public abstract class AbstractMultiworke
config.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
config.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
config.setSoLinger(HttpConnectionParams.getLinger(params));
+ config.setSoKeepalive(HttpConnectionParams.getSoKeepalive(params));
config.setConnectTimeout(HttpConnectionParams.getConnectionTimeout(params));
config.setSoReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
@@ -520,6 +521,7 @@ public abstract class AbstractMultiworke
protected void prepareSocket(final Socket socket) throws IOException {
socket.setTcpNoDelay(this.config.isTcpNoDelay());
socket.setSoTimeout(this.config.getSoTimeout());
+ socket.setKeepAlive(this.config.isSoKeepalive());
int linger = this.config.getSoLinger();
if (linger >= 0) {
socket.setSoLinger(linger > 0, linger);
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/ \
java/org/apache/http/impl/nio/reactor/IOReactorConfig.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java \
Wed Nov 30 17:09:39 2011 @@ -47,6 +47,7 @@ public final class IOReactorConfig imple
private int soTimeout;
private boolean soReuseAddress;
private int soLinger;
+ private boolean soKeepAlive;
private boolean tcpNoDelay;
private int connectTimeout;
@@ -59,6 +60,7 @@ public final class IOReactorConfig imple
this.soTimeout = 0;
this.soReuseAddress = false;
this.soLinger = -1;
+ this.soKeepAlive = false;
this.tcpNoDelay = false;
this.connectTimeout = 0;
}
@@ -157,6 +159,8 @@ public final class IOReactorConfig imple
* Determines the default socket timeout value for non-blocking I/O operations.
* <p/>
* Default: <code>0</code> (no timeout)
+ *
+ * @see SocketOptions#SO_TIMEOUT
*/
public int getSoTimeout() {
return soTimeout;
@@ -166,6 +170,8 @@ public final class IOReactorConfig imple
* Defines the default socket timeout value for non-blocking I/O operations.
* <p/>
* Default: <code>0</code> (no timeout)
+ *
+ * @see SocketOptions#SO_TIMEOUT
*/
public void setSoTimeout(int soTimeout) {
this.soTimeout = soTimeout;
@@ -176,6 +182,8 @@ public final class IOReactorConfig imple
* for newly created sockets.
* <p/>
* Default: <code>false</code>
+ *
+ * @see SocketOptions#SO_REUSEADDR
*/
public boolean isSoReuseAddress() {
return soReuseAddress;
@@ -184,6 +192,8 @@ public final class IOReactorConfig imple
/**
* Defines the default value of the {@link SocketOptions#SO_REUSEADDR} parameter
* for newly created sockets.
+ *
+ * @see SocketOptions#SO_REUSEADDR
*/
public void setSoReuseAddress(boolean soReuseAddress) {
this.soReuseAddress = soReuseAddress;
@@ -194,6 +204,8 @@ public final class IOReactorConfig imple
* for newly created sockets.
* <p/>
* Default: <code>-1</code>
+ *
+ * @see SocketOptions#SO_LINGER
*/
public int getSoLinger() {
return soLinger;
@@ -202,16 +214,44 @@ public final class IOReactorConfig imple
/**
* Defines the default value of the {@link SocketOptions#SO_LINGER} parameter
* for newly created sockets.
+ *
+ * @see SocketOptions#SO_LINGER
*/
public void setSoLinger(int soLinger) {
this.soLinger = soLinger;
}
/**
+ * Determines the default value of the {@link SocketOptions#SO_KEEPALIVE} \
parameter + * for newly created sockets.
+ * <p/>
+ * Default: <code>-1</code>
+ *
+ * @see SocketOptions#SO_KEEPALIVE
+ */
+ public boolean isSoKeepalive() {
+ return this.soKeepAlive;
+ }
+
+ /**
+ * Defines the default value of the {@link SocketOptions#SO_KEEPALIVE} parameter
+ * for newly created sockets.
+ * <p/>
+ * Default: <code>-1</code>
+ *
+ * @see SocketOptions#SO_KEEPALIVE
+ */
+ public void setSoKeepalive(boolean soKeepAlive) {
+ this.soKeepAlive = soKeepAlive;
+ }
+
+ /**
* Determines the default value of the {@link SocketOptions#TCP_NODELAY} \
parameter
* for newly created sockets.
* <p/>
* Default: <code>false</code>
+ *
+ * @see SocketOptions#TCP_NODELAY
*/
public boolean isTcpNoDelay() {
return tcpNoDelay;
@@ -220,6 +260,8 @@ public final class IOReactorConfig imple
/**
* Defines the default value of the {@link SocketOptions#TCP_NODELAY} parameter
* for newly created sockets.
+ *
+ * @see SocketOptions#TCP_NODELAY
*/
public void setTcpNoDelay(boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
@@ -256,6 +298,7 @@ public final class IOReactorConfig imple
.append(", soTimeout=").append(this.soTimeout)
.append(", soReuseAddress=").append(this.soReuseAddress)
.append(", soLinger=").append(this.soLinger)
+ .append(", soKeepAlive=").append(this.soKeepAlive)
.append(", tcpNoDelay=").append(this.tcpNoDelay)
.append(", \
connectTimeout=").append(this.connectTimeout).append("]"); return \
builder.toString();
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java \
/org/apache/http/impl/DefaultHttpClientConnection.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpClientConnection.java \
Wed Nov 30 17:09:39 2011 @@ -44,6 +44,7 @@ import org.apache.http.params.HttpParams
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_LINGER}</li>
+ * <li>{@link org.apache.http.params.CoreConnectionPNames#SO_KEEPALIVE}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
* </ul>
@@ -70,6 +71,7 @@ public class DefaultHttpClientConnection
assertNotOpen();
socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
+ socket.setKeepAlive(HttpConnectionParams.getSoKeepalive(params));
int linger = HttpConnectionParams.getLinger(params);
if (linger >= 0) {
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java \
/org/apache/http/impl/DefaultHttpServerConnection.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/impl/DefaultHttpServerConnection.java \
Wed Nov 30 17:09:39 2011 @@ -44,6 +44,7 @@ import org.apache.http.params.HttpParams
* <li>{@link org.apache.http.params.CoreConnectionPNames#TCP_NODELAY}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_TIMEOUT}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SO_LINGER}</li>
+ * <li>{@link org.apache.http.params.CoreConnectionPNames#SO_KEEPALIVE}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#SOCKET_BUFFER_SIZE}</li>
* <li>{@link org.apache.http.params.CoreConnectionPNames#MAX_LINE_LENGTH}</li>
* </ul>
@@ -68,6 +69,7 @@ public class DefaultHttpServerConnection
assertNotOpen();
socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
socket.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
+ socket.setKeepAlive(HttpConnectionParams.getSoKeepalive(params));
int linger = HttpConnectionParams.getLinger(params);
if (linger >= 0) {
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/CoreConnectionPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java \
/org/apache/http/params/CoreConnectionPNames.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/CoreConnectionPNames.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/CoreConnectionPNames.java \
Wed Nov 30 17:09:39 2011 @@ -150,4 +150,17 @@ public interface CoreConnectionPNames {
*/
public static final String MIN_CHUNK_LIMIT = "http.connection.min-chunk-limit";
+
+ /**
+ * Defines whether or not TCP is to send automatically a keepalive probe to the \
peer + * after an interval of inactivity (no data exchanged in either direction) \
between this + * host and the peer. The purpose of this option is to detect if \
the peer host crashes. + * <p>
+ * This parameter expects a value of type {@link Boolean}.
+ * </p>
+ * @see java.net.SocketOptions#SO_KEEPALIVE
+ * @since 4.2
+ */
+ public static final String SO_KEEPALIVE = "http.socket.keepalive";
+
}
Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java \
/org/apache/http/params/HttpConnectionParams.java?rev=1208523&r1=1208522&r2=1208523&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java \
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/params/HttpConnectionParams.java \
Wed Nov 30 17:09:39 2011 @@ -241,4 +241,38 @@ public final class HttpConnectionParams \
(CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
}
+ /**
+ * Obtains value of the {@link CoreConnectionPNames#SO_KEEPALIVE} parameter.
+ * If not set, defaults to <code>false</code>.
+ *
+ * @param params HTTP parameters.
+ * @return SO_KEEPALIVE.
+ *
+ * @since 4.2
+ */
+ public static boolean getSoKeepalive(final HttpParams params) {
+ if (params == null) {
+ throw new IllegalArgumentException("HTTP parameters may not be null");
+ }
+ return params.getBooleanParameter(CoreConnectionPNames.SO_KEEPALIVE, false);
+ }
+
+ /**
+ * Sets value of the {@link CoreConnectionPNames#SO_KEEPALIVE} parameter.
+ *
+ * @param params HTTP parameters.
+ * @param enableKeepalive SO_KEEPALIVE.
+ *
+ * @since 4.2
+ */
+ public static void setSoKeepalive(final HttpParams params, boolean \
enableKeepalive) { + if (params == null) {
+ throw new IllegalArgumentException("HTTP parameters may not be null");
+ }
+ params.setBooleanParameter(CoreConnectionPNames.SO_KEEPALIVE, \
enableKeepalive); + }
+
+
+
+
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic