Refine search
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(); 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()); 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());
private void run() { try { logger.info("Running distributedlog server : args = {}", Arrays.toString(args)); BasicParser parser = new BasicParser(); CommandLine cmdline = parser.parse(options, args); runCmd(cmdline); } catch (ParseException pe) { logger.error("Argument error : {}", pe.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (IllegalArgumentException iae) { logger.error("Argument error : {}", iae.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (ConfigurationException ce) { logger.error("Configuration error : {}", ce.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (IOException ie) { logger.error("Failed to start distributedlog server : ", ie); Runtime.getRuntime().exit(-1); } }
public static void storeConfiguration(final String fileName) throws IOException { try { PropertiesConfiguration.setDefaultListDelimiter('\0'); final PropertiesConfiguration config = new PropertiesConfiguration(); // store settings for (final Setting setting : settings.values()) { // story only modified settings and the super user password if (setting.isModified() || "superuser.password".equals(setting.getKey())) { config.setProperty(setting.getKey(), setting.getValue()); } } config.save(fileName); } catch (ConfigurationException ex) { System.err.println("Unable to store configuration: " + ex.getMessage()); } }
public static final Configuration getAppconfigFromClasspath() { Configuration appconfig; try { ClassLoader classLoader = GraphDatabaseBenchmark.class.getClassLoader(); URL resource = classLoader.getResource(DEFAULT_INPUT_PROPERTIES); appconfig = new PropertiesConfiguration(resource); } catch (ConfigurationException e) { throw new IllegalArgumentException(String.format( "Unable to load properties file from classpath because %s", e.getMessage())); } return appconfig; }
/** * 获取配置信息 */ public static PropertiesConfiguration getConfig() { try { return new PropertiesConfiguration("generator.properties" ); } catch (ConfigurationException e) { e.printStackTrace(); } return null; } }
private void writeToPropertiesFile(Configuration conf, File file) { try { PropertiesConfiguration propConf = new PropertiesConfiguration(file); propConf.append(conf); propConf.save(); } catch (ConfigurationException ex) { throw new RuntimeException("Failed writing Titan config to " + file.getAbsolutePath() + ": " + ex.getMessage(), ex); } }
/** * Initialize and read out properties from filename. * * @param filename * Name of the properties file. * @throws ConfigurationException * On errors in properties file. */ public PropertiesFile(String filename) throws ConfigurationException { config = new CrawljaxConfiguration(); File f = new File(filename); if (!f.exists()) { throw new ConfigurationException("Configuration file not found: " + filename); } read(new PropertiesConfiguration(filename)); }
public static void loadConfiguration(final String fileName) { try { PropertiesConfiguration.setDefaultListDelimiter('\0'); final PropertiesConfiguration config = new PropertiesConfiguration(fileName); final Iterator<String> keys = config.getKeys(); while (keys.hasNext()) { final String key = keys.next(); final String value = trim(config.getString(key)); Setting<?> setting = Settings.getSetting(key); if (setting != null) { setting.fromString(value); } else { SettingsGroup targetGroup = miscGroup; // put key in cron group if it contains ".cronExpression" if (key.contains(".cronExpression")) { targetGroup = cronGroup; } // create new StringSetting for unknown key Settings.createSettingForValue(targetGroup, key, value); } } } catch (ConfigurationException ex) { System.err.println("Unable to load configuration: " + ex.getMessage()); } }
public static InMemorySenseiService valueOf(File confDir) { try { JSONObject schema = SenseiServerBuilder.loadSchema(confDir); File senseiConfFile = new File(confDir, SenseiServerBuilder.SENSEI_PROPERTIES); if (!senseiConfFile.exists()) { throw new ConfigurationException("configuration file: " + senseiConfFile.getAbsolutePath() + " does not exist."); } Configuration senseiConf = new PropertiesConfiguration(); ((PropertiesConfiguration) senseiConf).setDelimiterParsingDisabled(true); ((PropertiesConfiguration) senseiConf).load(senseiConfFile); return new InMemorySenseiService(SenseiSchema.build(schema), SenseiPluginRegistry.build(senseiConf)); } catch (Exception ex) { throw new RuntimeException(ex); } }
try(FileInputStream db_prop_fstream = new FileInputStream(dbPropsFile);) { dbProps.load(db_prop_fstream); backupDBProps = new PropertiesConfiguration(dbPropsFile); } catch (FileNotFoundException e) { System.out.println("db.properties file not found while reading DB secret key" + e.getMessage()); System.out.println("Error while reading DB secret key from db.properties" + e.getMessage()); } catch (ConfigurationException e) { e.printStackTrace(); backupDBProps.save(); } catch (ConfigurationException e) { e.printStackTrace();
private void checkRequiredKeys() throws ConfigurationException { for (String keyString : REQUIRED_KEYS) { if (!_queryExecutorConfig.containsKey(keyString)) { throw new ConfigurationException("Cannot find required key : " + keyString); } } }
public void setProperty(String key, Object val) { propertiesConfiguration.setProperty(key, val); try { propertiesConfiguration.save(); } catch (ConfigurationException e) { e.printStackTrace(); } }
public void save(UserAccount user) { Configuration userConfig = getUserConfiguration(user); if (userConfig instanceof PropertiesConfiguration) { try { ((PropertiesConfiguration) userConfig).save(); } catch (ConfigurationException e) { log.error("could not save user configuration for user #0: #1", user.getLogin(), e.getMessage()); } } }
public SenseiServerBuilder(PropertiesConfiguration configuration) throws Exception { _senseiConfFile = configuration.getFile(); if (!_senseiConfFile.exists()) { throw new ConfigurationException("configuration file: " + _senseiConfFile.getAbsolutePath() + " does not exist."); } _senseiConf = configuration; pluginRegistry = SenseiPluginRegistry.build(_senseiConf); pluginRegistry.start(); processRelevanceFunctionPlugins(pluginRegistry); processRelevanceExternalObjectPlugins(pluginRegistry); _gateway = pluginRegistry.getBeanByFullPrefix(SENSEI_GATEWAY, SenseiGateway.class); _schemaDoc = loadSchema(_senseiConfFile.getParentFile()); _senseiSchema = SenseiSchema.build(_schemaDoc); }
public static void initialize() { try { propertiesContext = new PropertiesContext(PATH); } catch (ConfigurationException e) { e.printStackTrace(); } }
public void reload() { commonProperties.configurationChanged(); targetEnvironmentProps.configurationChanged(); connectors.configurationChanged(); oauth.configurationChanged(); lastCommitProperties.configurationChanged(); bodytrackProperties.configurationChanged(); try { commonProperties.refresh(); targetEnvironmentProps.refresh(); connectors.refresh(); oauth.refresh(); lastCommitProperties.refresh(); bodytrackProperties.refresh(); setBodytrackProperties(bodytrackProperties); } catch (ConfigurationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
@Override public void log(String testName, String pluginName, String pluginVersion) { PropertiesConfiguration config = null; try { config = new PropertiesConfiguration(file); } catch (ConfigurationException e) { LOGGER.error(e.getMessage()); return; } config.setProperty(testName + "$" + pluginName, pluginVersion); try { config.save(); } catch (ConfigurationException e) { LOGGER.error(e.getMessage()); return; } } }
/** * * @param propertiesFile * @param prefix * @throws SLIB_Ex_Critic */ public ModuleCst(String propertiesFile, String prefix) throws SLIB_Ex_Critic { Configuration config; try { config = new PropertiesConfiguration(propertiesFile); } catch (ConfigurationException ex) { throw new SLIB_Ex_Critic("Unable to load configuration file (properties) "+ex.getMessage()); } this.appName = config.getString(prefix+".name"); this.version = config.getString(prefix+".version"); this.reference = config.getString(prefix+".reference"); this.description = config.getString(prefix+".description"); this.contact = config.getString(prefix+".contact"); this.versionSnapshot = config.getString(prefix+".build.snapshot"); }
public static void init(String configFilePath) { try { defultConfigFilePath = configFilePath; config = new PropertiesConfiguration(defultConfigFilePath); } catch (ConfigurationException e) { e.printStackTrace(); } }
private void writeToPropertiesFile(Configuration conf, File file) { try { PropertiesConfiguration propConf = new PropertiesConfiguration(file); propConf.append(conf); propConf.save(); } catch (ConfigurationException ex) { throw new RuntimeException("Failed writing Titan config to " + file.getAbsolutePath() + ": " + ex.getMessage(), ex); } }