use of org.apache.phoenix.util.ReadOnlyProps in project phoenix by apache.
the class MigrateSystemTablesToSystemNamespaceIT method verifySyscatData.
private void verifySyscatData(Properties clientProps, String connName, Statement stmt) throws SQLException {
ResultSet rs = stmt.executeQuery("SELECT * FROM SYSTEM.CATALOG");
ReadOnlyProps props = new ReadOnlyProps((Map) clientProps);
boolean systemTablesMapped = SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM, props);
boolean systemSchemaExists = false;
Set<String> namespaceMappedSystemTablesSet = new HashSet<>(PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES);
Set<String> systemTablesSet = new HashSet<>(PHOENIX_SYSTEM_TABLES);
while (rs.next()) {
if (rs.getString("IS_NAMESPACE_MAPPED") == null) {
systemSchemaExists = rs.getString("TABLE_SCHEM").equals(PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME) ? true : systemSchemaExists;
} else if (rs.getString("COLUMN_NAME") == null) {
String schemaName = rs.getString("TABLE_SCHEM");
String tableName = rs.getString("TABLE_NAME");
if (schemaName.equals(PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME)) {
if (systemTablesMapped) {
namespaceMappedSystemTablesSet.remove(String.valueOf(TableName.valueOf(schemaName + QueryConstants.NAMESPACE_SEPARATOR + tableName)));
assertTrue(rs.getString("IS_NAMESPACE_MAPPED").equals(Boolean.TRUE.toString()));
} else {
systemTablesSet.remove(String.valueOf(TableName.valueOf(schemaName + QueryConstants.NAME_SEPARATOR + tableName)));
assertTrue(rs.getString("IS_NAMESPACE_MAPPED").equals(Boolean.FALSE.toString()));
}
}
}
}
if (!systemSchemaExists) {
fail(PhoenixDatabaseMetaData.SYSTEM_SCHEMA_NAME + " entry doesn't exist in SYSTEM.CATALOG table.");
}
// The set will contain SYSMUTEX table since that table is not exposed in SYSCAT
if (systemTablesMapped) {
assertTrue(namespaceMappedSystemTablesSet.size() == 1);
} else {
assertTrue(systemTablesSet.size() == 1);
}
}
use of org.apache.phoenix.util.ReadOnlyProps in project phoenix by apache.
the class IndexExtendedIT method doSetup.
@BeforeClass
public static void doSetup() throws Exception {
Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(2);
serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(2);
clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString());
clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString());
setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator()));
}
use of org.apache.phoenix.util.ReadOnlyProps in project phoenix by apache.
the class DropSchemaIT method doSetup.
@BeforeClass
public static void doSetup() throws Exception {
Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
// Drop the HBase table metadata for this test
props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true));
// Must update config before starting server
setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
}
use of org.apache.phoenix.util.ReadOnlyProps in project phoenix by apache.
the class MetaDataEndpointImpl method start.
/**
* Stores a reference to the coprocessor environment provided by the
* {@link org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost} from the region where this
* coprocessor is loaded. Since this is a coprocessor endpoint, it always expects to be loaded
* on a table region, so always expects this to be an instance of
* {@link RegionCoprocessorEnvironment}.
* @param env the environment provided by the coprocessor host
* @throws IOException if the provided environment is not an instance of
* {@code RegionCoprocessorEnvironment}
*/
@Override
public void start(CoprocessorEnvironment env) throws IOException {
if (env instanceof RegionCoprocessorEnvironment) {
this.env = (RegionCoprocessorEnvironment) env;
} else {
throw new CoprocessorException("Must be loaded on a table region!");
}
phoenixAccessCoprocessorHost = new PhoenixMetaDataCoprocessorHost(this.env);
Configuration config = env.getConfiguration();
this.accessCheckEnabled = config.getBoolean(QueryServices.PHOENIX_ACLS_ENABLED, QueryServicesOptions.DEFAULT_PHOENIX_ACLS_ENABLED);
this.blockWriteRebuildIndex = config.getBoolean(QueryServices.INDEX_FAILURE_BLOCK_WRITE, QueryServicesOptions.DEFAULT_INDEX_FAILURE_BLOCK_WRITE);
this.maxIndexesPerTable = config.getInt(QueryServices.MAX_INDEXES_PER_TABLE, QueryServicesOptions.DEFAULT_MAX_INDEXES_PER_TABLE);
this.isTablesMappingEnabled = SchemaUtil.isNamespaceMappingEnabled(PTableType.TABLE, new ReadOnlyProps(config.iterator()));
logger.info("Starting Tracing-Metrics Systems");
// Start the phoenix trace collection
Tracing.addTraceMetricsSource();
Metrics.ensureConfigured();
}
use of org.apache.phoenix.util.ReadOnlyProps in project phoenix by apache.
the class ConnectionQueryServicesImplTest method testExceptionHandlingOnSystemNamespaceCreation.
@SuppressWarnings("unchecked")
@Test
public void testExceptionHandlingOnSystemNamespaceCreation() throws Exception {
ConnectionQueryServicesImpl cqs = mock(ConnectionQueryServicesImpl.class);
// Invoke the real methods for these two calls
when(cqs.createSchema(any(List.class), anyString())).thenCallRealMethod();
doCallRealMethod().when(cqs).ensureSystemTablesMigratedToSystemNamespace(any(ReadOnlyProps.class));
// Do nothing for this method, just check that it was invoked later
doNothing().when(cqs).createSysMutexTableIfNotExists(any(HBaseAdmin.class), any(ReadOnlyProps.class));
// Spoof out this call so that ensureSystemTablesUpgrade() will return-fast.
when(cqs.getSystemTableNamesInDefaultNamespace(any(HBaseAdmin.class))).thenReturn(Collections.<TableName>emptyList());
// Throw a special exception to check on later
doThrow(PHOENIX_IO_EXCEPTION).when(cqs).ensureNamespaceCreated(anyString());
// Make sure that ensureSystemTablesMigratedToSystemNamespace will try to migrate the system tables.
Map<String, String> props = new HashMap<>();
props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
cqs.ensureSystemTablesMigratedToSystemNamespace(new ReadOnlyProps(props));
// Should be called after upgradeSystemTables()
// Proves that execution proceeded
verify(cqs).getSystemTableNamesInDefaultNamespace(any(HBaseAdmin.class));
try {
// Verifies that the exception is propagated back to the caller
cqs.createSchema(Collections.<Mutation>emptyList(), "");
} catch (PhoenixIOException e) {
assertEquals(PHOENIX_IO_EXCEPTION, e);
}
}
Aggregations