@Test public void invokeAllPropagatesExceptionWithTimeout() throws Exception { int numTasks = 5; final AtomicInteger id = new AtomicInteger(); List<Callable<Void>> tasks = new ArrayList<>(); final Exception testException = new Exception("test message"); for (int i = 0; i < numTasks; i++) { tasks.add(() -> { int myId = id.incrementAndGet(); if (myId == 3) { throw testException; } else { Thread.sleep(10 * Constants.SECOND_MS); } return null; }); } try { CommonUtils.invokeAll(tasks, 500); fail("Expected an exception to be thrown"); } catch (ExecutionException e) { assertSame(testException, e.getCause()); } }
public static <T> void invokeAll(List<Callable<T>> callables, long timeoutMs) throws TimeoutException, ExecutionException { ExecutorService service = Executors.newCachedThreadPool(); try { invokeAll(service, callables, timeoutMs); } finally { service.shutdownNow(); } }
CommonUtils { public static <T> void invokeAll(List<Callable<T>> callables, long timeoutMs) throws TimeoutException, ExecutionException { ExecutorService service = Executors.newCachedThreadPool(); try { invokeAll(service, callables, timeoutMs); } finally { service.shutdownNow(); } } }
CommonUtils { public static <T> void invokeAll(List<Callable<T>> callables, long timeoutMs) throws TimeoutException, ExecutionException { ExecutorService service = Executors.newCachedThreadPool(); try { invokeAll(service, callables, timeoutMs); } finally { service.shutdownNow(); } } private  CommonUtils(); }
CommonUtils { public static <T> void invokeAll(List<Callable<T>> callables, long timeoutMs) throws TimeoutException, ExecutionException { ExecutorService service = Executors.newCachedThreadPool(); try { invokeAll(service, callables, timeoutMs); } finally { service.shutdownNow(); } } 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 <T> void invokeAll(List<Callable<T>> callables, long timeoutMs) throws TimeoutException, ExecutionException { ExecutorService service = Executors.newCachedThreadPool(); try { invokeAll(service, callables, timeoutMs); } finally { service.shutdownNow(); } } 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; }