List of usage examples for org.apache.commons.configuration ConfigurationException ConfigurationException
public ConfigurationException(Throwable cause)
ConfigurationException
with specified nested Throwable
. From source file:com.linkedin.pinot.core.segment.store.SingleFileIndexDirectory.java
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); }//from ww w . j ava2 s . c o m 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()); } } }
From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java
private ReceiverConfiguration setupReceiver() throws ConfigurationException { // **************** receiver-specific settings ReceiverConfiguration receiverConfiguration = new ReceiverConfiguration(); final String sedexInboxCron = xmlConfig.getString("messageHandler.sedexInboxDirCheck[@cron]"); if (StringUtils.isBlank(sedexInboxCron)) { throw new ConfigurationException("Missing attribute: messageHandler.sedexInboxDirCheck[@cron]"); }/*from ww w. java 2 s. c o m*/ receiverConfiguration.setCron(sedexInboxCron); return receiverConfiguration; }
From source file:ch.admin.suis.msghandler.config.ClientConfigurationFactory.java
private StatusCheckerConfiguration setupChecker() throws ConfigurationException { // **************** checker-specific settings StatusCheckerConfiguration statusCheckerConfiguration = new StatusCheckerConfiguration(); final String sedexReceiptCron = xmlConfig.getString("messageHandler.sedexReceiptDirCheck[@cron]"); if (StringUtils.isBlank(sedexReceiptCron)) { throw new ConfigurationException("Missing attribute: messageHandler.sedexReceiptDirCheck[@cron]"); }/* www. j a v a 2 s .co m*/ statusCheckerConfiguration.setCron(sedexReceiptCron); return statusCheckerConfiguration; }
From source file:ch.admin.suis.msghandler.util.FileUtils.java
/** * Checks if the path is an existing file. <br />Used to validate configuration values. * * @param file The file// w w w .j av a2s. co m */ public static void isFile(File file, String helpText) throws ConfigurationException { if (file == null) { throwNullPointer(helpText); } if (!file.exists() || file.isDirectory()) { throw new ConfigurationException("File: " + file.getAbsolutePath() + " either not exist or is not a file. Param name: " + helpText); } }
From source file:it.unimi.di.big.mg4j.document.PropertyBasedDocumentFactory.java
/** Scans the property set, parsing the properties that concern this class. * /* w ww.ja v a 2 s .c o m*/ * @param properties a set of properties. * @return a metadata map. */ @SuppressWarnings("unchecked") public Reference2ObjectMap<Enum<?>, Object> parseProperties(final Properties properties) throws ConfigurationException { String key, qualifier, className = this.getClass().getName(); int lastDot; Reference2ObjectArrayMap<Enum<?>, Object> metadata = new Reference2ObjectArrayMap<Enum<?>, Object>(); for (Iterator<?> i = properties.getKeys(); i.hasNext();) { key = i.next().toString(); lastDot = key.lastIndexOf('.'); qualifier = lastDot == -1 ? "" : key.substring(0, lastDot); if (className.startsWith(qualifier) && !parseProperty(key.substring(lastDot + 1), properties.getStringArray(key), metadata) && className.equals(qualifier)) throw new ConfigurationException("Unknown property " + key); } return metadata.isEmpty() ? Reference2ObjectMaps.EMPTY_MAP : metadata; }
From source file:edu.nyu.tandon.tool.PrunedPartition.java
public PrunedPartition(final String inputBasename, final String outputBasename, final DocumentalPartitioningStrategy strategy, final String strategyFilename, final int BloomFilterPrecision, final int bufferSize, final Map<Component, Coding> writerFlags, IndexType indexType, boolean skips, final int quantum, final int height, final int skipBufferOrCacheSize, final long logInterval, final boolean docPruning) throws ConfigurationException, IOException, ClassNotFoundException, SecurityException, InstantiationException, IllegalAccessException, URISyntaxException, InvocationTargetException, NoSuchMethodException {// w w w . ja va 2s .com this.inputBasename = inputBasename; this.outputBasename = outputBasename; this.strategy = strategy; this.strategyFilename = strategyFilename; this.strategyProperties = strategy.properties(); this.bufferSize = bufferSize; this.logInterval = logInterval; this.bloomFilterPrecision = BloomFilterPrecision; this.docPruning = docPruning; numIndices = strategy.numberOfLocalIndices(); if (numIndices != 2) throw new ConfigurationException("Invalid number of indeces returnd from the strategy."); final Coding positionCoding = writerFlags.get(Component.POSITIONS); inputProperties = new Properties(inputBasename + DiskBasedIndex.PROPERTIES_EXTENSION); globalIndex = Index.getInstance(inputBasename, false, positionCoding == Coding.GOLOMB || positionCoding == Coding.INTERPOLATIVE, false); indexReader = globalIndex.getReader(); localBasename = new String[numIndices]; for (int i = 0; i < numIndices; i++) localBasename[i] = outputBasename + "-" + i; localTerms = new PrintWriter[numIndices]; maxDocSize = new int[numIndices]; maxDocPos = new int[numIndices]; numTerms = new long[numIndices]; occurrencies = new long[numIndices]; numOccurrences = new long[numIndices]; numPostings = new long[numIndices]; indexWriter = new IndexWriter[numIndices]; quasiSuccinctIndexWriter = new QuasiSuccinctIndexWriter[numIndices]; this.numberOfDocuments = new long[2]; numberOfDocuments[0] = strategy.numberOfDocuments(0); numberOfDocuments[1] = globalIndex.numberOfDocuments - numberOfDocuments[0]; if ((havePayloads = writerFlags.containsKey(Component.PAYLOADS)) && !globalIndex.hasPayloads) throw new IllegalArgumentException( "You requested payloads, but the global index does not contain them."); if ((haveCounts = writerFlags.containsKey(Component.COUNTS)) && !globalIndex.hasCounts) throw new IllegalArgumentException("You requested counts, but the global index does not contain them."); if (!globalIndex.hasPositions && writerFlags.containsKey(Component.POSITIONS)) writerFlags.remove(Component.POSITIONS); if ((havePositions = writerFlags.containsKey(Component.POSITIONS)) && !globalIndex.hasPositions) throw new IllegalArgumentException( "You requested positions, but the global index does not contain them."); if (indexType == IndexType.HIGH_PERFORMANCE && !havePositions) throw new IllegalArgumentException("You cannot disable positions for high-performance indices."); if (indexType != IndexType.INTERLEAVED && havePayloads) throw new IllegalArgumentException("Payloads are available in interleaved indices only."); skips |= indexType == IndexType.HIGH_PERFORMANCE; if (skips && (quantum <= 0 || height < 0)) throw new IllegalArgumentException( "You must specify a positive quantum and a nonnegative height (variable quanta are not available when partitioning documentally)."); // we only produce 1 index switch (indexType) { case INTERLEAVED: if (!skips) indexWriter[0] = new BitStreamIndexWriter(IOFactory.FILESYSTEM_FACTORY, localBasename[0], numberOfDocuments[0], true, writerFlags); else indexWriter[0] = new SkipBitStreamIndexWriter(IOFactory.FILESYSTEM_FACTORY, localBasename[0], numberOfDocuments[0], true, skipBufferOrCacheSize, writerFlags, quantum, height); break; case HIGH_PERFORMANCE: indexWriter[0] = new BitStreamHPIndexWriter(localBasename[0], numberOfDocuments[0], true, skipBufferOrCacheSize, writerFlags, quantum, height); break; case QUASI_SUCCINCT: quasiSuccinctIndexWriter[0] = (QuasiSuccinctIndexWriter) (indexWriter[0] = new QuasiSuccinctIndexWriter( IOFactory.FILESYSTEM_FACTORY, localBasename[0], numberOfDocuments[0], Fast.mostSignificantBit(quantum < 0 ? QuasiSuccinctIndex.DEFAULT_QUANTUM : quantum), skipBufferOrCacheSize, writerFlags, ByteOrder.nativeOrder())); } localTerms[0] = new PrintWriter(new BufferedWriter(new OutputStreamWriter( new FileOutputStream(localBasename[0] + DiskBasedIndex.TERMS_EXTENSION), "UTF-8"))); terms = new FastBufferedReader(new InputStreamReader( new FileInputStream(inputBasename + DiskBasedIndex.TERMS_EXTENSION), "UTF-8")); }
From source file:ch.admin.suis.msghandler.util.FileUtils.java
/** * Checks if the path is an existing directory. * <br />Used to validate configuration values. * * @param path The path/*from w w w. ja va 2 s . c o m*/ */ public static void isDirectory(File path, String helpText) throws ConfigurationException { if (path == null) { throwNullPointer(helpText); } if (!path.exists() || !path.isDirectory()) { throw new ConfigurationException("Directory: " + path.getAbsolutePath() + " either not exist or is not a directory. Param Name: " + helpText); } }
From source file:jdbc.pool.CXMLManager.java
/** * Returns the Pool Attributes stored in the XML file against the specified index. * * @param index//from w ww . ja v a 2s . c o m * @return CPoolAtribute * @throws ConfigurationException */ private CPoolAttribute getPoolAttribute(int index) throws ConfigurationException { CPoolAttribute attribute; attribute = new CPoolAttribute(); attribute.setPoolName(xmlPoolConfig.getString("pool(" + index + ")[@name]")); if (logger_.isDebugEnabled()) { logger_.debug("Reading attributes for pool #" + attribute.getPoolName()); } attribute.setDriver(xmlPoolConfig.getString("pool(" + index + ")[@driver]")); attribute.setVendor(xmlPoolConfig.getString("pool(" + index + ")[@vendor]")); attribute.setURL(xmlPoolConfig.getString("pool(" + index + ")[@url]")); attribute.setUser(xmlPoolConfig.getString("pool(" + index + ")[@user]")); attribute.setPassword(xmlPoolConfig.getString("pool(" + index + ")[@password]")); attribute.setInitialPoolSize(xmlPoolConfig.getInt("pool(" + index + ")[@initial-connections]")); attribute.setCapacityIncreament(xmlPoolConfig.getInt("pool(" + index + ")[@capacity-increament]")); attribute.setMaximumCapacity(xmlPoolConfig.getInt("pool(" + index + ")[@maximum-capacity]")); attribute.setConnectionIdleTimeout(xmlPoolConfig.getInt("pool(" + index + ")[@inactive-time-out]")); attribute.setShrinkPoolInterval(xmlPoolConfig.getInt("pool(" + index + ")[@shrink-pool-interval]")); attribute.setCriticalOperationTimeLimit( xmlPoolConfig.getInt("pool(" + index + ")[@critical-operation-time-limit]")); try { attribute.setInUseWaitTime(xmlPoolConfig.getInt("pool(" + index + ").in-use-wait-time")); } catch (NoSuchElementException e) { attribute.setInUseWaitTime(-1); } try { attribute.setLoadOnStartup(xmlPoolConfig.getBoolean("pool(" + index + ").load-on-startup")); } catch (NoSuchElementException nsee) { attribute.setLoadOnStartup(false); } try { attribute.setMaxUsagePerJDBCConnection( xmlPoolConfig.getInt("pool(" + index + ").max-usage-per-jdbc-connection")); if (attribute.getMaxUsagePerJDBCConnection() >= 0 && attribute.getMaxUsagePerJDBCConnection() < 2) { logger_.log(LogLevel.NOTICE, "Pool attribute max-usage-per-jdbc-connection defaulted to -1 for pool #" + attribute.getPoolName()); attribute.setMaxUsagePerJDBCConnection(-1); attribute.setToBeSaved(true); } } catch (NoSuchElementException nsee) { attribute.setMaxUsagePerJDBCConnection(-1); attribute.setToBeSaved(true); } try { attribute.setPoolAlgorithm(xmlPoolConfig.getString("pool(" + index + ").pool-algorithm")); } catch (NoSuchElementException nsee) { attribute.setPoolAlgorithm(IPool.FIFO_ALGORITHM); attribute.setToBeSaved(true); } try { attribute.setStatisticalHistoryRecordCount( xmlPoolConfig.getInt("pool(" + index + ").inmemory-statistics-history-size")); } catch (NoSuchElementException nsee) { attribute.setStatisticalHistoryRecordCount(1); attribute.setToBeSaved(true); } try { String sqlQuery = xmlPoolConfig.getString("pool(" + index + ").sql-query"); if (sqlQuery == null || "1".equals(sqlQuery)) { throw new IllegalArgumentException("sql-query element has to be defined"); } attribute.setSqlQuery(sqlQuery); } catch (NoSuchElementException nsee) { throw new ConfigurationException("sql-query element has to be defined."); } if (logger_.isDebugEnabled()) { logger_.debug("Pool Attributes read for pool #" + attribute.getPoolName()); } return attribute; }
From source file:ch.admin.suis.msghandler.util.FileUtils.java
private static void throwNullPointer(String helpText) throws ConfigurationException { throw new ConfigurationException("A required configuration parameter is not set. Param Name: " + helpText); }
From source file:jdbc.pool.CXMLManager.java
protected boolean create(CPoolAttribute attribute) throws ConfigurationException { int iSize = xmlPoolConfig.getMaxIndex("pool[@name]"); if (logger_.isDebugEnabled()) { logger_.debug("Validating Pool Existance"); }//from w ww. ja v a 2 s .c om for (int i = 0; i <= iSize; i++) { if (xmlPoolConfig.getString("pool(" + i + ")[@name]").equals(attribute.getPoolName())) { throw new ConfigurationException( "Pool Configuration Already Created. Unable to create a new configuration."); } } if (logger_.isDebugEnabled()) { logger_.debug("Pool does not exist."); logger_.debug("Creating new pool [in-memory] #" + attribute.getPoolName()); } iSize++; //Increment the iSize by 1 as we are adding a new element. xmlPoolConfig.addProperty("pool(-1)[@name]", attribute.getPoolName()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@driver]", attribute.getDriver()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@vendor]", attribute.getVendor()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@url]", attribute.getURL()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@user]", attribute.getUser()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@password]", attribute.getPassword()); xmlPoolConfig.addProperty("pool(" + iSize + ")[@initial-connections]", attribute.getInitialPoolSize() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ")[@capacity-increament]", attribute.getCapacityIncreament() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ")[@maximum-capacity]", attribute.getMaximumCapacity() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ")[@inactive-time-out]", attribute.getConnectionIdleTimeout() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ")[@shrink-pool-interval]", attribute.getShrinkPoolInterval() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ")[@critical-operation-time-limit]", attribute.getCriticalOperationTimeLimit() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ").in-use-wait-time", attribute.getInUseWaitTime() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ").load-on-startup", (attribute.isLoadOnStartup() ? "true" : "false")); xmlPoolConfig.addProperty("pool(" + iSize + ").max-usage-per-jdbc-connection", attribute.getMaxUsagePerJDBCConnection() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ").pool-algorithm", attribute.getPoolAlgorithm()); xmlPoolConfig.addProperty("pool(" + iSize + ").inmemory-statistics-history-size", attribute.getStatisticalHistoryRecordCount() + ""); xmlPoolConfig.addProperty("pool(" + iSize + ").sql-query", attribute.getSqlQuery() + ""); if (logger_.isDebugEnabled()) { logger_.debug("Pool created [in-memory] #" + attribute.getPoolName()); } return true; }