diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionConfiguration.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionConfiguration.java index b269508f701a..53091e0cadbf 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionConfiguration.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionConfiguration.java @@ -149,10 +149,11 @@ class AsyncConnectionConfiguration { private final int maxKeyValueSize; AsyncConnectionConfiguration(Configuration conf) { + long operationTimeoutMs = + conf.getLong(HBASE_CLIENT_OPERATION_TIMEOUT, DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT); + this.operationTimeoutNs = TimeUnit.MILLISECONDS.toNanos(operationTimeoutMs); this.metaOperationTimeoutNs = TimeUnit.MILLISECONDS.toNanos( - conf.getLong(HBASE_CLIENT_META_OPERATION_TIMEOUT, DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT)); - this.operationTimeoutNs = TimeUnit.MILLISECONDS.toNanos( - conf.getLong(HBASE_CLIENT_OPERATION_TIMEOUT, DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT)); + conf.getLong(HBASE_CLIENT_META_OPERATION_TIMEOUT, operationTimeoutMs)); long rpcTimeoutMs = conf.getLong(HBASE_RPC_TIMEOUT_KEY, DEFAULT_HBASE_RPC_TIMEOUT); this.rpcTimeoutNs = TimeUnit.MILLISECONDS.toNanos(rpcTimeoutMs); long readRpcTimeoutMillis = conf.getLong(HBASE_RPC_READ_TIMEOUT_KEY, rpcTimeoutMs); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionConfiguration.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionConfiguration.java index db7ef8e63c18..56f3a65c9575 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionConfiguration.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionConfiguration.java @@ -87,7 +87,8 @@ public class ConnectionConfiguration { WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS, WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS_DEFAULT); this.metaOperationTimeout = conf.getInt(HConstants.HBASE_CLIENT_META_OPERATION_TIMEOUT, - HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT); + conf.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, + HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT)); this.operationTimeout = conf.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT); diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionConfiguration.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionConfiguration.java index 022cab91267f..49f595a69456 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionConfiguration.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncConnectionConfiguration.java @@ -32,7 +32,7 @@ import org.junit.experimental.categories.Category; /** - * See HBASE-24513. + * See HBASE-24513, HBASE-28608. */ @Category({ ClientTests.class, SmallTests.class }) public class TestAsyncConnectionConfiguration { @@ -69,4 +69,16 @@ public void testDefaultReadWriteRpcTimeout() { assertEquals(expected, config.getReadRpcTimeoutNs()); assertEquals(expected, config.getWriteRpcTimeoutNs()); } + + @Test + public void testDefaultMetaOperationTimeout() { + Configuration conf = HBaseConfiguration.create(); + long timeoutMs = 1000; + conf.setLong(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, timeoutMs); + AsyncConnectionConfiguration config = new AsyncConnectionConfiguration(conf); + long expected = TimeUnit.MILLISECONDS.toNanos(timeoutMs); + assertEquals(expected, config.getOperationTimeoutNs()); + assertEquals(expected, config.getMetaOperationTimeoutNs()); + } + } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionConfiguration.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionConfiguration.java new file mode 100644 index 000000000000..0185c431033c --- /dev/null +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionConfiguration.java @@ -0,0 +1,34 @@ +package org.apache.hadoop.hbase.client; + +import static org.junit.Assert.assertEquals; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.testclassification.ClientTests; +import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +/** + * See HBASE-28608. Configuration tests for (non async) connections + */ +@Category({ ClientTests.class, SmallTests.class }) +public class TestConnectionConfiguration { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestConnectionConfiguration.class); + + @Test + public void testDefaultMetaOperationTimeout() { + Configuration conf = HBaseConfiguration.create(); + long clientOperationTimeoutMs = 1000; + conf.setLong(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, clientOperationTimeoutMs); + ConnectionConfiguration config = new ConnectionConfiguration(conf); + assertEquals(clientOperationTimeoutMs, config.getOperationTimeout()); + assertEquals(clientOperationTimeoutMs, config.getMetaOperationTimeout()); + } + +}