List of usage examples for java.util.concurrent ExecutionException printStackTrace
public void printStackTrace()
From source file:it.uniroma2.foundme.studente.UnFollowCourseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_unfollow_course); context = this; lvCorsiSeguiti = (ListView) findViewById(R.id.lvCorsiSeguiti); swipeUnfollow = (SwipeRefreshLayout) findViewById(R.id.swipe_unfollow); swipeUnfollow.setEnabled(false);/*from ww w .j av a2 s .co m*/ Bundle passed = getIntent().getExtras(); Sid = passed.getString(Variables_it.ID); try { getCourse(true); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:com.qubole.rubix.hadoop2.hadoop2CM.Hadoop2ClusterManager.java
@Override public boolean isMaster() { // issue get on nodesSupplier to ensure that isMaster is set correctly try {//from w w w . j a va2 s .com nodesCache.get("nodeList"); } catch (ExecutionException e) { e.printStackTrace(); } return isMaster; }
From source file:com.qubole.rubix.hadoop2.hadoop2CM.Hadoop2ClusterManager.java
@Override public List<String> getNodes() { try {/*from w w w .j a v a 2 s . c om*/ return nodesCache.get("nodeList"); } catch (ExecutionException e) { e.printStackTrace(); } return null; }
From source file:com.aliyun.odps.ship.upload.DshipUpload.java
private void uploadBlock() throws IOException, TunnelException, ParseException { int threads = Integer.valueOf(DshipContext.INSTANCE.get(Constants.THREADS)); ExecutorService executors = Executors.newFixedThreadPool(threads); ArrayList<Callable<Long>> callList = new ArrayList<Callable<Long>>(); for (BlockInfo block : blockIndex) { final BlockUploader uploader = new BlockUploader(block, tunnelUploadSession, sessionHistory); Callable<Long> call = new Callable<Long>() { @Override/*w w w. j av a2s .c o m*/ public Long call() throws Exception { uploader.upload(); return 0L; } }; callList.add(call); } try { List<Future<Long>> futures = executors.invokeAll(callList); ArrayList<String> failedBlock = new ArrayList<String>(); for (int i = 0; i < futures.size(); ++i) { try { futures.get(i).get(); } catch (ExecutionException e) { e.printStackTrace(); failedBlock.add(String.valueOf(i)); } } if (!failedBlock.isEmpty()) { throw new TunnelException("Block ID:" + StringUtils.join(failedBlock, ",") + " Failed."); } } catch (InterruptedException e) { throw new UserInterruptException(e.getMessage()); } }
From source file:org.openhab.io.mqttembeddedbroker.internal.MqttEmbeddedBrokerServiceTest.java
@Test public void connectUnsecureAndTestCredentials() throws InterruptedException, IOException, ExecutionException { subject.initialize(config);/* w ww . j a v a2 s .c om*/ MqttBrokerConnection c = subject.getConnection(); assertNotNull(c); waitForConnectionChange(c, MqttConnectionState.CONNECTED); assertThat(c.getUser(), is("username")); assertThat(c.getPassword(), is("password")); assertThat(c.connectionState(), is(MqttConnectionState.CONNECTED)); verify(service).addBrokerConnection(anyString(), eq(c)); // Connect with a second connection but wrong credentials MqttBrokerConnection wrongCredentials = new MqttBrokerConnection(Protocol.TCP, c.getHost(), c.getPort(), false, "wrongCred"); wrongCredentials.setCredentials("someUser", "somePassword"); try { if (wrongCredentials.start().get()) { fail("Wrong credentials accepted!"); } } catch (ExecutionException e) { e.printStackTrace(); } wrongCredentials.stop().get(); // Connect with a second connection but correct credentials MqttBrokerConnection correctCredentials = new MqttBrokerConnection(Protocol.TCP, c.getHost(), c.getPort(), false, "correctCred"); correctCredentials.setCredentials(c.getUser(), c.getPassword()); try { if (!correctCredentials.start().get()) { fail("Couldn't connect although correct credentials"); } } catch (ExecutionException e) { e.printStackTrace(); } correctCredentials.stop().get(); }
From source file:it.uniroma2.foundme.studente.FollowCourseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_follow_course); context = this; swipeFollow = (SwipeRefreshLayout) findViewById(R.id.swipe_follow); swipeFollow.setEnabled(false);/* w w w . j ava 2 s . c om*/ Bundle passed = getIntent().getExtras(); Sid = passed.getString(Variables_it.ID); lvTuttiCorsi = (ListView) findViewById(R.id.lvTuttiCorsi); etFilter = (EditText) findViewById(R.id.etFilter); try { getCourse(true); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:foundme.uniroma2.it.professore.ReadMessageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_message); context = this; Bundle passed = getIntent().getExtras(); Title = passed.getString(Variables_it.COURSE); swipeMsg = (SwipeRefreshLayout) findViewById(R.id.swipe_msg); swipeMsg.setEnabled(false);/*from w w w . ja v a 2 s . c om*/ lvMessaggi = (ListView) findViewById(R.id.lvmes); modeCallBack = new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.delete: if (!toEdit.equalsIgnoreCase(Variables_it.NO_MSG)) { try { deleteMsg(toEdit); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } toEdit = null; mode.finish(); break; } return false; } public void onDestroyActionMode(ActionMode mode) { viewList.setBackgroundColor(Color.TRANSPARENT); mode = null; } public boolean onCreateActionMode(ActionMode mode, Menu menu) { mode.setTitle(Variables_it.OPTION); mode.getMenuInflater().inflate(R.menu.context, menu); return true; } }; try { getMsg(Title, true); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:cc.kave.commons.pointsto.evaluation.cv.CVEvaluator.java
public double evaluate(SetProvider setProvider) { List<Future<Pair<Integer, Double>>> futures = new ArrayList<>(numFolds); double[] evaluationResults = new double[numFolds]; for (int i = 0; i < numFolds; ++i) { futures.add(executorService.submit(new FoldEvaluation(i, setProvider))); }/*from w w w . jav a2 s.c o m*/ for (int i = 0; i < evaluationResults.length; ++i) { try { Pair<Integer, Double> result = futures.get(i).get(); evaluationResults[i] = result.getValue(); log("\tFold %d: %.3f\n", i + 1, evaluationResults[i]); } catch (ExecutionException e) { throw new RuntimeException(e.getCause()); } catch (InterruptedException e) { e.printStackTrace(); return Double.NaN; } } return StatUtils.mean(evaluationResults); }
From source file:org.openmrs.module.restrictbyrole.api.impl.RestrictByRoleServiceImpl.java
/** * @see org.openmrs.module.restrictbyrole.api.RestrictByRoleService#getUserRestrictionResult(User) *//*from ww w .j ava2 s .com*/ public UserRestrictionResult getUserRestrictionResult(User user) { // This method can take a long time to execute, so the result is cached try { return cachedUserRestrictionResult.get(user); } catch (ExecutionException e) { e.printStackTrace(); return null; } }
From source file:com.aliyun.odps.ship.download.DshipDownload.java
private void multiThreadDownload() throws TunnelException { ArrayList<Callable<Long>> callList = new ArrayList<Callable<Long>>(); for (final FileDownloader downloader : workItems) { Callable<Long> call = new Callable<Long>() { @Override//from w w w. j a v a2 s . co m public Long call() throws Exception { downloader.download(); return downloader.getWrittenBytes(); } }; callList.add(call); } ExecutorService executors = Executors.newFixedThreadPool(threads); try { List<Future<Long>> futures = executors.invokeAll(callList); ArrayList<String> failedThread = new ArrayList<String>(); for (int i = 0; i < futures.size(); ++i) { try { writtenBytes += futures.get(i).get(); } catch (ExecutionException e) { e.printStackTrace(); failedThread.add(String.valueOf(i)); } } if (!failedThread.isEmpty()) { throw new TunnelException("Slice ID:" + StringUtils.join(failedThread, ",") + " Failed."); } } catch (InterruptedException e) { throw new UserInterruptException(e.getMessage()); } }