Example usage for java.util.concurrent ExecutionException getMessage

List of usage examples for java.util.concurrent ExecutionException getMessage

Introduction

In this page you can find the example usage for java.util.concurrent ExecutionException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:gridool.mapred.dht.task.DhtMapShuffleTask.java

private void shuffleAndCollectKeys(final ArrayQueue<byte[]> queue) {
    if (jobConf == null) {
        LOG.warn("jobConf was not set. Use the default OutputKeyCollectionName for collecting keys: "
                + DhtMapReduceJobConf.OutputKeyCollectionName);
    }// w  w w . j  ava  2 s  .com
    final AddOperation ops1;
    final AddOperation ops2;
    {
        // #1. shuffle key/values
        ops1 = new AddOperation(destTableName);
        ops1.setMaxNumReplicas(0);
        final int size = queue.size();
        final byte[][] shuffledKeys = new byte[size / 2][];
        for (int i = 0, j = 0; i < size; i += 2, j++) {
            byte[] k = queue.get(i);
            shuffledKeys[j] = k;
            byte[] v = queue.get(i + 1);
            ops1.addMapping(k, v);
        }
        // #2. collect keys
        String collectKeyDest = (jobConf == null) ? DhtMapReduceJobConf.OutputKeyCollectionName
                : jobConf.getOutputKeyCollectionName();
        byte[] key = StringUtils.getBytes(destTableName);
        byte[] value = GridUtils.compressOutputKeys(shuffledKeys);
        ops2 = new AddOperation(collectKeyDest, key, value);
        ops2.setMaxNumReplicas(0);
    }
    shuffleExecPool.execute(new Runnable() {
        public void run() {
            final GridJobFuture<Serializable> future1 = kernel.execute(DirectoryAddJob.class, ops1);
            final GridJobFuture<Serializable> future2 = kernel.execute(DirectoryAddJob.class, ops2);
            try {// TODO REVIEWME order of waiting                    
                future2.get(); // wait for execution
                future1.get(); // wait for execution 
            } catch (InterruptedException ie) {
                LOG.error(ie.getMessage(), ie);
            } catch (ExecutionException ee) {
                LOG.error(ee.getMessage(), ee);
            }
        }
    });
}

From source file:org.openengsb.connector.script.internal.ScriptServiceImpl.java

private String readResultFromFuture(Future<String> future) throws InterruptedException {
    String result;/*from  w  w w  .  j  a  va  2 s .c o  m*/
    try {
        result = future.get();
    } catch (ExecutionException e) {
        LOGGER.error(e.getMessage(), e.getCause());
        result = ExceptionUtils.getFullStackTrace(e);
    }
    return result;
}

From source file:org.jactr.core.model.six.DefaultCycleProcessor6.java

/**
 * run a single cycle of the model/*from ww w. j ava2 s  .c o  m*/
 * 
 * @see java.util.concurrent.Callable#call()
 */
public double cycle(IModel model, boolean eventsHaveFired) {
    BasicModel basicModel = (BasicModel) model;
    execute(_executeBefore);

    /*
     * what time is it?
     */
    double now = ACTRRuntime.getRuntime().getClock(basicModel).getTime();

    basicModel.setCycle(basicModel.getCycle() + 1);
    basicModel.dispatch(new ModelEvent(basicModel, ModelEvent.Type.CYCLE_STARTED));
    double nextWaitTime = Double.NEGATIVE_INFINITY;

    _isExecuting = true;

    try {
        double productionFiringTime = evaluateAndFireProduction(basicModel, now);
        nextWaitTime = calculateNextWaitTime(now, productionFiringTime, basicModel, eventsHaveFired);

        if (LOGGER.isDebugEnabled())
            LOGGER.debug("nextWaitTime : " + nextWaitTime);
    } catch (InterruptedException ie) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("Interrupted while executing production. Terminating ");

        nextWaitTime = Double.NaN;
    } catch (ExecutionException e) {
        LOGGER.error("Failed to fire production ", e);
        throw new RuntimeException(e.getMessage(), e.getCause());
    } finally {
        _isExecuting = false;

        /*
         * always fire the cycle stopped event
         */
        basicModel.dispatch(new ModelEvent(basicModel, ModelEvent.Type.CYCLE_STOPPED));

        execute(_executeAfter);
    }

    return nextWaitTime;
}

From source file:eclserver.threads.EmergencyNotifyPush.java

@Override
protected void done() {
    // whether we retrieved anything or not
    // we're done, so set the progress indicator accordingly

    try {//  w ww .  j  a  v  a 2s.c  o  m

        recipients = recListDao.getListEntries();
        ActionEvent callReload = new ActionEvent(new Object[] { "Reload Recs" }, 1, "RELOAD_RECS");
        recPanel.actionPerformed(callReload);
        recPanel.setRecipientsListEntries(recipients);

        String recCompleted = (String) get();

        System.out.println("\nNotification Push THREAD: " + recCompleted);

        enPanel.printToResults("\n\nCompleted Pushing Notification content to Users.");

        setProgress(100);
        System.out.println("Thread wrapping up");

    } catch (ExecutionException ex) {
        System.out.println("\nNotifications Push THREAD Thread Execution Exception: " + ex.getMessage());

    } catch (InterruptedException ex) {
        System.out.println("\nNotifications Push THREAD Thread Interrupted Exception: " + ex.getMessage());
    }
    if (recipients.isEmpty()) {
        enPanel.printToResults("\nDidn't retrieve anything from file in DONE() thread.");
    }

}

From source file:eclserver.threads.EmergencyCallPush.java

@Override
protected void done() {
    // whether we retrieved anything or not
    // we're done, so set the progress indicator accordingly

    try {/*from ww w  .  ja  v a2  s  . c o  m*/

        recipients = recListDao.getListEntries();
        ActionEvent callReload = new ActionEvent(new Object[] { "Reload Recs" }, 1, "RELOAD_RECS");
        recPanel.actionPerformed(callReload);
        recPanel.setRecipientsListEntries(recipients);

        String recCompleted = (String) get();

        System.out.println("Call Push THREAD: " + recCompleted);

        ecPanel.printToResults("\n\nCompleted Pushing Call content to Users.");

        setProgress(100);
        System.out.println("Thread wrapping up");

    } catch (ExecutionException ex) {
        System.out.println("\nContacts Push THREAD Thread Execution Exception: " + ex.getMessage());

    } catch (InterruptedException ex) {
        System.out.println("\nCall Push THREAD Thread Interrupted Exception: " + ex.getMessage());

    }
    if (recipients.isEmpty()) {
        ecPanel.printToResults("\nDidn't retrieve anything from file in DONE() thread.");
    }

}

From source file:org.springframework.batch.support.transaction.ConcurrentTransactionAwareProxyTests.java

@Ignore("This fails too often and is a false negative")
@Test/*from w w  w.j  a  v a  2 s .co  m*/
public void testConcurrentTransactionalList() throws Exception {
    List<String> list = TransactionAwareProxyFactory.createTransactionalList();
    try {
        testList(list, true);
        fail("Expected ExecutionException or AssertionError (but don't panic if it didn't happen: it probably just means we got lucky for a change)");
    } catch (ExecutionException e) {
        String message = e.getCause().getMessage();
        assertTrue("Wrong message: " + message, message.startsWith("Lost update"));
    } catch (AssertionError e) {
        String message = e.getMessage();
        assertTrue("Wrong message: " + message, message.startsWith("Wrong number of results"));
    }
}

From source file:demo.vmware.commands.schemaspecific.CommandCreateData.java

@Override
public CommandResult run(ConfigurableApplicationContext mainContext, List<String> parameters) {
    List<String> messages = new ArrayList<String>();

    // lets us track cache growth
    int attributeCounter = 0;

    CommandTimer timer = new CommandTimer();
    LOG.info("creating test data for " + numCompanies + "," + numRegions + "," + numGroups + "," + numBranches);
    // use the Java executor service because of it's awesome invokeAll method.
    // we have 4 cores but gemfire needs some. 2 is probably a more realistic number
    ExecutorService taskExecutor = Executors.newFixedThreadPool(2);
    Collection tasks = new ArrayList<CompanyHierarchyPopulator>();

    for (int i = 0; i < numCompanies; i++) {
        // add a task for each company we are creating
        CompanyHierarchyPopulator poper = new CompanyHierarchyPopulator();
        tasks.add(poper);/*from  w w w .java2 s  .  c  o  m*/
    }

    try {
        // run all the tasks in execution pool
        List<Future<?>> futures = taskExecutor.invokeAll(tasks);
        taskExecutor.shutdown();

        // aggregate the results from the call() method
        for (int i = 0; i < numCompanies; i++) {
            // should get resulting messages also -- sometime in the future
            attributeCounter += ((Integer) futures.get(i).get()).intValue();
        }

        timer.stop();
        messages.add("Created " + attributeCounter + " attributes and " + " took "
                + timer.getTimeDiffInSeconds() + " sec");
    } catch (ExecutionException e) {
        // this should never happen
        LOG.warn("something bad happend", e);
        messages.add("Something bad happend " + e.getMessage());
    } catch (InterruptedException e) {
        // this should never happen
        LOG.warn("something bad happend", e);
        messages.add("Something bad happend " + e.getMessage());
    }
    return new CommandResult(null, messages);
}

From source file:org.pentaho.platform.plugin.services.metadata.PentahoMetadataDomainRepositoryConcurrencyTest.java

private void runTest(final List<? extends Callable<String>> actors) throws Exception {
    List<String> errors = new ArrayList<String>();
    ExecutorService executorService = Executors.newFixedThreadPool(actors.size());
    try {//  w w w .j a va  2 s . c  o m
        CompletionService<String> completionService = new ExecutorCompletionService<String>(executorService);
        for (Callable<String> reader : actors) {
            completionService.submit(reader);
        }

        for (int i = 0; i < actors.size(); i++) {
            Future<String> take = completionService.take();
            String result;
            try {
                result = take.get();
            } catch (ExecutionException e) {
                result = "Execution exception: " + e.getMessage();
            }
            if (result != null) {
                errors.add(result);
            }
        }
    } finally {
        executorService.shutdown();
    }

    if (!errors.isEmpty()) {
        StringBuilder builder = new StringBuilder();
        builder.append("The following errors occurred: \n");
        for (String error : errors) {
            builder.append(error).append('\n');
        }
        fail(builder.toString());
    }
}

From source file:com.ok2c.lightmtp.impl.protocol.PipeliningReceiveEnvelopCodec.java

private SMTPReply getReply(final Future<SMTPReply> future) {
    try {/*  w w  w  .j  av a  2s.  co m*/
        return future.get();
    } catch (ExecutionException ex) {
        Throwable cause = ex.getCause();
        if (cause == null) {
            cause = ex;
        }
        return new SMTPReply(SMTPCodes.ERR_PERM_TRX_FAILED, new SMTPCode(5, 3, 0), cause.getMessage());
    } catch (InterruptedException ex) {
        return new SMTPReply(SMTPCodes.ERR_PERM_TRX_FAILED, new SMTPCode(5, 3, 0), ex.getMessage());
    }
}

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//from  w  w  w  .ja va2 s. co 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());
    }
}