HBASE-21857 Addendum fix broken UTs
authorzhangduo <zhangduo@apache.org>
Sun, 10 Feb 2019 10:21:24 +0000 (18:21 +0800)
committerDuo Zhang <zhangduo@apache.org>
Mon, 11 Feb 2019 02:06:54 +0000 (10:06 +0800)
hbase-server/src/main/java/org/apache/hadoop/hbase/master/replication/ReplicationPeerManager.java
hbase-server/src/test/java/org/apache/hadoop/hbase/client/replication/TestReplicationAdmin.java
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/DummyReplicationEndpoint.java [new file with mode: 0644]
hbase-shell/src/test/ruby/hbase/replication_admin_test.rb

index fa26f41..922bfed 100644 (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);
index 6462234..d337906 100644 (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) {
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 (file)
index 0000000..38f0dbe
--- /dev/null
@@ -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();
+  }
+}
index 7f5400f..3a3c447 100644 (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}