List of usage examples for java.util.concurrent TimeUnit toMillis
public long toMillis(long duration)
From source file:net.pms.io.ThreadedProcessWrapper.java
/** * Creates and runs a new {@link Process} in a new thread using the * specified commands. The process result is discarded. * * @param command the command(s) used to create the {@link Process}. * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. *///from www . jav a 2 s .com @Nonnull public static void runProcessNullOutput(@Nonnull List<String> command, long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS) { new ThreadedProcessWrapper<NullProcessWrapperConsumer, NullProcessWrapperResult, Void>( new NullProcessWrapperConsumer()).runProcess(command, timeUnit.toMillis(timeout), terminateTimeoutMS); }
From source file:net.pms.io.ThreadedProcessWrapper.java
/** * Creates and runs a new {@link Process} in a new thread using the * specified commands. The process result is returned as a {@link Future} * {@link ListProcessWrapperResult}./*from w ww. ja v a 2 s.co m*/ * * @param command the command(s) used to create the {@link Process}. * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @return The process result as a {@link Future} * {@link ListProcessWrapperResult}. */ @Nonnull public static Future<ListProcessWrapperResult> runProcessListOutput(@Nonnull List<String> command, long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS) { return new ThreadedProcessWrapper<ListProcessWrapperConsumer, ListProcessWrapperResult, List<String>>( new ListProcessWrapperConsumer()).runProcess(command, timeUnit.toMillis(timeout), terminateTimeoutMS); }
From source file:net.pms.io.ThreadedProcessWrapper.java
/** * Creates and runs a new {@link Process} in a new thread using the * specified commands. The process result is discarded. * * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @param command the command(s) used to create the {@link Process}. *///from w w w. ja v a 2s. co m @Nonnull public static void runProcessNullOutput(long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS, @Nonnull String... command) { new ThreadedProcessWrapper<NullProcessWrapperConsumer, NullProcessWrapperResult, Void>( new NullProcessWrapperConsumer()).runProcess(timeUnit.toMillis(timeout), terminateTimeoutMS, command); }
From source file:com.github.restdriver.serverdriver.RestServerDriver.java
/** * Use a single timeout value for both connection and socket timeouts. * //w ww. j a v a 2 s.c o m * @param timeout The timeout duration to use. * @param timeUnit The unit of the timeout. * * @return The RequestTimeout instance. */ public static AnyRequestModifier withTimeout(int timeout, TimeUnit timeUnit) { return new RequestTimeout(timeUnit.toMillis(timeout), timeUnit.toMillis(timeout)); }
From source file:net.pms.io.SimpleProcessWrapper.java
/** * Creates and runs a new {@link Process} in the same thread using the * specified commands. The process result is returned as a * {@link ByteProcessWrapperResult}.//from w ww . j ava 2 s. c om * * @param command the command(s) used to create the {@link Process}. * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @return The process result as a {@link ByteProcessWrapperResult}. * @throws InterruptedException If interrupted while waiting for the * {@link Process} to finish. */ @Nonnull public static ByteProcessWrapperResult runProcessByteOutput(@Nonnull List<String> command, long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS) throws InterruptedException { return new SimpleProcessWrapper<ByteProcessWrapperConsumer, ByteProcessWrapperResult, byte[]>( new ByteProcessWrapperConsumer()).runProcess(command, timeUnit.toMillis(timeout), terminateTimeoutMS); }
From source file:net.pms.io.SimpleProcessWrapper.java
/** * Creates and runs a new {@link Process} in the same thread using the * specified commands. The process result is discarded. * * @param command the command(s) used to create the {@link Process}. * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @throws InterruptedException If interrupted while waiting for the * {@link Process} to finish. *//*from w ww .j av a2 s . com*/ @Nonnull public static void runProcessNullOutput(@Nonnull List<String> command, long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS) throws InterruptedException { new SimpleProcessWrapper<NullProcessWrapperConsumer, NullProcessWrapperResult, Void>( new NullProcessWrapperConsumer()).runProcess(command, timeUnit.toMillis(timeout), terminateTimeoutMS); }
From source file:net.pms.io.ThreadedProcessWrapper.java
/** * Creates and runs a new {@link Process} in a new thread using the * specified commands. The process result is returned as a {@link Future} * {@link ByteProcessWrapperResult}.//from w w w . ja va 2s .co m * * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @param command the command(s) used to create the {@link Process}. * @return The process result as a {@link Future} * {@link ByteProcessWrapperResult}. */ @Nonnull public static Future<ByteProcessWrapperResult> runProcessByteOutput(long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS, @Nonnull String... command) { return new ThreadedProcessWrapper<ByteProcessWrapperConsumer, ByteProcessWrapperResult, byte[]>( new ByteProcessWrapperConsumer()).runProcess(timeUnit.toMillis(timeout), terminateTimeoutMS, command); }
From source file:com.github.restdriver.serverdriver.RestServerDriver.java
/** * Specify a socket timeout./* www . j a va 2 s . c o m*/ * * @param timeout The timeout duration to use. * @param timeUnit The unit of the timeout. * * @return The RequestSocketTimeout instance. */ public static AnyRequestModifier withSocketTimeout(int timeout, TimeUnit timeUnit) { return new RequestSocketTimeout(timeUnit.toMillis(timeout)); }
From source file:net.pms.io.SimpleProcessWrapper.java
/** * Creates and runs a new {@link Process} in the same thread using the * specified commands. The process result is returned as a * {@link ListProcessWrapperResult}.//w ww.j a va2 s .c om * * @param command the command(s) used to create the {@link Process}. * @param timeout the process timeout in {@code timeUnit}. * @param timeUnit the {@link TimeUnit} for {@code timeout}. * @param terminateTimeoutMS the timeout in milliseconds for each * termination attempt before a new attempt is made. * @return The process result as a {@link ListProcessWrapperResult}. * @throws InterruptedException If interrupted while waiting for the * {@link Process} to finish. */ @Nonnull public static ListProcessWrapperResult runProcessListOutput(@Nonnull List<String> command, long timeout, @Nonnull TimeUnit timeUnit, long terminateTimeoutMS) throws InterruptedException { return new SimpleProcessWrapper<ListProcessWrapperConsumer, ListProcessWrapperResult, List<String>>( new ListProcessWrapperConsumer()).runProcess(command, timeUnit.toMillis(timeout), terminateTimeoutMS); }
From source file:com.github.restdriver.serverdriver.RestServerDriver.java
/** * Specify a connection timeout.//from w w w .ja v a2 s . c o m * * @param timeout The timeout duration to use. * @param timeUnit The unit of the timeout. * * @return The RequestConnectionTimeout instance. */ public static AnyRequestModifier withConnectionTimeout(int timeout, TimeUnit timeUnit) { return new RequestConnectionTimeout(timeUnit.toMillis(timeout)); }