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:ch.sbb.releasetrain.action.jenkins.JenkinsJobThread.java

public void startBuildJobOnJenkins(final boolean blocking) {
    callURL(jobUrl);// www  .  j  a v  a 2 s  . co  m
    start = System.currentTimeMillis();
    super.start();
    running = true;
    try {
        if (blocking) {
            this.join();
        }
    } catch (final InterruptedException e) {
        log.error(e.getMessage(), e);
    }
}

From source file:com.oakesville.mythling.util.MediaStreamProxy.java

public void stop() {
    isRunning = false;/*from w  ww .j  av a  2 s  .co  m*/
    if (thread == null)
        throw new IllegalStateException("Cannot stop proxy; not started.");

    if (httpClient != null)
        httpClient.close();

    thread.interrupt();
    try {
        thread.join(5000);
    } catch (InterruptedException ex) {
        Log.e(TAG, ex.getMessage(), ex);
    }
    //        try {
    //            socket.close();
    //        } catch (IOException ex) {
    //            Log.e(TAG, ex.getMessage(), ex);
    //        }
}

From source file:ch.cyberduck.core.cryptomator.features.CryptoChecksumCompute.java

protected Checksum compute(final InputStream in, final long offset, final ByteBuffer header,
        final NonceGenerator nonces) throws ChecksumException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Calculate checksum with header %s", header));
    }//from  w  w  w  . j a  v a2 s  . c  o  m
    try {
        final PipedOutputStream source = new PipedOutputStream();
        final CryptoOutputStream<Void> out = new CryptoOutputStream<Void>(new VoidStatusOutputStream(source),
                cryptomator.getCryptor(), cryptomator.getCryptor().fileHeaderCryptor().decryptHeader(header),
                nonces, cryptomator.numberOfChunks(offset));
        final PipedInputStream sink = new PipedInputStream(source,
                PreferencesFactory.get().getInteger("connection.chunksize"));
        final ThreadPool pool = ThreadPoolFactory.get("checksum", 1);
        try {
            final Future execute = pool.execute(new Callable<TransferStatus>() {
                @Override
                public TransferStatus call() throws Exception {
                    if (offset == 0) {
                        source.write(header.array());
                    }
                    final TransferStatus status = new TransferStatus();
                    new StreamCopier(status, status).transfer(in, out);
                    return status;
                }
            });
            try {
                return delegate.compute(sink, new TransferStatus());
            } finally {
                try {
                    execute.get();
                } catch (InterruptedException e) {
                    throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"),
                            e.getMessage(), e);
                } catch (ExecutionException e) {
                    if (e.getCause() instanceof BackgroundException) {
                        throw (BackgroundException) e.getCause();
                    }
                    throw new DefaultExceptionMappingService().map(e.getCause());
                }
            }
        } finally {
            pool.shutdown(true);
        }
    } catch (ChecksumException e) {
        throw e;
    } catch (IOException | BackgroundException e) {
        throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(),
                e);
    }
}

From source file:com.nts.alphamale.handler.ExecutorHandler.java

/**
 * execute asynchronous commandline//w ww  . j av a2  s  . c  o m
 * @param cmdList
 * @param timeout
 * @return
 */
public Map<String, Object> executeAsynchronous(CommandLine cmd, long timeout) {
    asynchExecutor = Executors.newCachedThreadPool();
    Future<Map<String, Object>> future = asynchExecutor
            .submit(new AsynchronousTask(cmd, ExecuteWatchdog.INFINITE_TIMEOUT));
    try {
        return future.get();
    } catch (InterruptedException e) {
        future.cancel(true);
    } catch (ExecutionException e) {
        log.error(e.getMessage());
    }
    return null;
}

From source file:com.cloud.hypervisor.ovm3.objects.Pool.java

/**
 * New style ownership, we need a dict to go in.
 *  manager_uuid//from www .j a v a 2 s  . c o  m
 *  manager_event_url
 *  manager_statistic_url
 *  manager_certificate
 *  signed_server_certificate
 * @param uuid
 * @param apiurl
 * @return
 * @throws Ovm3ResourceException
 */
public Boolean takeOwnership33x(final String uuid, final String eventUrl, final String statUrl,
        final String managerCert, final String signedCert) throws Ovm3ResourceException {
    final Map<String, String> mgrConfig = new HashMap<String, String>() {
        {
            put("manager_uuid", uuid);
            put("manager_event_url", eventUrl);
            put("manager_statistic_url", statUrl);
            put("manager_certificate", managerCert);
            put("signed_server_certificate", signedCert);
        }
        private static final long serialVersionUID = 1L;
    };
    Boolean rc = nullIsTrueCallWrapper("take_ownership", mgrConfig);
    /* because it restarts when it's done.... 2000? -sigh- */
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        throw new Ovm3ResourceException(e.getMessage());
    }
    return rc;
}

From source file:edu.harvard.iq.dataverse.api.filesystem.FileRecordJobIT.java

License:asdf

/**
 * Poll the import job, pending completion
 * @param jobId job execution id//w  w w  .j a va2  s. c om
 * @param apiToken user token
 * @param retry max number of retry attempts
 * @param sleep milliseconds to wait between attempts
 * @return json job status
 */
public static String pollJobStatus(String jobId, String apiToken, int retry, long sleep) {
    int maxTries = 0;
    String json = "";
    String status = BatchStatus.STARTED.name();
    try {
        while (!status.equalsIgnoreCase(BatchStatus.COMPLETED.name())) {
            if (maxTries < retry) {
                maxTries++;
                Thread.sleep(sleep);
                Response jobResponse = given().header(API_TOKEN_HTTP_HEADER, apiToken)
                        .get(props.getProperty("job.status.api") + jobId);
                json = jobResponse.body().asString();
                status = JsonPath.from(json).getString("status");
                System.out.println("JOB STATUS RETRY ATTEMPT: " + maxTries);
            } else {
                System.out
                        .println("JOB STATUS ERROR: Failed to get job status after " + maxTries + " attempts.");
                break;
            }
        }
    } catch (InterruptedException ie) {
        System.out.println(ie.getMessage());
        ie.printStackTrace();
    }
    return json;
}

From source file:uk.co.flax.ukmp.twitter.TweetUpdateThread.java

@Override
public void run() {
    LOGGER.info("Starting twitter update thread.");
    while (partyListIds == null) {
        try {//from   w  ww .  j a  va  2s  .co m
            LOGGER.debug("No party list IDs - waiting...");
            Thread.sleep(QUEUE_CHECK_TIME);
        } catch (InterruptedException e) {
            LOGGER.error("Interrupted waiting for party list IDs: {}", e.getMessage());
        }
    }
    running = true;

    while (running) {
        List<Status> updates = new ArrayList<>(batchSize);
        while (!statusQueue.isEmpty() && updates.size() < batchSize) {
            updates.add(statusQueue.remove());
        }

        // Index the statuses
        storeUpdates(updates);

        // Sleep...
        try {
            Thread.sleep(QUEUE_CHECK_TIME);
        } catch (InterruptedException e) {
            LOGGER.error("Update thread sleep interrupted: {}", e.getMessage());
        }
    }
}

From source file:copter.ServerConnection.java

private boolean checkServerConnection() {
    Integer cycleNumber = 1;/*from  ww  w  .  j  a  v a  2  s  .  c o m*/
    while (true) {
        //!
        if (InternetConnector.getInstance().checkConnectionToServer()) {
            return true;
        }
        try {
            Thread.sleep(3000);

            logger.log("Checking connection to the server..." + cycleNumber.toString());

        } catch (InterruptedException ex) {
            logger.log(ex.getMessage());
            return false;
        }
        cycleNumber++;
        if (cycleNumber >= Config.getInstance().getInt("main", "initial_internet_checking_cycle_count")) {

            logger.log("Error: could not connect to the internet. Trying to reconnect...");
            return false;

        }
    }
}

From source file:com.google.api.ads.adwords.jaxws.extensions.processors.onfile.ReportProcessorOnFile.java

/**
 * Downloads all the files from the API and process all the rows, saving the data to the
 * configured data base.// w  ww.  j  a va 2  s .c o m
 *
 * @param builder the session builder.
 * @param reportType the report type.
 * @param dateRangeType the date range type.
 * @param dateStart the start date.
 * @param dateEnd the ending date.
 * @param acountIdList the account IDs.
 * @param properties the properties resource.
 */
private <R extends Report> void downloadAndProcess(String userId, String mccAccountId,
        AdWordsSession.Builder builder, ReportDefinitionReportType reportType,
        ReportDefinitionDateRangeType dateRangeType, String dateStart, String dateEnd, Set<Long> acountIdList,
        Properties properties) {

    // Download Reports to local files and Generate Report objects
    LOGGER.info("\n\n ** Generating: " + reportType.name() + " **");
    LOGGER.info(" Downloading reports...");
    Collection<File> localFiles = Lists.newArrayList();
    try {

        ReportDefinition reportDefinition = getReportDefinition(reportType, dateRangeType, dateStart, dateEnd,
                properties);

        localFiles = this.multipleClientReportDownloader.downloadReports(builder, reportDefinition,
                acountIdList);

    } catch (InterruptedException e) {
        LOGGER.error(e.getMessage());
        e.printStackTrace();
        return;
    }

    this.processLocalFiles(userId, mccAccountId, reportType, localFiles, dateStart, dateEnd, dateRangeType);

    this.deleteTemporaryFiles(localFiles, reportType);
}

From source file:com.aliyun.oss.common.comm.TimeoutServiceClient.java

@Override
public ResponseMessage sendRequestCore(ServiceClient.Request request, ExecutionContext context)
        throws IOException {
    HttpRequestBase httpRequest = httpRequestFactory.createHttpRequest(request, context);
    HttpClientContext httpContext = HttpClientContext.create();
    httpContext.setRequestConfig(this.requestConfig);

    CloseableHttpResponse httpResponse = null;
    HttpRequestTask httpRequestTask = new HttpRequestTask(httpRequest, httpContext);
    Future<CloseableHttpResponse> future = executor.submit(httpRequestTask);

    try {//from   w ww. jav  a  2 s  .  c o  m
        httpResponse = future.get(this.config.getRequestTimeout(), TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logException("[ExecutorService]The current thread was interrupted while waiting: ", e);

        httpRequest.abort();
        throw new ClientException(e.getMessage(), e);
    } catch (ExecutionException e) {
        RuntimeException ex;
        httpRequest.abort();

        if (e.getCause() instanceof IOException) {
            ex = ExceptionFactory.createNetworkException((IOException) e.getCause());
        } else {
            ex = new OSSException(e.getMessage(), e);
        }

        logException("[ExecutorService]The computation threw an exception: ", ex);
        throw ex;
    } catch (TimeoutException e) {
        logException("[ExecutorService]The wait " + this.config.getRequestTimeout() + " timed out: ", e);

        httpRequest.abort();
        throw new ClientException(e.getMessage(), OSSErrorCode.REQUEST_TIMEOUT, "Unknown", e);
    }

    return buildResponse(request, httpResponse);
}