forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-25542 Add client detail to scan name so when lease expires, we … (
apache#2930) * HBASE-25542 Add client detail to scan name so when lease expires, we have clue on who was scanning When we create a scanner lease, record client ip and port (removed unnecessary store of scannerName). Signed-off-by: Clara Xiong <[email protected]>
- Loading branch information
1 parent
8873c72
commit 8386f5d
Showing
2 changed files
with
171 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSRpcServices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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.regionserver; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.client.RegionInfoBuilder; | ||
import org.apache.hadoop.hbase.ipc.RpcCall; | ||
import org.apache.hadoop.hbase.ipc.RpcServer; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.apache.hadoop.hbase.testclassification.RegionServerTests; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.mockito.Mockito; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Test parts of {@link RSRpcServices} | ||
*/ | ||
@Category({ RegionServerTests.class, MediumTests.class}) | ||
public class TestRSRpcServices { | ||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestRSRpcServices.class); | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(TestRSRpcServices.class); | ||
|
||
/** | ||
* Simple test of the toString on RegionScannerHolder works. | ||
* Just creates one and calls #toString on it. | ||
*/ | ||
@Test | ||
public void testRegionScannerHolderToString() throws UnknownHostException { | ||
RpcCall call = Mockito.mock(RpcCall.class); | ||
int port = 1234; | ||
Mockito.when(call.getRemotePort()).thenReturn(port); | ||
InetAddress address = InetAddress.getLocalHost(); | ||
Mockito.when(call.getRemoteAddress()).thenReturn(address); | ||
RpcServer.setCurrentCall(call); | ||
String clientIpAndPort = RSRpcServices.getRemoteClientIpAndPort(); | ||
HRegion region = Mockito.mock(HRegion.class); | ||
Mockito.when(region.getRegionInfo()).thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO); | ||
RSRpcServices.RegionScannerHolder rsh = new RSRpcServices.RegionScannerHolder(null, region, | ||
null, null, false, false, clientIpAndPort); | ||
LOG.info("rsh={}", rsh); | ||
} | ||
} |