Repository: bookkeeper Updated Branches: refs/heads/branch-4.3 651bc61fd -> dada850b6
BOOKKEEPER-810: Allow to configure TCP connect timeout (Charles Xie via sijie) Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/dada850b Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/dada850b Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/dada850b Branch: refs/heads/branch-4.3 Commit: dada850b675f2c1be493efbec52c7da8d9705a26 Parents: 651bc61 Author: Sijie Guo <[email protected]> Authored: Fri Dec 5 22:56:49 2014 -0800 Committer: Sijie Guo <[email protected]> Committed: Fri Dec 5 22:56:49 2014 -0800 ---------------------------------------------------------------------- CHANGES.txt | 4 + .../bookkeeper/conf/ClientConfiguration.java | 111 +++++++++++++++++++ .../proto/PerChannelBookieClient.java | 5 + 3 files changed, 120 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/dada850b/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 8f4da25..eabeb41 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,10 @@ Release 4.3.1 - unreleased BOOKKEEPER-813: BookieShell doesn't find index directory (Charles Xie via sijie) + bookkeeper-client: + + BOOKKEEPER-810: Allow to configure TCP connect timeout (Charles Xie via sijie) + Release 4.3.0 - 2014-10-03 Non-backward compatible changes: http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/dada850b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java ---------------------------------------------------------------------- diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java index 2f4127a..ae63c70 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java @@ -48,6 +48,11 @@ public class ClientConfiguration extends AbstractConfiguration { // NIO Parameters protected final static String CLIENT_TCP_NODELAY = "clientTcpNoDelay"; + protected final static String CLIENT_SENDBUFFER_SIZE = "clientSendBufferSize"; + protected final static String CLIENT_RECEIVEBUFFER_SIZE = "clientReceiveBufferSize"; + protected final static String CLIENT_WRITEBUFFER_LOW_WATER_MARK = "clientWriteBufferLowWaterMark"; + protected final static String CLIENT_WRITEBUFFER_HIGH_WATER_MARK = "clientWriteBufferHighWaterMark"; + protected final static String CLIENT_CONNECT_TIMEOUT_MILLIS = "clientConnectTimeoutMillis"; protected final static String NUM_CHANNELS_PER_BOOKIE = "numChannelsPerBookie"; // Read Parameters protected final static String READ_TIMEOUT = "readTimeout"; @@ -199,6 +204,112 @@ public class ClientConfiguration extends AbstractConfiguration { } /** + * Get client netty channel send buffer size. + * + * @return client netty channel send buffer size + */ + public int getClientSendBufferSize() { + return getInt(CLIENT_SENDBUFFER_SIZE, 1 * 1024 * 1024); + } + + /** + * Set client netty channel send buffer size. + * + * @param bufferSize + * client netty channel send buffer size. + * @return client configuration. + */ + public ClientConfiguration setClientSendBufferSize(int bufferSize) { + setProperty(CLIENT_SENDBUFFER_SIZE, bufferSize); + return this; + } + + /** + * Get client netty channel receive buffer size. + * + * @return client netty channel receive buffer size. + */ + public int getClientReceiveBufferSize() { + return getInt(CLIENT_RECEIVEBUFFER_SIZE, 1 * 1024 * 1024); + } + + /** + * Set client netty channel receive buffer size. + * + * @param bufferSize + * netty channel receive buffer size. + * @return client configuration. + */ + public ClientConfiguration setClientReceiveBufferSize(int bufferSize) { + setProperty(CLIENT_RECEIVEBUFFER_SIZE, bufferSize); + return this; + } + + /** + * Get client netty channel write buffer low water mark. + * + * @return netty channel write buffer low water mark. + */ + public int getClientWriteBufferLowWaterMark() { + return getInt(CLIENT_WRITEBUFFER_LOW_WATER_MARK, 32 * 1024); + } + + /** + * Set client netty channel write buffer low water mark. + * + * @param waterMark + * netty channel write buffer low water mark. + * @return client configuration. + */ + public ClientConfiguration setClientWriteBufferLowWaterMark(int waterMark) { + setProperty(CLIENT_WRITEBUFFER_LOW_WATER_MARK, waterMark); + return this; + } + + /** + * Get client netty channel write buffer high water mark. + * + * @return netty channel write buffer high water mark. + */ + public int getClientWriteBufferHighWaterMark() { + return getInt(CLIENT_WRITEBUFFER_HIGH_WATER_MARK, 64 * 1024); + } + + /** + * Set client netty channel write buffer high water mark. + * + * @param waterMark + * netty channel write buffer high water mark. + * @return client configuration. + */ + public ClientConfiguration setClientWriteBufferHighWaterMark(int waterMark) { + setProperty(CLIENT_WRITEBUFFER_HIGH_WATER_MARK, waterMark); + return this; + } + + /** + * Get client netty connect timeout in millis. + * + * @return client netty connect timeout in millis. + */ + public int getClientConnectTimeoutMillis() { + // 10 seconds as netty default value. + return getInt(CLIENT_CONNECT_TIMEOUT_MILLIS, 10000); + } + + /** + * Set client netty connect timeout in millis. + * + * @param connectTimeoutMillis + * client netty connect timeout in millis. + * @return client configuration. + */ + public ClientConfiguration setClientConnectTimeoutMillis(int connectTimeoutMillis) { + setProperty(CLIENT_CONNECT_TIMEOUT_MILLIS, connectTimeoutMillis); + return this; + } + + /** * Get num channels per bookie. * * @return num channels per bookie. http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/dada850b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java ---------------------------------------------------------------------- diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java index deef9f4..1dbc850 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java @@ -171,6 +171,11 @@ public class PerChannelBookieClient extends SimpleChannelHandler implements Chan bootstrap.setPipelineFactory(this); bootstrap.setOption("tcpNoDelay", conf.getClientTcpNoDelay()); bootstrap.setOption("keepAlive", true); + bootstrap.setOption("connectTimeoutMillis", conf.getClientConnectTimeoutMillis()); + bootstrap.setOption("child.sendBufferSize", conf.getClientSendBufferSize()); + bootstrap.setOption("child.receiveBufferSize", conf.getClientReceiveBufferSize()); + bootstrap.setOption("writeBufferLowWaterMark", conf.getClientWriteBufferLowWaterMark()); + bootstrap.setOption("writeBufferHighWaterMark", conf.getClientWriteBufferHighWaterMark()); ChannelFuture future = bootstrap.connect(addr.getSocketAddress()); future.addListener(new ChannelFutureListener() {
