Search in sources :

Example 81 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project pinot by linkedin.

the class SingleFileIndexDirectory method loadMap.

private void loadMap() throws ConfigurationException {
    File mapFile = new File(segmentDirectory, INDEX_MAP_FILE);
    PropertiesConfiguration mapConfig = new PropertiesConfiguration(mapFile);
    Iterator keys = mapConfig.getKeys();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        // column names can have '.' in it hence scan from backwards
        // parsing names like "column.name.dictionary.startOffset"
        // or, "column.name.dictionary.endOffset" where column.name is the key
        int lastSeparatorPos = key.lastIndexOf(MAP_KEY_SEPARATOR);
        Preconditions.checkState(lastSeparatorPos != -1, "Key separator not found: " + key + ", segment: " + segmentDirectory);
        String propertyName = key.substring(lastSeparatorPos + 1);
        int indexSeparatorPos = key.lastIndexOf(MAP_KEY_SEPARATOR, lastSeparatorPos - 1);
        Preconditions.checkState(indexSeparatorPos != -1, "Index separator not found: " + key + " , segment: " + segmentDirectory);
        String indexName = key.substring(indexSeparatorPos + 1, lastSeparatorPos);
        String columnName = key.substring(0, indexSeparatorPos);
        IndexKey indexKey = new IndexKey(columnName, ColumnIndexType.getValue(indexName));
        IndexEntry entry = columnEntries.get(indexKey);
        if (entry == null) {
            entry = new IndexEntry(indexKey);
            columnEntries.put(indexKey, entry);
        }
        if (propertyName.equals(MAP_KEY_NAME_START_OFFSET)) {
            entry.startOffset = mapConfig.getLong(key);
        } else if (propertyName.equals(MAP_KEY_NAME_SIZE)) {
            entry.size = mapConfig.getLong(key);
        } else {
            throw new ConfigurationException("Invalid map file key: " + key + ", segmentDirectory: " + segmentDirectory.toString());
        }
    }
    // validation
    for (Map.Entry<IndexKey, IndexEntry> colIndexEntry : columnEntries.entrySet()) {
        IndexEntry entry = colIndexEntry.getValue();
        if (entry.size < 0 || entry.startOffset < 0) {
            throw new ConfigurationException("Invalid map entry for key: " + colIndexEntry.getKey().toString() + ", segment: " + segmentDirectory.toString());
        }
    }
}
Also used : ConfigurationException(org.apache.commons.configuration.ConfigurationException) Iterator(java.util.Iterator) File(java.io.File) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 82 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project pinot by linkedin.

the class StartServerCommand method execute.

@Override
public boolean execute() throws Exception {
    if (_serverHost == null) {
        _serverHost = NetUtil.getHostAddress();
    }
    Configuration configuration = readConfigFromFile(_configFileName);
    if (configuration == null) {
        if (_configFileName != null) {
            LOGGER.error("Error: Unable to find file {}.", _configFileName);
            return false;
        }
        configuration = new PropertiesConfiguration();
        configuration.addProperty(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST, _serverHost);
        configuration.addProperty(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT, _serverPort);
        configuration.addProperty("pinot.server.instance.dataDir", _dataDir + _serverPort + "/index");
        configuration.addProperty("pinot.server.instance.segmentTarDir", _segmentDir + _serverPort + "/segmentTar");
    }
    LOGGER.info("Executing command: " + toString());
    final HelixServerStarter pinotHelixStarter = new HelixServerStarter(_clusterName, _zkAddress, configuration);
    String pidFile = ".pinotAdminServer-" + String.valueOf(System.currentTimeMillis()) + ".pid";
    savePID(System.getProperty("java.io.tmpdir") + File.separator + pidFile);
    return true;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) HelixServerStarter(com.linkedin.pinot.server.starter.helix.HelixServerStarter) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 83 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project pinot by linkedin.

the class StartBrokerCommand method execute.

@Override
public boolean execute() throws Exception {
    if (_brokerHost == null) {
        _brokerHost = NetUtil.getHostAddress();
    }
    Configuration configuration = readConfigFromFile(_configFileName);
    if (configuration == null) {
        if (_configFileName != null) {
            LOGGER.error("Error: Unable to find file {}.", _configFileName);
            return false;
        }
        configuration = new PropertiesConfiguration();
        configuration.addProperty(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, _brokerPort);
        configuration.setProperty("pinot.broker.routing.table.builder.class", "random");
    }
    LOGGER.info("Executing command: " + toString());
    final HelixBrokerStarter pinotHelixBrokerStarter = new HelixBrokerStarter(_clusterName, _zkAddress, configuration);
    String pidFile = ".pinotAdminBroker-" + String.valueOf(System.currentTimeMillis()) + ".pid";
    savePID(System.getProperty("java.io.tmpdir") + File.separator + pidFile);
    return true;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) HelixBrokerStarter(com.linkedin.pinot.broker.broker.helix.HelixBrokerStarter) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 84 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project pinot by linkedin.

the class PerfBenchmarkDriver method startServer.

private void startServer() throws Exception {
    if (!_conf.shouldStartServer()) {
        LOGGER.info("Skipping start server step. Assumes server is already started.");
        return;
    }
    Configuration serverConfiguration = new PropertiesConfiguration();
    serverConfiguration.addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR, _serverInstanceDataDir);
    serverConfiguration.addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR, _serverInstanceSegmentTarDir);
    serverConfiguration.setProperty(CommonConstants.Server.CONFIG_OF_SEGMENT_FORMAT_VERSION, _segmentFormatVersion);
    serverConfiguration.setProperty("instanceId", _serverInstanceName);
    LOGGER.info("Starting server instance: {}", _serverInstanceName);
    new HelixServerStarter(_clusterName, _zkAddress, serverConfiguration);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) HelixServerStarter(com.linkedin.pinot.server.starter.helix.HelixServerStarter) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Example 85 with PropertiesConfiguration

use of org.apache.commons.configuration.PropertiesConfiguration in project es6draft by anba.

the class Resources method loadConfiguration.

/**
     * Loads the configuration file.
     */
public static Configuration loadConfiguration(Class<?> clazz) {
    TestConfiguration config = clazz.getAnnotation(TestConfiguration.class);
    String file = config.file();
    String name = config.name();
    try {
        PropertiesConfiguration properties = new PropertiesConfiguration();
        // entries are mandatory unless an explicit default value was given
        properties.setThrowExceptionOnMissing(true);
        properties.getInterpolator().setParentInterpolator(MISSING_VAR);
        properties.load(resource(file), "UTF-8");
        Configuration configuration = new CompositeConfiguration(Arrays.asList(new SystemConfiguration(), properties));
        return configuration.subset(name);
    } catch (ConfigurationException | IOException e) {
        throw new RuntimeException(e);
    } catch (NoSuchElementException e) {
        throw e;
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigurationException(org.apache.commons.configuration.ConfigurationException) CompositeConfiguration(org.apache.commons.configuration.CompositeConfiguration) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration)

Aggregations

PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)118 File (java.io.File)38 Configuration (org.apache.commons.configuration.Configuration)33 ConfigurationException (org.apache.commons.configuration.ConfigurationException)33 IOException (java.io.IOException)12 Test (org.testng.annotations.Test)11 BeforeClass (org.testng.annotations.BeforeClass)10 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)9 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)8 FileBasedInstanceDataManager (com.linkedin.pinot.core.data.manager.offline.FileBasedInstanceDataManager)8 FileInputStream (java.io.FileInputStream)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 URL (java.net.URL)6 ServerQueryExecutorV1Impl (com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl)5 ServerConf (com.linkedin.pinot.server.conf.ServerConf)5 FileNotFoundException (java.io.FileNotFoundException)5 Path (java.nio.file.Path)5 HashMap (java.util.HashMap)5 Properties (java.util.Properties)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4