Example usage for java.lang InterruptedException getMessage

List of usage examples for java.lang InterruptedException getMessage

Introduction

In this page you can find the example usage for java.lang InterruptedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cellbots.eyes.EyesActivity.java

private void uploadImage(byte[] imageData) {
    try {/*from  w w w  .  j a  v a  2  s  .  co  m*/
        YuvImage yuvImage = new YuvImage(imageData, previewFormat, previewWidth, previewHeight, null);
        yuvImage.compressToJpeg(r, 20, out); // Tweak the quality here - 20
        // seems pretty decent for quality + size.
        if (putUrl.contains("127.0.0.1") || putUrl.contains("localhost")) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            resetConnection();
        }
        PutMethod put = new PutMethod(putUrl);
        put.setRequestBody(new ByteArrayInputStream(out.toByteArray()));
        int result = put.execute(mHttpState, mConnection);
        //Log.e("result", result + "");
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "UnsupportedEncodingException: Error uploading image: " + e.getMessage());
    } catch (IllegalStateException e) {
        Log.e(TAG, "IllegalStateException: Error uploading image: " + e.getMessage());
        resetConnection();
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolException: Error uploading image: " + e.getMessage());
        resetConnection();
    } catch (UnknownHostException e) {
        Log.e(TAG, "UnknownHostException: Error uploading image: " + e.getMessage());
        resetConnection();
    } catch (NoHttpResponseException e) {
        // Silently ignore this.
    } catch (IOException e) {
        Log.e(TAG, "IOException: Error uploading image: " + e.getMessage());
        resetConnection();
    } finally {
        out.reset();
        if (mCamera != null) {
            mCamera.addCallbackBuffer(mCallbackBuffer);
        }
        isUploading = false;
    }

}

From source file:com.yahoo.omid.tsoclient.TSOClientImpl.java

private void connectToZK(Configuration conf) throws ZKException {

    String zkCluster = conf.getString(TSO_ZK_CLUSTER_CONFKEY, DEFAULT_ZK_CLUSTER);
    try {/*  w  ww.  j av  a2s. c  o  m*/
        zkClient = provideZookeeperClient(zkCluster);
        LOG.info("\t* Connecting to ZK cluster {}", zkClient.getState());
        zkClient.start();
        if (!zkClient.blockUntilConnected(3, TimeUnit.SECONDS)) {
            throw new ZKException("Cannot connect to ZK Cluster " + zkCluster + " after 3 seconds");
        }
        LOG.info("\t* Connection to ZK cluster {}", zkClient.getState());
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new ZKException("Cannot connect to ZK Cluster " + zkCluster + " Cause: " + e.getMessage());
    }
}

From source file:cn.edu.buaa.act.petuumOnYarn.ApplicationMaster.java

@VisibleForTesting
protected boolean finish() {
    // wait for completion.
    while (!done && (numCompletedContainers.get() != numTotalContainers)) {
        try {/* w  ww.  j a  v  a 2  s  . c  om*/
            Thread.sleep(200);
        } catch (InterruptedException ex) {
        }
    }

    // Join all launched threads
    // needed for when we time out
    // and we need to release containers
    for (Thread launchThread : launchThreads) {
        try {
            launchThread.join(10000);
        } catch (InterruptedException e) {
            LOG.info("Exception thrown in thread join: " + e.getMessage());
            e.printStackTrace();
        }
    }

    // When the application completes, it should stop all running containers
    LOG.info("Application completed. Stopping running containers");
    nmClientAsync.stop();

    // When the application completes, it should send a finish application
    // signal to the RM
    LOG.info("Application completed. Signalling finish to RM");

    FinalApplicationStatus appStatus;
    String appMessage = null;
    boolean success = true;
    if (numFailedContainers.get() == 0 && numCompletedContainers.get() == numTotalContainers) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed="
                + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed="
                + numFailedContainers.get();
        LOG.info(appMessage);
        success = false;
    }
    try {
        amRMClient.unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException ex) {
        LOG.error("Failed to unregister application", ex);
    } catch (IOException e) {
        LOG.error("Failed to unregister application", e);
    }

    amRMClient.stop();

    return success;
}

From source file:com.sogou.dockeronyarn.client.DockerApplicationMaster_23.java

private void finish() {
    // Join all launched threads
    // needed for when we time out
    // and we need to release containers
    for (Thread launchThread : launchThreads) {
        try {/*w w  w.  j a v a  2s  .c  o m*/
            launchThread.join(10000);
        } catch (InterruptedException e) {
            LOG.info("Exception thrown in thread join: " + e.getMessage());
            e.printStackTrace();
        }
    }

    // When the application completes, it should stopContainer all running containers
    LOG.info("Application completed. Stopping running containers");
    nmClientAsync.stop();

    // When the application completes, it should send a shutdown application
    // signal to the RM
    LOG.info("Application completed. Signalling shutdown to RM");

    FinalApplicationStatus appStatus;
    String appMessage = null;
    success = true;
    if (numFailedContainers.get() == 0 && numCompletedContainers.get() == numTotalContainers) {
        appStatus = FinalApplicationStatus.SUCCEEDED;
    } else {
        appStatus = FinalApplicationStatus.FAILED;
        appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed="
                + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed="
                + numFailedContainers.get();
        success = false;
    }
    try {
        amRMClient.unregisterApplicationMaster(appStatus, appMessage, null);
    } catch (YarnException ex) {
        LOG.error("Failed to unregister application", ex);
    } catch (IOException e) {
        LOG.error("Failed to unregister application", e);
    }

    amRMClient.stop();
}

From source file:com.amazonaws.eclipse.dynamodb.testtool.TestToolManager.java

/**
 * Download the given object from S3 to the given file, updating the
 * given progress monitor periodically./* w w w. jav  a2s . c  o m*/
 *
 * @param key The key of the object to download.
 * @param destination The destination file to download to.
 * @param monitor The progress monitor to update.
 */
private void download(final String key, final File destination, final IProgressMonitor monitor) {
    try {

        TransferManager tm = getTransferManager();
        Download download = tm.download(TEST_TOOL_BUCKET, key, destination);

        int totalWork = (int) download.getProgress().getTotalBytesToTransfer();
        monitor.beginTask("Downloading DynamoDB Local", totalWork);

        int worked = 0;
        while (!download.isDone()) {
            int bytes = (int) download.getProgress().getBytesTransferred();
            if (bytes > worked) {
                int newWork = bytes - worked;
                monitor.worked(newWork);
                worked = bytes;
            }
            Thread.sleep(500);
        }

    } catch (InterruptedException exception) {
        Thread.currentThread().interrupt();
        throw new RuntimeException("Interrupted while installing DynamoDB Local", exception);
    } catch (AmazonServiceException exception) {
        throw new RuntimeException("Error downloading DynamoDB Local: " + exception.getMessage(), exception);
    }
}

From source file:com.exxonmobile.ace.hybris.test.orders.B2BAcceleratorTestOrderData.java

protected ScheduledCartData scheduleOrder(final String customerUid, final Map<String, Long> products,
        final AddressData deliveryAddress, final String purchaseOrderNumber, final String costCenterCode,
        final String quotePetition, final TriggerData triggerData) {
    // Impersonate site and customer
    final B2BCustomerModel customer = getUserService().getUserForUID(customerUid.toLowerCase(),
            B2BCustomerModel.class);

    final ImpersonationContext ctx = new ImpersonationContext();
    ctx.setSite(getCmsAdminSiteService().getSiteForId(ExxonmobilTestConstants.POWERTOOLS_SITE));
    ctx.setUser(customer);/*from  ww w  . j a  v a2 s. co m*/
    ctx.setCurrency(i18nService.getCurrency(CURRENCY_ISO_CODE));

    return (ScheduledCartData) getImpersonationService().executeInContext(ctx,
            new ImpersonationService.Executor<Object, ImpersonationService.Nothing>() {
                @Override
                public Object execute() throws ImpersonationService.Nothing {

                    ScheduledCartData scheduledCartData = null;
                    // Check if the order already exists by PurchaseOrderNumber

                    if (prepareANewSessionCartForCheckout(products, deliveryAddress, purchaseOrderNumber,
                            costCenterCode, quotePetition, customer)) {
                        scheduledCartData = getB2bCheckoutFacade().scheduleOrder(triggerData);

                        if (scheduledCartData == null) {
                            LOG.error("Failed to placeOrder");
                        } else {
                            LOG.info("Scheduled Order order job [" + scheduledCartData.getJobCode() + "]");
                            // Sleep for 10s to allow the fulfilment processes to run for this order
                            // Only have to worry about this here if we are running initialize from ant
                            // as the process will exit immediately that we finish initialising.
                            // Also to allow approval process to locate approver
                            try {
                                Thread.sleep(10000);
                            } catch (final InterruptedException e) {
                                LOG.error(e.getMessage(), e);
                            }
                        }
                    }
                    return scheduledCartData;
                }
            });
}

From source file:de.hybris.platform.yb2bacceleratortest.orders.B2BAcceleratorTestOrderData.java

protected ScheduledCartData scheduleOrder(final String customerUid, final Map<String, Long> products,
        final AddressData deliveryAddress, final String purchaseOrderNumber, final String costCenterCode,
        final String quotePetition, final TriggerData triggerData) {
    // Impersonate site and customer
    final B2BCustomerModel customer = getUserService().getUserForUID(customerUid.toLowerCase(),
            B2BCustomerModel.class);

    final ImpersonationContext ctx = new ImpersonationContext();
    ctx.setSite(getCmsAdminSiteService().getSiteForId(YB2BAcceleratorTestConstants.POWERTOOLS_SITE));
    ctx.setUser(customer);/*from   w  w w .  j  av a  2 s .c om*/
    ctx.setCurrency(i18nService.getCurrency(CURRENCY_ISO_CODE));

    return (ScheduledCartData) getImpersonationService().executeInContext(ctx,
            new ImpersonationService.Executor<Object, ImpersonationService.Nothing>() {
                @Override
                public Object execute() throws ImpersonationService.Nothing {

                    ScheduledCartData scheduledCartData = null;
                    // Check if the order already exists by PurchaseOrderNumber

                    if (prepareANewSessionCartForCheckout(products, deliveryAddress, purchaseOrderNumber,
                            costCenterCode, quotePetition, customer)) {
                        scheduledCartData = getB2bCheckoutFacade().scheduleOrder(triggerData);

                        if (scheduledCartData == null) {
                            LOG.error("Failed to placeOrder");
                        } else {
                            LOG.info("Scheduled Order order job [" + scheduledCartData.getJobCode() + "]");
                            // Sleep for 10s to allow the fulfilment processes to run for this order
                            // Only have to worry about this here if we are running initialize from ant
                            // as the process will exit immediately that we finish initialising.
                            // Also to allow approval process to locate approver
                            try {
                                Thread.sleep(10000);
                            } catch (final InterruptedException e) {
                                LOG.error(e.getMessage(), e);
                            }
                        }
                    }
                    return scheduledCartData;
                }
            });
}

From source file:edu.harvard.i2b2.ontology.ws.OntologyService.java

private OMElement execute(RequestHandler handler, long waitTime) throws I2B2Exception {
    // do Ontology query processing inside thread, so that
    // service could sends back message with timeout error.
    OMElement returnElement = null;//from ww w .  j  a  va2 s .c o m

    String unknownErrorMessage = "Error message delivered from the remote server \n"
            + "You may wish to retry your last action";

    ExecutorRunnable er = new ExecutorRunnable();

    er.setRequestHandler(handler);

    Thread t = new Thread(er);
    String ontologyDataResponse = null;

    synchronized (t) {
        t.start();

        // try {
        // if (waitTime > 0) {
        // t.wait(waitTime);
        // } else {
        // t.wait();
        // }

        try {
            long startTime = System.currentTimeMillis();
            long deltaTime = -1;
            while ((er.isJobCompleteFlag() == false) && (deltaTime < waitTime)) {
                if (waitTime > 0) {
                    t.wait(waitTime - deltaTime);
                    deltaTime = System.currentTimeMillis() - startTime;
                } else {
                    t.wait();
                }
            }

            ontologyDataResponse = er.getOutputString();

            if (ontologyDataResponse == null) {
                if (er.getJobException() != null) {
                    log.error("er.jobException is " + er.getJobException().getMessage());

                    log.info("waitTime is " + waitTime);

                    ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null,
                            unknownErrorMessage);
                    ontologyDataResponse = MessageFactory.convertToXMLString(responseMsgType);

                } else if (er.isJobCompleteFlag() == false) {
                    // <result_waittime_ms>5000</result_waittime_ms>
                    String timeOuterror = "Remote server timed out \n" + "Result waittime = " + waitTime
                            + " ms elapsed,\nPlease try again";
                    log.error(timeOuterror);

                    log.debug("ontology waited " + deltaTime + "ms for "
                            + er.getRequestHandler().getClass().getName());

                    ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null,
                            timeOuterror);
                    ontologyDataResponse = MessageFactory.convertToXMLString(responseMsgType);

                } else {
                    log.error("ontology data response is null");
                    log.info("waitTime is " + waitTime);
                    log.debug("ontology waited " + deltaTime + "ms for "
                            + er.getRequestHandler().getClass().getName());
                    ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null,
                            unknownErrorMessage);
                    ontologyDataResponse = MessageFactory.convertToXMLString(responseMsgType);
                }
            }
        } catch (InterruptedException e) {
            log.error(e.getMessage());
            throw new I2B2Exception("Thread error while running Ontology job ");
        } finally {
            t.interrupt();
            er = null;
            t = null;
        }
    }
    returnElement = MessageFactory.createResponseOMElementFromString(ontologyDataResponse);

    return returnElement;
}

From source file:com.exxonmobile.ace.hybris.test.orders.B2BAcceleratorTestOrderData.java

protected OrderData placeOrder(final String customerUid, final Map<String, Long> products,
        final AddressData deliveryAddress, final String purchaseOrderNumber, final String costCenterCode,
        final String quotePetition) {
    // Impersonate site and customer
    final B2BCustomerModel customer = getUserService().getUserForUID(customerUid.toLowerCase(),
            B2BCustomerModel.class);

    final ImpersonationContext ctx = new ImpersonationContext();
    ctx.setSite(getCmsAdminSiteService().getSiteForId(ExxonmobilTestConstants.POWERTOOLS_SITE));
    ctx.setUser(customer);/*from  ww w  . j a  va  2s .  co m*/
    ctx.setCurrency(i18nService.getCurrency(CURRENCY_ISO_CODE));

    return (OrderData) getImpersonationService().executeInContext(ctx,
            new ImpersonationService.Executor<Object, ImpersonationService.Nothing>() {
                @Override
                public Object execute() throws ImpersonationService.Nothing {

                    OrderData orderData = null;

                    // Check if the order already exists by PurchaseOrderNumber
                    if (prepareANewSessionCartForCheckout(products, deliveryAddress, purchaseOrderNumber,
                            costCenterCode, quotePetition, customer)) {
                        try {
                            orderData = getB2bCheckoutFacade().placeOrder();

                            if (orderData == null) {
                                LOG.error("Failed to placeOrder");
                            } else {
                                LOG.info("Created order [" + orderData.getCode() + "]");
                                // Sleep for 10s to allow the fulfilment processes to run for this order
                                // Only have to worry about this here if we are running initialize from ant
                                // as the process will exit immediately that we finish initialising.
                                // Also to allow approval process to locate approver
                                try {
                                    Thread.sleep(DELAY_IN_MILLIS);
                                } catch (final InterruptedException e) {
                                    LOG.error(e.getMessage(), e);
                                }
                            }
                        } catch (final InvalidCartException e) {
                            LOG.error(e.getMessage(), e);
                        }
                    }
                    return orderData;
                }
            });
}

From source file:de.hybris.platform.yb2bacceleratortest.orders.B2BAcceleratorTestOrderData.java

protected OrderData placeOrder(final String customerUid, final Map<String, Long> products,
        final AddressData deliveryAddress, final String purchaseOrderNumber, final String costCenterCode,
        final String quotePetition) {
    // Impersonate site and customer
    final B2BCustomerModel customer = getUserService().getUserForUID(customerUid.toLowerCase(),
            B2BCustomerModel.class);

    final ImpersonationContext ctx = new ImpersonationContext();
    ctx.setSite(getCmsAdminSiteService().getSiteForId(YB2BAcceleratorTestConstants.POWERTOOLS_SITE));
    ctx.setUser(customer);// w  ww .j  a  v  a2  s  . co m
    ctx.setCurrency(i18nService.getCurrency(CURRENCY_ISO_CODE));

    return (OrderData) getImpersonationService().executeInContext(ctx,
            new ImpersonationService.Executor<Object, ImpersonationService.Nothing>() {
                @Override
                public Object execute() throws ImpersonationService.Nothing {

                    OrderData orderData = null;

                    // Check if the order already exists by PurchaseOrderNumber
                    if (prepareANewSessionCartForCheckout(products, deliveryAddress, purchaseOrderNumber,
                            costCenterCode, quotePetition, customer)) {
                        try {
                            orderData = getB2bCheckoutFacade().placeOrder();

                            if (orderData == null) {
                                LOG.error("Failed to placeOrder");
                            } else {
                                LOG.info("Created order [" + orderData.getCode() + "]");
                                // Sleep for 10s to allow the fulfilment processes to run for this order
                                // Only have to worry about this here if we are running initialize from ant
                                // as the process will exit immediately that we finish initialising.
                                // Also to allow approval process to locate approver
                                try {
                                    Thread.sleep(DELAY_IN_MILLIS);
                                } catch (final InterruptedException e) {
                                    LOG.error(e.getMessage(), e);
                                }
                            }
                        } catch (final InvalidCartException e) {
                            LOG.error(e.getMessage(), e);
                        }
                    }
                    return orderData;
                }
            });
}