Example usage for java.util Properties putAll

List of usage examples for java.util Properties putAll

Introduction

In this page you can find the example usage for java.util Properties putAll.

Prototype

@Override
    public synchronized void putAll(Map<?, ?> t) 

Source Link

Usage

From source file:org.apache.geode.distributed.internal.membership.gms.messenger.JGroupsMessengerJUnitTest.java

/**
 * Create stub and mock objects/*from  w ww  . j ava  2 s.co m*/
 */
private void initMocks(boolean enableMcast, Properties addProp) throws Exception {
    if (messenger != null) {
        messenger.stop();
        messenger = null;
    }
    Properties nonDefault = new Properties();
    nonDefault.put(DISABLE_TCP, "true");
    nonDefault.put(MCAST_PORT, enableMcast ? "" + AvailablePortHelper.getRandomAvailableUDPPort() : "0");
    nonDefault.put(MCAST_TTL, "0");
    nonDefault.put(LOG_FILE, "");
    nonDefault.put(LOG_LEVEL, "fine");
    nonDefault.put(LOCATORS, "localhost[10344]");
    nonDefault.put(ACK_WAIT_THRESHOLD, "1");
    nonDefault.putAll(addProp);
    DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
    RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);

    stopper = mock(Stopper.class);
    when(stopper.isCancelInProgress()).thenReturn(false);

    manager = mock(Manager.class);
    when(manager.isMulticastAllowed()).thenReturn(enableMcast);

    healthMonitor = mock(HealthMonitor.class);

    joinLeave = mock(JoinLeave.class);

    ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);

    services = mock(Services.class);
    when(services.getConfig()).thenReturn(serviceConfig);
    when(services.getCancelCriterion()).thenReturn(stopper);
    when(services.getHealthMonitor()).thenReturn(healthMonitor);
    when(services.getManager()).thenReturn(manager);
    when(services.getJoinLeave()).thenReturn(joinLeave);

    DM dm = mock(DM.class);
    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));

    messenger = new JGroupsMessenger();
    messenger.init(services);

    // if I do this earlier then test this return messenger as null
    when(services.getMessenger()).thenReturn(messenger);

    String jgroupsConfig = messenger.getJGroupsStackConfig();
    int startIdx = jgroupsConfig.indexOf("<org");
    int insertIdx = jgroupsConfig.indexOf('>', startIdx + 4) + 1;
    jgroupsConfig = jgroupsConfig.substring(0, insertIdx) + "<" + InterceptUDP.class.getName() + "/>"
            + jgroupsConfig.substring(insertIdx);
    messenger.setJGroupsStackConfigForTesting(jgroupsConfig);
    // System.out.println("jgroups config: " + jgroupsConfig);

    messenger.start();
    messenger.started();

    interceptor = (InterceptUDP) messenger.myChannel.getProtocolStack().getTransport().getUpProtocol();

}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * @param entries//w  w  w.j av a2  s. c  o m
 * @return
 */
private Vector<String> getKeyWordsList(final Collection<RegProcEntry> entries) {
    Properties props = new Properties();
    Hashtable<String, Boolean> statKeywords = new Hashtable<String, Boolean>();
    for (RegProcEntry entry : entries) {
        props.clear();
        props.putAll(entry.getProps());

        String os = props.getProperty("os_name");
        String ver = props.getProperty("os_version");
        props.put("platform", os + " " + ver);

        for (Object keywordObj : props.keySet()) {
            statKeywords.put(keywordObj.toString(), true);
        }
    }

    String[] trackKeys = rp.getTrackKeys();

    for (String keyword : new Vector<String>(statKeywords.keySet())) {
        if (keyword.startsWith("Usage") || keyword.startsWith("num_") || keyword.endsWith("_portal")
                || keyword.endsWith("_number") || keyword.endsWith("_website") || keyword.endsWith("id")
                || keyword.endsWith("os_name") || keyword.endsWith("os_version")) {
            statKeywords.remove(keyword);

        } else {
            for (String key : trackKeys) {
                if (keyword.startsWith(key)) {
                    statKeywords.remove(keyword);
                }
            }
        }
    }

    statKeywords.remove("date");
    //statKeywords.remove("time");
    statKeywords.put("by_date", true);
    statKeywords.put("by_month", true);
    statKeywords.put("by_year", true);

    return new Vector<String>(statKeywords.keySet());
}

From source file:org.apache.flink.streaming.connectors.kafka.KafkaConsumerTestBase.java

private static void printTopic(String topicName, int elements, DeserializationSchema<?> deserializer)
        throws IOException {
    // write the sequence to log for debugging purposes
    Properties newProps = new Properties(standardProps);
    newProps.setProperty("group.id", "topic-printer" + UUID.randomUUID().toString());
    newProps.setProperty("auto.offset.reset", "smallest");
    newProps.setProperty("zookeeper.connect", standardProps.getProperty("zookeeper.connect"));
    newProps.putAll(secureProps);

    ConsumerConfig printerConfig = new ConsumerConfig(newProps);
    printTopic(topicName, printerConfig, deserializer, elements);
}

From source file:org.fusesource.cloudmix.agent.InstallerAgent.java

protected void installProperties(Feature feature, List<ConfigurationUpdate> featureCfgOverrides) {
    Properties applicationProperties = feature.getProperties("applicationProperties");
    Properties systemProperties = System.getProperties();
    boolean changed = false;

    // time to apply the application's configuration overrides
    if (featureCfgOverrides != null && featureCfgOverrides.size() > 0) {
        if (applicationProperties == null) {
            applicationProperties = new Properties();
        }/*from   w w  w.  j ava2 s. c  o  m*/
        for (ConfigurationUpdate cfgUpdate : featureCfgOverrides) {
            applicationProperties.put(cfgUpdate.getProperty(), cfgUpdate.getValue());
        }
    }

    if (applicationProperties != null) {
        systemProperties.putAll(applicationProperties);
        changed = true;
        LOG.info(" ===>> adding app props to system");
    }

    if (changed) {
        System.setProperties(systemProperties);
        LOG.info(" ===>> applying props updates");
    }

}

From source file:org.apache.maven.archetype.creator.FilesetArchetypeCreator.java

private Properties getReversedProperties(ArchetypeDescriptor archetypeDescriptor, Properties properties) {
    Properties reversedProperties = new Properties();

    reversedProperties.putAll(properties);
    reversedProperties.remove(Constants.ARCHETYPE_GROUP_ID);
    reversedProperties.remove(Constants.ARCHETYPE_ARTIFACT_ID);
    reversedProperties.remove(Constants.ARCHETYPE_VERSION);

    String packageName = properties.getProperty(Constants.PACKAGE);
    String packageInPathFormat = getPackageInPathFormat(packageName);
    if (!packageInPathFormat.equals(packageName)) {
        reversedProperties.setProperty(Constants.PACKAGE_IN_PATH_FORMAT, packageInPathFormat);
    }/*from   w  w w.  j  a va2  s .  c o m*/

    // TODO check that reversed properties are all different and no one is a substring of another?
    // to avoid wrong variable replacements

    return reversedProperties;
}

From source file:org.apache.maven.archetype.creator.FilesetArchetypeCreator.java

private void addRequiredProperties(ArchetypeDescriptor archetypeDescriptor, Properties properties) {
    Properties requiredProperties = new Properties();
    requiredProperties.putAll(properties);
    requiredProperties.remove(Constants.ARCHETYPE_GROUP_ID);
    requiredProperties.remove(Constants.ARCHETYPE_ARTIFACT_ID);
    requiredProperties.remove(Constants.ARCHETYPE_VERSION);
    requiredProperties.remove(Constants.GROUP_ID);
    requiredProperties.remove(Constants.ARTIFACT_ID);
    requiredProperties.remove(Constants.VERSION);
    requiredProperties.remove(Constants.PACKAGE);
    requiredProperties.remove(Constants.EXCLUDE_PATTERNS);

    for (Iterator<?> propertiesIterator = requiredProperties.keySet().iterator(); propertiesIterator
            .hasNext();) {//from   www.  ja  v  a 2 s  .co m
        String propertyKey = (String) propertiesIterator.next();

        RequiredProperty requiredProperty = new RequiredProperty();
        requiredProperty.setKey(propertyKey);
        requiredProperty.setDefaultValue(requiredProperties.getProperty(propertyKey));

        archetypeDescriptor.addRequiredProperty(requiredProperty);

        getLogger().debug("Adding requiredProperty " + propertyKey + "="
                + requiredProperties.getProperty(propertyKey) + " to archetype's descriptor");
    }
}

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   ww  w  .  j  a  v  a 2  s.  c  om*/
        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);
    }
}

From source file:com.xpn.xwiki.gwt.api.server.XWikiServiceImpl.java

@Override
public Dictionary getTranslation(String translationPage, String locale) throws XWikiGWTException {
    try {//from  ww  w.  j  av  a  2  s .co  m
        XWikiContext context = getXWikiContext();
        XWikiMessageTool msg = context.getMessageTool();
        String defaultLanguage = context.getWiki().getDefaultLanguage(context);

        // Get the translated version of the translation page document with the default language one
        List docBundles = msg.getDocumentBundles(translationPage, defaultLanguage);
        Properties properties = new Properties();

        // loop backwards to have the default language updated first and then overwritten with the current language
        for (int i = 0; i < docBundles.size(); i++) {
            Properties encproperties = (msg == null) ? null
                    : msg.getDocumentBundleProperties(
                            (XWikiDocument) docBundles.get(docBundles.size() - i - 1));
            if (encproperties != null) {
                properties.putAll(encproperties);
            }
        }

        return new Dictionary(properties);
    } catch (Exception e) {
        throw getXWikiGWTException(e);
    }
}

From source file:er.extensions.foundation.ERXProperties.java

/** 
 * <div class="en">/*from   w  ww  . j  a v  a 2 s  .  com*/
 * Copies all properties from source to dest. 
 * </div>
 * 
 * <div class="ja">
 *    ???????
 * </div>
 * 
 * @param source <div class="en">properties copied from</div>
 *               <div class="ja">?</div>
 * @param dest <div class="en">properties copied to</div>
 *             <div class="ja">?</div>
 */
public static void transferPropertiesFromSourceToDest(Properties source, Properties dest) {
    if (source != null) {
        dest.putAll(source);
        if (dest == System.getProperties()) {
            systemPropertiesChanged();
        }
    }
}

From source file:org.apache.falcon.oozie.feed.FeedReplicationCoordinatorBuilder.java

private Properties doBuild(Cluster srcCluster, Cluster trgCluster, Path buildPath) throws FalconException {
    long replicationDelayInMillis = getReplicationDelayInMillis(srcCluster);
    Date sourceStartDate = getStartDate(srcCluster, replicationDelayInMillis);
    Date sourceEndDate = getEndDate(srcCluster);

    Date targetStartDate = getStartDate(trgCluster, replicationDelayInMillis);
    Date targetEndDate = getEndDate(trgCluster);

    if (noOverlapExists(sourceStartDate, sourceEndDate, targetStartDate, targetEndDate)) {
        LOG.warn("Not creating replication coordinator, as the source cluster: {} and target cluster: {} do "
                + "not have overlapping dates", srcCluster.getName(), trgCluster.getName());
        return null;
    }//  ww w.  j  a  va 2 s  .c om

    // Different workflow for each source since hive credentials vary for each cluster
    OozieOrchestrationWorkflowBuilder builder = OozieOrchestrationWorkflowBuilder.get(entity, trgCluster,
            Tag.REPLICATION);
    Properties wfProps = builder.build(trgCluster, buildPath);

    COORDINATORAPP coord = unmarshal(REPLICATION_COORD_TEMPLATE);

    String coordName = EntityUtil.getWorkflowName(Tag.REPLICATION, Arrays.asList(srcCluster.getName()), entity)
            .toString();
    String start = sourceStartDate.after(targetStartDate) ? SchemaHelper.formatDateUTC(sourceStartDate)
            : SchemaHelper.formatDateUTC(targetStartDate);
    String end = sourceEndDate.before(targetEndDate) ? SchemaHelper.formatDateUTC(sourceEndDate)
            : SchemaHelper.formatDateUTC(targetEndDate);

    initializeCoordAttributes(coord, coordName, start, end, replicationDelayInMillis);
    setCoordControls(coord);

    final Storage sourceStorage = FeedHelper.createReadOnlyStorage(srcCluster, entity);
    initializeInputDataSet(srcCluster, coord, sourceStorage);

    final Storage targetStorage = FeedHelper.createStorage(trgCluster, entity);
    initializeOutputDataSet(trgCluster, coord, targetStorage);

    ACTION replicationWorkflowAction = getReplicationWorkflowAction(srcCluster, trgCluster, buildPath,
            coordName, sourceStorage, targetStorage);
    coord.setAction(replicationWorkflowAction);

    Path marshalPath = marshal(trgCluster, coord, buildPath);
    wfProps.putAll(getProperties(marshalPath, coordName));
    return wfProps;
}