public static DdbConfig load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("ddb"); String jbossHost = config.getStringProperty("jbossHost"); String jbossPort = config.getStringProperty("jbossPort"); String jbossUserName = config.getStringProperty("jbossUserName"); String jbossPassword = config.getStringProperty("jbossPassword"); return new DdbConfig(jbossHost, jbossPort, jbossUserName, jbossPassword); }
public static DdbConfig load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("ddb"); String jbossHost = config.getStringProperty("jbossHost"); String jbossPort = config.getStringProperty("jbossPort"); String jbossUserName = config.getStringProperty("jbossUserName"); String jbossPassword = config.getStringProperty("jbossPassword"); return new DdbConfig(jbossHost, jbossPort, jbossUserName, jbossPassword); }
public static DdbConfig load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("ddb"); String jbossHost = config.getStringProperty("jbossHost"); String jbossPort = config.getStringProperty("jbossPort"); String jbossUserName = config.getStringProperty("jbossUserName"); String jbossPassword = config.getStringProperty("jbossPassword"); return new DdbConfig(jbossHost, jbossPort, jbossUserName, jbossPassword); }
public static HistoDbConfig load(String moduleName) { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig(moduleName); String histoDbHost = config.getStringProperty("histoDbHost"); int histoDbPort = config.getIntProperty("histoDbPort"); String histoDbUserName = config.getStringProperty("histoDbUserName"); String histoDbPassword = config.getStringProperty("histoDbPassword"); ConnectionParameters proxyParameters = null; String proxyHost = config.getStringProperty("proxyHost", null); if (proxyHost != null) { int proxyPort = config.getIntProperty("proxyPort"); String proxyUserName = config.getStringProperty("proxyUserName"); String proxyPassword = config.getStringProperty("proxyPassword"); proxyParameters = new ConnectionParameters(proxyHost, proxyPort, proxyUserName, proxyPassword); } String histoDbStoreName = config.getStringProperty("histoDbStoreName"); String histoDbSourceName = config.getStringProperty("histoDbSourceName", null); return new HistoDbConfig(new ConnectionParameters(histoDbHost, histoDbPort, histoDbUserName, histoDbPassword), proxyParameters, histoDbStoreName, histoDbSourceName); }
public static void setProxy() { try { URLConnection connection = new URL("http://www.google.com").openConnection(); connection.setConnectTimeout(1000); connection.connect(); } catch (IOException e) { // get proxy config PlatformConfig.defaultConfig().getOptionalModuleConfig("proxy") .ifPresent(proxyConfig -> { String host = proxyConfig.getStringProperty("host"); int port = proxyConfig.getIntProperty("port"); String user = proxyConfig.getStringProperty("user"); String password = proxyConfig.getStringProperty("password"); LOGGER.info("Set proxy host={}, port={}, user={}", host, port, user); System.getProperties().put("http.proxyHost", host); System.getProperties().put("http.proxyPort", Integer.toString(port)); Authenticator.setDefault( new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password.toCharArray()); } } ); }); } } }
private static void load(ModuleConfig moduleConfig, OptionalInt num, List<LocalAppFileSystemConfig> configs) { StringBuilder driveNameTag = new StringBuilder("drive-name"); StringBuilder rootDirTag = new StringBuilder("root-dir"); StringBuilder remotelyAccessibleTag = new StringBuilder("remotely-accessible"); num.ifPresent(value -> { driveNameTag.append("-").append(value); rootDirTag.append("-").append(value); remotelyAccessibleTag.append("-").append(value); }); if (moduleConfig.hasProperty(driveNameTag.toString()) && moduleConfig.hasProperty(rootDirTag.toString())) { String driveName = moduleConfig.getStringProperty(driveNameTag.toString()); boolean remotelyAccessible = moduleConfig.getBooleanProperty(remotelyAccessibleTag.toString(), DEFAULT_REMOTELY_ACCESSIBLE); Path rootDir = moduleConfig.getPathProperty(rootDirTag.toString()); configs.add(new LocalAppFileSystemConfig(driveName, remotelyAccessible, rootDir)); } }
public HistoDbConfiguration() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("histodb-server"); mapDb.setPersistent(config.getBooleanProperty("persistent")); mapDb.setBasedir(config.getStringProperty("basedir")); formatter.setSeparator(config.getStringProperty("separator", ";").charAt(0)); formatter.setLocale(config.getStringProperty("locale")); server.setHost(config.getStringProperty("host")); server.setPort(config.getIntProperty("port", 8080)); ssl.setKeyStoreType(config.getStringProperty("keyStoreType")); ssl.setKeyStore(config.getStringProperty("keyStore")); ssl.setKeyStorePassword(config.getStringProperty("keyStorePassword")); ssl.setKeyAlias(config.getStringProperty("keyAlias")); security.setUsername(config.getStringProperty("username")); security.setPassword(config.getStringProperty("password")); }
public static synchronized DymolaConfig load() { if (INSTANCE == null) { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("dymola"); String dymolaSeviceWSDL = config.getStringProperty("dymolaSeviceWSDL", null); Path indexesBinDir = config.getPathProperty("indexesBinDir", null); int simTimeout = config.getIntProperty("simTimeout", SIM_DEFAULT_TIMEOUT); int idxTimeout = config.getIntProperty("idxTimeout", IDX_DEFAULT_TIMEOUT); boolean debug = config.getBooleanProperty("debug", false); String modelicaVersion = config.getStringProperty("modelicaVersion"); String sourceEngine = config.getStringProperty("sourceEngine"); String sourceEngineVersion = config.getStringProperty("sourceEngineVersion"); String modelicaPowerSystemLibraryFile = config.getStringProperty("modelicaPowerSystemLibraryFile"); boolean fakeDymolaExecution = config.getBooleanProperty("fakeDymolaExecution", false); String indexesNames = config.getStringProperty("indexesNames"); String slackId = config.getStringProperty("slackId", null); Class<? extends LoadFlowFactory> loadFlowFactoryClass = config.getClassProperty("loadFlowFactoryClass", LoadFlowFactory.class); INSTANCE = new DymolaConfig(dymolaSeviceWSDL, indexesBinDir, simTimeout, idxTimeout, debug, modelicaVersion, sourceEngine, sourceEngineVersion, modelicaPowerSystemLibraryFile, fakeDymolaExecution, indexesNames, slackId, loadFlowFactoryClass); } return INSTANCE; }
public static ExternalSecurityAnalysisConfig load(PlatformConfig platformConfig) { return platformConfig.getOptionalModuleConfig("external-security-analysis-config") .map(module -> { boolean debug = module.getBooleanProperty("debug", DEFAULT_DEBUG); String itoolsCommand = module.getStringProperty("itools-command", DEFAULT_COMMAND); return new ExternalSecurityAnalysisConfig(debug, itoolsCommand); }) .orElseGet(() -> new ExternalSecurityAnalysisConfig(DEFAULT_DEBUG, DEFAULT_COMMAND)); } }
public static EurostagStepUpTransformerConfig load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig(EurostagStepUpTransformerPostProcessor.class.getSimpleName()); List<Path> ddbPath = config.getPathListProperty("ddbPath"); String genDictFileName = config.getStringProperty("genDict"); String auxDictFileName = config.getStringProperty("auxDict"); String statorVoltageLevelsFileName = config.getStringProperty("statorVoltageLevelsFileName"); Class<? extends LoadFlowFactory> loadFlowFactoryClass = config.getClassProperty("loadFlowFactoryClass", LoadFlowFactory.class); boolean moveAux = config.getBooleanProperty("moveAux", DEFAULT_MOVE_AUX); boolean noReactiveLimits = config.getBooleanProperty("noReactiveLimits", DEFAULT_NO_REACTIVE_LIMITS); boolean noActiveLosses = config.getBooleanProperty("noActiveLosses", DEFAULT_NO_ACTIVE_LOSSES); boolean removeAlreadyExistingStators = config.getBooleanProperty("removeAlreadyExistingStators", DEFAULT_REMOVE_ALREADY_EXISTING_STATORS); return new EurostagStepUpTransformerConfig(ddbPath, genDictFileName, auxDictFileName, statorVoltageLevelsFileName, loadFlowFactoryClass, moveAux, noReactiveLimits, noActiveLosses, removeAlreadyExistingStators); }
public static OfflineUIConfig load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("offlineui"); String jmxHost = config.getStringProperty("jmxHost"); int jmxPort = config.getIntProperty("jmxPort"); return new OfflineUIConfig(jmxHost, jmxPort); }
public static EurostagEchExportConfig load(PlatformConfig platformConfig) { // specificCompatibility parameter = true forces svcAsFixedInjectionInLF to true ModuleConfig loadFlowModuleConfig = platformConfig.getModuleConfigIfExists("load-flow-default-parameters"); boolean specificCompatibility = (loadFlowModuleConfig != null) ? loadFlowModuleConfig.getBooleanProperty("specificCompatibility", DEFAULT_SPECIFIC_COMPATIBILITY) : DEFAULT_SPECIFIC_COMPATIBILITY; if (platformConfig.moduleExists(EUROSTAG_ECH_EXPORT_CONFIG)) { ModuleConfig config = platformConfig.getModuleConfig(EUROSTAG_ECH_EXPORT_CONFIG); boolean noGeneratorMinMaxQ = config.getBooleanProperty("noGeneratorMinMaxQ", DEFAULT_NOGENERATORMINMAXQ); boolean noSwitch = config.getBooleanProperty("noSwitch", DEFAULT_NOSWITCH); boolean svcAsFixedInjectionInLF = config.getBooleanProperty("svcAsFixedInjectionInLF", DEFAULT_SVC_AS_FIXED_INJECTION_IN_LF); String forbiddenCharacters = config.getStringProperty("forbiddenCharacters", DEFAULT_FORBIDDEN_CHARACTERS); String replacementCharString = config.getStringProperty("forbiddenCharactersReplacement", DEFAULT_FORBIDDEN_CHARACTERS_REPLACEMENT.toString()); if (replacementCharString.length() != 1) { throw new IllegalArgumentException("forbiddenCharactersReplacement must be a single character: " + replacementCharString); } Character forbiddenCharactersReplacement = replacementCharString.charAt(0); boolean exportMainCCOnly = config.getBooleanProperty("exportMainCCOnly", DEFAULT_EXPORT_MAIN_CC_ONLY); return new EurostagEchExportConfig(noGeneratorMinMaxQ, noSwitch, forbiddenCharacters, forbiddenCharactersReplacement, svcAsFixedInjectionInLF, specificCompatibility, exportMainCCOnly); } else { LOGGER.warn("no eurostag-ech-export config found: Using defaults."); return new EurostagEchExportConfig(DEFAULT_NOGENERATORMINMAXQ, DEFAULT_NOSWITCH, DEFAULT_FORBIDDEN_CHARACTERS, DEFAULT_FORBIDDEN_CHARACTERS_REPLACEMENT, DEFAULT_SVC_AS_FIXED_INJECTION_IN_LF, specificCompatibility, DEFAULT_EXPORT_MAIN_CC_ONLY); } }
public static ForecastErrorsAnalysisParameters load() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("fea-parameters"); DateTime baseCaseDate = DateTime.parse(config.getStringProperty("baseCaseDate")); Interval histoInterval = Interval.parse(config.getStringProperty("histoInterval")); String feAnalysisId = config.getStringProperty("feAnalysisId"); double ir = config.getDoubleProperty("ir"); Integer flagPQ = config.getIntProperty("flagPQ"); Integer method = config.getIntProperty("method"); Integer nClusters = config.getIntProperty("nClusters"); double percentileHistorical = config.getDoubleProperty("percentileHistorical"); Integer modalityGaussian = config.getOptionalIntegerProperty("modalityGaussian").orElse(null); Integer outliers = config.getOptionalIntegerProperty("outliers").orElse(null); Integer conditionalSampling = config.getOptionalIntegerProperty("conditionalSampling").orElse(null); Integer nSamples = config.getIntProperty("nSamples"); Set<Country> countries = config.getEnumSetProperty("countries", Country.class, DEFAULT_COUNTRIES); CaseType caseType = config.getEnumProperty("caseType", CaseType.class, DEFAULT_CASE_TYPE); boolean allInjections = config.getBooleanProperty("all-injections", DEFAULT_ALL_INJECTIONS); return new ForecastErrorsAnalysisParameters(baseCaseDate, histoInterval, feAnalysisId, ir, flagPQ, method, nClusters, percentileHistorical, modalityGaussian, outliers, conditionalSampling, nSamples, countries, caseType, allInjections); }
public Object getValue(String format, Parameter parameter) { Objects.requireNonNull(format); Objects.requireNonNull(parameter); String name = format + "_" + parameter.getName(); ModuleConfig moduleConfig = getModuleConfig(); switch (parameter.getType()) { case BOOLEAN: { boolean defaultValue = (Boolean) parameter.getDefaultValue(); return moduleConfig != null ? moduleConfig.getBooleanProperty(name, defaultValue) : defaultValue; } case STRING: { String defaultValue = (String) parameter.getDefaultValue(); return moduleConfig != null ? moduleConfig.getStringProperty(name, defaultValue) : defaultValue; } case STRING_LIST: { List<String> defaultValue = (List<String>) parameter.getDefaultValue(); return moduleConfig != null ? moduleConfig.getStringListProperty(name, defaultValue) : defaultValue; } default: throw new AssertionError(); } }
public static WCAConfig load(PlatformConfig platformConfig) { ModuleConfig config = platformConfig.getModuleConfig("wca"); Path xpressHome = config.getPathProperty("xpressHome"); float reducedVariableRatio = config.getFloatProperty("reducedVariableRatio", DEFAULT_REDUCED_VARIABLE_RATIO); boolean debug = config.getBooleanProperty("debug", DEFAULT_DEBUG); boolean exportStates = config.getBooleanProperty("exportStates", DEFAULT_EXPORT_STATE); Set<WCARestrictingThresholdLevel> restrictingThresholdLevels = config.getEnumSetProperty("restrictingThresholdLevels", WCARestrictingThresholdLevel.class, DEFAULT_RESTRICTING_THRESHOLD_LEVELS); float margin = Float.parseFloat(config.getStringProperty("margin", Float.toString(DEFAULT_MARGIN))); boolean ignoreVoltageConstraints = config.getBooleanProperty("ignoreVoltageConstraints", DEFAULT_IGNORE_VOLTAGE_CONSTRAINTS); boolean activateFiltering = config.getBooleanProperty("activateFiltering", DEFAULT_ACTIVATE_FILTERING); WCAPreventiveActionsFilter preventiveActionsFilter = config.getEnumProperty("preventiveActionsFilter", WCAPreventiveActionsFilter.class, DEFAULT_PREVENTIVE_ACTIONS_FILTER); WCAPreventiveActionsOptimizer preventiveActionsOptimizer = config.getEnumProperty("preventiveActionsOptimizer", WCAPreventiveActionsOptimizer.class, DEFAULT_PREVENTIVE_ACTIONS_OPTIMIZER); boolean applyPreventiveActions = config.getBooleanProperty("applyPreventiveActions", DEFAULT_APPLY_PREVENTIVE_ACTIONS); WCACurativeActionsOptimizer curativeActionsOptimizer = config.getEnumProperty("curativeActionsOptimizer", WCACurativeActionsOptimizer.class, DEFAULT_CURATIVE_ACTIONS_OPTIMIZER); float voltageLevelConstraintFilter = Float.parseFloat(config.getStringProperty("voltageLevelConstraintFilter", Float.toString(DEFAULT_VOLTAGE_LEVEL_CONSTRAINTS_FILTER))); Set<Country> countryConstraintFilter = config.getEnumSetProperty("countryConstraintFilter", Country.class, new HashSet<Country>(DEFAULT_COUNTRY_CONSTRAINTS_FILTER)); boolean filterPreventiveActions = config.getBooleanProperty("filterPreventiveActions", DEFAULT_FILTER_PREVENTIVE_ACTIONS); boolean filterCurativeActions = config.getBooleanProperty("filterCurativeActions", DEFAULT_FILTER_CURATIVE_ACTIONS); boolean loosenConstraints = config.getBooleanProperty("loosenConstraints", DEFAULT_LOOOSEN_CONSTRAINTS); return new WCAConfig(xpressHome, reducedVariableRatio, debug, exportStates, restrictingThresholdLevels, margin, ignoreVoltageConstraints, activateFiltering, preventiveActionsFilter, preventiveActionsOptimizer, applyPreventiveActions, curativeActionsOptimizer, voltageLevelConstraintFilter, countryConstraintFilter, filterPreventiveActions, filterCurativeActions, loosenConstraints); }
public static synchronized DymolaSimulationConfig load() { if (INSTANCE == null) { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("dymola-simulation"); int numberOfIntervals = config.getIntProperty("numberOfIntervals", 0); double outputInterval = config.getDoubleProperty("outputInterval", 0.0); String method = config.getStringProperty("method", "Lsodar"); double tolerance = config.getDoubleProperty("tolerance", 0.0001); double outputFixedstepSize = config.getDoubleProperty("fixedStepSize", 0.0); INSTANCE = new DymolaSimulationConfig(numberOfIntervals, outputInterval, method, tolerance, outputFixedstepSize); } return INSTANCE; }
public static OnlineWorkflowStartParameters loadDefault() { ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("online-start-parameters"); int threads = config.getIntProperty("threads", DEFAULT_THREADS); String jmxHost = config.getStringProperty("jmxHost"); int jmxPort = config.getIntProperty("jmxPort"); Class<? extends OnlineWorkflowFactory> onlineWorkflowFactory = config.getClassProperty("onlineWorkflowFactoryClass", OnlineWorkflowFactory.class, OnlineWorkflowFactoryImpl.class); Class<? extends OnlineApplicationListenerFactory> listenerFactoryClass = config.getClassProperty("listenerFactoryClasses", OnlineApplicationListenerFactory.class, null); return new OnlineWorkflowStartParameters(threads, jmxHost, jmxPort, listenerFactoryClass, onlineWorkflowFactory); }
@Test public void properties2XmlConvertionTest() throws IOException, XMLStreamException { try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) { Path cfgDir = Files.createDirectory(fileSystem.getPath("config")); Properties prop1 = new Properties(); prop1.setProperty("a", "hello"); prop1.setProperty("b", "bye"); try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod1.properties"), StandardCharsets.UTF_8)) { prop1.store(w, null); } Properties prop2 = new Properties(); prop2.setProperty("c", "thanks"); try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod2.properties"), StandardCharsets.UTF_8)) { prop2.store(w, null); } PlatformConfig propsConfig = new PlatformConfig(new PropertiesModuleConfigRepository(cfgDir), cfgDir); assertEquals("hello", propsConfig.getModuleConfig("mod1").getStringProperty("a")); assertEquals("bye", propsConfig.getModuleConfig("mod1").getStringProperty("b")); assertEquals("thanks", propsConfig.getModuleConfig("mod2").getStringProperty("c")); Path xmlConfigFile = cfgDir.resolve("config.xml"); PropertiesModuleConfigRepository.writeXml(cfgDir, xmlConfigFile); PlatformConfig xmlConfig = new PlatformConfig(new XmlModuleConfigRepository(xmlConfigFile), cfgDir); assertEquals("hello", xmlConfig.getModuleConfig("mod1").getStringProperty("a")); assertEquals("bye", xmlConfig.getModuleConfig("mod1").getStringProperty("b")); assertEquals("thanks", xmlConfig.getModuleConfig("mod2").getStringProperty("c")); } }
@Test public void test() { StackedModuleConfigRepository stackedRepository = new StackedModuleConfigRepository(createRepository2(), createRepository1()); ModuleConfig config1 = stackedRepository.getModuleConfig("config1").orElse(null); assertNotNull(config1); assertEquals("newValue1", config1.getStringProperty("key1")); assertEquals("value2", config1.getStringProperty("key2")); } }
public static synchronized EurostagConfig load(PlatformConfig platformConfig) { ModuleConfig config = platformConfig.getModuleConfig("eurostag"); Path eurostagHomeDir = config.getPathProperty("eurostagHomeDir", null); Path indexesBinDir = config.getPathProperty("indexesBinDir", null); boolean lfNoGeneratorMinMaxQ = config.getBooleanProperty("lfNoGeneratorMinMaxQ", false); int lfTimeout = config.getIntProperty("lfTimeout", LF_DEFAULT_TIMEOUT); int simTimeout = config.getIntProperty("simTimeout", SIM_DEFAULT_TIMEOUT); int idxTimeout = config.getIntProperty("idxTimeout", IDX_DEFAULT_TIMEOUT); int lfMaxNumIteration = config.getIntProperty("lfMaxNumIteration", DEFAULT_LF_MAX_NUM_ITERATION); double minimumStep = config.getDoubleProperty("minimumStep", DEFAULT_MINIMUM_STEP); boolean lfWarmStart = config.getBooleanProperty("lfWarmStart", DEFAULT_LF_WARM_START); boolean useBroadcast = config.getBooleanProperty("useBroadcast", DEFAULT_USE_BROADCAST); boolean ddbCaching = config.getBooleanProperty("ddbCaching", DEFAULT_DDB_CACHING); double minStepAtEndOfStabilization = config.getDoubleProperty("minStepAtEndOfStabilization", DEFAULT_MIN_STEP_AT_END_OF_STABILIZATION); boolean debug = config.getBooleanProperty("debug", false); String eurostagCptCommandName = config.getStringProperty("eurostagCptCommandName", DEFAULT_EUROSTAG_CMD_NAME); return new EurostagConfig(eurostagHomeDir, indexesBinDir, lfNoGeneratorMinMaxQ, lfTimeout, simTimeout, idxTimeout, lfMaxNumIteration, minimumStep, lfWarmStart, useBroadcast, ddbCaching, minStepAtEndOfStabilization, debug, eurostagCptCommandName); }