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-26963 ReplicationSource#removePeer hangs if we try to remove ba…
…d peer. (apache#4413) Signed-off-by: Andrew Purtell <apurtell@apache.org> Conflicts: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (cherry picked from commit daaf5ad) Change-Id: I9da537c53fc041cc80b3ea18f32bb73114a6e92c
- Loading branch information
Showing
2 changed files
with
106 additions
and
2 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
93 changes: 93 additions & 0 deletions
93
...rver/src/test/java/org/apache/hadoop/hbase/client/replication/TestBadReplicationPeer.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,93 @@ | ||
/* | ||
* 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.replication; | ||
|
||
import java.io.IOException; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.HBaseTestingUtility; | ||
import org.apache.hadoop.hbase.HConstants; | ||
import org.apache.hadoop.hbase.client.Admin; | ||
import org.apache.hadoop.hbase.client.Connection; | ||
import org.apache.hadoop.hbase.client.ConnectionFactory; | ||
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; | ||
import org.apache.hadoop.hbase.replication.ReplicationPeerConfigBuilder; | ||
import org.apache.hadoop.hbase.testclassification.ClientTests; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.rules.TestName; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@Category({ MediumTests.class, ClientTests.class }) | ||
public class TestBadReplicationPeer { | ||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestBadReplicationPeer.class); | ||
private static final Logger LOG = LoggerFactory.getLogger(TestBadReplicationPeer.class); | ||
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); | ||
private static Configuration conf; | ||
|
||
@Rule | ||
public TestName name = new TestName(); | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1); | ||
TEST_UTIL.getConfiguration().setBoolean("replication.source.regionserver.abort", false); | ||
TEST_UTIL.startMiniCluster(); | ||
conf = TEST_UTIL.getConfiguration(); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownAfterClass() throws Exception { | ||
TEST_UTIL.shutdownMiniCluster(); | ||
} | ||
|
||
/* | ||
* Add dummy peer and make sure that we are able to remove that peer. | ||
*/ | ||
@Test | ||
public void testRemovePeerSucceeds() throws IOException { | ||
String peerId = "dummypeer_1"; | ||
try (Connection connection = ConnectionFactory.createConnection(conf); | ||
Admin admin = connection.getAdmin()) { | ||
ReplicationPeerConfigBuilder rpcBuilder = ReplicationPeerConfig.newBuilder(); | ||
String quorum = TEST_UTIL.getHBaseCluster().getMaster().getZooKeeper().getQuorum(); | ||
rpcBuilder.setClusterKey(quorum + ":/1"); | ||
ReplicationPeerConfig rpc = rpcBuilder.build(); | ||
admin.addReplicationPeer(peerId, rpc); | ||
LOG.info("Added replication peer with peer id: {}", peerId); | ||
} finally { | ||
LOG.info("Removing replication peer with peer id: {}", peerId); | ||
cleanPeer(peerId); | ||
} | ||
} | ||
|
||
private static void cleanPeer(String peerId) throws IOException { | ||
try (Connection connection = ConnectionFactory.createConnection(conf); | ||
Admin admin = connection.getAdmin()) { | ||
admin.removeReplicationPeer(peerId); | ||
} | ||
} | ||
} |