List of usage examples for java.util.concurrent ExecutionException printStackTrace
public void printStackTrace()
From source file:mzb.Balancer.java
private long dispatchBlockMoves() throws InterruptedException { long bytesLastMoved = bytesMoved.get(); try {/*from w w w.j a v a 2 s. c o m*/ Future<?>[] futures = new Future<?>[sources.size()]; int i = 0; for (Source source : sources) { futures[i++] = dispatcherExecutor.submit(source.new BlockMoveDispatcher()); } // wait for all dispatcher threads to finish for (Future<?> future : futures) { try { future.get(); } catch (ExecutionException e) { LOG.warn("Dispatcher thread failed", e.getCause()); } } } catch (Exception e) { e.printStackTrace(); LOG.error("no move! QAQ"); System.exit(0); } // wait for all block moving to be done waitForMoveCompletion(); return bytesMoved.get() - bytesLastMoved; }
From source file:org.apache.geode.internal.cache.wan.WANTestBase.java
public static void doMultiThreadedPuts(String regionName, int numPuts) { final AtomicInteger ai = new AtomicInteger(-1); final ExecutorService execService = Executors.newFixedThreadPool(5, new ThreadFactory() { AtomicInteger threadNum = new AtomicInteger(); public Thread newThread(final Runnable r) { Thread result = new Thread(r, "Client Put Thread-" + threadNum.incrementAndGet()); result.setDaemon(true);/* w w w . j ava2 s . c om*/ return result; } }); final Region r = cache.getRegion(Region.SEPARATOR + regionName); assertNotNull(r); List<Callable<Object>> tasks = new ArrayList<Callable<Object>>(); for (long i = 0; i < 5; i++) tasks.add(new PutTask(r, ai, numPuts)); try { List<Future<Object>> l = execService.invokeAll(tasks); for (Future<Object> f : l) f.get(); } catch (InterruptedException e1) { // TODO: eats exception e1.printStackTrace(); } catch (ExecutionException e) { // TODO: eats exceptions e.printStackTrace(); } execService.shutdown(); }
From source file:hudson.model.Hudson.java
private synchronized void load() throws IOException { long startTime = System.currentTimeMillis(); XmlFile cfg = getConfigFile();//from w w w . ja va 2 s .c o m if (cfg.exists()) { // reset some data that may not exit in the disk file // so that we can take a proper compensation action later. primaryView = null; views.clear(); cfg.unmarshal(this); } clouds.setOwner(this); File projectsDir = new File(root, "jobs"); if (!projectsDir.isDirectory() && !projectsDir.mkdirs()) { if (projectsDir.exists()) throw new IOException(projectsDir + " is not a directory"); throw new IOException("Unable to create " + projectsDir + "\nPermission issue? Please create this directory manually."); } File[] subdirs = projectsDir.listFiles(new FileFilter() { public boolean accept(File child) { return child.isDirectory() && Items.getConfigFile(child).exists(); } }); items.clear(); if (PARALLEL_LOAD) { // load jobs in parallel for better performance LOGGER.info("Loading in " + TWICE_CPU_NUM + " parallel threads"); List<Future<TopLevelItem>> loaders = new ArrayList<Future<TopLevelItem>>(); for (final File subdir : subdirs) { loaders.add(threadPoolForLoad.submit(new Callable<TopLevelItem>() { public TopLevelItem call() throws Exception { Thread t = Thread.currentThread(); String name = t.getName(); t.setName("Loading " + subdir); try { long start = System.currentTimeMillis(); TopLevelItem item = (TopLevelItem) Items.load(Hudson.this, subdir); if (LOG_STARTUP_PERFORMANCE) LOGGER.info("Loaded " + item.getName() + " in " + (System.currentTimeMillis() - start) + "ms by " + name); return item; } finally { t.setName(name); } } })); } for (Future<TopLevelItem> loader : loaders) { try { TopLevelItem item = loader.get(); items.put(item.getName(), item); } catch (ExecutionException e) { LOGGER.log(Level.WARNING, "Failed to load a project", e.getCause()); } catch (InterruptedException e) { e.printStackTrace(); // this is probably not the right thing to do } } } else { for (File subdir : subdirs) { try { long start = System.currentTimeMillis(); TopLevelItem item = (TopLevelItem) Items.load(this, subdir); if (LOG_STARTUP_PERFORMANCE) LOGGER.info( "Loaded " + item.getName() + " in " + (System.currentTimeMillis() - start) + "ms"); items.put(item.getName(), item); } catch (Error e) { LOGGER.log(Level.WARNING, "Failed to load " + subdir, e); } catch (RuntimeException e) { LOGGER.log(Level.WARNING, "Failed to load " + subdir, e); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to load " + subdir, e); } } } rebuildDependencyGraph(); {// recompute label objects for (Node slave : slaves) slave.getAssignedLabels(); getAssignedLabels(); } // initialize views by inserting the default view if necessary // this is both for clean Hudson and for backward compatibility. if (views.size() == 0 || primaryView == null) { View v = new AllView(Messages.Hudson_ViewName()); v.owner = this; views.add(0, v); primaryView = v.getViewName(); } // read in old data that doesn't have the security field set if (authorizationStrategy == null) { if (useSecurity == null || !useSecurity) authorizationStrategy = AuthorizationStrategy.UNSECURED; else authorizationStrategy = new LegacyAuthorizationStrategy(); } if (securityRealm == null) { if (useSecurity == null || !useSecurity) setSecurityRealm(SecurityRealm.NO_AUTHENTICATION); else setSecurityRealm(new LegacySecurityRealm()); } else { // force the set to proxy setSecurityRealm(securityRealm); } if (useSecurity != null && !useSecurity) { // forced reset to the unsecure mode. // this works as an escape hatch for people who locked themselves out. authorizationStrategy = AuthorizationStrategy.UNSECURED; setSecurityRealm(SecurityRealm.NO_AUTHENTICATION); } // Initialize the filter with the crumb issuer setCrumbIssuer(crumbIssuer); // auto register root actions actions.addAll(getExtensionList(RootAction.class)); LOGGER.info(String.format("Took %s ms to load", System.currentTimeMillis() - startTime)); if (KILL_AFTER_LOAD) System.exit(0); }