Java Code Examples for org.apache.commons.configuration.XMLConfiguration#getInt()

The following examples show how to use org.apache.commons.configuration.XMLConfiguration#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdentityApplicationManagementServiceClient.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
public IdentityApplicationManagementServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);
        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");

            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new IdentityApplicationManagementServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
	        String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }
 
Example 2
Source File: IdentityApplicationManagementServiceClient.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
private String getIdToken(String compositeAppId, String consumerKey, String consumerSecret) throws OAuthSystemException, OAuthProblemException {
    XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
    String hostname = conf.getString("autoscaler.identity.hostname", "localhost");
    int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants.IS_DEFAULT_PORT);
    String tokenEndpoint = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.TOKEN_ENDPOINT_SFX;
    OAuthClientRequest accessRequest = OAuthClientRequest.tokenLocation(tokenEndpoint)
            .setGrantType(GrantType.CLIENT_CREDENTIALS)
            .setClientId(consumerKey)
            .setClientSecret(consumerSecret)
            .setScope(compositeAppId)
            .buildBodyMessage();
    OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

    OAuthClientResponse oAuthResponse = oAuthClient.accessToken(accessRequest);
    return oAuthResponse.getParam(ID_TOKEN);
}
 
Example 3
Source File: InternalMetaAnalysisSettings.java    From systemsgenetics with GNU General Public License v3.0 6 votes vote down vote up
public void parse(String settings, String texttoreplace, String replacetextwith) {
    try {
        config = new XMLConfiguration(settings);

        nrPermutations = config.getInt("defaults.permutations", 0);
        startPermutations = config.getInt("defaults.startpermutation", 0);
        output = config.getString("defaults.output");
        probeToFeature = config.getString("defaults.probeToFeature");
        datasetname = config.getString("defaults.dataset.name");  // see if a dataset is defined
        datasetPrefix = config.getString("defaults.dataset.prefix");  // see if a dataset is defined
        zScoreMergeOption = config.getString("defaults.zScoreMerge").toLowerCase();
        if (datasetPrefix == null) {
            datasetPrefix = "Dataset";
        }
        String datasetloc = config.getString("defaults.dataset.location");  // see if a dataset is defined
        if (texttoreplace != null && replacetextwith != null && datasetloc.contains(texttoreplace)) {
            datasetloc = datasetloc.replace(texttoreplace, replacetextwith);
        }
        datasetlocation = datasetloc;
        
        // parse datasets
    } catch (ConfigurationException e) {
    
    }
}
 
Example 4
Source File: OAuthAdminServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public OAuthAdminServiceClient(String epr) throws AxisFault {

        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int autosclaerSocketTimeout = conf.getInt("autoscaler.identity.clientTimeout", 180000);

        try {
            ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
            String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
            String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
            String type = serverConfig.getFirstProperty("Security.TrustStore.Type");
            System.setProperty("javax.net.ssl.trustStore", trustStorePath);
            System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
            System.setProperty("javax.net.ssl.trustStoreType", type);

            stub = new OAuthAdminServiceStub(epr);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, autosclaerSocketTimeout);
            stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, autosclaerSocketTimeout);
            //String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
            //TODO StratosAuthenticationHandler does not set to carbon context, thus user name becomes null.
            // For the moment username is hardcoded since above is fixed.
            String username = conf.getString("autoscaler.identity.adminUser", "admin");
            Utility.setAuthHeaders(stub._getServiceClient(), username);

        } catch (AxisFault axisFault) {
            String msg = "Failed to initiate identity service client. " + axisFault.getMessage();
            log.error(msg, axisFault);
            throw new AxisFault(msg, axisFault);
        }
    }
 
Example 5
Source File: OAuthAdminServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public static OAuthAdminServiceClient getServiceClient() throws AxisFault {
    if (serviceClient == null) {
        synchronized (OAuthAdminServiceClient.class) {
            if (serviceClient == null) {
                XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
                String hostname = conf.getString("autoscaler.identity.hostname", "localhost");
                int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants.IS_DEFAULT_PORT);
                String epr = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.OAUTH_SERVICE_SFX;
                serviceClient = new OAuthAdminServiceClient(epr);
            }
        }
    }
    return serviceClient;
}
 
Example 6
Source File: AutoscalerCloudControllerClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private AutoscalerCloudControllerClient() {
    MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager = new
            MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(AS_CC_CLIENT_MAX_CONNECTIONS_PER_HOST);
    params.setMaxTotalConnections(AS_CC_CLIENT_MAX_TOTAL_CONNECTIONS);
    multiThreadedHttpConnectionManager.setParams(params);
    HttpClient httpClient = new HttpClient(multiThreadedHttpConnectionManager);

    try {
        ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
        ctx.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
        int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants
                .CLOUD_CONTROLLER_DEFAULT_PORT);
        String hostname = conf.getString("autoscaler.cloudController.hostname", "localhost");
        String epr = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.CLOUD_CONTROLLER_SERVICE_SFX;
        int cloudControllerClientTimeout = conf.getInt("autoscaler.cloudController.clientTimeout", 180000);

        stub = new CloudControllerServiceStub(ctx, epr);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, cloudControllerClientTimeout);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
                cloudControllerClientTimeout);
        stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
        stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, Boolean
                .TRUE);
    } catch (Exception e) {
        log.error("Could not initialize cloud controller client", e);
    }
}
 
Example 7
Source File: IdentityApplicationManagementServiceClient.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public static IdentityApplicationManagementServiceClient getServiceClient() throws AxisFault {
    if (serviceClient == null) {
        synchronized (IdentityApplicationManagementServiceClient.class) {
            if (serviceClient == null) {
                XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
                String hostname = conf.getString("autoscaler.identity.hostname", "localhost");
                int port = conf.getInt("autoscaler.cloudController.port", AutoscalerConstants.IS_DEFAULT_PORT);
                String epr = "https://" + hostname + ":" + port + "/" + AutoscalerConstants.IDENTITY_APPLICATION_SERVICE_SFX;
                serviceClient = new IdentityApplicationManagementServiceClient(epr);
            }
        }
    }
    return serviceClient;
}
 
Example 8
Source File: ClusterMonitor.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
private void readConfigurations() {
    XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration();
    int monitorInterval = conf.getInt(AutoscalerConstants.Cluster_MONITOR_INTERVAL, 90000);
    setMonitorIntervalMilliseconds(monitorInterval);
    if (log.isDebugEnabled()) {
        log.debug("ClusterMonitor task interval set to : [application-id] " + appId +
                " [cluster] " + clusterId + " [monitor-interval] " +
                getMonitorIntervalMilliseconds());
    }
}
 
Example 9
Source File: TestSettings.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
@Test
public void testServerSettings()
{
	try
	{
		String configFilePath = new File(".").getCanonicalPath();

		String fileFQN = configFilePath + File.separator
		+ "cfg" + File.separator
		+ "config.xml";

		if(new File(fileFQN).exists())
		{
			XMLConfiguration config = new XMLConfiguration( fileFQN );
			config.load();

			Object servers = config.getProperty("Environment.ConnectionManager.Services.Service[@name]");

			if(servers instanceof Collection<?>)
			{
				for(int i = 0 ; i < ((Collection<?>) servers).size(); i++)
				{
					String key = String.format( "Environment.ConnectionManager.Services.Service(%d)[@type]", i );
					String keyValue = config.getString(key );

                       if("NTG-Server".equals(keyValue))
					{
						String instIdKey = String.format( "Environment.ConnectionManager.Services.Service(%d).strategies.strategy.instrumentID", i );
						Object prop = config.getList(instIdKey);

						if(prop instanceof Collection<?>)
						{
                               NTGServerSettings serverSettings = new NTGServerSettings();
                               Map<String, NTGServerStrategy> strategy = new HashMap<String, NTGServerStrategy>();

							int j = 0 ;

							for(Object instrValue : (Collection<?>)prop)
							{
								//String symbol = config.getString(String.format( "Environment.ConnectionManager.Services.Service(%d).strategies.strategy(%d).instrumentID", i, j));
								String symbol = instrValue.toString();

								if(! strategy.containsKey( symbol ))
								{
									String strategyValueString = config.getString(String.format( "Environment.ConnectionManager.Services.Service(%d).strategies.strategy(%d).strategyValue", i, j));
                                       NTGServerStrategy strategyValue =
                                               Enum.valueOf(NTGServerStrategy.class, strategyValueString);
									strategy.put( symbol, strategyValue );
								}
								++j;
							}

							int heartbeatTimeout = config.getInt(String.format("Environment.ConnectionManager.Services.Service(%d).heartbeatTimeout", i ));
							int maxMissedHeartbeats = config.getInt(String.format("Environment.ConnectionManager.Services.Service(%d).maxMissedHeartbeats", i ));
							int serverPort = config.getInt( String.format("Environment.ConnectionManager.Services.Service(%d).serverPort", i ));
							String serverIP = config.getString(String.format("Environment.ConnectionManager.Services.Service(%d).serverIP", i ));

							serverSettings.setHeartbeatTimeout( heartbeatTimeout );
							serverSettings.setMaxMissedHeartbeats( maxMissedHeartbeats );
							serverSettings.setServerPort( serverPort ) ;
							serverSettings.setServerIP( serverIP ) ;

							serverSettings.setStrategy( strategy );
						}
						break;
					}
					Assert.fail();
				}
			}
		}
	}
	catch(Exception ex)
	{
		ex.printStackTrace();
		Assert.fail();
	}
}
 
Example 10
Source File: MetaSettings.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
public void parse(String settings, String texttoreplace, String replacetextwith) {
		try {
			config = new XMLConfiguration(settings);

			nrPermutations = config.getInt("defaults.permutations", 0);

			useAbsoluteZscore = config.getBoolean("defaults.absolutezscore", false);
			finalEQTLBufferMaxLength = config.getInt("defaults.finalnreqtls", 100000);
			fdrthreshold = config.getDouble("defaults.fdrthreshold", 0.05);
			cisdistance = config.getInt("defaults.cisprobedistance", 250000);
			transdistance = config.getInt("defaults.transprobedistance", 5000000);
			includeProbesWithoutProperMapping = config.getBoolean("defaults.includeprobeswithoutmapping", true);
			includeSNPsWithoutProperMapping = config.getBoolean("defaults.includesnpswithoutmapping", true);
			makezscoreplot = config.getBoolean("defaults.makezscoreplot", true);
			makezscoretable = config.getBoolean("defaults.makezscoretable", false);
			probetranslationfile = config.getString("defaults.probetranslationfile");
			String outputStr = config.getString("defaults.output");

			System.out.println("outputstr: " + outputStr);

			if (texttoreplace != null && replacetextwith != null && outputStr.contains(texttoreplace)) {
				outputStr = outputStr.replaceAll(texttoreplace, replacetextwith);
				System.out.println("outputstr: " + outputStr);
			}
			output = outputStr;
			System.out.println("outputstr: " + outputStr);
//			System.exit(-1);


			probeDatasetPresenceThreshold = config.getInt("defaults.minimalnumberofdatasetsthatcontainprobe", 0);
			snpDatasetPresenceThreshold = config.getInt("defaults.minimalnumberofdatasetsthatcontainsnp", 0);
			probeAndSNPPresenceFilterSampleThreshold = config.getInt("defaults.snpprobeselectsamplesizethreshold", -1);

			runonlypermutation = config.getInt("defaults.runonlypermutation", -1);
			nrThresds = config.getInt("defaults.threads", 0);
			cis = config.getBoolean("defaults.cis", false);
			trans = config.getBoolean("defaults.trans", false);

			probeselection = config.getString("defaults.probeselection");

			if (probeselection != null && probeselection.trim().length() == 0) {
				probeselection = null;
			}
			snpselection = config.getString("defaults.snpselection");

			if (snpselection != null && snpselection.trim().length() == 0) {
				snpselection = null;
			}

			if (texttoreplace != null && replacetextwith != null && snpselection.contains(texttoreplace)) {
				snpselection = snpselection.replaceAll(texttoreplace, replacetextwith);
			}

			snpprobeselection = config.getString("defaults.snpprobeselection");

			if (snpprobeselection != null && snpprobeselection.trim().length() == 0) {
				snpprobeselection = null;
			} else {
				System.out.println("SNP PROBE SELECTION: " + snpprobeselection);
			}


			int i = 0;

			String dataset = "";
			datasetnames = new ArrayList<String>();
			datasetlocations = new ArrayList<String>();
			datasetannotations = new ArrayList<String>();
			datasetPrefix = new ArrayList<String>();

			while (dataset != null) {
				dataset = config.getString("datasets.dataset(" + i + ").name");  // see if a dataset is defined
				if (dataset != null) {

					datasetnames.add(dataset);
					String prefix = config.getString("datasets.dataset(" + i + ").prefix");  // see if a dataset is defined

					if (prefix == null) {
						prefix = "Dataset";
					}
					datasetPrefix.add(prefix);
					String datasetlocation = config.getString("datasets.dataset(" + i + ").location");  // see if a dataset is defined
					if (texttoreplace != null && replacetextwith != null && datasetlocation.contains(texttoreplace)) {
						datasetlocation = datasetlocation.replace(texttoreplace, replacetextwith);
					}
					String datasetannotation = config.getString("datasets.dataset(" + i + ").expressionplatform");  // see if a dataset is defined

					datasetlocations.add(datasetlocation);
					datasetannotations.add(datasetannotation);
				}
				i++;
			}


			// parse datasets
		} catch (ConfigurationException e) {
			e.printStackTrace();
		}
	}