public Boolean getUseClientSink() { return this.getConf().getBooleanProperty(USE_CLIENT_SINK, false); }
public static <T> T getProperty(@NonNull final Configuration conf, @NotEmpty final String key, @NonNull final T defaultValue) { if (defaultValue instanceof Integer) { return (T) new Integer(conf.getIntProperty(key, ((Integer) defaultValue).intValue())); } else if (defaultValue instanceof Long) { return (T) new Long(conf.getLongProperty(key, ((Long) defaultValue).longValue())); } else if (defaultValue instanceof String) { return (T) conf.getProperty(key, (String) defaultValue); } else if (defaultValue instanceof Double) { return (T) new Double(conf.getDoubleProperty(key, ((Double) defaultValue).doubleValue())); } else if (defaultValue instanceof Boolean) { return (T) new Boolean(conf.getBooleanProperty(key, ((Boolean) defaultValue).booleanValue())); } else { throw new IllegalArgumentException("Not supported :" + defaultValue.getClass()); } }
public ErrorTableConfiguration(@NonNull final Configuration conf) { this.conf = conf; this.isEnabled = conf.getBooleanProperty(IS_ENABLED, DEFAULT_IS_ENABLED); if (this.isEnabled()) { ConfigUtil.checkMandatoryProperties(this.conf, getMandatoryProperties()); this.destPath = new Path(conf.getProperty(DESTINATION_PATH).get()); } this.isDatePartitioned = conf.getBooleanProperty(IS_DATE_PARTITIONED, DEFAULT_IS_DATE_PARTITIONED); this.writeParallelism = conf.getIntProperty(WRITE_PARALLELISM, DEFAULT_WRITE_PARALLELISM); }
public HiveSourceConfiguration(@NonNull final Configuration conf) { super(conf); this.saveCheckpoint = this.getConf().getBooleanProperty(SAVE_CHECKPOINT, true); this.startDate = getConf().getProperty(HIVE_START_DATE).isPresent() ? Optional.of(DateTime.parse(getConf().getProperty(HIVE_START_DATE).get(), DateTimeFormat.forPattern(HIVE_START_DATE_FORMAT).withZoneUTC()).toDate()) : Optional.absent(); }
public CassandraSinkConfiguration(@NonNull final Configuration conf) { this.conf = conf; ConfigUtil.checkMandatoryProperties(this.conf, this.getMandatoryProperties()); this.partitionKeys = this.splitString(this.conf.getProperty(PARTITION_KEYS).get()); if (this.conf.getProperty(INITIAL_HOSTS).isPresent()) { this.initialHosts = this.splitString(this.conf.getProperty(INITIAL_HOSTS).get()); } else { this.initialHosts = new ArrayList<>(); } // Source fields can be case insensitive so we convert everything to lower case for comparing this.filteredColumns = this.conf.getProperty(COLUMN_LIST).isPresent() ? Optional.of(new HashSet<>(this.splitString(this.conf.getProperty(COLUMN_LIST).get().toLowerCase()))) : Optional.absent(); this.clusteringKeys = this.conf.getProperty(CLUSTERING_KEYS).isPresent() ? initClusterKeys(this.splitString(this.conf.getProperty(CLUSTERING_KEYS).get())) : Collections.EMPTY_LIST; if (this.conf.getProperty(PARTITION_TYPE).isPresent()) { this.partitionType = PartitionType.valueOf(this.conf.getProperty(PARTITION_TYPE) .get().trim().toUpperCase()); } else { this.partitionType = PartitionType.NONE; } this.writeTimestamp = this.conf.getProperty(TIMESTAMP); this.timestampIsLongType = this.conf.getBooleanProperty(TIMESTAMP_IS_LONG_TYPE, false); }
this.fileType = this.conf.getProperty(FILE_TYPE, DEFAULT_FILE_TYPE); this.fileSizeMegaBytes = this.conf.getDoubleProperty(FILE_SIZE_MEGABYTE, DEFAULT_FILE_SIZE); this.columnHeader = this.conf.getBooleanProperty(CSV_COLUMN_HEADER, DEFAULT_CSV_COLUMN_HEADER);
public LockManagerConfiguration(@NonNull final Configuration conf) { this.conf = conf; this.isEnabled = this.getConf().getBooleanProperty(IS_ENABLED, DEFAULT_IS_ENABLED); if (this.isEnabled()) { ConfigUtil.checkMandatoryProperties(conf, getMandatoryProperties()); this.zkBasePath = cleanZkBasePath(this.getConf().getProperty(ZK_BASE_PATH).get()); } else { this.zkBasePath = null; } this.zkSessionTimeoutMs = this.getConf().getIntProperty(ZK_SESSION_TIMEOUT_MS, DEFAULT_ZK_SESSION_TIMEOUT_MS); this.zkConnectionTimeoutMs = this.getConf().getIntProperty(ZK_CONNECTION_TIMEOUT_MS, DEFAULT_ZK_CONNECTION_TIMEOUT_MS); this.acquireLockTimeMs = this.getConf().getIntProperty(ACQUIRE_LOCK_TIME_MS, DEFAULT_ACQUIRE_LOCK_TIME_MS); }
@Test public void loadConfigurationYaml() { final Configuration conf = new Configuration(new File(CONFIG_YAML), Optional.absent()); conf.setProperty("marmaray.string_configs.string3", "string3"); Assert.assertEquals(1, conf.getIntProperty("marmaray.scalar_configs.integer", -1)); Assert.assertEquals(1234567890123L, conf.getLongProperty("marmaray.scalar_configs.long", -1)); Assert.assertEquals(1.23, conf.getDoubleProperty("marmaray.scalar_configs.double", -1.0), DELTA); Assert.assertEquals(true, conf.getBooleanProperty("marmaray.scalar_configs.boolean", false)); Assert.assertEquals("string1", conf.getProperty("marmaray.string_configs.string1", "not string1")); Assert.assertEquals("string2", conf.getProperty("marmaray.string_configs.stringlist.string2").get()); final Map<String, String> configMap = conf.getPropertiesWithPrefix("marmaray.string_configs.", true); Assert.assertEquals("string2", configMap.get("stringlist.string2")); Assert.assertEquals("string3", configMap.get("string3")); Assert.assertEquals(-1, conf.getIntProperty("marmaray.scalar_configs.notinteger", -1)); Assert.assertEquals(-1, conf.getLongProperty("marmaray.scalar_configs.notlong", -1)); Assert.assertEquals(-1.0, conf.getDoubleProperty("marmaray.scalar_configs.notdouble", -1.0), DELTA); Assert.assertEquals(false, conf.getBooleanProperty("marmaray.scalar_configs.notboolean", false)); Assert.assertEquals("not string1", conf.getProperty("marmaray.string_configs.notstring1", "not string1")); }