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 19, 2024
1 parent f2b7b77 commit 4eff2fe
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 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) {
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));
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, 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,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 4eff2fe

Please sign in to comment.