List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:com.mkwhitacre.kafka.mapreduce.utils.KafkaBrokerTestHarness.java
/** * Returns configuration properties for each Kafka broker in the cluster. * * @return Broker properties.//from www .ja v a 2 s.c o m */ public List<Properties> getBrokerProps() { List<Properties> props = new ArrayList<Properties>(brokers.size()); for (KafkaServer broker : brokers) { Properties prop = new Properties(); prop.putAll(broker.config().props()); props.add(prop); } return props; }
From source file:org.apache.juddi.v3.client.mapping.UDDIServiceCache.java
public UDDIServiceCache(UDDIClerk clerk, URLLocalizer urlLocalizer, Properties properties) throws DatatypeConfigurationException, MalformedURLException, RemoteException, ConfigurationException, WSDLException, TransportException, Exception { super();/*from w ww. ja v a 2 s .c o m*/ this.clerk = clerk; this.urlLocalizer = urlLocalizer; Properties properties2 = clerk.getUDDINode().getProperties(); if (properties2 != null) { properties2.putAll(properties); } else { properties2 = properties; } this.properties = properties2; }
From source file:org.apache.james.transport.mailets.remote.delivery.RemoteDeliveryConfiguration.java
private Properties computeJavaxProperties(MailetConfig mailetConfig) { Properties result = new Properties(); // deal with <mail.*> attributes, passing them to javamail result.putAll(ImmutableList.copyOf(mailetConfig.getInitParameterNames()).stream() .filter(propertyName -> propertyName.startsWith(JAVAX_PREFIX)) .map(propertyName -> Pair.of(propertyName, mailetConfig.getInitParameter(propertyName))) .collect(Guavate.toImmutableMap(Pair::getKey, Pair::getValue))); return result; }
From source file:org.apache.geode.management.internal.cli.commands.AlterRuntimeConfigCommand.java
@CliCommand(value = { CliStrings.ALTER_RUNTIME_CONFIG }, help = CliStrings.ALTER_RUNTIME_CONFIG__HELP) @CliMetaData(relatedTopic = {//from ww w.j a va 2 s . c o m CliStrings.TOPIC_GEODE_CONFIG }, interceptor = "org.apache.geode.management.internal.cli.commands.AlterRuntimeConfigCommand$AlterRuntimeInterceptor") @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.MANAGE) public Result alterRuntimeConfig(@CliOption(key = { CliStrings.MEMBER, CliStrings.MEMBERS }, optionContext = ConverterHint.ALL_MEMBER_IDNAME, help = CliStrings.ALTER_RUNTIME_CONFIG__MEMBER__HELP) String[] memberNameOrId, @CliOption(key = { CliStrings.GROUP, CliStrings.GROUPS }, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.ALTER_RUNTIME_CONFIG__MEMBER__HELP) String[] group, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT }, help = CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT__HELP) Integer archiveDiskSpaceLimit, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT }, help = CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT__HELP) Integer archiveFileSizeLimit, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT }, help = CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT__HELP) Integer logDiskSpaceLimit, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT }, help = CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT__HELP) Integer logFileSizeLimit, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL }, optionContext = ConverterHint.LOG_LEVEL, help = CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL__HELP) String logLevel, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE }, help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE__HELP) String statisticArchiveFile, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE }, help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE__HELP) Integer statisticSampleRate, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED }, help = CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED__HELP) Boolean statisticSamplingEnabled, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ }, specifiedDefaultValue = "false", help = CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ__HELP) Boolean setCopyOnRead, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE }, help = CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE__HELP) Integer lockLease, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__LOCK__TIMEOUT }, help = CliStrings.ALTER_RUNTIME_CONFIG__LOCK__TIMEOUT__HELP) Integer lockTimeout, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL }, help = CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL__HELP) Integer messageSyncInterval, @CliOption(key = { CliStrings.ALTER_RUNTIME_CONFIG__SEARCH__TIMEOUT }, help = CliStrings.ALTER_RUNTIME_CONFIG__SEARCH__TIMEOUT__HELP) Integer searchTimeout) { Map<String, String> runTimeDistributionConfigAttributes = new HashMap<>(); Map<String, String> rumTimeCacheAttributes = new HashMap<>(); Set<DistributedMember> targetMembers = CliUtil.findMembers(group, memberNameOrId); if (targetMembers.isEmpty()) { return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE); } if (archiveDiskSpaceLimit != null) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, archiveDiskSpaceLimit.toString()); } if (archiveFileSizeLimit != null) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, archiveFileSizeLimit.toString()); } if (logDiskSpaceLimit != null) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, logDiskSpaceLimit.toString()); } if (logFileSizeLimit != null) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, logFileSizeLimit.toString()); } if (logLevel != null && !logLevel.isEmpty()) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, logLevel); } if (statisticArchiveFile != null && !statisticArchiveFile.isEmpty()) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, statisticArchiveFile); } if (statisticSampleRate != null) { runTimeDistributionConfigAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, statisticSampleRate.toString()); } if (statisticSamplingEnabled != null) { runTimeDistributionConfigAttributes.put(STATISTIC_SAMPLING_ENABLED, statisticSamplingEnabled.toString()); } // Attributes that are set on the cache. if (setCopyOnRead != null) { rumTimeCacheAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ, setCopyOnRead.toString()); } if (lockLease != null && lockLease > 0 && lockLease < Integer.MAX_VALUE) { rumTimeCacheAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE, lockLease.toString()); } if (lockTimeout != null && lockTimeout > 0 && lockTimeout < Integer.MAX_VALUE) { rumTimeCacheAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__LOCK__TIMEOUT, lockTimeout.toString()); } if (messageSyncInterval != null && messageSyncInterval > 0 && messageSyncInterval < Integer.MAX_VALUE) { rumTimeCacheAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL, messageSyncInterval.toString()); } if (searchTimeout != null && searchTimeout > 0 && searchTimeout < Integer.MAX_VALUE) { rumTimeCacheAttributes.put(CliStrings.ALTER_RUNTIME_CONFIG__SEARCH__TIMEOUT, searchTimeout.toString()); } if (runTimeDistributionConfigAttributes.isEmpty() && rumTimeCacheAttributes.isEmpty()) { return ResultBuilder.createUserErrorResult(CliStrings.ALTER_RUNTIME_CONFIG__RELEVANT__OPTION__MESSAGE); } Map<String, String> allRunTimeAttributes = new HashMap<>(); allRunTimeAttributes.putAll(runTimeDistributionConfigAttributes); allRunTimeAttributes.putAll(rumTimeCacheAttributes); ResultCollector<?, ?> rc = CliUtil.executeFunction(alterRunTimeConfigFunction, allRunTimeAttributes, targetMembers); List<CliFunctionResult> results = CliFunctionResult.cleanResults((List<?>) rc.getResult()); Set<String> successfulMembers = new TreeSet<>(); Set<String> errorMessages = new TreeSet<>(); for (CliFunctionResult result : results) { if (result.getThrowable() != null) { logger.info("Function failed: " + result.getThrowable()); errorMessages.add(result.getThrowable().getMessage()); } else { successfulMembers.add(result.getMemberIdOrName()); } } final String lineSeparator = System.getProperty("line.separator"); if (!successfulMembers.isEmpty()) { StringBuilder successMessageBuilder = new StringBuilder(); successMessageBuilder.append(CliStrings.ALTER_RUNTIME_CONFIG__SUCCESS__MESSAGE); successMessageBuilder.append(lineSeparator); for (String member : successfulMembers) { successMessageBuilder.append(member); successMessageBuilder.append(lineSeparator); } Properties properties = new Properties(); properties.putAll(runTimeDistributionConfigAttributes); Result result = ResultBuilder.createInfoResult(successMessageBuilder.toString()); // Set the Cache attributes to be modified final XmlEntity xmlEntity = XmlEntity.builder().withType(CacheXml.CACHE) .withAttributes(rumTimeCacheAttributes).build(); persistClusterConfiguration(result, () -> getSharedConfiguration().modifyXmlAndProperties(properties, xmlEntity, group)); return result; } else { StringBuilder errorMessageBuilder = new StringBuilder(); errorMessageBuilder.append("Following errors occurred while altering runtime config"); errorMessageBuilder.append(lineSeparator); for (String errorMessage : errorMessages) { errorMessageBuilder.append(errorMessage); errorMessageBuilder.append(lineSeparator); } return ResultBuilder.createUserErrorResult(errorMessageBuilder.toString()); } }
From source file:it.cnr.icar.eric.common.AbstractProperties.java
public Properties cloneProperties() { Properties clone = new Properties(); clone.putAll(props); return clone; }
From source file:org.apache.solr.cloud.TestConfigSetsAPI.java
private void verifyCreate(String baseConfigSetName, String configSetName, Map<String, String> oldProps, Map<String, String> newProps) throws Exception { final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString(); final SolrClient solrClient = getHttpSolrClient(baseUrl); setupBaseConfigSet(baseConfigSetName, oldProps); SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null); try {//from w w w.j a v a2s . com ZkConfigManager configManager = new ZkConfigManager(zkClient); assertFalse(configManager.configExists(configSetName)); Create create = new Create(); create.setBaseConfigSetName(baseConfigSetName).setConfigSetName(configSetName); if (newProps != null) { Properties p = new Properties(); p.putAll(newProps); create.setNewConfigSetProperties(p); } ConfigSetAdminResponse response = create.process(solrClient); assertNotNull(response.getResponse()); assertTrue(configManager.configExists(configSetName)); verifyProperties(configSetName, oldProps, newProps, zkClient); } finally { zkClient.close(); } solrClient.close(); }
From source file:org.apache.pig.backend.hadoop.executionengine.HExecutionEngine.java
@Override public Properties getConfiguration() { Properties properties = new Properties(); properties.putAll(pigContext.getProperties()); return properties; }
From source file:org.apache.isis.core.commons.configbuilder.IsisConfigurationBuilder.java
/** * Creates a copy of the current {@link #getConfiguration()}, without locking. * * <p>/* w w w .j av a 2 s . c o m*/ * Used while bootstrapping, to obtain the web.server port etc. * </p> */ public IsisConfiguration peekConfiguration() { IsisConfigurationDefault cfg = new IsisConfigurationDefault(resourceStreamSourceChain); // no locking Properties props = new Properties(); props.putAll(configuration.asMap()); cfg.add(props, ContainsPolicy.OVERWRITE); return cfg; }
From source file:org.apache.pig.scripting.BoundScript.java
/** * Run multiple instances of bound pipeline on Hadoop in parallel. * @param prop Map of properties that Pig should set when running the script. * This is intended for use with scripting languages that do not support * the Properties object./* w w w. j a va 2 s. co m*/ * @return a list of {@link PigStats}, one for each map of variables passed * to bind. * @throws IOException */ public List<PigStats> run(Properties prop) throws IOException { List<PigStats> stats = new ArrayList<PigStats>(); if (queries.isEmpty()) { LOG.info("No bound query to run."); return stats; } if (queries.size() == 1) { PigStats ps = runSingle(); stats.add(ps); return stats; } if (prop != null) { scriptContext.getPigContext().getProperties().putAll(prop); } List<PigProgressNotificationListener> listeners = ScriptState.get().getAllListeners(); SyncProgressNotificationAdaptor adaptor = new SyncProgressNotificationAdaptor(listeners); List<Future<PigStats>> futures = new ArrayList<Future<PigStats>>(); ExecutorService executor = Executors.newFixedThreadPool(queries.size()); for (int i = 0; i < queries.size(); i++) { Properties props = new Properties(); props.putAll(scriptContext.getPigContext().getProperties()); PigContext ctx = new PigContext(scriptContext.getPigContext().getExecType(), props); MyCallable worker = new MyCallable(queries.get(i), ctx, adaptor); Future<PigStats> submit = executor.submit(worker); futures.add(submit); } for (Future<PigStats> future : futures) { try { stats.add(future.get()); } catch (InterruptedException e) { LOG.error("Pig pipeline failed to complete", e); PigStatsUtil.getEmptyPigStats(); PigStatsUtil.setErrorMessage(e.getMessage()); PigStats failed = PigStatsUtil.getPigStats(ReturnCode.FAILURE); stats.add(failed); } catch (ExecutionException e) { LOG.error("Pig pipeline failed to complete", e); PigStatsUtil.getEmptyPigStats(); PigStatsUtil.setErrorMessage(e.getMessage()); PigStats failed = PigStatsUtil.getPigStats(ReturnCode.FAILURE); stats.add(failed); } } if (!stats.isEmpty()) { setPigStats(stats); ; } return stats; }
From source file:org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.java
private Properties toProperties(Map<String, String> dominant, Map<String, String> recessive) { Properties props = new Properties(); if (recessive != null) { props.putAll(recessive); }/*from ww w .j a v a 2 s .co m*/ if (dominant != null) { props.putAll(dominant); } return props; }