Example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration.

Prototype

public PropertiesConfiguration() 

Source Link

Document

Creates an empty PropertyConfiguration object which can be used to synthesize a new Properties file by adding values and then saving().

Usage

From source file:edu.cmu.lti.oaqa.bioasq.concept.rerank.scorers.GoPubMedConceptRetrievalScorer.java

@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
    super.initialize(aSpecifier, aAdditionalParams);
    String conf = String.class.cast(getParameterValue("conf"));
    PropertiesConfiguration gopubmedProperties = new PropertiesConfiguration();
    try {/*w w w  .j  ava  2 s .  c o m*/
        gopubmedProperties.load(getClass().getResourceAsStream(conf));
    } catch (ConfigurationException e) {
        throw new ResourceInitializationException(e);
    }
    service = new GoPubMedService(gopubmedProperties);
    pages = Integer.class.cast(getParameterValue("pages"));
    hits = Integer.class.cast(getParameterValue("hits"));
    timeout = Integer.class.cast(getParameterValue("timeout"));
    String stoplistPath = String.class.cast(getParameterValue("stoplist-path"));
    try {
        stoplist = Resources.readLines(getClass().getResource(stoplistPath), UTF_8).stream().map(String::trim)
                .collect(toSet());
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
    uri2conf2score = HashBasedTable.create();
    uri2conf2rank = HashBasedTable.create();
    return true;
}

From source file:com.linkedin.pinot.server.request.ScheduledRequestHandlerTest.java

@BeforeTest
public void setupTestMethod() {
    serverMetrics = new ServerMetrics(new MetricsRegistry());
    channelHandlerContext = mock(ChannelHandlerContext.class, RETURNS_DEEP_STUBS);
    when(channelHandlerContext.channel().remoteAddress()).thenAnswer(new Answer<InetSocketAddress>() {
        @Override// w  ww  . j  av  a 2s .c  om
        public InetSocketAddress answer(InvocationOnMock invocationOnMock) throws Throwable {
            return new InetSocketAddress("localhost", 60000);
        }
    });

    queryScheduler = mock(QueryScheduler.class);
    queryExecutor = new ServerQueryExecutorV1Impl();
    resourceManager = new UnboundedResourceManager(new PropertiesConfiguration());
}

From source file:main.java.entry.ReadConfig.java

public static void readConfigFile(String file_name) {
    FileInputStream config_file = null;
    AbstractFileConfiguration config_param = null;

    Global.LOGGER.info("-----------------------------------------------------------------------------");
    Global.LOGGER.info("Reading simulation aspects from file ...");

    try {/* ww  w. jav a  2s  .co  m*/
        // Access configuration file
        try {
            config_file = new FileInputStream(file_name);
            Global.LOGGER
                    .info("Simulation configuration file \"sim.cnf\" is found in the root directory and read.");

        } catch (IOException e) {
            e.printStackTrace();
            System.out.println(
                    "Simulation configuration file \"sim.cnf\" is missing in the working directory !!");
            System.exit(0);
        }

        // Load configuration parameters
        config_param = new PropertiesConfiguration();
        config_param.load(config_file);

        //Read the number of servers, partitions and replicas
        Global.simulation = (String) config_param.getProperty("simulation.name");
        Global.setup = (String) config_param.getProperty("setup");
        Global.servers = Integer.parseInt((String) config_param.getProperty("initial.servers"));
        Global.serverSSD = Integer.parseInt((String) config_param.getProperty("server.ssd"));
        Global.serverSSDCapacity = Integer.parseInt((String) config_param.getProperty("server.ssd.capacity"));
        Global.partitions = Integer.parseInt((String) config_param.getProperty("fixed.partitions"));
        Global.partitionCapacity = Integer
                .parseInt((String) config_param.getProperty("fixed.partition.capacity"));
        Global.replicas = Integer.parseInt((String) config_param.getProperty("number.of.replicas"));

        Global.LOGGER.info("-----------------------------------------------------------------------------");
        Global.LOGGER.info("Initial number of servers: " + Global.servers);
        Global.LOGGER.info(
                "Number of SSD in each server: " + Global.serverSSD + " " + Global.serverSSDCapacity + "GB");
        Global.LOGGER.info("Individual server's capacity: "
                + ((Global.serverSSD * Global.serverSSDCapacity) / 1000) + "GB");
        Global.LOGGER.info("Fixed number of partitions: " + Global.partitions);
        Global.LOGGER.info("Individual partition's capacity: " + (Global.partitionCapacity / 1000) + "GB");
        Global.LOGGER.info("Replication value: " + Global.replicas);

        // Workload execution parameters --  will be used in Workload Executor
        Global.simulationPeriod = Double.parseDouble((String) config_param.getProperty("simulation.period"));
        Global.warmupPeriod = Double.parseDouble((String) config_param.getProperty("warmup.period"));

        Global.meanInterArrivalTime = Double
                .parseDouble((String) config_param.getProperty("inverse.of.mean.inter.arrival.time"));
        Global.meanServiceTime = Double
                .parseDouble((String) config_param.getProperty("inverse.of.mean.service.time"));

        Global.percentageChangeInWorkload = Double
                .parseDouble((String) config_param.getProperty("percentage.change.in.workload"));
        //Global.adjustment = Double.parseDouble((String) config_param.getProperty("adjustment"));         
        Global.observationWindow = Integer
                .parseInt((String) config_param.getProperty("observation.window.size"));
        Global.uniqueMaxFixed = Integer.parseInt((String) config_param.getProperty("unique.max.fixed"));
        Global.expAvgWt = Double.parseDouble((String) config_param.getProperty("exponential.Avg.Weight"));
        Global.uniqueEnabled = Boolean.parseBoolean((String) config_param.getProperty("unique.enable"));

        Global.LOGGER.info("-----------------------------------------------------------------------------");
        Global.LOGGER.info("Simulation name: " + Global.simulation);
        Global.LOGGER
                .info("Simulation Period: " + (Global.simulationPeriod / Global.observationWindow) + " hrs");
        Global.LOGGER.info("Warmup time: " + (Global.warmupPeriod / Global.observationWindow) + " hrs");
        Global.LOGGER.info("-----------------------------------------------------------------------------");
        Global.LOGGER.info("Probability of Transaction birth and death: " + Global.percentageChangeInWorkload);
        Global.LOGGER.info("Mean inter Transaction arrival time: " + Global.meanInterArrivalTime);
        Global.LOGGER.info("Mean Transaction service time: " + Global.meanServiceTime);

        // Read configuration parameters
        Global.workloadAware = Boolean.parseBoolean((String) config_param.getProperty("workload.aware"));
        Global.workloadRepresentation = (String) config_param.getProperty("workload.representation");

        Global.LOGGER.info("-----------------------------------------------------------------------------");
        Global.LOGGER.info("Workload aware: " + Global.workloadAware);
        Global.LOGGER.info("Workload representation: " + Global.workloadRepresentation);

        if (Global.workloadAware) {

            Global.incrementalRepartitioning = Boolean
                    .parseBoolean((String) config_param.getProperty("incremental.repartitioning"));
            Global.graphcutBasedRepartitioning = Boolean
                    .parseBoolean((String) config_param.getProperty("graphcutbased.repartitioning"));

            Global.dynamicPartitioning = Boolean
                    .parseBoolean((String) config_param.getProperty("dynamic.partitioning"));
            Global.dynamicPartitions = Global.partitions; // Initialisation

            Global.repartStatic = Boolean
                    .parseBoolean((String) config_param.getProperty("static.repartitioning"));
            Global.repartHourly = Boolean
                    .parseBoolean((String) config_param.getProperty("hourly.repartitioning"));
            Global.repartThreshold = Boolean
                    .parseBoolean((String) config_param.getProperty("threshold.repartitioning"));

            Global.streamCollection = Boolean
                    .parseBoolean((String) config_param.getProperty("stream.collection"));
            Global.streamCollectorSizeFactor = Integer
                    .parseInt((String) config_param.getProperty("stream.collector.size.factor"));

            if (Global.streamCollection) {
                Global.dsm = new DataStreamMining();
                Global.associative = Boolean.parseBoolean((String) config_param.getProperty("associative"));
                Global.adaptive = Boolean.parseBoolean((String) config_param.getProperty("adaptive"));
            }

            Global.enableTrClassification = Boolean
                    .parseBoolean((String) config_param.getProperty("transaction.classification"));
            Global.trClassificationStrategy = (String) config_param
                    .getProperty("transaction.classification.strategy");

            Global.dataMigrationStrategy = (String) config_param.getProperty("data.migration.strategy");

            Global.compressionEnabled = Boolean
                    .parseBoolean((String) config_param.getProperty("compression.enabled"));
            Global.compressionBeforeSetup = Boolean
                    .parseBoolean((String) config_param.getProperty("compression.before.setup"));

            if (!Global.compressionBeforeSetup)
                Global.swordInitial = false;

            if (Global.incrementalRepartitioning) {
                Global.userDefinedIDtThreshold = Double
                        .parseDouble((String) config_param.getProperty("idt.threshold"));

                Global.spanReduction = Boolean
                        .parseBoolean((String) config_param.getProperty("span.reduction"));

                if (Global.spanReduction)
                    Global.spanReduce = Integer.parseInt((String) config_param.getProperty("span.reduce"));

                Global.lambda = Double.parseDouble((String) config_param.getProperty("lambda"));

                if (Global.lambda < 0 || Global.lambda > 1) {
                    Global.LOGGER.error("Wrong value set for 'lambda' !!");
                    System.exit(400);
                }
            }

            Global.LOGGER.info("-----------------------------------------------------------------------------");
            Global.LOGGER.info("Incremental repartitioning: " + Global.incrementalRepartitioning);
            Global.LOGGER.info("Static repartitioning: " + Global.repartStatic);
            Global.LOGGER.info("Hourly repartitioning: " + Global.repartHourly);
            Global.LOGGER.info("Threshold-based repartitioning: " + Global.repartThreshold);

            Global.LOGGER.info("-----------------------------------------------------------------------------");
            Global.LOGGER.info("Transaction classification: " + Global.enableTrClassification);
            Global.LOGGER.info("Transaction classification strategy: " + Global.trClassificationStrategy);

            Global.LOGGER.info("-----------------------------------------------------------------------------");
            Global.LOGGER.info("Data migration strategy: " + Global.dataMigrationStrategy);

            Global.LOGGER.info("-----------------------------------------------------------------------------");
            Global.LOGGER.info("Workload compression enabled: " + Global.compressionEnabled);
            Global.LOGGER.info("Compression before setup enabled: " + Global.compressionBeforeSetup);

            if (Global.compressionEnabled) {
                Global.compressionRatio = Double
                        .parseDouble((String) config_param.getProperty("compression.ratio"));
                Global.LOGGER.info("Compression ratio: " + Global.compressionRatio);
            }
        }
    } catch (ConfigurationException e) {
        Global.LOGGER.error("Failed to read the configurations from sim.cnf file !!", e);
    } finally {
        if (config_file != null) {
            try {
                config_file.close();
            } catch (IOException e) {
                Global.LOGGER.error("Failed to close the sim.cnf file !!", e);
            }
        }
    }
}

From source file:com.nilostep.xlsql.database.xlInstanceOLD.java

private xlInstanceOLD(String cfg) throws xlException {
    logger = Logger.getLogger(this.getClass().getName());
    instance = this;
    //name = cfg;

    try {//from  ww  w . j a v  a2  s  .  c  o  m
        //            file = new File(cfg + "_config.xml");
        //            handler = new XMLFileHandler();
        //            handler.setFile(file);
        //
        //            cm = ConfigurationManager.getInstance();
        //            config = cm.getConfiguration(name);
        //            config.addConfigurationListener(this);
        //
        //            if (file.exists()) {

        PropertiesConfiguration config = new PropertiesConfiguration();
        config.load(this.getClass().getResourceAsStream(cfg + ".properties"));
        String engine = config.getString("general.engine");

        //cm.load(handler, name);                
        //Category cat = config.getCategory("general");                                                                
        //engine = config.getProperty("engine", null, "general");
        //config.setCategory(engine, true);
        //logger.info("Configuration file: " + file + " loaded");
        logger.info("Configuration engine: " + engine + " loaded");
        //            } else {

        //
        //                assert (config.isNew());
        //
        //                //
        //                config.setCategory("general", true);
        //
        //                String engine = "hsqldb";
        //                setLog("xlsql.log");
        //                setDatabase(System.getProperty("user.dir"));
        //
        //                //
        //                this.engine = engine;
        //                this.config.setProperty("engine", engine);
        //                addEngine(engine);
        //                config.setCategory(engine, true);
        //
        //
        //                //
        //                setDriver("org.hsqldb.jdbcDriver");
        //                setUrl("jdbc:hsqldb:.");
        //                setSchema("");
        //                setUser("sa");
        //                setPassword("");
        //                config.setCategory(getEngine(), true);
        //                logger.info("Configuration file: " + file + " created.");
        //            }
    }
    //catch (ConfigurationManagerException cme) {
    //   config = cm.getConfiguration(name);
    //} 
    catch (ConfigurationException e) {
        e.printStackTrace();
        throw new xlException(e.getMessage());
    }

    try {
        if (getLog() == null) {
            setLog("xlsql.log");
        }

        boolean append = true;
        FileHandler loghandler = new FileHandler(getLog(), append);
        loghandler.setFormatter(new SimpleFormatter());
        logger.addHandler(loghandler);
    } catch (IOException e) {
        throw new xlException("error while creating logfile");
    }

    //logger.info("Instance created with engine " + getEngine());
    logger.info("Instance created with engine " + engine);

    //
    //
    //
}

From source file:com.manydesigns.portofino.i18n.ResourceBundleManager.java

public ResourceBundle getBundle(Locale locale) {
    ConfigurationResourceBundle bundle = resourceBundles.get(locale);
    if (bundle == null) {
        CompositeConfiguration configuration = new CompositeConfiguration();
        Iterator<String> iterator = searchPaths.descendingIterator();
        while (iterator.hasNext()) {
            String path = iterator.next();
            int index = path.lastIndexOf('/') + 1;
            String basePath = path.substring(0, index);
            int suffixIndex = path.length() - ".properties".length();
            String resourceBundleBaseName = path.substring(index, suffixIndex);
            String bundleName = getBundleFileName(resourceBundleBaseName, locale);
            PropertiesConfiguration conf;
            try {
                conf = new PropertiesConfiguration();
                conf.setFileName(basePath + bundleName);
                conf.setDelimiterParsingDisabled(true);
                conf.load();/*from ww w  .j  av  a  2 s . c  o  m*/
            } catch (ConfigurationException e) {
                logger.debug("Couldn't load resource bundle for locale " + locale + " from " + basePath, e);
                //Fall back to default .properties without _locale
                try {
                    String defaultBundleName = basePath + resourceBundleBaseName + ".properties";
                    conf = new PropertiesConfiguration();
                    conf.setFileName(defaultBundleName);
                    conf.setDelimiterParsingDisabled(true);
                    conf.load();
                } catch (ConfigurationException e1) {
                    logger.debug("Couldn't load default resource bundle from " + basePath, e1);
                    conf = null;
                }
            }
            if (conf != null) {
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                conf.setReloadingStrategy(reloadingStrategy);
                configuration.addConfiguration(conf);
            }
        }
        bundle = new ConfigurationResourceBundle(configuration, locale);
        //TODO setParent?
        resourceBundles.put(locale, bundle);
    }
    return bundle;
}

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtilTest.java

@Test
public void testPreloadArtifact() throws DependencyResolutionException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty(DependencyConfigurationUtil.PRELOAD_ARTIFACTS, EXAMPLE_APP_COORDS);

    DependencyConfigurationUtil.getConfiguredDependencies(configuration);

    ArgumentCaptor<Artifact> artifact = ArgumentCaptor.forClass(Artifact.class);

    verify(mavenRepositorySystem, times(1)).resolveDependencies(artifact.capture(), argThat(isEmptyList()),
            argThat(isEmptyList()));// w w  w  .  j av a 2  s . c om
    assertThat(artifact.getValue().getGroupId(), is(equalTo(EXAMPLE_APP_GROUPID)));
    assertThat(artifact.getValue().getArtifactId(), is(equalTo(EXAMPLE_APP_ARTIFACTID)));
    assertThat(artifact.getValue().getVersion(), is(equalTo(EXAMPLE_APP_VERSION)));
}

From source file:dk.dma.ais.abnormal.analyzer.analysis.CloseEncounterAnalysisTest.java

@Before
public void setUp() throws Exception {
    context = new JUnit4Mockery();
    trackingService = context.mock(EventEmittingTracker.class);
    statisticsService = context.mock(AppStatisticsService.class);
    eventRepository = context.mock(EventRepository.class);
    analysis = new CloseEncounterAnalysis(new PropertiesConfiguration(), statisticsService, trackingService,
            eventRepository);//from  w w  w  . j  a  v a  2 s  .c o  m

    long timestamp = System.currentTimeMillis();
    long tooOld = timestamp - maxTimestampDeviationMillis - 1;
    long old = timestamp - maxTimestampDeviationMillis + 1;
    long tooNew = timestamp + maxTimestampDeviationMillis + 1;
    long nyw = timestamp + maxTimestampDeviationMillis - 1;

    Position position = Position.create(56, 12);
    Position tooFarAway = Position.create(56.1, 12.1);
    assertTrue(position.distanceTo(tooFarAway, CoordinateSystem.CARTESIAN) > maxDistanceDeviationMeters);
    Position farAway = Position.create(56.014, 12.014);
    assertTrue(position.distanceTo(farAway, CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters);

    track = new Track(219000606);
    track.update(vessel1StaticPacket);
    track.update(timestamp, position, 90.0f, 10.0f, 90.0f);

    closeTrack = new Track(219002827);
    closeTrack.update(vessel2StaticPacket);
    closeTrack.update(timestamp - 40000, Position.create(56.1000, 12.0010), 180.0f, 10.0f, 180.0f);
    closeTrack.update(timestamp - 30000, Position.create(56.0800, 12.0010), 180.0f, 10.0f, 180.0f);
    closeTrack.update(timestamp - 20000, Position.create(56.0600, 12.0010), 180.0f, 10.0f, 180.0f);
    closeTrack.update(timestamp - 10000, Position.create(56.0400, 12.0010), 180.0f, 10.0f, 180.0f);
    closeTrack.update(timestamp, Position.create(56.00001, 12.0000), 180.0f, 10.0f, 180.0f);
    closeTrack.getTrackingReports().forEach(tr -> {
        tr.setProperty("event-certainty-CloseEncounterEvent", EventCertainty.LOWERED);
    });
    assertTrue(closeTrack.getPosition().equals(Position.create(56.00001, 12.0000)));
    assertTrue(track.getPosition().distanceTo(closeTrack.getPosition(), CoordinateSystem.CARTESIAN) < 200);

    distantTrack = new Track(219000606);
    distantTrack.update(vessel1StaticPacket);
    distantTrack.update(timestamp, Position.create(57, 13), 90.0f, 10.0f, 90.0f);

    Track track1 = new Track(1);
    track1.update(tooOld, position, 90.0f, 10.0f, 90.0f);

    oldNearbyTrack = new Track(2);
    oldNearbyTrack.update(old, position, 90.0f, 10.0f, 90.0f);

    Track track3 = new Track(3);
    track3.update(tooNew, position, 90.0f, 10.0f, 90.0f);

    newNearbyTrack = new Track(3);
    newNearbyTrack.update(nyw, position, 90.0f, 10.0f, 90.0f);

    Track track4 = new Track(4);
    track4.update(timestamp, tooFarAway, 90.0f, 10.0f, 90.0f);

    distantNearbyTrack = new Track(5);
    distantNearbyTrack.update(timestamp, farAway, 90.0f, 10.0f, 90.0f);

    tracks = new HashSet<>();
    tracks.add(track);
    tracks.add(track1);
    tracks.add(oldNearbyTrack);
    tracks.add(track3);
    tracks.add(track4);
    tracks.add(distantNearbyTrack);
    tracks.add(newNearbyTrack);
}

From source file:com.yahoo.bard.webservice.config.ConfigResourceLoader.java

/**
 * Build a configuration object from a resource, processing it as a properties file.
 *
 * @param resource  The resource referring to a properties file
 *
 * @return a Configuration object containing a properties configuration
 *//* ww w .j av a  2 s  .c  o  m*/
public Configuration loadConfigFromResource(Resource resource) {
    PropertiesConfiguration result = new PropertiesConfiguration();
    try {
        result.load(resource.getInputStream());
        return result;
    } catch (ConfigurationException | IOException e) {
        LOG.error(CONFIGURATION_LOAD_ERROR.format(resource.getFilename()), e);
        throw new SystemConfigException(CONFIGURATION_LOAD_ERROR.format(resource.getFilename()), e);
    }
}

From source file:com.mirth.connect.server.servlets.WebStartServlet.java

private Document getAdministratorJnlp(HttpServletRequest request) throws Exception {
    InputStream is = ResourceUtil.getResourceStream(this.getClass(), "mirth-client.jnlp");
    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
    IOUtils.closeQuietly(is);//  ww  w .  j ava 2  s .  c o  m

    Element jnlpElement = document.getDocumentElement();

    // Change the title to include the version of Mirth Connect
    PropertiesConfiguration versionProperties = new PropertiesConfiguration();
    versionProperties.setDelimiterParsingDisabled(true);
    versionProperties.load(ResourceUtil.getResourceStream(getClass(), "version.properties"));
    String version = versionProperties.getString("mirth.version");

    Element informationElement = (Element) jnlpElement.getElementsByTagName("information").item(0);
    Element title = (Element) informationElement.getElementsByTagName("title").item(0);
    String titleText = title.getTextContent() + " " + version;

    // If a server name is set, prepend the application title with it
    String serverName = configurationController.getServerSettings().getServerName();
    if (StringUtils.isNotBlank(serverName)) {
        titleText = serverName + " - " + titleText;
    }

    title.setTextContent(titleText);

    String scheme = request.getScheme();
    String serverHostname = request.getServerName();
    int serverPort = request.getServerPort();
    String contextPath = request.getContextPath();
    String codebase = scheme + "://" + serverHostname + ":" + serverPort + contextPath;

    PropertiesConfiguration mirthProperties = new PropertiesConfiguration();
    mirthProperties.setDelimiterParsingDisabled(true);
    mirthProperties.load(ResourceUtil.getResourceStream(getClass(), "mirth.properties"));

    String server = null;

    if (StringUtils.isNotBlank(mirthProperties.getString("server.url"))) {
        server = mirthProperties.getString("server.url");
    } else {
        int httpsPort = mirthProperties.getInt("https.port", 8443);
        String contextPathProp = mirthProperties.getString("http.contextpath", "");

        // Add a starting slash if one does not exist
        if (!contextPathProp.startsWith("/")) {
            contextPathProp = "/" + contextPathProp;
        }

        // Remove a trailing slash if one exists
        if (contextPathProp.endsWith("/")) {
            contextPathProp = contextPathProp.substring(0, contextPathProp.length() - 1);
        }

        server = "https://" + serverHostname + ":" + httpsPort + contextPathProp;
    }

    jnlpElement.setAttribute("codebase", codebase);

    Element resourcesElement = (Element) jnlpElement.getElementsByTagName("resources").item(0);

    String maxHeapSize = request.getParameter("maxHeapSize");
    if (StringUtils.isBlank(maxHeapSize)) {
        maxHeapSize = mirthProperties.getString("administrator.maxheapsize");
    }
    if (StringUtils.isNotBlank(maxHeapSize)) {
        Element j2se = (Element) resourcesElement.getElementsByTagName("j2se").item(0);
        j2se.setAttribute("max-heap-size", maxHeapSize);
    }

    List<String> defaultClientLibs = new ArrayList<String>();
    defaultClientLibs.add("mirth-client.jar");
    defaultClientLibs.add("mirth-client-core.jar");
    defaultClientLibs.add("mirth-crypto.jar");
    defaultClientLibs.add("mirth-vocab.jar");

    for (String defaultClientLib : defaultClientLibs) {
        Element jarElement = document.createElement("jar");
        jarElement.setAttribute("download", "eager");
        jarElement.setAttribute("href", "webstart/client-lib/" + defaultClientLib);

        if (defaultClientLib.equals("mirth-client.jar")) {
            jarElement.setAttribute("main", "true");
        }

        resourcesElement.appendChild(jarElement);
    }

    List<String> clientLibs = ControllerFactory.getFactory().createExtensionController().getClientLibraries();

    for (String clientLib : clientLibs) {
        if (!defaultClientLibs.contains(clientLib)) {
            Element jarElement = document.createElement("jar");
            jarElement.setAttribute("download", "eager");
            jarElement.setAttribute("href", "webstart/client-lib/" + clientLib);
            resourcesElement.appendChild(jarElement);
        }
    }

    List<MetaData> allExtensions = new ArrayList<MetaData>();
    allExtensions
            .addAll(ControllerFactory.getFactory().createExtensionController().getConnectorMetaData().values());
    allExtensions
            .addAll(ControllerFactory.getFactory().createExtensionController().getPluginMetaData().values());

    // we are using a set so that we don't have duplicates
    Set<String> extensionPathsToAddToJnlp = new HashSet<String>();

    for (MetaData extension : allExtensions) {
        if (doesExtensionHaveClientOrSharedLibraries(extension)) {
            extensionPathsToAddToJnlp.add(extension.getPath());
        }
    }

    for (String extensionPath : extensionPathsToAddToJnlp) {
        Element extensionElement = document.createElement("extension");
        extensionElement.setAttribute("href", "webstart/extensions/" + extensionPath + ".jnlp");
        resourcesElement.appendChild(extensionElement);
    }

    Element applicationDescElement = (Element) jnlpElement.getElementsByTagName("application-desc").item(0);
    Element serverArgumentElement = document.createElement("argument");
    serverArgumentElement.setTextContent(server);
    applicationDescElement.appendChild(serverArgumentElement);
    Element versionArgumentElement = document.createElement("argument");
    versionArgumentElement.setTextContent(version);
    applicationDescElement.appendChild(versionArgumentElement);

    String[] protocols = configurationController.getHttpsClientProtocols();
    String[] cipherSuites = configurationController.getHttpsCipherSuites();

    // Only add arguments for the protocols / cipher suites if they are non-default
    if (!Arrays.areEqual(protocols, MirthSSLUtil.DEFAULT_HTTPS_CLIENT_PROTOCOLS)
            || !Arrays.areEqual(cipherSuites, MirthSSLUtil.DEFAULT_HTTPS_CIPHER_SUITES)) {
        Element sslArgumentElement = document.createElement("argument");
        sslArgumentElement.setTextContent("-ssl");
        applicationDescElement.appendChild(sslArgumentElement);

        Element protocolsArgumentElement = document.createElement("argument");
        protocolsArgumentElement.setTextContent(StringUtils.join(protocols, ','));
        applicationDescElement.appendChild(protocolsArgumentElement);

        Element cipherSuitesArgumentElement = document.createElement("argument");
        cipherSuitesArgumentElement.setTextContent(StringUtils.join(cipherSuites, ','));
        applicationDescElement.appendChild(cipherSuitesArgumentElement);
    }

    return document;
}

From source file:com.linkedin.pinot.core.query.scheduler.PrioritySchedulerTest.java

@Test
public void testStartStopQueries() throws ExecutionException, InterruptedException, IOException {
    TestPriorityScheduler scheduler = TestPriorityScheduler.create();
    scheduler.start();//w  w  w  . j  ava2s .c om

    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(ResourceLimitPolicy.TABLE_THREADS_HARD_LIMIT, 5);
    conf.setProperty(MultiLevelPriorityQueue.MAX_PENDING_PER_GROUP_KEY, 5);
    List<ListenableFuture<byte[]>> results = new ArrayList<>();
    results.add(scheduler.submit(createServerQueryRequest("1", metrics)));
    TestSchedulerGroup group = TestPriorityScheduler.groupFactory.groupMap.get("1");
    group.addReservedThreads(10);
    group.addLast(createQueryRequest("1", metrics));
    results.add(scheduler.submit(createServerQueryRequest("1", metrics)));

    scheduler.stop();
    long queueWakeTimeMicros = ((MultiLevelPriorityQueue) scheduler.getQueue()).getWakeupTimeMicros();
    long sleepTimeMs = queueWakeTimeMicros >= 1000 ? queueWakeTimeMicros / 1000 + 10 : 10;
    Thread.sleep(sleepTimeMs);
    int hasServerShuttingDownError = 0;
    for (ListenableFuture<byte[]> result : results) {
        DataTable table = DataTableFactory.getDataTable(result.get());
        hasServerShuttingDownError += table.getMetadata().containsKey(
                DataTable.EXCEPTION_METADATA_KEY + QueryException.SERVER_SCHEDULER_DOWN_ERROR.getErrorCode())
                        ? 1
                        : 0;
    }
    assertTrue(hasServerShuttingDownError > 0);
}