List of usage examples for java.util Properties putAll
@Override public synchronized void putAll(Map<?, ?> t)
From source file:org.apache.falcon.cli.commands.BaseFalconCommands.java
protected static Properties getClientProperties() { if (clientProperties == null) { InputStream inputStream = null; Properties prop = new Properties(System.getProperties()); prop.putAll(backupProperties); try {//from ww w .j a va2 s .c om inputStream = BaseFalconCommands.class.getResourceAsStream(CLIENT_PROPERTIES); if (inputStream != null) { try { prop.load(inputStream); } catch (IOException e) { throw new FalconCLIRuntimeException(e); } } } finally { IOUtils.closeQuietly(inputStream); } String urlOverride = System.getenv(FALCON_URL); if (urlOverride != null) { prop.setProperty(FALCON_URL_PROPERTY, urlOverride); } if (prop.getProperty(FALCON_URL_PROPERTY) == null) { throw new FalconCLIRuntimeException( "Failed to get falcon url from environment or client properties"); } String doAsOverride = System.getenv(DO_AS); if (doAsOverride != null) { prop.setProperty(DO_AS_PROPERTY, doAsOverride); } clientProperties = prop; backupProperties.clear(); } return clientProperties; }
From source file:info.magnolia.cms.core.SystemProperty.java
/** * @deprecated since 4.5 - while this still "works" and returns an aggregate of the local properties and those provided by * MagnoliaConfigurationProperties, writing to this Property object will not be reflected anywhere. *//* ww w. jav a2 s . c om*/ public static Properties getProperties() { // DeprecationUtil.isDeprecated(); // providing a MagnoliaConfigurationProperties-compliant replacement... final Properties p = new Properties(); p.putAll(properties); for (String k : magnoliaConfigurationProperties.getKeys()) { p.put(k, magnoliaConfigurationProperties.getProperty(k)); } return p; }
From source file:ezbake.security.EzSecurityITBase.java
@BeforeClass public static void setUpServerPool() throws Exception { Random portChooser = new Random(); int port = portChooser.nextInt((34999 - 30000) + 1) + 30000; int zooPort = portChooser.nextInt((20499 - 20000) + 1) + 20000; redisServer = new LocalRedis(); EzConfiguration ezConfiguration = new EzConfiguration(new ClasspathConfigurationLoader()); properties = ezConfiguration.getProperties(); properties.setProperty(EzBakePropertyConstants.REDIS_HOST, "localhost"); properties.setProperty(EzBakePropertyConstants.REDIS_PORT, Integer.toString(redisServer.getPort())); properties.setProperty(EzBakePropertyConstants.ZOOKEEPER_CONNECTION_STRING, "localhost:" + String.valueOf(zooPort)); properties.setProperty(FileUAService.USERS_FILENAME, EzSecurityITBase.class.getResource("/users.json").getFile()); properties.setProperty(EzBakePropertyConstants.EZBAKE_ADMINS_FILE, EzSecurityITBase.class.getResource("/admins").getFile()); properties.setProperty(AdminServiceModule.PUBLISHING, Boolean.TRUE.toString()); Properties localConfig = new Properties(); localConfig.putAll(properties); localConfig.setProperty(EzBakePropertyConstants.EZBAKE_CERTIFICATES_DIRECTORY, EzSecurityITBase.class.getResource("/pki/server").getFile()); localConfig.setProperty("storage.directory", folder.getRoot().toString()); serverPool = new ThriftServerPool(localConfig, port); serverPool.startCommonService(new EzSecurityHandler(), EzSecurityServicesConstants.SECURITY_SERVICE_NAME, "12345"); serverPool.startCommonService(new ezbake.groups.service.EzBakeThriftService(), EzGroupsConstants.SERVICE_NAME, "12345"); ServiceDiscoveryClient client = new ServiceDiscoveryClient( properties.getProperty(EzBakePropertyConstants.ZOOKEEPER_CONNECTION_STRING)); client.setSecurityIdForCommonService(AppName, "10000000"); client.setSecurityIdForApplication(AppName, "10000000"); properties.setProperty(EzBakePropertyConstants.EZBAKE_CERTIFICATES_DIRECTORY, EzSecurityITBase.class.getResource("/pki/client").getFile()); properties.setProperty(EzBakePropertyConstants.EZBAKE_SECURITY_ID, "10000000"); }
From source file:org.apache.falcon.shell.commands.BaseFalconCommands.java
public static Properties getShellProperties() { if (clientProperties == null) { InputStream inputStream = null; Properties prop = new Properties(System.getProperties()); prop.putAll(backupProperties); try {/*w w w . j a v a 2 s. c om*/ inputStream = BaseFalconCommands.class.getResourceAsStream(SHELL_PROPERTIES); if (inputStream != null) { try { prop.load(inputStream); } catch (IOException e) { throw new FalconCLIException(e); } } } finally { IOUtils.closeQuietly(inputStream); } String urlOverride = System.getenv(FALCON_URL); if (urlOverride != null) { prop.setProperty(FALCON_URL_PROPERTY, urlOverride); } if (prop.getProperty(FALCON_URL_PROPERTY) == null) { throw new FalconCLIException(FALCON_URL_ABSENT); } String doAsOverride = System.getenv(DO_AS); if (doAsOverride != null) { prop.setProperty(DO_AS_PROPERTY, doAsOverride); } clientProperties = prop; backupProperties.clear(); } return clientProperties; }
From source file:com.aionlightning.commons.utils.PropertiesUtils.java
/** * All initial properties will be overriden with properties supplied as second argument * //from w w w . j av a 2 s . com * @param initialProperties * @param properties * @return */ public static Properties[] overrideProperties(Properties[] initialProperties, Properties properties) { if (properties != null) { for (Properties initialProps : initialProperties) { initialProps.putAll(properties); } } return initialProperties; }
From source file:org.apache.falcon.lifecycle.engine.oozie.retention.AgeBasedCoordinatorBuilder.java
/** * Builds the coordinator app./*from www .j a va 2 s .c om*/ * @param cluster - cluster to schedule retention on. * @param basePath - Base path to marshal coordinator app. * @param feed - feed for which retention is to be scheduled. * @param wfProp - properties passed from workflow to coordinator e.g. ENTITY_PATH * @return - Properties from creating the coordinator application to be used by Bundle. * @throws FalconException */ public static Properties build(Cluster cluster, Path basePath, Feed feed, Properties wfProp) throws FalconException { org.apache.falcon.entity.v0.feed.Cluster feedCluster = FeedHelper.getCluster(feed, cluster.getName()); if (feedCluster.getValidity().getEnd().before(new Date())) { LOG.warn("Feed Retention is not applicable as Feed's end time for cluster {} is not in the future", cluster.getName()); return null; } COORDINATORAPP coord = new COORDINATORAPP(); String coordName = EntityUtil.getWorkflowName(LifeCycle.EVICTION.getTag(), feed).toString(); coord.setName(coordName); Date endDate = feedCluster.getValidity().getEnd(); if (RuntimeProperties.get().getProperty("falcon.retention.keep.instances.beyond.validity", "true") .equalsIgnoreCase("false")) { int retentionLimitinSecs = FeedHelper.getRetentionLimitInSeconds(feed, cluster.getName()); endDate = DateUtils.addSeconds(endDate, retentionLimitinSecs); } coord.setEnd(SchemaHelper.formatDateUTC(endDate)); coord.setStart(SchemaHelper.formatDateUTC(new Date())); coord.setTimezone(feed.getTimezone().getID()); Frequency retentionFrequency = FeedHelper.getLifecycleRetentionFrequency(feed, cluster.getName()); // set controls long frequencyInMillis = ExpressionHelper.get().evaluate(retentionFrequency.toString(), Long.class); CONTROLS controls = new CONTROLS(); controls.setExecution(ExecutionType.LAST_ONLY.value()); controls.setTimeout(String.valueOf(frequencyInMillis / (1000 * 60))); controls.setConcurrency("1"); controls.setThrottle("1"); coord.setControls(controls); coord.setFrequency("${coord:" + retentionFrequency.toString() + "}"); Path buildPath = OozieBuilderUtils.getBuildPath(basePath, LifeCycle.EVICTION.getTag()); Properties props = OozieBuilderUtils.createCoordDefaultConfiguration(coordName, feed); props.putAll(OozieBuilderUtils.getProperties(buildPath, coordName)); WORKFLOW workflow = new WORKFLOW(); String entityPath = wfProp.getProperty(OozieBuilderUtils.ENTITY_PATH); String storagePath = OozieBuilderUtils.getStoragePath(entityPath); workflow.setAppPath(storagePath); workflow.setConfiguration(OozieBuilderUtils.getCoordinatorConfig(props)); ACTION action = new ACTION(); action.setWorkflow(workflow); coord.setAction(action); Path marshalPath = OozieBuilderUtils.marshalCoordinator(cluster, coord, buildPath); return OozieBuilderUtils.getProperties(marshalPath, coordName); }
From source file:JNDIUtil.java
public static Properties getDefaultProperties() { Properties defaultProperties = new Properties(); try {//from ww w . j av a 2 s .c om InitialContext context = new InitialContext(); defaultProperties.putAll(context.getEnvironment()); } catch (Exception e) { System.out.println("Unexpected exception when trying to retrieve default naming context." + e); } return defaultProperties; }
From source file:org.apache.falcon.lifecycle.engine.oozie.retention.AgeBasedWorkflowBuilder.java
public static Properties build(Cluster cluster, Path basePath, Feed feed) throws FalconException { Path buildPath = OozieBuilderUtils.getBuildPath(basePath, LifeCycle.EVICTION.getTag()); WORKFLOWAPP workflow = new WORKFLOWAPP(); String wfName = EntityUtil.getWorkflowName(Tag.RETENTION, feed).toString(); //Add eviction action ACTION eviction = OozieBuilderUtils.unmarshalAction(EVICTION_ACTION_TEMPLATE); OozieBuilderUtils.addTransition(eviction, OozieBuilderUtils.SUCCESS_POSTPROCESS_ACTION_NAME, OozieBuilderUtils.FAIL_POSTPROCESS_ACTION_NAME); workflow.getDecisionOrForkOrJoin().add(eviction); //Add post-processing actions ACTION success = OozieBuilderUtils.getSuccessPostProcessAction(); OozieBuilderUtils.addTransition(success, OozieBuilderUtils.OK_ACTION_NAME, OozieBuilderUtils.FAIL_ACTION_NAME); workflow.getDecisionOrForkOrJoin().add(success); ACTION fail = OozieBuilderUtils.getFailPostProcessAction(); OozieBuilderUtils.addTransition(fail, OozieBuilderUtils.FAIL_ACTION_NAME, OozieBuilderUtils.FAIL_ACTION_NAME); workflow.getDecisionOrForkOrJoin().add(fail); OozieBuilderUtils.decorateWorkflow(workflow, wfName, EVICTION_ACTION_NAME); OozieBuilderUtils.addLibExtensionsToWorkflow(cluster, workflow, Tag.RETENTION, EntityType.FEED); // Prepare and marshal properties to config-default.xml Properties props = OozieBuilderUtils.getProperties(buildPath, wfName); props.putAll(getWorkflowProperties(feed, cluster)); props.putAll(OozieBuilderUtils.createDefaultConfiguration(cluster, feed, WorkflowExecutionContext.EntityOperations.DELETE)); props.putAll(FeedHelper.getUserWorkflowProperties(LifeCycle.EVICTION)); // override the queueName and priority RetentionStage retentionStage = FeedHelper.getRetentionStage(feed, cluster.getName()); if (StringUtils.isNotBlank(retentionStage.getQueue())) { props.put(OozieBuilderUtils.MR_QUEUE_NAME, retentionStage.getQueue()); }/*w w w . j av a 2s . com*/ if (StringUtils.isNotBlank(retentionStage.getPriority())) { props.put(OozieBuilderUtils.MR_JOB_PRIORITY, retentionStage.getPriority()); } if (EntityUtil.isTableStorageType(cluster, feed)) { setupHiveCredentials(cluster, buildPath, workflow); // copy paste todo kludge send source hcat creds for coord dependency check to pass props.putAll(HiveUtil.getHiveCredentials(cluster)); } // Write out the config to config-default.xml OozieBuilderUtils.marshalDefaultConfig(cluster, workflow, props, buildPath); // write out the workflow.xml OozieBuilderUtils.marshalWokflow(cluster, workflow, buildPath); return props; }
From source file:org.apache.sqoop.connector.jdbc.oracle.util.OracleConnectionFactory.java
public static Connection makeConnection(ConnectionConfig config) throws SQLException { String connectStr = config.connectionString; String username = config.username; String password = config.password; Properties additionalProps = new Properties(); if (config.jdbcProperties != null) { additionalProps.putAll(config.jdbcProperties); }/*from ww w . j av a2 s . c o m*/ Connection connection = OracleConnectionFactory.createOracleJdbcConnection( OracleJdbcConnectorConstants.ORACLE_JDBC_DRIVER_CLASS, connectStr, username, password, additionalProps); //TODO: This is from the other Oracle Manager // if (username == null) { // username = OracleManager.getSessionUser(connection); // } OracleUtilities.setCurrentSessionUser(username); return connection; }
From source file:de.fiz.ddb.aas.util.AasConfiguration.java
/** * Loads the Properties from properties-file. * * @return The properties/*w w w .j ava2 s .c o m*/ * @throws IOException If the loading of the properties fails. */ private static Properties loadProperties() throws IOException { final Properties result = getProperties(PROPERTIES_DEFAULT_FILENAME); final Properties overwrite = getProperties(PROPERTIES_FILENAME); result.putAll(overwrite); return result; }