Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2572,6 +2572,11 @@ private synchronized HbckRegionInfo getOrCreateInfo(String name) {

private void checkAndFixReplication() throws ReplicationException, IOException {
ReplicationChecker checker = new ReplicationChecker(getConf(), zkw, connection, errors);

if (!checker.checkHasDataInQueues()) {
return;
}

checker.checkUnDeletedQueues();

if (checker.hasUnDeletedQueues() && this.fixReplication) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,8 @@ public void fixUnDeletedQueues() throws ReplicationException {
queueStorage.removePeerFromHFileRefs(peerId);
}
}

public boolean checkHasDataInQueues() throws ReplicationException {
return queueStorage.hasData();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;

@Category({ MiscTests.class, MediumTests.class })
public class TestHBaseFsckWithoutTableHbaseReplication {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHBaseFsckWithoutTableHbaseReplication.class);

@ClassRule
public static final TestName name = new TestName();

private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static final TableName tableName =
TableName.valueOf("replication_" + name.getMethodName());

@Before
public void setUp() throws Exception {
UTIL.getConfiguration().setBoolean("hbase.write.hbck1.lock.file", false);
UTIL.getConfiguration().set(ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME,
tableName.getNameAsString());
UTIL.startMiniCluster(1);
}

@After
public void tearDown() throws Exception {
UTIL.shutdownMiniCluster();
}

@Test
public void test() throws Exception {
assertFalse(UTIL.getAdmin().tableExists(tableName));
HBaseFsck hBaseFsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), true);
assertEquals(0, hBaseFsck.getRetCode());
}
}