@Test public void convertMsToClockTime() { assertEquals("0 day(s), 0 hour(s), 0 minute(s), and 0 second(s)", CommonUtils.convertMsToClockTime(10)); assertEquals("0 day(s), 0 hour(s), 0 minute(s), and 1 second(s)", CommonUtils.convertMsToClockTime(TimeUnit.SECONDS.toMillis(1))); assertEquals("0 day(s), 0 hour(s), 1 minute(s), and 0 second(s)", CommonUtils.convertMsToClockTime(TimeUnit.MINUTES.toMillis(1))); assertEquals("0 day(s), 0 hour(s), 1 minute(s), and 30 second(s)", CommonUtils.convertMsToClockTime(TimeUnit.MINUTES.toMillis(1) + TimeUnit.SECONDS.toMillis(30))); assertEquals("0 day(s), 1 hour(s), 0 minute(s), and 0 second(s)", CommonUtils.convertMsToClockTime(TimeUnit.HOURS.toMillis(1))); long time = TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(4) + TimeUnit.MINUTES.toMillis(10) + TimeUnit.SECONDS.toMillis(45); String out = CommonUtils.convertMsToClockTime(time); assertEquals("1 day(s), 4 hour(s), 10 minute(s), and 45 second(s)", out); }
public static String convertMsToClockTime(long millis) { Preconditions.checkArgument(millis >= 0, "Negative values %s are not supported to convert to clock time.", millis); long days = millis / Constants.DAY_MS; long hours = (millis % Constants.DAY_MS) / Constants.HOUR_MS; long mins = (millis % Constants.HOUR_MS) / Constants.MINUTE_MS; long secs = (millis % Constants.MINUTE_MS) / Constants.SECOND_MS; return String.format("%d day(s), %d hour(s), %d minute(s), and %d second(s)", days, hours, mins, secs); }
CommonUtils { public static String convertMsToClockTime(long millis) { Preconditions.checkArgument(millis >= 0, "Negative values %s are not supported to convert to clock time.", millis); long days = millis / Constants.DAY_MS; long hours = (millis % Constants.DAY_MS) / Constants.HOUR_MS; long mins = (millis % Constants.HOUR_MS) / Constants.MINUTE_MS; long secs = (millis % Constants.MINUTE_MS) / Constants.SECOND_MS; return String.format("%d day(s), %d hour(s), %d minute(s), and %d second(s)", days, hours, mins, secs); } }
CommonUtils { public static String convertMsToClockTime(long millis) { Preconditions.checkArgument(millis >= 0, "Negative values %s are not supported to convert to clock time.", millis); long days = millis / Constants.DAY_MS; long hours = (millis % Constants.DAY_MS) / Constants.HOUR_MS; long mins = (millis % Constants.HOUR_MS) / Constants.MINUTE_MS; long secs = (millis % Constants.MINUTE_MS) / Constants.SECOND_MS; return String.format("%d day(s), %d hour(s), %d minute(s), and %d second(s)", days, hours, mins, secs); } private  CommonUtils(); }
CommonUtils { public static String convertMsToClockTime(long millis) { Preconditions.checkArgument(millis >= 0, "Negative values %s are not supported to convert to clock time.", millis); long days = millis / Constants.DAY_MS; long hours = (millis % Constants.DAY_MS) / Constants.HOUR_MS; long mins = (millis % Constants.HOUR_MS) / Constants.MINUTE_MS; long secs = (millis % Constants.MINUTE_MS) / Constants.SECOND_MS; return String.format("%d day(s), %d hour(s), %d minute(s), and %d second(s)", days, hours, mins, secs); } private  CommonUtils(); static Thread createProgressThread(PrintStream stream); static Thread createProgressThread(final long intervalMs, final PrintStream stream); static long getCurrentMs(); static int getJavaVersion(); static String getTmpDir(List<String> tmpDirs); static String getWorkerDataDirectory(String storageDir, AlluxioConfiguration conf); static String listToString(List<T> list); static String argsToString(String separator, T... args); static String[] toStringArray(ArrayList<String> src); static String randomAlphaNumString(int length); static byte[] randomBytes(int length); static void sleepMs(long timeMs); static void sleepMs(Logger logger, long timeMs); static void warmUpLoop(); static T createNewClassInstance(Class<T> cls, Class<?>[] ctorClassArgs,
      Object[] ctorArgs); static List<String> getUnixGroups(String user); static void waitFor(String description, Supplier<Boolean> condition); static void waitFor(String description, Supplier<Boolean> condition,
      WaitForOptions options); static T waitForResult(String description, Supplier<T> objectSupplier,
                                    Function<T, Boolean> condition); static T waitForResult(String description, Supplier<T> objectSupplier,
                                    Function<T, Boolean> condition, WaitForOptions options); static String getPrimaryGroupName(String userName, AlluxioConfiguration conf); static List<String> getGroups(String userName, AlluxioConfiguration conf); static String stripSuffixIfPresent(final String key, final String suffix); static String stripPrefixIfPresent(final String key, final String prefix); static String stripLeadingAndTrailingQuotes(String str); @Nullable static String getValueFromStaticMapping(String mapping, String key); static Throwable getRootCause(Throwable e); static IOException castToIOException(Throwable e); static Iterator<T> singleElementIterator(final T element); static void invokeAll(List<Callable<T>> callables, long timeoutMs); static void invokeAll(ExecutorService service, List<Callable<T>> callables,
      long timeoutMs); static RuntimeException closeAndRethrow(Closer closer, Throwable t); static RuntimeException closeAndRethrowRuntimeException(Closer closer, Throwable t); static void unwrapResponse(Protocol.Response response); static void unwrapResponseFrom(Protocol.Response response, Channel channel); static boolean isLocalHost(WorkerNetAddress address, AlluxioConfiguration conf); static String convertMsToDate(long millis, String dateFormatPattern); static String convertMsToClockTime(long millis); static Map<String, ByteString> convertToByteString(Map<String, byte[]> input); static Map<String, byte[]> convertFromByteString(Map<String, ByteString> input); static Supplier<T> memoize(Supplier<T> original); static List<List<T>> partition(List<T> list, int numLists); static boolean isAddressReachable(String hostname, int port); static List<File> recursiveListLocalDir(File dir); static int parseMajorVersion(String version); }
CommonUtils { public static String convertMsToClockTime(long millis) { Preconditions.checkArgument(millis >= 0, "Negative values %s are not supported to convert to clock time.", millis); long days = millis / Constants.DAY_MS; long hours = (millis % Constants.DAY_MS) / Constants.HOUR_MS; long mins = (millis % Constants.HOUR_MS) / Constants.MINUTE_MS; long secs = (millis % Constants.MINUTE_MS) / Constants.SECOND_MS; return String.format("%d day(s), %d hour(s), %d minute(s), and %d second(s)", days, hours, mins, secs); } private  CommonUtils(); static Thread createProgressThread(PrintStream stream); static Thread createProgressThread(final long intervalMs, final PrintStream stream); static long getCurrentMs(); static int getJavaVersion(); static String getTmpDir(List<String> tmpDirs); static String getWorkerDataDirectory(String storageDir, AlluxioConfiguration conf); static String listToString(List<T> list); static String argsToString(String separator, T... args); static String[] toStringArray(ArrayList<String> src); static String randomAlphaNumString(int length); static byte[] randomBytes(int length); static void sleepMs(long timeMs); static void sleepMs(Logger logger, long timeMs); static void warmUpLoop(); static T createNewClassInstance(Class<T> cls, Class<?>[] ctorClassArgs,
      Object[] ctorArgs); static List<String> getUnixGroups(String user); static void waitFor(String description, Supplier<Boolean> condition); static void waitFor(String description, Supplier<Boolean> condition,
      WaitForOptions options); static T waitForResult(String description, Supplier<T> objectSupplier,
                                    Function<T, Boolean> condition); static T waitForResult(String description, Supplier<T> objectSupplier,
                                    Function<T, Boolean> condition, WaitForOptions options); static String getPrimaryGroupName(String userName, AlluxioConfiguration conf); static List<String> getGroups(String userName, AlluxioConfiguration conf); static String stripSuffixIfPresent(final String key, final String suffix); static String stripPrefixIfPresent(final String key, final String prefix); static String stripLeadingAndTrailingQuotes(String str); @Nullable static String getValueFromStaticMapping(String mapping, String key); static Throwable getRootCause(Throwable e); static IOException castToIOException(Throwable e); static Iterator<T> singleElementIterator(final T element); static void invokeAll(List<Callable<T>> callables, long timeoutMs); static void invokeAll(ExecutorService service, List<Callable<T>> callables,
      long timeoutMs); static RuntimeException closeAndRethrow(Closer closer, Throwable t); static RuntimeException closeAndRethrowRuntimeException(Closer closer, Throwable t); static void unwrapResponse(Protocol.Response response); static void unwrapResponseFrom(Protocol.Response response, Channel channel); static boolean isLocalHost(WorkerNetAddress address, AlluxioConfiguration conf); static String convertMsToDate(long millis, String dateFormatPattern); static String convertMsToClockTime(long millis); static Map<String, ByteString> convertToByteString(Map<String, byte[]> input); static Map<String, byte[]> convertFromByteString(Map<String, ByteString> input); static Supplier<T> memoize(Supplier<T> original); static List<List<T>> partition(List<T> list, int numLists); static boolean isAddressReachable(String hostname, int port); static List<File> recursiveListLocalDir(File dir); static int parseMajorVersion(String version); static final AtomicReference<ProcessType> PROCESS_TYPE; }