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 numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,6 @@

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand DownExpand Up@@ -54,7 +53,8 @@ public static synchronized void doSetup() throws Exception {
doSetup(null);
}

public static synchronized void doSetup(Map<String, String> props) throws Exception {
public static synchronized void doSetup(Map<String, String> props)
throws Exception {
NUM_SLAVES_BASE = 6;
if (props == null) {
props = Collections.emptyMap();
Expand All@@ -69,18 +69,20 @@ public static synchronized void doSetup(Map<String, String> props) throws Except
}
}

protected static void splitSystemCatalog() throws SQLException, Exception {
try (Connection conn = DriverManager.getConnection(getUrl())) {
protected static void splitSystemCatalog() throws Exception {
try (Connection ignored = DriverManager.getConnection(getUrl())) {
}
String tableName = "TABLE";
String fullTableName1 = SchemaUtil.getTableName(SCHEMA1, tableName);
String fullTableName2 = SchemaUtil.getTableName(SCHEMA2, tableName);
String fullTableName3 = SchemaUtil.getTableName(SCHEMA3, tableName);
String fullTableName4 = SchemaUtil.getTableName(SCHEMA4, tableName);
ArrayList<String> tableList = Lists.newArrayList(fullTableName1, fullTableName2, fullTableName3);
ArrayList<String> tableList = Lists.newArrayList(fullTableName1,
fullTableName2, fullTableName3);
Map<String, List<String>> tenantToTableMap = Maps.newHashMap();
tenantToTableMap.put(null, tableList);
tenantToTableMap.put(TENANT1, Lists.newArrayList(fullTableName2, fullTableName3));
tenantToTableMap.put(TENANT1, Lists.newArrayList(fullTableName2,
fullTableName3));
tenantToTableMap.put(TENANT2, Lists.newArrayList(fullTableName4));
splitSystemCatalog(tenantToTableMap);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
Expand All@@ -31,7 +32,6 @@
import java.util.Map;
import java.util.Properties;

import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionLocator;
Expand All@@ -51,8 +51,7 @@
* Tests various scenarios when
* {@link QueryServices#ALLOW_SPLITTABLE_SYSTEM_CATALOG_ROLLBACK}
* is set to true and SYSTEM.CATALOG should not be allowed to split.
* Note that this config must
* be set on both the client and server
* Note that this config must be set on both the client and server
*/
@Category(NeedsOwnMiniClusterTest.class)
public class SystemCatalogRollbackEnabledIT extends BaseTest {
Expand DownExpand Up@@ -100,37 +99,34 @@ private Connection getTenantConnection(String tenantId)
return DriverManager.getConnection(getUrl(), tenantProps);
}

private void assertNumRegions(HBaseTestingUtility testUtil,
TableName tableName, int expectedNumRegions) throws IOException {
RegionLocator rl = testUtil.getConnection().getRegionLocator(tableName);
assertEquals(expectedNumRegions, rl.getAllRegionLocations().size());
}

/**
* Make sure that SYSTEM.CATALOG cannot be split if
* {@link QueryServices#SYSTEM_CATALOG_SPLITTABLE} is false
*/
@Test
public void testSystemTableDoesNotSplit() throws Exception {
public void testSystemCatalogDoesNotSplit() throws Exception {
HBaseTestingUtility testUtil = getUtility();
for (int i=0; i<10; i++) {
createTableAndTenantViews("schema"+i+".table_"+i);
}
TableName systemCatalog = TableName.valueOf(
PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME);
RegionLocator rl = testUtil.getConnection()
.getRegionLocator(systemCatalog);
assertEquals(1, rl.getAllRegionLocations().size());
try {
// now attempt to split SYSTEM.CATALOG
testUtil.getHBaseAdmin().split(systemCatalog);
// make sure the split finishes (there's no synchronous splitting
// before HBase 2.x)
testUtil.getHBaseAdmin().disableTable(systemCatalog);
testUtil.getHBaseAdmin().enableTable(systemCatalog);
} catch (DoNotRetryIOException e) {
// table is not splittable
assertTrue(e.getMessage().contains("NOT splittable"));
}
assertNumRegions(testUtil, systemCatalog, 1);

// now attempt to split SYSTEM.CATALOG
// The expectation is for the split to be a no-op. It should not fail/
// throw any exception in HBase 1.x. Also, this split is synchronous
// since there's no asynchronous splitting before HBase 2.x
testUtil.getHBaseAdmin().split(systemCatalog);

// test again... Must still be exactly one region.
rl = testUtil.getConnection().getRegionLocator(systemCatalog);
assertEquals(1, rl.getAllRegionLocations().size());
assertNumRegions(testUtil, systemCatalog, 1);
}

/**
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -1874,7 +1874,8 @@ protected static void splitTable(TableName fullTableName, List<byte[]> splitPoin
availableRegionServers.remove(serverName);
}
}
assertTrue("No region servers available to move regions on to ", !availableRegionServers.isEmpty());
assertFalse("No region servers available to move regions on to ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like assertFalse here and remove !

availableRegionServers.isEmpty());
for (Entry<ServerName, List<HRegionInfo>> entry : serverToRegionsList.entrySet()) {
List<HRegionInfo> regions = entry.getValue();
if (regions.size()>1) {
Expand Down