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());
}
}
}
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;
}
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;
}
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);
}
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;
}
}
Aggregations