You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/02/11 02:40:29 UTC

[hbase] branch branch-2.2 updated: HBASE-21857 Addendum fix broken UTs

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.2 by this push:
     new 8876e01  HBASE-21857 Addendum fix broken UTs
8876e01 is described below

commit 8876e0104eb1c3697ab58460e236ad7e3f91c3ca
Author: zhangduo <zh...@apache.org>
AuthorDate: Sun Feb 10 18:21:24 2019 +0800

    HBASE-21857 Addendum fix broken UTs
---
 .../master/replication/ReplicationPeerManager.java |  2 +-
 .../client/replication/TestReplicationAdmin.java   |  6 +-
 .../replication/DummyReplicationEndpoint.java      | 68 ++++++++++++++++++++++
 .../src/test/ruby/hbase/replication_admin_test.rb  |  6 +-
 4 files changed, 75 insertions(+), 7 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
index af00aae..17bbb82 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
@@ -252,7 +252,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);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
index a753d23..3f5b6bc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
@@ -41,6 +41,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;
@@ -48,7 +49,6 @@ import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
 import org.apache.hadoop.hbase.replication.ReplicationQueueStorage;
 import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
 import org.apache.hadoop.hbase.replication.TestReplicationEndpoint.InterClusterReplicationEndpointForTest;
-import org.apache.hadoop.hbase.replication.TestReplicationEndpoint.ReplicationEndpointForTest;
 import org.apache.hadoop.hbase.testclassification.ClientTests;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.junit.After;
@@ -874,7 +874,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 {
@@ -899,7 +899,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) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/DummyReplicationEndpoint.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/DummyReplicationEndpoint.java
new file mode 100644
index 0000000..38f0dbe
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/DummyReplicationEndpoint.java
@@ -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();
+  }
+}
diff --git a/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb b/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb
index d8a6302..17ab98b 100644
--- a/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb
+++ b/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb
@@ -601,7 +601,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 }
@@ -621,7 +621,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)
@@ -636,7 +636,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}