List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.rhq.server.control.command.Upgrade.java
private void upgradeServerPropertiesFile(CommandLine commandLine) throws Exception { File oldServerDir = getFromServerDir(commandLine); File oldServerPropsFile = new File(oldServerDir, "bin/rhq-server.properties"); Properties oldServerProps = new Properties(); FileInputStream oldServerPropsFileInputStream = new FileInputStream(oldServerPropsFile); try {/* www .ja va 2 s.com*/ oldServerProps.load(oldServerPropsFileInputStream); } finally { oldServerPropsFileInputStream.close(); } oldServerProps.setProperty("rhq.autoinstall.enabled", "true"); // ensure that we always enable the installer oldServerProps.setProperty("rhq.autoinstall.database", "auto"); // the old value could have been "overwrite" - NOT what we want when upgrading // For upgrades the RHQ Server super-user should already exist. But to pass server properties file validation // this property must be set. Setting it to an invalid plain-text value will fail the upgrade if for some reason // the rhqadmin user does not exist, which is, I think, what we would want to have happen. oldServerProps.setProperty("rhq.autoinstall.server.admin.password", "ignored-on-upgrade"); // remove some old, obsolete settings no longer needed or used oldServerProps.remove("rhq.server.embedded-agent.name"); oldServerProps.remove("rhq.server.embedded-agent.reset-configuration"); oldServerProps.remove("rhq.server.embedded-agent.disable-native-system"); oldServerProps.remove("rhq.server.embedded-agent.enabled"); oldServerProps.remove("rhq.server.startup.jrmpinvoker.rmiport"); oldServerProps.remove("rhq.server.startup.webservice.port"); oldServerProps.remove("rhq.server.startup.unifiedinvoker.port"); oldServerProps.remove("rhq.server.startup.namingservice.rmiport"); oldServerProps.remove("rhq.server.startup.pooledinvoker.rmiport"); oldServerProps.remove("rhq.server.startup.ajp.port"); oldServerProps.remove("rhq.server.startup.namingservice.port"); oldServerProps.remove("rhq.server.startup.aspectdeployer.bind-port"); oldServerProps.remove("rhq.server.plugin-deployer-threads"); oldServerProps.remove("rhq.server.database.xa-datasource-class"); oldServerProps.remove("rhq.server.database.driver-class"); oldServerProps.remove("java.rmi.server.hostname"); // do not set the keystore/truststore algorithms if they are the defaults to allow for runtime defaults to take effect String[] algPropNames = new String[] { "rhq.communications.connector.security.truststore.algorithm", // "rhq.communications.connector.security.keystore.algorithm", // "rhq.server.client.security.keystore.algorithm", // "rhq.server.client.security.truststore.algorithm", // "rhq.server.tomcat.security.algorithm" }; for (String algPropName : algPropNames) { String algValue = oldServerProps.getProperty(algPropName, "SunX509"); if (algValue.equals("SunX509") || algValue.equals("IbmX509")) { oldServerProps.remove(algPropName); // let the default take effect at runtime - which will depend on the JVM } } // the older servers stored the HTTP and HTTPS ports under different names - make sure we reuse those ports with the new properties String httpPort = oldServerProps.getProperty("rhq.server.startup.web.http.port"); if (httpPort != null) { oldServerProps.remove("rhq.server.startup.web.http.port"); oldServerProps.setProperty("rhq.server.socket.binding.port.http", httpPort); } String httpsPort = oldServerProps.getProperty("rhq.server.startup.web.https.port"); if (httpsPort != null) { oldServerProps.remove("rhq.server.startup.web.https.port"); oldServerProps.setProperty("rhq.server.socket.binding.port.https", httpsPort); } //Migrate storage node properties String storageUsername = oldServerProps.getProperty("rhq.cassandra.username"); if (storageUsername != null) { oldServerProps.remove("rhq.cassandra.username"); oldServerProps.setProperty("rhq.storage.username", storageUsername); } String storagePassword = oldServerProps.getProperty("rhq.cassandra.password"); if (storagePassword != null) { // In RHQ 4.8 the Cassandra username/password had to be rhqadmin/rhqadmin; so, // we can safely set rhq.storage.password to the obfuscated version freeing the // user of performing the additional step of generated the obfuscated password. oldServerProps.remove("rhq.cassandra.password"); oldServerProps.setProperty("rhq.storage.password", "1eeb2f255e832171df8592078de921bc"); } String storageSeeds = oldServerProps.getProperty("rhq.cassandra.seeds"); if (storageSeeds != null) { StringBuffer storageNodes = new StringBuffer(); String cqlPort = ""; String[] unparsedNodes = storageSeeds.split(","); for (int index = 0; index < unparsedNodes.length; index++) { String[] params = unparsedNodes[index].split("\\|"); if (params.length == 3) { storageNodes.append(params[0]); if (index < unparsedNodes.length - 1) { storageNodes.append(","); } cqlPort = params[2]; } } oldServerProps.remove("rhq.cassandra.seeds"); oldServerProps.setProperty("rhq.storage.nodes", storageNodes.toString()); oldServerProps.setProperty("rhq.storage.cql-port", cqlPort); } String storageCompression = oldServerProps.getProperty("rhq.cassandra.client.compression-enabled"); if (storageCompression != null) { oldServerProps.remove("rhq.cassandra.client.compression-enabled"); oldServerProps.setProperty("rhq.storage.client.compression-enabled", storageCompression); } // copy the old key/truststore files from the old location to the new server configuration directory copyReferredFile(commandLine, oldServerProps, "rhq.server.tomcat.security.keystore.file"); copyReferredFile(commandLine, oldServerProps, "rhq.server.tomcat.security.truststore.file"); copyReferredFile(commandLine, oldServerProps, "rhq.communications.connector.security.keystore.file"); copyReferredFile(commandLine, oldServerProps, "rhq.communications.connector.security.truststore.file"); copyReferredFile(commandLine, oldServerProps, "rhq.server.client.security.keystore.file"); copyReferredFile(commandLine, oldServerProps, "rhq.server.client.security.truststore.file"); // for oracle, ensure the unused properties are set to unused, otherwise prop file validation may fail String dbType = oldServerProps.getProperty("rhq.server.database.type-mapping"); if (null != dbType && dbType.toLowerCase().contains("oracle")) { oldServerProps.setProperty("rhq.server.database.server-name", "unused"); oldServerProps.setProperty("rhq.server.database.port", "unused"); oldServerProps.setProperty("rhq.server.database.db-name", "unused"); } // now merge the old settings in with the default properties from the new server install String newServerPropsFilePath = getServerPropertiesFile().getAbsolutePath(); PropertiesFileUpdate newServerPropsFile = new PropertiesFileUpdate(newServerPropsFilePath); newServerPropsFile.update(oldServerProps); return; }
From source file:org.cesecore.certificates.ca.catoken.CAToken.java
/** Next sign key becomes current. Current becomes previous. Same goes for KeySequence. CRL sign key is updated if it is the same as cert sign key */ public void activateNextSignKey() { final Properties caTokenProperties = getProperties(); // Replace certificate (and crl) signing key aliases (if present) boolean swichedSigningKey = false; final String nextCertSignKeyLabel = keyStrings.getAlias(CATokenConstants.CAKEYPURPOSE_CERTSIGN_NEXT); if (nextCertSignKeyLabel != null) { final String currentCertSignKeyLabel = keyStrings.getAlias(CATokenConstants.CAKEYPURPOSE_CERTSIGN); final String currentCrlSignKeyLabel = keyStrings.getAlias(CATokenConstants.CAKEYPURPOSE_CRLSIGN); if (log.isDebugEnabled()) { log.debug("CERTSIGN_NEXT: " + nextCertSignKeyLabel); log.debug("CERTSIGN: " + currentCertSignKeyLabel); log.debug("CRLSIGN: " + currentCrlSignKeyLabel); }/*from w ww . ja va2s .co m*/ if (StringUtils.equals(currentCertSignKeyLabel, currentCrlSignKeyLabel)) { log.info("Setting CRL signing key alias to: " + nextCertSignKeyLabel); caTokenProperties.setProperty(CATokenConstants.CAKEYPURPOSE_CRLSIGN_STRING, nextCertSignKeyLabel); } log.info("Setting certificate signing key alias to: " + nextCertSignKeyLabel); caTokenProperties.setProperty(CATokenConstants.CAKEYPURPOSE_CERTSIGN_STRING_PREVIOUS, currentCertSignKeyLabel); caTokenProperties.setProperty(CATokenConstants.CAKEYPURPOSE_CERTSIGN_STRING, nextCertSignKeyLabel); caTokenProperties.remove(CATokenConstants.CAKEYPURPOSE_CERTSIGN_STRING_NEXT); swichedSigningKey = !StringUtils.equals(nextCertSignKeyLabel, currentCertSignKeyLabel); } // Replace key sequence (if present) final String nextKeySequence = caTokenProperties.getProperty(CATokenConstants.NEXT_SEQUENCE_PROPERTY); final String currentKeySequence = getKeySequence(); if (nextKeySequence != null) { if (log.isDebugEnabled()) { log.debug("Current KeySequence: " + getKeySequence()); } log.info("Set key sequence from nextSequence: " + nextKeySequence); caTokenProperties.setProperty(CATokenConstants.PREVIOUS_SEQUENCE_PROPERTY, currentKeySequence); setKeySequence(nextKeySequence); caTokenProperties.remove(CATokenConstants.NEXT_SEQUENCE_PROPERTY); } else if (swichedSigningKey) { // If we did not have a next key sequence before this activation we generate one and push back the current. final String newKeySequence = StringTools.incrementKeySequence(getKeySequenceFormat(), currentKeySequence); caTokenProperties.setProperty(CATokenConstants.PREVIOUS_SEQUENCE_PROPERTY, currentKeySequence); setKeySequence(newKeySequence); } else { // So there is no key sequence and we didn't switch singing key.. // ..let us just set the previous sequence to the current to at least match the singing key alias caTokenProperties.setProperty(CATokenConstants.PREVIOUS_SEQUENCE_PROPERTY, currentKeySequence); } // Store changes in the CAToken's properties setCATokenPropertyData(storeProperties(caTokenProperties)); }
From source file:org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.java
public void doTestQueryMixedServers(boolean partitioned, String oldVersion) throws Exception { final Host host = Host.getHost(0); VM currentServer1 = host.getVM(0);/*from w w w.j a va2s. c o m*/ VM oldServer = host.getVM(oldVersion, 1); VM currentServer2 = host.getVM(2); VM oldServerAndLocator = host.getVM(oldVersion, 3); String regionName = "cqs"; RegionShortcut shortcut = RegionShortcut.REPLICATE; if (partitioned) { shortcut = RegionShortcut.PARTITION; } String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0)); int port = AvailablePortHelper.getRandomAvailableTCPPort(); try { Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); invokeRunnableInVMs(invokeCreateCache(props), currentServer1, currentServer2, oldServer); currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); // oldServer.invoke(invokeAssertVersion(oldOrdinal)); // oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal)); // create region invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServer, oldServerAndLocator); putDataSerializableAndVerify(currentServer1, regionName, 0, 100, currentServer2, oldServer, oldServerAndLocator); query("Select * from /" + regionName + " p where p.timeout > 0L", 99, currentServer1, currentServer2, oldServer, oldServerAndLocator); } finally { invokeRunnableInVMs(invokeCloseCache(), currentServer1, currentServer2, oldServer, oldServerAndLocator); } }
From source file:org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.java
public void doTestTracePRQuery(boolean partitioned, String oldVersion) throws Exception { final Host host = Host.getHost(0); VM currentServer1 = host.getVM(0);// w w w. j a v a 2 s. c o m VM oldServer = host.getVM(oldVersion, 1); VM currentServer2 = host.getVM(2); VM oldServerAndLocator = host.getVM(oldVersion, 3); String regionName = "cqs"; RegionShortcut shortcut = RegionShortcut.REPLICATE; if (partitioned) { shortcut = RegionShortcut.PARTITION; } String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0)); int port = AvailablePortHelper.getRandomAvailableTCPPort(); try { Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); invokeRunnableInVMs(invokeCreateCache(props), currentServer1, currentServer2, oldServer); currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); // oldServer.invoke(invokeAssertVersion(oldOrdinal)); // oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal)); // create region invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServer, oldServerAndLocator); putDataSerializableAndVerify(currentServer1, regionName, 0, 100, currentServer2, oldServer, oldServerAndLocator); query("<trace> Select * from /" + regionName + " p where p.timeout > 0L", 99, currentServer1, currentServer2, oldServer, oldServerAndLocator); } finally { invokeRunnableInVMs(invokeCloseCache(), currentServer1, currentServer2, oldServer, oldServerAndLocator); } }
From source file:org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.java
public void doTestCreateIndexes(boolean createMultiIndexes, boolean partitioned, String oldVersion) throws Exception { final Host host = Host.getHost(0); final VM currentServer1 = host.getVM(0); final VM oldServer = host.getVM(oldVersion, 1); final VM currentServer2 = host.getVM(2); final VM oldServerAndLocator = host.getVM(oldVersion, 3); String regionName = "cqs"; RegionShortcut shortcut = RegionShortcut.REPLICATE; if (partitioned) { shortcut = RegionShortcut.PARTITION; }//from w w w . j a va 2 s . c o m String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0)); int port = AvailablePortHelper.getRandomAvailableTCPPort(); try { Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); invokeRunnableInVMs(invokeCreateCache(props), currentServer1, currentServer2, oldServer); currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); // oldServer.invoke(invokeAssertVersion(oldOrdinal)); // oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal)); // create region invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServer, oldServerAndLocator); putDataSerializableAndVerify(currentServer1, regionName, 0, 100, currentServer2, oldServer, oldServerAndLocator); if (createMultiIndexes) { doCreateIndexes("/" + regionName, currentServer1); } else { doCreateIndex("/" + regionName, oldServer); } } finally { invokeRunnableInVMs(invokeCloseCache(), currentServer1, currentServer2, oldServer, oldServerAndLocator); } }
From source file:org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.java
/** * This test starts up multiple servers from the current code base and multiple servers from the * old version and executes puts and gets on a new server and old server and verifies that the * results are present. Note that the puts have overlapping region keys just to test new puts and * replaces/*from w w w .j a v a 2 s. co m*/ */ public void doTestPutAndGetMixedServers(String objectType, boolean partitioned, String oldVersion) throws Exception { final Host host = Host.getHost(0); VM currentServer1 = host.getVM(0); VM oldServerAndLocator = host.getVM(oldVersion, 1); VM currentServer2 = host.getVM(2); VM oldServer2 = host.getVM(oldVersion, 3); String regionName = "aRegion"; RegionShortcut shortcut = RegionShortcut.REPLICATE; if (partitioned) { shortcut = RegionShortcut.PARTITION; } String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0)); int port = AvailablePortHelper.getRandomAvailableTCPPort(); DistributedTestUtils.deleteLocatorStateFile(port); try { Properties props = getSystemProperties(); props.remove(DistributionConfig.LOCATORS_NAME); invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator); props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]"); invokeRunnableInVMs(invokeCreateCache(props), oldServer2, currentServer1, currentServer2); currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL)); // oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal)); // oldServer2.invoke(invokeAssertVersion(oldOrdinal)); // create region invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServerAndLocator, oldServer2); putAndVerify(objectType, currentServer1, regionName, 0, 10, currentServer2, oldServerAndLocator, oldServer2); putAndVerify(objectType, oldServerAndLocator, regionName, 5, 15, currentServer1, currentServer2, oldServer2); } finally { invokeRunnableInVMs(true, invokeCloseCache(), currentServer1, currentServer2, oldServerAndLocator, oldServer2); } }
From source file:org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.java
public Properties getSystemProperties() { Properties props = DistributedTestUtils.getAllDistributedSystemProperties(new Properties()); props.remove("disable-auto-reconnect"); props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true"); props.put(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "false"); props.remove(DistributionConfig.LOAD_CLUSTER_CONFIG_FROM_DIR_NAME); props.remove(DistributionConfig.OFF_HEAP_MEMORY_SIZE_NAME); props.remove(DistributionConfig.LOCK_MEMORY_NAME); return props; }
From source file:org.sonarsource.scanner.maven.bootstrap.MavenProjectConverter.java
private void synchronizeFileSystemAndOtherProps(MavenProject pom, Properties props) throws MojoExecutionException { props.setProperty(ScanProperties.PROJECT_BASEDIR, pom.getBasedir().getAbsolutePath()); File buildDir = getBuildDir(pom); if (buildDir != null) { props.setProperty(PROPERTY_PROJECT_BUILDDIR, buildDir.getAbsolutePath()); props.setProperty(ScannerProperties.WORK_DIR, getSonarWorkDir(pom).getAbsolutePath()); }/*from w ww . j a v a 2s . c o m*/ populateBinaries(pom, props); populateLibraries(pom, props, false); populateLibraries(pom, props, true); populateSurefireReportsPath(pom, props); // IMPORTANT NOTE : reference on properties from POM model must not be saved, // instead they should be copied explicitly - see SONAR-2896 for (String k : pom.getModel().getProperties().stringPropertyNames()) { props.put(k, pom.getModel().getProperties().getProperty(k)); } props.putAll(envProperties); // Add user properties (ie command line arguments -Dsonar.xxx=yyyy) in last position to // override all other props.putAll(userProperties); List<File> mainDirs = mainSources(pom); props.setProperty(ScanProperties.PROJECT_SOURCE_DIRS, StringUtils.join(toPaths(mainDirs), SEPARATOR)); List<File> testDirs = testSources(pom); if (!testDirs.isEmpty()) { props.setProperty(ScanProperties.PROJECT_TEST_DIRS, StringUtils.join(toPaths(testDirs), SEPARATOR)); } else { props.remove(ScanProperties.PROJECT_TEST_DIRS); } }
From source file:org.cesecore.keys.token.CryptoTokenManagementSessionBean.java
@Override public void createCryptoToken(final AuthenticationToken authenticationToken, final String tokenName, final Integer cryptoTokenId, final String className, final Properties properties, final byte[] data, final char[] authenticationCode) throws AuthorizationDeniedException, CryptoTokenNameInUseException, CryptoTokenOfflineException, CryptoTokenAuthenticationFailedException, NoSuchSlotException { if (log.isTraceEnabled()) { log.trace(">createCryptoToken: " + tokenName + ", " + className); }/*from w w w.java2s .c o m*/ assertAuthorizedToModifyCryptoTokens(authenticationToken); if (CryptoTokenFactory.instance().getAvailableCryptoToken(className) == null) { throw new CryptoTokenClassNotFoundException("Invalid token class name: " + className); } // Note: if data is null, a new empty keystore will be created final CryptoToken cryptoToken = CryptoTokenFactory.createCryptoToken(className, properties, data, cryptoTokenId.intValue(), tokenName); if (authenticationCode != null) { if (log.isDebugEnabled()) { log.debug("Activating new crypto token using supplied authentication code."); } cryptoToken.activate(authenticationCode); } // This property is used only once during crypto token creation properties.remove(CryptoToken.ALLOW_NONEXISTING_SLOT_PROPERTY); final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("msg", "Created CryptoToken with id " + cryptoTokenId); details.put("name", cryptoToken.getTokenName()); details.put("encProviderName", cryptoToken.getEncProviderName()); details.put("signProviderName", cryptoToken.getSignProviderName()); putDelta(new Properties(), cryptoToken.getProperties(), details); cryptoTokenSession.mergeCryptoToken(cryptoToken); securityEventsLoggerSession.log(EventTypes.CRYPTOTOKEN_CREATE, EventStatus.SUCCESS, ModuleTypes.CRYPTOTOKEN, ServiceTypes.CORE, authenticationToken.toString(), String.valueOf(cryptoTokenId), null, null, details); if (log.isTraceEnabled()) { log.trace("<createCryptoToken: " + tokenName + ", " + className); } }
From source file:org.apache.falcon.workflow.engine.OozieWorkflowEngine.java
@Override public void reRun(String cluster, String jobId, Properties props, boolean isForced) throws FalconException { OozieClient client = OozieClientFactory.get(cluster); try {/*from w w w.j ava2 s .com*/ WorkflowJob jobInfo = client.getJobInfo(jobId); Properties jobprops = OozieUtils.toProperties(jobInfo.getConf()); if (props != null) { jobprops.putAll(props); } //if user has set any of these oozie rerun properties then force rerun flag is ignored if (!jobprops.containsKey(OozieClient.RERUN_FAIL_NODES) && !jobprops.containsKey(OozieClient.RERUN_SKIP_NODES)) { jobprops.put(OozieClient.RERUN_FAIL_NODES, String.valueOf(!isForced)); } jobprops.remove(OozieClient.COORDINATOR_APP_PATH); jobprops.remove(OozieClient.BUNDLE_APP_PATH); client.reRun(jobId, jobprops); assertStatus(cluster, jobId, Job.Status.RUNNING); LOG.info("Rerun job {} on cluster {}", jobId, cluster); } catch (Exception e) { LOG.error("Unable to rerun workflows", e); throw new FalconException(e); } }