List of usage examples for java.util Properties put
@Override public synchronized Object put(Object key, Object value)
From source file:com.linkedin.kafka.clients.utils.tests.KafkaTestUtils.java
public static KafkaProducer<String, String> vanillaProducerFor(EmbeddedBroker broker) { String bootstrap = broker.getPlaintextAddr(); if (bootstrap == null) { bootstrap = broker.getSslAddr(); }/*from www. j a v a 2s .c o m*/ Properties props = new Properties(); props.put("bootstrap.servers", bootstrap); props.put("acks", "all"); props.put("retries", 0); props.put("batch.size", 16384); props.put("linger.ms", 1); props.put("buffer.memory", 1024 * 1024); props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); return new KafkaProducer<>(props); }
From source file:com.svds.genericconsumer.main.GenericConsumerGroup.java
/** * Returns a ConsumerConfig with connection information for Kafka * // w w w .ja v a 2 s .c o m * @param zookeeper zookeeper server list to connect to * @param groupId unique id for this consumer group * @return the configured connection information */ private static ConsumerConfig createConsumerConfig(String zookeeper, String groupId) { Properties props = new Properties(); props.put("zookeeper.connect", zookeeper); props.put("group.id", groupId); props.put("zookeeper.session.timeout.ms", "40000"); props.put("zookeeper.sync.time.ms", "200"); props.put("auto.commit.interval.ms", "1000"); return new ConsumerConfig(props); }
From source file:edu.sampleu.common.FreemarkerUtil.java
/** * Loads properties from user defined properties file, if not available uses resource file * * writes processed template to file/*from w w w . j a va 2 s. com*/ * @param key * @param output * @param template * @throws IOException * @throws TemplateException */ public static File ftlWrite(String key, File output, Template template, InputStream inputStream) throws IOException, TemplateException { PropertiesUtils propUtils = new PropertiesUtils(); Properties props = propUtils.loadProperties(inputStream); props.put("baseName", output.getName().substring(0, output.getName().indexOf("ST"))); props.put("className", output.getName().substring(0, output.getName().indexOf("ST"))); // backwards compatibility if (output.getName().contains("TmplMthd")) { // Template method pattern props.put("className", output.getName().substring(0, output.getName().indexOf("TmplMthd"))); } if (props.get("test1") == null) { // backwards compatibility for Smoke Test Freemarker Generation props.put("test1", "test" + props.get("className") + "Bookmark"); props.put("test2", "test" + props.get("className") + "Nav"); } props = propUtils.systemPropertiesOverride(props, key); props = propUtils.transformNumberedPropertiesToList(props); File outputFile = writeTemplateToFile(output, template, props); return outputFile; }
From source file:edu.samplu.common.FreemarkerUtil.java
/** * Loads properties from user defined properties file, if not available uses resource file * * writes processed template to file// w w w. j av a2 s . com * @param key * @param output * @param template * @throws IOException * @throws TemplateException */ public static File ftlWrite(String key, File output, Template template, InputStream inputStream) throws IOException, TemplateException { Properties props = PropertiesUtils.loadProperties(inputStream); props.put("baseName", output.getName().substring(0, output.getName().indexOf("ST"))); props.put("className", output.getName().substring(0, output.getName().indexOf("ST"))); // backwards compatibility if (output.getName().contains("TmplMthd")) { // Template method pattern props.put("className", output.getName().substring(0, output.getName().indexOf("TmplMthd"))); } if (props.get("test1") == null) { // backwards compatibility for Smoke Test Freemarker Generation props.put("test1", "test" + props.get("className") + "Bookmark"); props.put("test2", "test" + props.get("className") + "Nav"); } PropertiesUtils.systemPropertiesOverride(props, key); PropertiesUtils.transformNumberedPropertiesToList(props); File outputFile = writeTemplateToFile(output, template, props); return outputFile; }
From source file:ezbake.security.persistence.impl.FileJsonRegManagerTest.java
private static JsonFileRegManager setUpManager(File testFile) { Properties properties = new Properties(); properties.put(FileRegManager.REGISTRATION_FILE_PATH, testFile.getAbsolutePath()); return new JsonFileRegManager(properties); }
From source file:gobblin.source.extractor.extract.kafka.KafkaSimpleStreamingSource.java
static public Consumer getKafkaConsumer(Config config) { List<String> brokers = ConfigUtils.getStringList(config, ConfigurationKeys.KAFKA_BROKERS); Properties props = new Properties(); props.put("bootstrap.servers", Joiner.on(",").join(brokers)); props.put("group.id", ConfigUtils.getString(config, ConfigurationKeys.JOB_NAME_KEY, StringUtils.EMPTY)); props.put("enable.auto.commit", "false"); Preconditions.checkArgument(config.hasPath(TOPIC_KEY_DESERIALIZER)); props.put("key.deserializer", config.getString(TOPIC_KEY_DESERIALIZER)); Preconditions.checkArgument(config.hasPath(TOPIC_VALUE_DESERIALIZER)); props.put("value.deserializer", config.getString(TOPIC_VALUE_DESERIALIZER)); Consumer consumer = null;//from ww w . j a v a 2 s .c o m try { consumer = new KafkaConsumer<>(props); } catch (Exception e) { LOG.error("Exception when creating Kafka consumer - {}", e); throw Throwables.propagate(e); } return consumer; }
From source file:org.apache.streams.kafka.KafkaPersistReader.java
private static ConsumerConfig createConsumerConfig(String a_zookeeper, String a_groupId) { Properties props = new Properties(); props.put("zookeeper.connect", a_zookeeper); props.put("group.id", a_groupId); props.put("zookeeper.session.timeout.ms", "400"); props.put("zookeeper.sync.time.ms", "200"); props.put("auto.commit.interval.ms", "1000"); return new ConsumerConfig(props); }
From source file:org.esigate.MockRequestExecutor.java
private static Properties getDefaultProperties() { Properties defaultProperties = new Properties(); defaultProperties.put(Parameters.REMOTE_URL_BASE.getName(), "http://localhost"); return defaultProperties; }
From source file:Main.java
/** * Returns common properties for both XA and Non-XA datasource * @param indiName/* w ww. j a v a 2s.c o m*/ */ public static Properties commonDsProperties(String jndiName) { Properties params = new Properties(); //attributes params.put("use-java-context", "true"); params.put("spy", "false"); params.put("use-ccm", "true"); params.put("jndi-name", jndiName); //common elements params.put("driver-name", "h2"); params.put("new-connection-sql", "select 1"); params.put("transaction-isolation", "TRANSACTION_READ_COMMITTED"); params.put("url-delimiter", ":"); params.put("url-selector-strategy-class-name", "someClass"); //pool params.put("min-pool-size", "1"); params.put("max-pool-size", "5"); params.put("pool-prefill", "true"); params.put("pool-use-strict-min", "true"); params.put("flush-strategy", "EntirePool"); //security params.put("user-name", "sa"); params.put("password", "sa"); params.put("security-domain", "HsqlDbRealm"); params.put("reauth-plugin-class-name", "someClass1"); //validation params.put("valid-connection-checker-class-name", "someClass2"); params.put("check-valid-connection-sql", "select 1"); params.put("validate-on-match", "true"); params.put("background-validation", "true"); params.put("background-validation-millis", "2000"); params.put("use-fast-fail", "true"); params.put("stale-connection-checker-class-name", "someClass3"); params.put("exception-sorter-class-name", "someClass4"); //time-out params.put("blocking-timeout-wait-millis", "20000"); params.put("idle-timeout-minutes", "4"); params.put("set-tx-query-timeout", "true"); params.put("query-timeout", "120"); params.put("use-try-lock", "100"); params.put("allocation-retry", "2"); params.put("allocation-retry-wait-millis", "3000"); //statement params.put("track-statements", "nowarn"); params.put("prepared-statements-cache-size", "30"); params.put("share-prepared-statements", "true"); return params; }
From source file:es.eucm.rage.realtime.PerformanceDataTest.java
private static Producer<String, String> createProducer() { Properties props = new Properties(); props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS); props.put(ProducerConfig.CLIENT_ID_CONFIG, "KafkaExampleProducer"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); return new KafkaProducer<>(props); }