Skip to content

Commit 198f2b4

Browse files
author
Ray Mattingly
committed
fix ConnectionImplementation constructor, mostly relates to tests
1 parent 19f53ba commit 198f2b4

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,6 @@ public class ConnectionImplementation implements ClusterConnection, Closeable {
280280

281281
private ChoreService choreService;
282282

283-
/**
284-
* constructor
285-
* @param conf Configuration object
286-
*/
287-
ConnectionImplementation(Configuration conf, ExecutorService pool, User user) throws IOException {
288-
this(conf, pool, user, null, Collections.emptyMap());
289-
}
290-
291283
/**
292284
* constructor
293285
* @param conf Configuration object

hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.net.UnknownHostException;
2828
import java.util.Arrays;
2929
import java.util.List;
30+
import java.util.Map;
3031
import java.util.Optional;
3132
import java.util.concurrent.CompletableFuture;
3233
import java.util.concurrent.ExecutorService;
@@ -140,8 +141,9 @@ public static void setupMasterlessConnection(Configuration conf) {
140141
* region re-lookups.
141142
*/
142143
static class MasterlessConnection extends ConnectionImplementation {
143-
MasterlessConnection(Configuration conf, ExecutorService pool, User user) throws IOException {
144-
super(conf, pool, user);
144+
MasterlessConnection(Configuration conf, ExecutorService pool, User user,
145+
Map<String, byte[]> requestAttributes) throws IOException {
146+
super(conf, pool, user, requestAttributes);
145147
}
146148

147149
@Override

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public CompletableFuture<String> getClusterId() {
526526
final AtomicInteger nbThreads = new AtomicInteger(0);
527527

528528
protected MyConnectionImpl(Configuration conf) throws IOException {
529-
super(setupConf(conf), null, null);
529+
super(setupConf(conf), null, null, Collections.emptyMap());
530530
}
531531

532532
private static Configuration setupConf(Configuration conf) {

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ public void testConnectionClosedOnRegionLocate() throws IOException {
329329
static class RegionServerStoppedOnScannerOpenConnection extends ConnectionImplementation {
330330
final ClientService.BlockingInterface stub;
331331

332-
RegionServerStoppedOnScannerOpenConnection(Configuration conf, ExecutorService pool, User user)
333-
throws IOException {
334-
super(conf, pool, user);
332+
RegionServerStoppedOnScannerOpenConnection(Configuration conf, ExecutorService pool, User user,
333+
Map<String, byte[]> requestAttributes) throws IOException {
334+
super(conf, pool, user, requestAttributes);
335335
// Mock up my stub so open scanner returns a scanner id and then on next, we throw
336336
// exceptions for three times and then after that, we return no more to scan.
337337
this.stub = Mockito.mock(ClientService.BlockingInterface.class);
@@ -360,8 +360,9 @@ public BlockingInterface getClient(ServerName sn) throws IOException {
360360
static class RpcTimeoutConnection extends ConnectionImplementation {
361361
final ClientService.BlockingInterface stub;
362362

363-
RpcTimeoutConnection(Configuration conf, ExecutorService pool, User user) throws IOException {
364-
super(conf, pool, user);
363+
RpcTimeoutConnection(Configuration conf, ExecutorService pool, User user,
364+
Map<String, byte[]> requestAttributes) throws IOException {
365+
super(conf, pool, user, requestAttributes);
365366
// Mock up my stub so an exists call -- which turns into a get -- throws an exception
366367
this.stub = Mockito.mock(ClientService.BlockingInterface.class);
367368
try {

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestConnectionImplementationTracing.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.hbase.client;
1919

2020
import java.io.IOException;
21+
import java.util.Collections;
2122
import org.apache.hadoop.hbase.HBaseClassTestRule;
2223
import org.apache.hadoop.hbase.ServerName;
2324
import org.apache.hadoop.hbase.security.UserProvider;
@@ -44,7 +45,8 @@ public class TestConnectionImplementationTracing extends TestTracingBase {
4445
@Before
4546
public void setUp() throws Exception {
4647
super.setUp();
47-
conn = new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent());
48+
conn = new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent(),
49+
Collections.emptyMap());
4850
}
4951

5052
@After

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestHTableTracing.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import io.opentelemetry.sdk.trace.data.SpanData;
4545
import java.io.IOException;
4646
import java.util.Arrays;
47+
import java.util.Collections;
4748
import java.util.List;
4849
import java.util.concurrent.ForkJoinPool;
4950
import java.util.concurrent.atomic.AtomicInteger;
@@ -191,35 +192,34 @@ public GetResponse answer(InvocationOnMock invocation) throws Throwable {
191192
}
192193
}).when(stub).get(any(HBaseRpcController.class), any(GetRequest.class));
193194

194-
conn =
195-
spy(new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent()) {
196-
@Override
197-
public RegionLocator getRegionLocator(TableName tableName) throws IOException {
198-
RegionLocator locator = mock(HRegionLocator.class);
199-
Answer<HRegionLocation> answer = new Answer<HRegionLocation>() {
200-
201-
@Override
202-
public HRegionLocation answer(InvocationOnMock invocation) throws Throwable {
203-
TableName tableName = TableName.META_TABLE_NAME;
204-
RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build();
205-
ServerName serverName = MASTER_HOST;
206-
HRegionLocation loc = new HRegionLocation(info, serverName);
207-
return loc;
208-
}
209-
};
210-
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyInt(),
211-
anyBoolean());
212-
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class));
213-
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyInt());
214-
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyBoolean());
215-
return locator;
216-
}
195+
conn = spy(new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent(),
196+
Collections.emptyMap()) {
197+
@Override
198+
public RegionLocator getRegionLocator(TableName tableName) throws IOException {
199+
RegionLocator locator = mock(HRegionLocator.class);
200+
Answer<HRegionLocation> answer = new Answer<HRegionLocation>() {
201+
202+
@Override
203+
public HRegionLocation answer(InvocationOnMock invocation) throws Throwable {
204+
TableName tableName = TableName.META_TABLE_NAME;
205+
RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build();
206+
ServerName serverName = MASTER_HOST;
207+
HRegionLocation loc = new HRegionLocation(info, serverName);
208+
return loc;
209+
}
210+
};
211+
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyInt(), anyBoolean());
212+
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class));
213+
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyInt());
214+
doAnswer(answer).when(locator).getRegionLocation(any(byte[].class), anyBoolean());
215+
return locator;
216+
}
217217

218-
@Override
219-
public ClientService.BlockingInterface getClient(ServerName serverName) throws IOException {
220-
return stub;
221-
}
222-
});
218+
@Override
219+
public ClientService.BlockingInterface getClient(ServerName serverName) throws IOException {
220+
return stub;
221+
}
222+
});
223223
// this setup of AsyncProcess is for MultiResponse
224224
AsyncProcess asyncProcess = mock(AsyncProcess.class);
225225
AsyncRequestFuture asyncRequestFuture = mock(AsyncRequestFuture.class);

hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestRegionLocatorTracing.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.opentelemetry.sdk.trace.data.SpanData;
3333
import java.io.IOException;
3434
import java.util.Arrays;
35+
import java.util.Collections;
3536
import org.apache.hadoop.hbase.HBaseClassTestRule;
3637
import org.apache.hadoop.hbase.HConstants;
3738
import org.apache.hadoop.hbase.HRegionLocation;
@@ -59,7 +60,8 @@ public class TestRegionLocatorTracing extends TestTracingBase {
5960
@Before
6061
public void setUp() throws Exception {
6162
super.setUp();
62-
conn = new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent());
63+
conn = new ConnectionImplementation(conf, null, UserProvider.instantiate(conf).getCurrent(),
64+
Collections.emptyMap());
6365
}
6466

6567
@After

hbase-server/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.hbase.client;
1919

2020
import java.io.IOException;
21+
import java.util.Collections;
2122
import java.util.Optional;
2223
import java.util.concurrent.atomic.AtomicLong;
2324
import org.apache.hadoop.conf.Configuration;
@@ -149,7 +150,7 @@ public static ClusterConnection getMockedConnectionAndDecorate(final Configurati
149150
*/
150151
public static ClusterConnection getSpiedConnection(final Configuration conf) throws IOException {
151152
ConnectionImplementation connection =
152-
Mockito.spy(new ConnectionImplementation(conf, null, null));
153+
Mockito.spy(new ConnectionImplementation(conf, null, null, Collections.emptyMap()));
153154
return connection;
154155
}
155156

0 commit comments

Comments
 (0)