public BatchWriterConfig getBatchWriterConfig() { ensureOpen(); if (batchWriterConfig == null) { Properties props = info.getProperties(); batchWriterConfig = new BatchWriterConfig(); Long maxMemory = ClientProperty.BATCH_WRITER_MEMORY_MAX.getBytes(props); if (maxMemory != null) { batchWriterConfig.setMaxMemory(maxMemory); } Long maxLatency = ClientProperty.BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props); if (maxLatency != null) { batchWriterConfig.setMaxLatency(maxLatency, TimeUnit.SECONDS); } Long timeout = ClientProperty.BATCH_WRITER_TIMEOUT_MAX.getTimeInMillis(props); if (timeout != null) { batchWriterConfig.setTimeout(timeout, TimeUnit.SECONDS); } String durability = ClientProperty.BATCH_WRITER_DURABILITY.getValue(props); if (!durability.isEmpty()) { batchWriterConfig.setDurability(Durability.valueOf(durability.toUpperCase())); } } return batchWriterConfig; }
/** * Gets the {@link BatchWriterConfig} settings that were stored with ClientInfo */ public static BatchWriterConfig getBatchWriterOptions(Class<?> implementingClass, Configuration conf) { BatchWriterConfig bwConfig = new BatchWriterConfig(); Properties props = getClientProperties(implementingClass, conf); String property = props.getProperty(BATCH_WRITER_DURABILITY.getKey()); if (property != null) bwConfig.setDurability(DurabilityImpl.fromString(property)); Long value = BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props); if (value != null) bwConfig.setMaxLatency(value, TimeUnit.MILLISECONDS); value = BATCH_WRITER_MEMORY_MAX.getBytes(props); if (value != null) bwConfig.setMaxMemory(value); value = BATCH_WRITER_TIMEOUT_MAX.getTimeInMillis(props); if (value != null) bwConfig.setTimeout(value, TimeUnit.MILLISECONDS); Integer intValue = BATCH_WRITER_THREADS_MAX.getInteger(props); if (intValue != null) bwConfig.setMaxWriteThreads(intValue); return bwConfig; }