/** * Extracts the time unit for the chore period and initial delay from the configuration. The * configuration value for {@link #POLICY_REFRESHER_CHORE_TIMEUNIT_KEY} must correspond to * a {@link TimeUnit} value. * * @param conf The configuration object. * @return The configured time unit for the chore period and initial delay or the default value. */ static TimeUnit getTimeUnit(Configuration conf) { return TimeUnit.valueOf(conf.get(POLICY_REFRESHER_CHORE_TIMEUNIT_KEY, POLICY_REFRESHER_CHORE_TIMEUNIT_DEFAULT)); }
/** * Extracts the time unit for the chore period and initial delay from the configuration. The * configuration value for {@link #QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY} must correspond to * a {@link TimeUnit} value. * * @param conf The configuration object. * @return The configured time unit for the chore period and initial delay or the default value. */ static TimeUnit getTimeUnit(Configuration conf) { return TimeUnit.valueOf(conf.get(QUOTA_OBSERVER_CHORE_TIMEUNIT_KEY, QUOTA_OBSERVER_CHORE_TIMEUNIT_DEFAULT)); }
/** * Extracts the time unit for the chore period and initial delay from the configuration. The * configuration value for {@link #SNAPSHOT_QUOTA_CHORE_TIMEUNIT_KEY} must correspond to * a {@link TimeUnit} value. * * @param conf The configuration object. * @return The configured time unit for the chore period and initial delay or the default value. */ static TimeUnit getTimeUnit(Configuration conf) { return TimeUnit.valueOf(conf.get(SNAPSHOT_QUOTA_CHORE_TIMEUNIT_KEY, SNAPSHOT_QUOTA_CHORE_TIMEUNIT_DEFAULT)); } }
/** * Extracts the time unit for the chore period and initial delay from the configuration. The * configuration value for {@link #FS_UTILIZATION_CHORE_TIMEUNIT_KEY} must correspond to a * {@link TimeUnit} value. * * @param conf The configuration object. * @return The configured time unit for the chore period and initial delay or the default value. */ static TimeUnit getTimeUnit(Configuration conf) { return TimeUnit.valueOf(conf.get(FS_UTILIZATION_CHORE_TIMEUNIT_KEY, FS_UTILIZATION_CHORE_TIMEUNIT_DEFAULT)); } }
/** * Extracts the time unit for the chore period and initial delay from the configuration. The * configuration value for {@link #REGION_SIZE_REPORTING_CHORE_TIMEUNIT_KEY} must correspond to a * {@link TimeUnit} value. * * @param conf The configuration object. * @return The configured time unit for the chore period and initial delay or the default value. */ static TimeUnit getTimeUnit(Configuration conf) { return TimeUnit.valueOf(conf.get(REGION_SIZE_REPORTING_CHORE_TIMEUNIT_KEY, REGION_SIZE_REPORTING_CHORE_TIMEUNIT_DEFAULT)); } }
@Override public TimeUnit deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { return TimeUnit.valueOf(jp.getValueAsString().toUpperCase()); } }
/** * Gets the polling time unit. * * @return the polling time unit set by properties, If it is not set, a default value SECONDS is * returned. */ private TimeUnit getPollUnit() { String unit = mProperties.getProperty(GRAPHITE_KEY_UNIT); if (unit == null) { unit = GRAPHITE_DEFAULT_UNIT; } return TimeUnit.valueOf(unit.toUpperCase()); } }
/** * Gets the polling time unit. * * @return the polling time unit set by properties, If it is not set, a default value SECONDS is * returned. */ private TimeUnit getPollUnit() { String unit = mProperties.getProperty(CONSOLE_KEY_UNIT); if (unit == null) { unit = CONSOLE_DEFAULT_UNIT; } return TimeUnit.valueOf(unit.toUpperCase()); } }
/** * Gets the polling time unit. * * @return the polling time unit set by properties, If it is not set, a default value SECONDS is * returned. */ private TimeUnit getPollUnit() { String unit = mProperties.getProperty(CSV_KEY_UNIT); if (unit == null) { unit = CSV_DEFAULT_UNIT; } return TimeUnit.valueOf(unit.toUpperCase()); } }
private static TimeUnit getTimeUnitForConfig(Map reporterConf, String configName) { String rateUnitString = ObjectReader.getString(reporterConf.get(configName), null); if (rateUnitString != null) { return TimeUnit.valueOf(rateUnitString); } return null; }
private static TimeUnit getTimeUnitForCofig(Map<String, Object> topoConf, String configName) { String rateUnitString = ObjectReader.getString(topoConf.get(configName), null); if (rateUnitString != null) { return TimeUnit.valueOf(rateUnitString); } return null; } }
private LatencyContainer toLatencyContainer() { return LatencyContainer.latencyWithUnit(duration, TimeUnit.valueOf(unit.toUpperCase() + 'S')); } }
/** * Constructs a dateTimeGranularitySpec granularity from a string * @param granularity * @return */ public DateTimeGranularitySpec(String granularity) { _granularity = granularity; isValidGranularity(granularity); String[] granularityTokens = _granularity.split(COLON_SEPARATOR); _size = Integer.valueOf(granularityTokens[GRANULARITY_SIZE_POSITION]); _timeUnit = TimeUnit.valueOf(granularityTokens[GRANULARITY_UNIT_POSITION]); }
public static TimeUnitTransformer getTimeUnitTransformer(@Nonnull TimeUnit inputTimeUnit, @Nonnull String outputTimeUnitName) { outputTimeUnitName = outputTimeUnitName.toUpperCase(); try { return new JavaTimeUnitTransformer(inputTimeUnit, TimeUnit.valueOf(outputTimeUnitName)); } catch (Exception e) { return new CustomTimeUnitTransformer(inputTimeUnit, outputTimeUnitName); } } }
private CarteStatusCache() { period = Integer.parseInt( Const.getEnvironmentVariable( "CARTE_CLEAR_PERIOD", "1" ) ); timeUnit = TimeUnit.valueOf( Const.getEnvironmentVariable( "CARTE_CLEAR_TIMEUNIT", "DAYS" ) ); removeService.scheduleAtFixedRate( this::clear, 1, 1, TimeUnit.DAYS ); }
public DateTimeFormatUnitSpec(String unit) { if (!isValidUnitSpec(unit)) { throw new IllegalArgumentException("Unit must belong to enum TimeUnit or DateTimeTransformUnit"); } if (EnumUtils.isValidEnum(TimeUnit.class, unit)) { _timeUnit = TimeUnit.valueOf(unit); } if (EnumUtils.isValidEnum(DateTimeTransformUnit.class, unit)) { _dateTimeTransformUnit = DateTimeTransformUnit.valueOf(unit); } }
@Override protected Integer fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final long timeout = annotationInstance.value().asLong(); AnnotationValue unitAnnVal = annotationInstance.value("unit"); final TimeUnit unit = unitAnnVal != null ? TimeUnit.valueOf(unitAnnVal.asEnum()) : TimeUnit.SECONDS; return (int) unit.toSeconds(timeout); } }
private static long date_diff(long timestamp1, long timestamp2, String unitString) { try { TimeUnit unit = TimeUnit.valueOf(TimeUnit.class, StringUtils.upperCase(unitString)); return unit.convert(timestamp1 - timestamp2, TimeUnit.MILLISECONDS); } catch (IllegalArgumentException e) { log.error("Valid input for unitString is java.util.concurrent.TimeUnit", e); } return 0l; }
@Override protected AccessTimeoutDetails fromAnnotation(final AnnotationInstance annotationInstance, final PropertyReplacer propertyReplacer) { final long timeout = annotationInstance.value().asLong(); AnnotationValue unitAnnVal = annotationInstance.value("unit"); final TimeUnit unit = unitAnnVal != null ? TimeUnit.valueOf(unitAnnVal.asEnum()) : TimeUnit.MILLISECONDS; return new AccessTimeoutDetails(timeout, unit); } }