Search in sources :

Example 1 with DerbyMetadataStorage

use of io.druid.metadata.storage.derby.DerbyMetadataStorage in project hive by apache.

the class DruidStorageHandler method getConnector.

private SQLMetadataConnector getConnector() {
    if (connector != null) {
        return connector;
    }
    final String dbType = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_TYPE);
    final String username = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_USERNAME);
    final String password = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_PASSWORD);
    final String uri = HiveConf.getVar(getConf(), HiveConf.ConfVars.DRUID_METADATA_DB_URI);
    final Supplier<MetadataStorageConnectorConfig> storageConnectorConfigSupplier = Suppliers.<MetadataStorageConnectorConfig>ofInstance(new MetadataStorageConnectorConfig() {

        @Override
        public String getConnectURI() {
            return uri;
        }

        @Override
        public String getUser() {
            return Strings.emptyToNull(username);
        }

        @Override
        public String getPassword() {
            return Strings.emptyToNull(password);
        }
    });
    if (dbType.equals("mysql")) {
        connector = new MySQLConnector(storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else if (dbType.equals("postgresql")) {
        connector = new PostgreSQLConnector(storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else if (dbType.equals("derby")) {
        connector = new DerbyConnector(new DerbyMetadataStorage(storageConnectorConfigSupplier.get()), storageConnectorConfigSupplier, Suppliers.ofInstance(getDruidMetadataStorageTablesConfig()));
    } else {
        throw new IllegalStateException(String.format("Unknown metadata storage type [%s]", dbType));
    }
    return connector;
}
Also used : DerbyConnector(io.druid.metadata.storage.derby.DerbyConnector) MetadataStorageConnectorConfig(io.druid.metadata.MetadataStorageConnectorConfig) MySQLConnector(io.druid.metadata.storage.mysql.MySQLConnector) PostgreSQLConnector(io.druid.metadata.storage.postgresql.PostgreSQLConnector) DerbyMetadataStorage(io.druid.metadata.storage.derby.DerbyMetadataStorage)

Aggregations

MetadataStorageConnectorConfig (io.druid.metadata.MetadataStorageConnectorConfig)1 DerbyConnector (io.druid.metadata.storage.derby.DerbyConnector)1 DerbyMetadataStorage (io.druid.metadata.storage.derby.DerbyMetadataStorage)1 MySQLConnector (io.druid.metadata.storage.mysql.MySQLConnector)1 PostgreSQLConnector (io.druid.metadata.storage.postgresql.PostgreSQLConnector)1