Source:
<code>void ensureSystemTablesMigratedToSystemNamespace() throws SQLException, IOException, IllegalArgumentException, InterruptedException { if (!SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM, this.getProps())) { return; } HTableInterface metatable = null; try (HBaseAdmin admin = getAdmin()) { List<TableName> tableNames = getSystemTableNamesInDefaultNamespace(admin); if (tableNames.size() == 0) { return; } if (tableNames.size() > 7) { <START> logger.warn("Expected 5 system tables but found " + tableNames.size() + ":" + tableNames); <END> } byte[] mappedSystemTable = SchemaUtil .getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, this.getProps()).getName(); metatable = getTable(mappedSystemTable); if (tableNames.contains(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME)) { if (!admin.tableExists(mappedSystemTable)) { logger.info("Migrating SYSTEM.CATALOG table to SYSTEM namespace."); UpgradeUtil.mapTableToNamespace(admin, metatable, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, this.getProps(), null, PTableType.SYSTEM, null); ConnectionQueryServicesImpl.this.removeTable(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, null, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0); } tableNames.remove(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); } for (TableName table : tableNames) { logger.info(String.format("Migrating %s table to SYSTEM namespace.", table.getNameAsString())); UpgradeUtil.mapTableToNamespace(admin, metatable, table.getNameAsString(), this.getProps(), null, PTableType.SYSTEM, null); ConnectionQueryServicesImpl.this.removeTable(null, table.getNameAsString(), null, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0); } clearCache(); } finally { if (metatable != null) { metatable.close(); } } }</code><technical_language>nit: change log message appropriately. Extract constant a variable</technical_language>

Target:
void ensureSystemTablesMigratedToSystemNamespace() throws SQLException, IOException, IllegalArgumentException, InterruptedException { if (!SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM, this.getProps())) { return; } HTableInterface metatable = null; try (HBaseAdmin admin = getAdmin()) { List<TableName> tableNames = getSystemTableNamesInDefaultNamespace(admin); if (tableNames.size() == 0) { return; } if (tableNames.size() > 7) { logger.warn("Expected 7 system tables but found " + tableNames.size() + ":" + tableNames); } byte[] mappedSystemTable = SchemaUtil .getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, this.getProps()).getName(); metatable = getTable(mappedSystemTable); if (tableNames.contains(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME)) { if (!admin.tableExists(mappedSystemTable)) { logger.info("Migrating SYSTEM.CATALOG table to SYSTEM namespace."); UpgradeUtil.mapTableToNamespace(admin, metatable, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, this.getProps(), null, PTableType.SYSTEM, null); ConnectionQueryServicesImpl.this.removeTable(null, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME, null, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0); } tableNames.remove(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); } for (TableName table : tableNames) { logger.info(String.format("Migrating %s table to SYSTEM namespace.", table.getNameAsString())); UpgradeUtil.mapTableToNamespace(admin, metatable, table.getNameAsString(), this.getProps(), null, PTableType.SYSTEM, null); ConnectionQueryServicesImpl.this.removeTable(null, table.getNameAsString(), null, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0); } clearCache(); } finally { if (metatable != null) { metatable.close(); } } }