You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/05/17 10:09:20 UTC

[GitHub] [hbase] HorizonNet commented on a change in pull request #1722: HBASE-24359 Optionally ignore edits for deleted CFs for replication

HorizonNet commented on a change in pull request #1722:
URL: https://github.com/apache/hbase/pull/1722#discussion_r426241594



##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEditsDroppedWithDroppedTable.java
##########
@@ -0,0 +1,251 @@
+/**
+ * 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 static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.JVMClusterUtil;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Category({ LargeTests.class })
+public class TestReplicationEditsDroppedWithDroppedTable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(TestReplicationEditsDroppedWithDroppedTable.class);
+
+  private static Configuration conf1 = HBaseConfiguration.create();
+  private static Configuration conf2 = HBaseConfiguration.create();
+
+  protected static HBaseTestingUtility utility1;
+  protected static HBaseTestingUtility utility2;
+
+  private static Admin admin1;
+  private static Admin admin2;
+
+  private static final String namespace = "NS";
+  private static final TableName NORMAL_TABLE = TableName.valueOf("normal-table");
+  private static final TableName DROPPED_TABLE = TableName.valueOf("dropped-table");
+  private static final TableName DROPPED_NS_TABLE = TableName.valueOf("NS:dropped-table");
+  private static final byte[] ROW = Bytes.toBytes("row");
+  private static final byte[] FAMILY = Bytes.toBytes("f");
+  private static final byte[] QUALIFIER = Bytes.toBytes("q");
+  private static final byte[] VALUE = Bytes.toBytes("value");
+
+  private static final String PEER_ID = "1";
+  private static final long SLEEP_TIME = 1000;
+  private static final int NB_RETRIES = 10;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    // Set true to filter replication edits for dropped table
+    conf1.setBoolean(HBaseInterClusterReplicationEndpoint.REPLICATION_DROP_ON_DELETED_TABLE_KEY, true);
+    conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
+    conf1.setInt("replication.source.nb.capacity", 1);
+    utility1 = new HBaseTestingUtility(conf1);
+    utility1.startMiniZKCluster();
+    MiniZooKeeperCluster miniZK = utility1.getZkCluster();
+    conf1 = utility1.getConfiguration();
+
+    conf2 = HBaseConfiguration.create(conf1);
+    conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
+    utility2 = new HBaseTestingUtility(conf2);
+    utility2.setZkCluster(miniZK);
+
+    utility1.startMiniCluster(1);
+    utility2.startMiniCluster(1);
+
+    admin1 = utility1.getAdmin();
+    admin2 = utility2.getAdmin();
+
+    NamespaceDescriptor nsDesc = NamespaceDescriptor.create(namespace).build();
+    admin1.createNamespace(nsDesc);
+    admin2.createNamespace(nsDesc);
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    utility2.shutdownMiniCluster();
+    utility1.shutdownMiniCluster();
+  }
+
+  @Before
+  public void setup() throws Exception {
+    // Roll log
+    for (JVMClusterUtil.RegionServerThread r : utility1.getHBaseCluster()
+        .getRegionServerThreads()) {
+      utility1.getAdmin().rollWALWriter(r.getRegionServer().getServerName());
+    }
+    // add peer
+    ReplicationPeerConfig rpc = new ReplicationPeerConfig();
+    rpc.setClusterKey(utility2.getClusterKey()).setReplicateAllUserTables(true);
+    admin1.addReplicationPeer(PEER_ID, rpc);
+    // create table
+    createTable(NORMAL_TABLE);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    // Remove peer
+    admin1.removeReplicationPeer(PEER_ID);
+    Thread.sleep(SLEEP_TIME);
+//    utility1.getMiniHBaseCluster().getMaster().getReplicationZKNodeCleanerChore().choreForTesting();
+    Thread.sleep(SLEEP_TIME);
+    // Drop table
+    admin1.disableTable(NORMAL_TABLE);
+    admin1.deleteTable(NORMAL_TABLE);
+    admin2.disableTable(NORMAL_TABLE);
+    admin2.deleteTable(NORMAL_TABLE);
+  }
+
+  private void createTable(TableName tableName) throws Exception {
+    HTableDescriptor desc = new HTableDescriptor(tableName);

Review comment:
       As it is deprecated, please use `TableDescriptorBuilder` instead.

##########
File path: hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java
##########
@@ -1306,10 +1306,6 @@
   public static final String REPLICATION_SOURCE_MAXTHREADS_KEY =
       "hbase.replication.source.maxthreads";
 
-  /** Drop edits for tables that been deleted from the replication source and target */
-  public static final String REPLICATION_DROP_ON_DELETED_TABLE_KEY =

Review comment:
       As HConstants is marked as `InterfaceAudience.Public` this one should be deprecated first.

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationEditsDroppedWithDroppedTable.java
##########
@@ -0,0 +1,251 @@
+/**
+ * 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 static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.replication.regionserver.HBaseInterClusterReplicationEndpoint;
+import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.JVMClusterUtil;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Category({ LargeTests.class })
+public class TestReplicationEditsDroppedWithDroppedTable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(TestReplicationEditsDroppedWithDroppedTable.class);
+
+  private static Configuration conf1 = HBaseConfiguration.create();
+  private static Configuration conf2 = HBaseConfiguration.create();
+
+  protected static HBaseTestingUtility utility1;
+  protected static HBaseTestingUtility utility2;
+
+  private static Admin admin1;
+  private static Admin admin2;
+
+  private static final String namespace = "NS";
+  private static final TableName NORMAL_TABLE = TableName.valueOf("normal-table");
+  private static final TableName DROPPED_TABLE = TableName.valueOf("dropped-table");
+  private static final TableName DROPPED_NS_TABLE = TableName.valueOf("NS:dropped-table");
+  private static final byte[] ROW = Bytes.toBytes("row");
+  private static final byte[] FAMILY = Bytes.toBytes("f");
+  private static final byte[] QUALIFIER = Bytes.toBytes("q");
+  private static final byte[] VALUE = Bytes.toBytes("value");
+
+  private static final String PEER_ID = "1";
+  private static final long SLEEP_TIME = 1000;
+  private static final int NB_RETRIES = 10;
+
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    // Set true to filter replication edits for dropped table
+    conf1.setBoolean(HBaseInterClusterReplicationEndpoint.REPLICATION_DROP_ON_DELETED_TABLE_KEY, true);
+    conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
+    conf1.setInt("replication.source.nb.capacity", 1);
+    utility1 = new HBaseTestingUtility(conf1);
+    utility1.startMiniZKCluster();
+    MiniZooKeeperCluster miniZK = utility1.getZkCluster();
+    conf1 = utility1.getConfiguration();
+
+    conf2 = HBaseConfiguration.create(conf1);
+    conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
+    utility2 = new HBaseTestingUtility(conf2);
+    utility2.setZkCluster(miniZK);
+
+    utility1.startMiniCluster(1);
+    utility2.startMiniCluster(1);
+
+    admin1 = utility1.getAdmin();
+    admin2 = utility2.getAdmin();
+
+    NamespaceDescriptor nsDesc = NamespaceDescriptor.create(namespace).build();
+    admin1.createNamespace(nsDesc);
+    admin2.createNamespace(nsDesc);
+  }
+
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    utility2.shutdownMiniCluster();
+    utility1.shutdownMiniCluster();
+  }
+
+  @Before
+  public void setup() throws Exception {
+    // Roll log
+    for (JVMClusterUtil.RegionServerThread r : utility1.getHBaseCluster()
+        .getRegionServerThreads()) {
+      utility1.getAdmin().rollWALWriter(r.getRegionServer().getServerName());
+    }
+    // add peer
+    ReplicationPeerConfig rpc = new ReplicationPeerConfig();
+    rpc.setClusterKey(utility2.getClusterKey()).setReplicateAllUserTables(true);
+    admin1.addReplicationPeer(PEER_ID, rpc);
+    // create table
+    createTable(NORMAL_TABLE);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    // Remove peer
+    admin1.removeReplicationPeer(PEER_ID);
+    Thread.sleep(SLEEP_TIME);
+//    utility1.getMiniHBaseCluster().getMaster().getReplicationZKNodeCleanerChore().choreForTesting();
+    Thread.sleep(SLEEP_TIME);
+    // Drop table
+    admin1.disableTable(NORMAL_TABLE);
+    admin1.deleteTable(NORMAL_TABLE);
+    admin2.disableTable(NORMAL_TABLE);
+    admin2.deleteTable(NORMAL_TABLE);
+  }
+
+  private void createTable(TableName tableName) throws Exception {
+    HTableDescriptor desc = new HTableDescriptor(tableName);
+    HColumnDescriptor familyDesc = new HColumnDescriptor(FAMILY);

Review comment:
       As it is deprecated, please use the appropriate builder.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org