HBASE-21857 Addendum fix broken UTs

This commit is contained in:
zhangduo 2019-02-10 18:21:24 +08:00 committed by Duo Zhang
parent b322d0a3e5
commit c48438fcb0
4 changed files with 75 additions and 7 deletions

View File

@ -344,7 +344,7 @@ public class ReplicationPeerManager {
try {
endpoint = Class.forName(replicationEndpointImpl)
.asSubclass(ReplicationEndpoint.class).getDeclaredConstructor().newInstance();
} catch (Exception e) {
} catch (Throwable e) {
throw new DoNotRetryIOException(
"Can not instantiate configured replication endpoint class=" + replicationEndpointImpl,
e);

View File

@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.ReplicationPeerNotFoundException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.replication.DummyReplicationEndpoint;
import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
import org.apache.hadoop.hbase.replication.ReplicationPeerConfigBuilder;
@ -52,7 +53,6 @@ import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
import org.apache.hadoop.hbase.replication.ReplicationUtils;
import org.apache.hadoop.hbase.replication.SyncReplicationState;
import org.apache.hadoop.hbase.replication.TestReplicationEndpoint.InterClusterReplicationEndpointForTest;
import org.apache.hadoop.hbase.replication.regionserver.TestReplicator.ReplicationEndpointForTest;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
@ -937,7 +937,7 @@ public class TestReplicationAdmin {
public void testPeerReplicationEndpointImpl() throws Exception {
ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder();
builder.setClusterKey(KEY_ONE);
builder.setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName());
builder.setReplicationEndpointImpl(DummyReplicationEndpoint.class.getName());
hbaseAdmin.addReplicationPeer(ID_ONE, builder.build());
try {
@ -962,7 +962,7 @@ public class TestReplicationAdmin {
hbaseAdmin.addReplicationPeer(ID_SECOND, builder.build());
try {
builder.setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName());
builder.setReplicationEndpointImpl(DummyReplicationEndpoint.class.getName());
hbaseAdmin.updateReplicationPeerConfig(ID_SECOND, builder.build());
fail("Change replication endpoint implementation class on an existing peer is not allowed");
} catch (Exception e) {

View File

@ -0,0 +1,68 @@
/**
* 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.replication;
import java.util.UUID;
import org.apache.yetus.audience.InterfaceAudience;
/**
* A dummy replication endpoint that does nothing, for test use only.
*/
@InterfaceAudience.Private
public class DummyReplicationEndpoint extends BaseReplicationEndpoint {
@Override
public boolean canReplicateToSameCluster() {
return true;
}
@Override
public UUID getPeerUUID() {
return ctx.getClusterId();
}
@Override
public WALEntryFilter getWALEntryfilter() {
return null;
}
@Override
public boolean replicate(ReplicateContext replicateContext) {
return true;
}
@Override
public void start() {
startAsync();
}
@Override
public void stop() {
stopAsync();
}
@Override
protected void doStart() {
notifyStarted();
}
@Override
protected void doStop() {
notifyStopped();
}
}

View File

@ -655,7 +655,7 @@ module Hbase
define_test "get_peer_config: works with replicationendpointimpl peer and config params" do
cluster_key = 'localhost:2181:/hbase-test'
repl_impl = 'org.apache.hadoop.hbase.replication.ReplicationEndpointForTest'
repl_impl = 'org.apache.hadoop.hbase.replication.DummyReplicationEndpoint'
config_params = { "config1" => "value1", "config2" => "value2" }
args = { CLUSTER_KEY => cluster_key, ENDPOINT_CLASSNAME => repl_impl,
CONFIG => config_params }
@ -675,7 +675,7 @@ module Hbase
peer_id_second = '2'
command(:add_peer, @peer_id, args)
repl_impl = "org.apache.hadoop.hbase.replication.ReplicationEndpointForTest"
repl_impl = "org.apache.hadoop.hbase.replication.DummyReplicationEndpoint"
config_params = { "config1" => "value1", "config2" => "value2" }
args2 = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params}
command(:add_peer, peer_id_second, args2)
@ -690,7 +690,7 @@ module Hbase
end
define_test "update_peer_config: can update peer config and data" do
repl_impl = "org.apache.hadoop.hbase.replication.ReplicationEndpointForTest"
repl_impl = "org.apache.hadoop.hbase.replication.DummyReplicationEndpoint"
config_params = { "config1" => "value1", "config2" => "value2" }
data_params = {"data1" => "value1", "data2" => "value2"}
args = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params, DATA => data_params}