本文整理汇总了Java中java.util.concurrent.TimeUnit.HOURS属性的典型用法代码示例。如果您正苦于以下问题:Java TimeUnit.HOURS属性的具体用法?Java TimeUnit.HOURS怎么用?Java TimeUnit.HOURS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.concurrent.TimeUnit
的用法示例。
在下文中一共展示了TimeUnit.HOURS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toTimeUnit
/**
* To time unit time unit.
*
* @param tu the tu
* @return the time unit
*/
public static TimeUnit toTimeUnit(final ChronoUnit tu) {
if (tu == null) {
return null;
}
switch (tu) {
case DAYS:
return TimeUnit.DAYS;
case HOURS:
return TimeUnit.HOURS;
case MINUTES:
return TimeUnit.MINUTES;
case SECONDS:
return TimeUnit.SECONDS;
case MICROS:
return TimeUnit.MICROSECONDS;
case MILLIS:
return TimeUnit.MILLISECONDS;
case NANOS:
return TimeUnit.NANOSECONDS;
default:
throw new UnsupportedOperationException("Temporal unit is not supported");
}
}
示例2: serviceInit
@Override
protected void serviceInit(Configuration conf) throws Exception {
int threadCount = conf.getInt(
YarnConfiguration.RM_AMLAUNCHER_THREAD_COUNT,
YarnConfiguration.DEFAULT_RM_AMLAUNCHER_THREAD_COUNT);
ThreadFactory tf = new ThreadFactoryBuilder()
.setNameFormat("ApplicationMasterLauncher #%d")
.build();
launcherPool = new ThreadPoolExecutor(threadCount, threadCount, 1,
TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>());
launcherPool.setThreadFactory(tf);
Configuration newConf = new YarnConfiguration(conf);
newConf.setInt(CommonConfigurationKeysPublic.
IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY,
conf.getInt(YarnConfiguration.RM_NODEMANAGER_CONNECT_RETIRES,
YarnConfiguration.DEFAULT_RM_NODEMANAGER_CONNECT_RETIRES));
setConfig(newConf);
super.serviceInit(newConf);
}
示例3: toTimeUnit
/**
* Convert a protocol buffer TimeUnit to a client TimeUnit
* @param proto
* @return the converted client TimeUnit
*/
public static TimeUnit toTimeUnit(final HBaseProtos.TimeUnit proto) {
switch (proto) {
case NANOSECONDS:
return TimeUnit.NANOSECONDS;
case MICROSECONDS:
return TimeUnit.MICROSECONDS;
case MILLISECONDS:
return TimeUnit.MILLISECONDS;
case SECONDS:
return TimeUnit.SECONDS;
case MINUTES:
return TimeUnit.MINUTES;
case HOURS:
return TimeUnit.HOURS;
case DAYS:
return TimeUnit.DAYS;
default:
throw new RuntimeException("Invalid TimeUnit " + proto);
}
}
示例4: add
public void add(String key, Object value, long data, int timeType){//data为在redis存储有效时间
Object type = null;
switch (timeType) {
case 0:
type = TimeUnit.MINUTES;
break;
case 1:
type = TimeUnit.HOURS;
break;
case 2:
type = TimeUnit.DAYS;
}
redisTemplate.opsForValue().set(key, value, data, (TimeUnit)type);
}
示例5: getTimeout
/**
* Getter for the timeout
* @return TimeOut
*/
public TimeOut getTimeout() {
TimeOut timeOut = new TimeOut();
Integer timeoutInt;
if (timeoutSpinner.getValue() == "∞") {
timeoutInt = 0;
} else {
timeoutInt = Integer.parseInt(timeoutSpinner.getValue().toString());
}
switch (timeoutUnit.getSelectedIndex()) {
case 0:
timeOut = new TimeOut(TimeUnit.SECONDS, timeoutInt.longValue());
break;
case 1:
timeOut = new TimeOut(TimeUnit.MINUTES, timeoutInt.longValue());
break;
case 2:
timeOut = new TimeOut(TimeUnit.HOURS, timeoutInt.longValue());
break;
case 3:
timeOut = new TimeOut(TimeUnit.DAYS, timeoutInt.longValue());
break;
default:
break;
}
return timeOut;
}
示例6: setUpClass
@BeforeClass
public static void setUpClass() {
projectSaverLoader = new ProjectSaverLoader();
ElectionTemplateHandler electionTemplateHandler = new ElectionTemplateHandler();
ElectionTypeContainer inputType = electionTemplateHandler.getById(ElectionTypeContainer.ElectionInputTypeIds.WEIGHTED_APPROVAL);
ElectionTypeContainer outputType = electionTemplateHandler.getStandardResult();
ElectionDescription electionDescription = new ElectionDescription("testDescription", inputType, outputType, 2);
ArrayList<String> code = new ArrayList<String>();
code.add("sdfgokdffg");
code.add("sdkofgdfg");
electionDescription.setCode(code);
FormalPropertiesDescription pre = new FormalPropertiesDescription("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD");
FormalPropertiesDescription post = new FormalPropertiesDescription("CODECODEOCDEOASD ASDAOSDASOD ;;; ;ASODAOSD");
SymbolicVariableList list = new SymbolicVariableList();
list.addSymbolicVariable("voter1", new InternalTypeContainer(InternalTypeRep.VOTER));
list.addSymbolicVariable("voter2", new InternalTypeContainer(InternalTypeRep.VOTER));
list.addSymbolicVariable("candidate", new InternalTypeContainer(InternalTypeRep.CANDIDATE));
list.addSymbolicVariable("seat", new InternalTypeContainer(InternalTypeRep.SEAT));
PreAndPostConditionsDescription description1 = new PreAndPostConditionsDescription("description1",
pre, post, list);
PreAndPostConditionsDescription description2 = new PreAndPostConditionsDescription("description2",
pre, post, list);
PLModel plModel = new PLModel();
plModel.initialize();
PropertyItem propertyItem = new PropertyItem(description1, true, true);
PropertyItem propertyItem2 = new PropertyItem(description2, false, false);
plModel.addDescription(propertyItem);
plModel.addDescription(propertyItem2);
ElectionCheckParameter electionCheckParameter = new ElectionCheckParameter(Arrays.asList(new Integer[]{1, 2}),
Arrays.asList(new Integer[]{1, 2}), Arrays.asList(new Integer[]{1, 2}), new TimeOut(TimeUnit.HOURS,
(long) 3.2),4, "-- unwind 6");
project = new Project(electionCheckParameter, plModel, electionDescription, "TestProject");
}
示例7: niceTimeRounded
public static long niceTimeRounded ( final long value )
{
final TimeUnit tu;
if ( value >= TimeUnit.DAYS.toMillis ( 1 ) )
{
tu = TimeUnit.DAYS;
}
else if ( value >= TimeUnit.HOURS.toMillis ( 1 ) )
{
tu = TimeUnit.HOURS;
}
else if ( value >= TimeUnit.MINUTES.toMillis ( 1 ) )
{
tu = TimeUnit.MINUTES;
}
else if ( value >= TimeUnit.SECONDS.toMillis ( 1 ) )
{
tu = TimeUnit.SECONDS;
}
else
{
tu = TimeUnit.MILLISECONDS;
}
double v = (double)value / (double)tu.toMillis ( 1 );
v = niceNum ( v, true );
return (long) ( v * tu.toMillis ( 1 ) );
}
示例8: parse
@Override
public void parse(CacheBuilderSpec spec, String key, String value) {
checkArgument(value != null && !value.isEmpty(), "value of key %s omitted", key);
try {
char lastChar = value.charAt(value.length() - 1);
TimeUnit timeUnit;
switch (lastChar) {
case 'd':
timeUnit = TimeUnit.DAYS;
break;
case 'h':
timeUnit = TimeUnit.HOURS;
break;
case 'm':
timeUnit = TimeUnit.MINUTES;
break;
case 's':
timeUnit = TimeUnit.SECONDS;
break;
default:
throw new IllegalArgumentException(
format(
"key %s invalid format. was %s, must end with one of [dDhHmMsS]", key, value));
}
long duration = Long.parseLong(value.substring(0, value.length() - 1));
parseDuration(spec, duration, timeUnit);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
format("key %s value set to %s, must be integer", key, value));
}
}
示例9: catchAllAndLogWithThrottle
private Runnable catchAllAndLogWithThrottle(Runnable r) {
LogThrottle throttle = new LogThrottle(1, TimeUnit.HOURS);
return () -> {
try {
r.run();
} catch (RuntimeException e) {
if (throttle.throttle(e)) {
log.error("Execution failed: " + e);
} else {
log.error("Execution failed", e);
}
}
};
}
示例10: serializeTimeUnit_resultJsonHasTimeUnit
@Test
public void serializeTimeUnit_resultJsonHasTimeUnit() throws IOException {
//given
TimeStringFormat timeStringFormat = new TimeStringFormat(TimeUnit.HOURS);
//when
JsonNode actualObj = serializeTimeStringFormat(timeStringFormat);
//then
Assertions.assertThat(actualObj.has("unit")).isTrue();
Assertions.assertThat(actualObj.get("unit").asText()).isEqualTo("HOURS");
}
示例11:
@LifeCache(duration = 1, timeUnit = TimeUnit.HOURS)
Observable<Results> getDataResults(Observable<Results> oResults, DynamicKeyGroup pageAndType, EvictDynamicKeyGroup refresh);
示例12: setUpClass
@BeforeClass
public static void setUpClass() {
timeOut = new TimeOut(TimeUnit.HOURS, (long) 3.2);
}
示例13: setUpClass
@BeforeClass
public static void setUpClass() {
electionCheckParameter = new ElectionCheckParameter(Arrays.asList(new Integer[]{1, 2}),
Arrays.asList(new Integer[]{1, 2}), Arrays.asList(new Integer[]{1, 2}), new TimeOut(TimeUnit.HOURS,
(long) 3.2),4, "-- unwind 6");
}
示例14: timeValueHours
public static TimeValue timeValueHours(long hours) {
return new TimeValue(hours, TimeUnit.HOURS);
}
示例15: TipiThreadPoolExecutor
public TipiThreadPoolExecutor() {
super(0, Integer.MAX_VALUE, 1, TimeUnit.HOURS, new SynchronousQueue<Runnable>());
}