@Test public void testSetOnlyIntervalTimeUnit() { Properties properties = new Properties(); properties.put("repair.interval.time.unit", "days"); assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> RepairProperties.from(properties)); }
public static RepairProperties from(Properties properties) throws ConfigurationException { long repairIntervalInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_INTERVAL_BASE, DEFAULT_REPAIR_INTERVAL_DURATION, DEFAULT_REPAIR_INTERVAL_TIMEUNIT); RepairOptions.RepairParallelism repairParallelism; try { repairParallelism = RepairOptions.RepairParallelism.valueOf(properties.getProperty(CONFIG_REPAIR_PARALLELISM, DEFAULT_REPAIR_PARALLELISM).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair parallelism specified in '" + CONFIG_REPAIR_PARALLELISM + "'", e); } long repairAlarmWarnInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_WARN_BASE, DEFAULT_REPAIR_WARN_DURATION, DEFAULT_REPAIR_WARN_TIMEUNIT); long repairAlarmErrorInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_ERROR_BASE, DEFAULT_REPAIR_ERROR_DURATION, DEFAULT_REPAIR_ERROR_TIMEUNIT); RepairLockType repairLockType; try { repairLockType = RepairLockType.valueOf(properties.getProperty(CONFIG_REPAIR_LOCK_TYPE, DEFAULT_REPAIR_LOCK_TYPE).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair lock type specified in '" + CONFIG_REPAIR_LOCK_TYPE + "'", e); } double repairUnwindRatio = Double.parseDouble(properties.getProperty(CONFIG_REPAIR_UNWIND_RATIO, DEFAULT_REPAIR_UNWIND_RATIO)); long repairHistoryLookbackInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_HISTORY_LOOKBACK_BASE, DEFAULT_REPAIR_HISTORY_LOOKBACK_DURATION, DEFAULT_REPAIR_HISTORY_LOOKBACK_TIMEUNIT); return new RepairProperties(repairIntervalInMs, repairParallelism, repairAlarmWarnInMs, repairAlarmErrorInMs, repairLockType, repairUnwindRatio, repairHistoryLookbackInMs); }
RepairProperties { public static RepairProperties from(Properties properties) throws ConfigurationException { long repairIntervalInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_INTERVAL_BASE, DEFAULT_REPAIR_INTERVAL_DURATION, DEFAULT_REPAIR_INTERVAL_TIMEUNIT); RepairOptions.RepairParallelism repairParallelism; try { repairParallelism = RepairOptions.RepairParallelism.valueOf(properties.getProperty(CONFIG_REPAIR_PARALLELISM, DEFAULT_REPAIR_PARALLELISM).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair parallelism specified in '" + CONFIG_REPAIR_PARALLELISM + "'", e); } long repairAlarmWarnInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_WARN_BASE, DEFAULT_REPAIR_WARN_DURATION, DEFAULT_REPAIR_WARN_TIMEUNIT); long repairAlarmErrorInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_ERROR_BASE, DEFAULT_REPAIR_ERROR_DURATION, DEFAULT_REPAIR_ERROR_TIMEUNIT); RepairLockType repairLockType; try { repairLockType = RepairLockType.valueOf(properties.getProperty(CONFIG_REPAIR_LOCK_TYPE, DEFAULT_REPAIR_LOCK_TYPE).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair lock type specified in '" + CONFIG_REPAIR_LOCK_TYPE + "'", e); } double repairUnwindRatio = Double.parseDouble(properties.getProperty(CONFIG_REPAIR_UNWIND_RATIO, DEFAULT_REPAIR_UNWIND_RATIO)); long repairHistoryLookbackInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_HISTORY_LOOKBACK_BASE, DEFAULT_REPAIR_HISTORY_LOOKBACK_DURATION, DEFAULT_REPAIR_HISTORY_LOOKBACK_TIMEUNIT); return new RepairProperties(repairIntervalInMs, repairParallelism, repairAlarmWarnInMs, repairAlarmErrorInMs, repairLockType, repairUnwindRatio, repairHistoryLookbackInMs); } }
RepairProperties { public static RepairProperties from(Properties properties) throws ConfigurationException { long repairIntervalInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_INTERVAL_BASE, DEFAULT_REPAIR_INTERVAL_DURATION, DEFAULT_REPAIR_INTERVAL_TIMEUNIT); RepairOptions.RepairParallelism repairParallelism; try { repairParallelism = RepairOptions.RepairParallelism.valueOf(properties.getProperty(CONFIG_REPAIR_PARALLELISM, DEFAULT_REPAIR_PARALLELISM).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair parallelism specified in '" + CONFIG_REPAIR_PARALLELISM + "'", e); } long repairAlarmWarnInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_WARN_BASE, DEFAULT_REPAIR_WARN_DURATION, DEFAULT_REPAIR_WARN_TIMEUNIT); long repairAlarmErrorInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_ERROR_BASE, DEFAULT_REPAIR_ERROR_DURATION, DEFAULT_REPAIR_ERROR_TIMEUNIT); RepairLockType repairLockType; try { repairLockType = RepairLockType.valueOf(properties.getProperty(CONFIG_REPAIR_LOCK_TYPE, DEFAULT_REPAIR_LOCK_TYPE).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair lock type specified in '" + CONFIG_REPAIR_LOCK_TYPE + "'", e); } double repairUnwindRatio = Double.parseDouble(properties.getProperty(CONFIG_REPAIR_UNWIND_RATIO, DEFAULT_REPAIR_UNWIND_RATIO)); long repairHistoryLookbackInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_HISTORY_LOOKBACK_BASE, DEFAULT_REPAIR_HISTORY_LOOKBACK_DURATION, DEFAULT_REPAIR_HISTORY_LOOKBACK_TIMEUNIT); return new RepairProperties(repairIntervalInMs, repairParallelism, repairAlarmWarnInMs, repairAlarmErrorInMs, repairLockType, repairUnwindRatio, repairHistoryLookbackInMs); } private  RepairProperties(long repairIntervalInMs, RepairOptions.RepairParallelism repairParallelism,
                             long repairAlarmWarnInMs, long repairAlarmErrorInMs, RepairLockType repairLockType,
                             double repairUnwindRatio, long repairHistoryLookbackInMs); }
RepairProperties { public static RepairProperties from(Properties properties) throws ConfigurationException { long repairIntervalInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_INTERVAL_BASE, DEFAULT_REPAIR_INTERVAL_DURATION, DEFAULT_REPAIR_INTERVAL_TIMEUNIT); RepairOptions.RepairParallelism repairParallelism; try { repairParallelism = RepairOptions.RepairParallelism.valueOf(properties.getProperty(CONFIG_REPAIR_PARALLELISM, DEFAULT_REPAIR_PARALLELISM).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair parallelism specified in '" + CONFIG_REPAIR_PARALLELISM + "'", e); } long repairAlarmWarnInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_WARN_BASE, DEFAULT_REPAIR_WARN_DURATION, DEFAULT_REPAIR_WARN_TIMEUNIT); long repairAlarmErrorInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_ERROR_BASE, DEFAULT_REPAIR_ERROR_DURATION, DEFAULT_REPAIR_ERROR_TIMEUNIT); RepairLockType repairLockType; try { repairLockType = RepairLockType.valueOf(properties.getProperty(CONFIG_REPAIR_LOCK_TYPE, DEFAULT_REPAIR_LOCK_TYPE).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair lock type specified in '" + CONFIG_REPAIR_LOCK_TYPE + "'", e); } double repairUnwindRatio = Double.parseDouble(properties.getProperty(CONFIG_REPAIR_UNWIND_RATIO, DEFAULT_REPAIR_UNWIND_RATIO)); long repairHistoryLookbackInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_HISTORY_LOOKBACK_BASE, DEFAULT_REPAIR_HISTORY_LOOKBACK_DURATION, DEFAULT_REPAIR_HISTORY_LOOKBACK_TIMEUNIT); return new RepairProperties(repairIntervalInMs, repairParallelism, repairAlarmWarnInMs, repairAlarmErrorInMs, repairLockType, repairUnwindRatio, repairHistoryLookbackInMs); } private  RepairProperties(long repairIntervalInMs, RepairOptions.RepairParallelism repairParallelism,
                             long repairAlarmWarnInMs, long repairAlarmErrorInMs, RepairLockType repairLockType,
                             double repairUnwindRatio, long repairHistoryLookbackInMs); long getRepairIntervalInMs(); RepairOptions.RepairParallelism getRepairParallelism(); long getRepairAlarmWarnInMs(); long getRepairAlarmErrorInMs(); RepairLockType getRepairLockType(); double getRepairUnwindRatio(); long getRepairHistoryLookbackInMs(); @Override String toString(); static RepairProperties from(Properties properties); }
RepairProperties { public static RepairProperties from(Properties properties) throws ConfigurationException { long repairIntervalInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_INTERVAL_BASE, DEFAULT_REPAIR_INTERVAL_DURATION, DEFAULT_REPAIR_INTERVAL_TIMEUNIT); RepairOptions.RepairParallelism repairParallelism; try { repairParallelism = RepairOptions.RepairParallelism.valueOf(properties.getProperty(CONFIG_REPAIR_PARALLELISM, DEFAULT_REPAIR_PARALLELISM).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair parallelism specified in '" + CONFIG_REPAIR_PARALLELISM + "'", e); } long repairAlarmWarnInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_WARN_BASE, DEFAULT_REPAIR_WARN_DURATION, DEFAULT_REPAIR_WARN_TIMEUNIT); long repairAlarmErrorInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_ALARM_ERROR_BASE, DEFAULT_REPAIR_ERROR_DURATION, DEFAULT_REPAIR_ERROR_TIMEUNIT); RepairLockType repairLockType; try { repairLockType = RepairLockType.valueOf(properties.getProperty(CONFIG_REPAIR_LOCK_TYPE, DEFAULT_REPAIR_LOCK_TYPE).toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { throw new ConfigurationException("Unknown repair lock type specified in '" + CONFIG_REPAIR_LOCK_TYPE + "'", e); } double repairUnwindRatio = Double.parseDouble(properties.getProperty(CONFIG_REPAIR_UNWIND_RATIO, DEFAULT_REPAIR_UNWIND_RATIO)); long repairHistoryLookbackInMs = parseTimeUnitToMs(properties, CONFIG_REPAIR_HISTORY_LOOKBACK_BASE, DEFAULT_REPAIR_HISTORY_LOOKBACK_DURATION, DEFAULT_REPAIR_HISTORY_LOOKBACK_TIMEUNIT); return new RepairProperties(repairIntervalInMs, repairParallelism, repairAlarmWarnInMs, repairAlarmErrorInMs, repairLockType, repairUnwindRatio, repairHistoryLookbackInMs); } private  RepairProperties(long repairIntervalInMs, RepairOptions.RepairParallelism repairParallelism,
                             long repairAlarmWarnInMs, long repairAlarmErrorInMs, RepairLockType repairLockType,
                             double repairUnwindRatio, long repairHistoryLookbackInMs); long getRepairIntervalInMs(); RepairOptions.RepairParallelism getRepairParallelism(); long getRepairAlarmWarnInMs(); long getRepairAlarmErrorInMs(); RepairLockType getRepairLockType(); double getRepairUnwindRatio(); long getRepairHistoryLookbackInMs(); @Override String toString(); static RepairProperties from(Properties properties);  }