You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2019/09/06 16:51:07 UTC
[hbase-operator-tools] branch master updated: HBASE-22984 [HBCK2]
HBCKMetaTableAccessor.deleteFromMetaTable throwing
java.lang.UnsupportedOperationException at runtime (#24)
This is an automated email from the ASF dual-hosted git repository.
wchevreuil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 4f3f9a7 HBASE-22984 [HBCK2] HBCKMetaTableAccessor.deleteFromMetaTable throwing java.lang.UnsupportedOperationException at runtime (#24)
4f3f9a7 is described below
commit 4f3f9a7179e334a286f022ecb6a01081e9b02db3
Author: Wellington Ramos Chevreuil <wc...@apache.org>
AuthorDate: Fri Sep 6 17:51:03 2019 +0100
HBASE-22984 [HBCK2] HBCKMetaTableAccessor.deleteFromMetaTable throwing java.lang.UnsupportedOperationException at runtime (#24)
Signed-off-by: Sean Busbey <bu...@apache.org>
---
.../org/apache/hbase/HBCKMetaTableAccessor.java | 3 +-
.../apache/hbase/TestHBCKMetaTableAccessor.java | 85 ++++++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
index 52e9313..c59f189 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKMetaTableAccessor.java
@@ -131,7 +131,8 @@ public final class HBCKMetaTableAccessor {
throw new IOException("connection is closed");
}
try (Table t = connection.getTable(TableName.META_TABLE_NAME)) {
- List<Delete> deletes = Arrays.asList(d);
+ List<Delete> deletes = new ArrayList<>();
+ deletes.add(d);
LOG.debug("Add {} delete to meta table", deletes);
t.delete(deletes);
}
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKMetaTableAccessor.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKMetaTableAccessor.java
new file mode 100644
index 0000000..c68c280
--- /dev/null
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestHBCKMetaTableAccessor.java
@@ -0,0 +1,85 @@
+/*
+ * 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.hbase;
+
+import static org.junit.Assert.assertFalse;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.logging.log4j.LogManager;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test class for the MetaTableAccessor wrapper.
+ */
+public class TestHBCKMetaTableAccessor {
+
+ private static final org.apache.logging.log4j.Logger LOG = LogManager.getLogger(TestHBCK2.class);
+ private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+
+ @Rule
+ public TestName testName = new TestName();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ TEST_UTIL.startMiniCluster(3);
+ }
+
+ @Test
+ public void testDeleteRegionInfo() throws Exception {
+ TableName tableName = createTestTable(5);
+ List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tableName);
+ RegionInfo toBeDeleted = regions.get(0);
+ HBCKMetaTableAccessor.deleteRegionInfo(TEST_UTIL.getConnection(), toBeDeleted);
+ assertFalse(listRegionsInMeta().contains(toBeDeleted));
+ }
+
+ private List<RegionInfo> listRegionsInMeta() throws Exception {
+ Connection connection = TEST_UTIL.getConnection();
+ Table table = connection.getTable(TableName.META_TABLE_NAME);
+ Scan scan = new Scan();
+ scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
+ ResultScanner scanner = table.getScanner(scan);
+ final List<RegionInfo> regionInfos = new ArrayList<>();
+ for(Result r : scanner) {
+ regionInfos.add(RegionInfo.parseFrom(r.getValue(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER)));
+ }
+ return regionInfos;
+ }
+
+ private TableName createTestTable(int totalRegions) throws IOException {
+ TableName tableName = TableName.valueOf(testName.getMethodName());
+ TEST_UTIL.createMultiRegionTable(tableName, Bytes.toBytes("family1"), totalRegions);
+ return tableName;
+ }
+}