Skip to content

Commit

Permalink
HBASE-28608 Correct client meta operation timeout to default to clien…
Browse files Browse the repository at this point in the history
…t operation timeout
  • Loading branch information
Daniel Roudnitsky committed Jun 18, 2024
1 parent f2b7b77 commit ec99eab
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
@@ -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());
}

}

0 comments on commit ec99eab

Please sign in to comment.