@SuppressWarnings("unchecked") static Set<Object> getWebAppStatSet0() { Properties properties = System.getProperties(); Set<Object> webAppStats = (Set<Object>) properties.get(SYS_PROP_INSTANCES); if (webAppStats == null) { synchronized (properties) { webAppStats = (Set<Object>) properties.get(SYS_PROP_INSTANCES); if (webAppStats == null) { webAppStats = new CopyOnWriteArraySet<Object>(); properties.put(SYS_PROP_INSTANCES, webAppStats); } } } return webAppStats; }
private static Properties createSampleProperties() { Properties properties = new Properties(); properties.put("com.example.service.One", "service"); properties.put("com.example.service.sub.Two", "service"); properties.put("com.example.service.Three", "service"); properties.put("com.example.domain.Four", "entity"); return properties; }
private static Properties convertValuesToString(Map props) { Properties newProps = new Properties(); for (Object o : props.entrySet()) { Map.Entry next = (Map.Entry) o; Object key = next.getKey(); Object value = next.getValue(); newProps.put(key, value != null ? value.toString() : null); } return newProps; }
public Properties loadProperties(final Supplier<Properties> overridePropertySupplier) throws IOException { final Properties properties = new Properties(); try (FileInputStream inputStream = new FileInputStream(propertiesFile)) { properties.load(inputStream); } final Properties sysProperties = overridePropertySupplier.get(); sysProperties.stringPropertyNames() .stream() .filter(key -> systemPropertyExclusions.stream().noneMatch(key::startsWith)) .forEach(key -> properties.put(key, sysProperties.getProperty(key))); return properties; }
/** * * @return Properties consisting mailHost and mailFrom property */ private Properties getMailHostConfiguration() { Properties result = new Properties(); if (mailHost == null) { mailHost = ""; } if (mailFrom == null) { mailFrom = ""; } result.setProperty("mail.host", mailHost); result.put("mail.from", mailFrom); return result; }
private Properties buildProducerProperties(Table table) { String brokers = table.getParameters().get(KafkaTableProperties.HIVE_KAFKA_BOOTSTRAP_SERVERS.getName()); if (brokers == null || brokers.isEmpty()) { throw new RuntimeException("kafka brokers string is null or empty"); } final Properties properties = new Properties(); properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName()); properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName()); properties.setProperty(CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG, brokers); if (UserGroupInformation.isSecurityEnabled()) { KafkaUtils.addKerberosJaasConf(getConf(), properties); } table.getParameters() .entrySet() .stream() .filter(objectObjectEntry -> objectObjectEntry.getKey() .toLowerCase() .startsWith(KafkaUtils.PRODUCER_CONFIGURATION_PREFIX)) .forEach(entry -> { String key = entry.getKey().substring(KafkaUtils.PRODUCER_CONFIGURATION_PREFIX.length() + 1); if (KafkaUtils.FORBIDDEN_PROPERTIES.contains(key)) { throw new IllegalArgumentException("Not suppose to set Kafka Property " + key); } properties.put(key, entry.getValue()); }); return properties; }
public void addConnectionProperty(String name, String value) { if (StringUtils.equals(connectProperties.getProperty(name), value)) { return; } if (inited) { throw new UnsupportedOperationException(); } connectProperties.put(name, value); }
@Override public Properties toSecurityProperties() { Properties result = new Properties(); for (Object attName : security.keySet()) { if (attName instanceof String) { result.put(attName, getAttribute((String) attName)); } else { result.put(attName, security.get(attName)); } } return result; }
public void propertiesCantContainNull(Properties p) { p.put("a", null); p.put(null, "a"); p.get(null); p.getProperty(null); p.getProperty(null, "foo"); p.setProperty(null, "a"); p.setProperty("a", null); }
public T withHttpService(boolean useDefaultPort) { properties.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost"); if (!useDefaultPort) { properties.put(HTTP_SERVICE_PORT, portSupplier.getAvailablePort() + ""); this.httpPort = Integer.parseInt(properties.getProperty(HTTP_SERVICE_PORT)); } else { // indicate start http service but with default port // (different from Gemfire properties, 0 means do not start http service) httpPort = 0; } return (T) this; }
protected void init(boolean audited, String auditStrategy) throws IOException { this.audited = audited; Properties configurationProperties = new Properties(); configurationProperties.putAll( Environment.getProperties() ); if ( !audited ) { configurationProperties.setProperty( EnversIntegrator.AUTO_REGISTER, "false" ); } if ( createSchema() ) { configurationProperties.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); configurationProperties.setProperty( Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true" ); configurationProperties.setProperty( EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false" ); } if ( auditStrategy != null && !"".equals( auditStrategy ) ) { configurationProperties.setProperty( "org.hibernate.envers.audit_strategy", auditStrategy ); } addConfigurationProperties( configurationProperties ); configurationProperties.put( AvailableSettings.LOADED_CLASSES, Arrays.asList( getAnnotatedClasses() ) ); entityManagerFactoryBuilder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder( new PersistenceUnitDescriptorAdapter(), configurationProperties ); emf = entityManagerFactoryBuilder.build().unwrap( HibernateEntityManagerFactory.class ); serviceRegistry = (StandardServiceRegistryImpl) emf.getSessionFactory() .getServiceRegistry() .getParentServiceRegistry(); newEntityManager(); }
@Override public IRichBolt getConsumer() { Preconditions.checkArgument(!props.isEmpty(), "Writable Kafka table " + topic + " must contain producer config"); HashMap<String, Object> producerConfig = (HashMap<String, Object>) props.get(CONFIG_KEY_PRODUCER); props.putAll(producerConfig); Preconditions.checkState(!props.containsKey(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG), "Writable Kafka table " + topic + " must not contain \"bootstrap.servers\" config, set it in the kafka URL instead"); Preconditions.checkState(!props.containsKey(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG), "Writable Kafka table " + topic + "must not contain " + ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG + ", it will be hardcoded to be " + ByteBufferSerializer.class); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteBufferSerializer.class); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); TupleToKafkaMapper<Object, ByteBuffer> mapper = new SqlKafkaMapper(serializer); return new KafkaBolt<Object, ByteBuffer>() .withTopicSelector(new DefaultTopicSelector(topic)) .withProducerProperties(props) .withTupleToKafkaMapper(mapper); } }
public Props(Properties props) { this.properties = new Properties(); props.forEach((k, v) -> this.properties.put(k.toString().trim(), v == null ? null : v.toString().trim())); this.encryption = new Encryption(props.getProperty(AesCipher.ENCRYPTION_SECRET_KEY_PATH)); }
public String getProperties() { if (this.properties == null) { return null; } Properties properties = new Properties(this.properties); if (properties.contains("password")) { properties.put("password", "******"); } return properties.toString(); }
public Properties getSecureProperties() { Properties prop = new Properties(); if (config.isSecureMode()) { prop.put("security.inter.broker.protocol", "SASL_PLAINTEXT"); prop.put("security.protocol", "SASL_PLAINTEXT"); prop.put("sasl.kerberos.service.name", "kafka"); //add special timeout for Travis prop.setProperty("zookeeper.session.timeout.ms", zkTimeout); prop.setProperty("zookeeper.connection.timeout.ms", zkTimeout); prop.setProperty("metadata.fetch.timeout.ms", "120000"); } return prop; }
protected void addAll( Properties target, Map source ) { Iterator itr = source.entrySet().iterator(); while ( itr.hasNext() ) { final Map.Entry entry = ( Map.Entry ) itr.next(); final String propertyName = ( String ) entry.getKey(); final String propertyValue = ( String ) entry.getValue(); if ( propertyName != null && propertyValue != null ) { // Make sure we don't override previous set values if ( !target.keySet().contains( propertyName ) ) { if ( !getExcludedPropertyNames().contains( propertyName) ) { target.put( propertyName, propertyValue ); } } } } }
public void setSystemProperty(String key, String value) { checkKeyAndValue(key, value); String systemValue = systemProps.getProperty(key); if (LOG.isDebugEnabled() && systemValue != null && !value.equals(systemValue)) { LOG.debug(format("System property '%s' with value '%s' overwritten with value '%s'", key, systemValue, value)); } overwrittenSystemProps.put(key, value.trim()); }