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:org.apache.kylin.engine.mr.common.HadoopStatusGetter.java

private String getHttpResponse(String url) throws IOException {
    HttpClient client = new HttpClient();

    String response = null;//w  w w  .  j a v a 2s.co  m
    while (response == null) { // follow redirects via 'refresh'
        if (url.startsWith("https://")) {
            registerEasyHttps();
        }
        if (url.contains("anonymous=true") == false) {
            url += url.contains("?") ? "&" : "?";
            url += "anonymous=true";
        }

        HttpMethod get = new GetMethod(url);
        get.addRequestHeader("accept", "application/json");

        try {
            client.executeMethod(get);

            String redirect = null;
            Header h = get.getResponseHeader("Location");
            if (h != null) {
                redirect = h.getValue();
                if (isValidURL(redirect) == false) {
                    logger.info("Get invalid redirect url, skip it: " + redirect);
                    Thread.sleep(1000L);
                    continue;
                }
            } else {
                h = get.getResponseHeader("Refresh");
                if (h != null) {
                    String s = h.getValue();
                    int cut = s.indexOf("url=");
                    if (cut >= 0) {
                        redirect = s.substring(cut + 4);

                        if (isValidURL(redirect) == false) {
                            logger.info("Get invalid redirect url, skip it: " + redirect);
                            Thread.sleep(1000L);
                            continue;
                        }
                    }
                }
            }

            if (redirect == null) {
                response = get.getResponseBodyAsString();
                logger.debug("Job " + mrJobId + " get status check result.\n");
            } else {
                url = redirect;
                logger.debug("Job " + mrJobId + " check redirect url " + url + ".\n");
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            logger.error(e.getMessage());
        } finally {
            get.releaseConnection();
        }
    }

    return response;
}

From source file:com.couchbase.sqoop.mapreduce.db.CouchbaseRecordReader.java

private void createTapStreamTimeout(final TapStream tapStream, final long duration) {
    if (duration > 0) {
        final Runnable r = new Runnable() {
            @Override//from  w w  w  . j  ava 2s  .  c  om
            public void run() {
                try {
                    Thread.sleep(TimeUnit.MILLISECONDS.convert(duration, TimeUnit.MINUTES));
                } catch (final InterruptedException e) {
                    Thread.currentThread().interrupt();
                    CouchbaseRecordReader.LOG.error("Tap stream closing early. Reason: " + e.getMessage());
                }
                tapStream.cancel();
            }
        };
        new Thread(r).start();
    }
}

From source file:co.turnus.analysis.buffers.util.AbstractTraceCutScheduler.java

private BuffersData nearestNeighborSchedule() {
    // start the progress monitor
    ProgressTheadPrinter pPrinter = new ProgressTheadPrinter(
            "Trace Graph post-processing, heuristic " + heuristic + ", iteration " + iteration, traceLength);
    pPrinter.start();/* w  w  w. j  a v a2 s .  com*/

    // get the initial steps and fire them
    Set<Step> ancestors = Sets.newHashSet(trace.getInitialSteps());
    Set<Step> fireables = Sets.newHashSet(ancestors);

    do {

        for (Step s : fireables) {

            fire(s);
            pPrinter.increment();
        }

        if (firings == traceLength) {
            break;
        }

        ancestors.addAll(fireables);
        removeFiredUnconnectedSteps(ancestors);

        Set<Step> ngh = NearestNeighbor.find(ancestors, maxSteps, maxDegree, STEP_FIRED);

        traceCutStat.addValue(ngh.size());

        fireables = getNextSteps(ngh);

    } while (!fireables.isEmpty());

    TurnusLogger.debug("fired steps: " + firings + " of " + traceLength);

    // stop the progress monitor
    try {
        pPrinter.finish();
        pPrinter.join();
    } catch (InterruptedException e) {
        TurnusLogger.warning("Progress monitor stopping error: " + e.getMessage());
    }

    if (firings > traceLength) {
        throw new TurnusRuntimeException("The number of firings is bigger then the trace size!");
    }

    boolean deadlockFree = firings == traceLength;
    if (!deadlockFree) {
        TurnusLogger.warning("Infeasible configuration:" + "deadlock free not guaranteed!!");
    }

    return collectResults(deadlockFree);
}

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

/**
 * Downloads all the files from the API and process all the rows, saving the data to the
 * configured data base./*from  w  ww. j av  a  2s  .c o  m*/
 *
 * @param sessionBuilder 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 mccAccountId,
        AdWordsSessionBuilderSynchronizer sessionBuilder, ReportDefinitionReportType reportType,
        ReportDefinitionDateRangeType dateRangeType, String dateStart, String dateEnd, Set<Long> acountIdList,
        String reportDefinitionKey, 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,
                reportDefinitionKey, properties);

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

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

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

    this.deleteTemporaryFiles(localFiles, reportType);
}

From source file:org.openbaton.vnfm.core.MediaServerResourceManagement.java

@Async
public Future<Boolean> release(VNFCInstance vnfcInstance, VimInstance vimInstance) throws VimException {
    log.debug("Removing VM with ExtId: " + vnfcInstance.getVc_id() + " from VimInstance "
            + vimInstance.getName());/* w  w w .  j a v a  2  s .  c  om*/
    try {
        client.deleteServerByIdAndWait(vimInstance, vnfcInstance.getVc_id());
        log.info("Removed VM with ExtId: " + vnfcInstance.getVc_id() + " from VimInstance "
                + vimInstance.getName());
    } catch (VimDriverException e) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {
            log.error(e1.getMessage(), e);
        }
        try {
            client.deleteServerByIdAndWait(vimInstance, vnfcInstance.getVc_id());
        } catch (VimDriverException e1) {
            log.error(e1.getMessage(), e);
            throw new VimException(
                    "Not removed VM with ExtId " + vnfcInstance.getVc_id() + " successfully from VimInstance "
                            + vimInstance.getName() + ". Caused by: " + e.getMessage(),
                    e);
        }
    }
    return new AsyncResult<Boolean>(true);
}

From source file:org.openinfinity.core.async.ParallelServiceActivator.java

/**
 * Activates all prepared queries simultaniously.
 *
 * @return Instanse of the service activator.
 * @throws SystemException//from w w w  . j  a v  a 2 s  .  c om
 */
public ParallelServiceActivator activate() throws SystemException {
    try {
        executorServiceAdapter.invokeAll(callables);
    } catch (InterruptedException interruptedException) {
        ExceptionUtil.throwSystemException(interruptedException.getMessage(), interruptedException,
                ExceptionLevel.ERROR, "unique.exception.system.threading.error");
    }
    return this;
}

From source file:com.bt.sdk.callcontrol.sip.util.EhCacheCollectionImpl.java

@SuppressWarnings("unchecked")
public void replace(T info) {
    if (info == null)
        throw new IllegalArgumentException(String.format(
                "Trying to replace element in collection %s with null info", this.getClass().getSimpleName()));

    String infoId = info.getId();
    log.debug(String.format("InMemoryInfoCollection replacing %s", infoId));
    if (!semaphoreCache.getKeys().contains(infoId))
        throw new IllegalArgumentException(
                String.format("Trying to replace non-existing info %s in collection %s", infoId,
                        this.getClass().getSimpleName()));
    Semaphore semaphore = (Semaphore) semaphoreCache.get(infoId).getObjectValue();
    if (semaphore == null)
        throw new IllegalArgumentException(
                String.format("Trying to replace non-existing info %s in collection %s", infoId,
                        this.getClass().getSimpleName()));

    try {//from w w w.  ja  v a  2  s .co m
        semaphore.acquire();
    } catch (InterruptedException e) {
        log.error(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(),
                e.getMessage()), e);
        throw new CollectionAccessInterruptedException(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId,
                this.getClass().getSimpleName(), e.getMessage()), e);
    }

    try {
        //T oldInfo = infos.get(infoId);
        T oldInfo = (T) cache.get(infoId).getObjectValue();
        if (!oldInfo.getVersionId().equals(info.getVersionId()))
            throw new ConcurrentUpdateException(infoId, String.format(
                    "Info %s modified in collection %s, try again", infoId, this.getClass().getSimpleName()));

        T newInfo = info.cloneObject();
        newInfo.updateVersionId();
        doExtraUpdates(info, newInfo);
        //infos.put(infoId, (T)newInfo);
        cache.put(new Element(infoId, newInfo));
        info.setVersionId(newInfo.getVersionId());
        log.debug(String.format("Replaced info %s, new version %s", infoId, newInfo.getVersionId()));
    } finally {
        semaphore.release();
    }
}

From source file:org.openinfinity.core.async.ParallelServiceActivator.java

/**
 * Activates all prepared queries simultaniously.
 * // w  w w  . j av a 2 s  . c  o  m
 * @param crudService Represents the actual service implement <code>org.openinfinity.core.integration.CrudService</code>.
 * @param timeout Represents the timeout if activation is not processed in given time frame. 
 * @param unit Represents the time unit of the given time frame. 
 * @return
 * @throws SystemException
 */
@Log
public ParallelServiceActivator activate(long timeout, TimeUnit unit) throws SystemException {
    try {
        executorServiceAdapter.invokeAll(callables, timeout, unit);
    } catch (InterruptedException interruptedException) {
        ExceptionUtil.throwSystemException(interruptedException.getMessage(), interruptedException,
                ExceptionLevel.ERROR, "unique.exception.system.threading.error");
    }
    return this;
}

From source file:ch.sourcepond.io.checksum.impl.DefaultChecksum.java

/**
 * @throws IOException/*from   ww  w  . ja  va 2 s.c  o m*/
 * @throws InterruptedException
 */
private void awaitCalculation() throws ChecksumException {
    try {
        while (updating) {
            strategy.wait();
        }
    } catch (final InterruptedException e) {
        currentThread().interrupt();
        throw new ChecksumException(e.getMessage(), e);
    }

    if (throwable != null) {
        if (throwable instanceof Error) {
            throw (Error) throwable;
        }
        throw (ChecksumException) throwable;
    }
}

From source file:edu.indiana.d2i.sloan.utils.SSHProxy.java

/**
 * execute a list of commands in blocking way
 * //from w w  w  .j a  v  a  2  s .  c o m
 * @param cmds
 * @param requireSudo
 * @return
 * @throws JSchException
 * @throws IOException
 * @throws Exception
 */
public CmdsExecResult execCmdSync(Commands cmds) throws JSchException, IOException {
    String command = cmds.getConcatenatedForm();
    int exitCode = Integer.MIN_VALUE;

    if (cmds.isSudoCmds)
        command = SUDO_PREFIX + command;
    logger.info("ssh execute: " + command);

    StringBuilder screenOutput = new StringBuilder();

    Channel channel = session.openChannel("exec");

    ((ChannelExec) channel).setCommand(command);
    ((ChannelExec) channel).setErrStream(System.err);

    channel.connect();

    InputStream is = channel.getInputStream();

    byte[] buf = new byte[BUFFER_SIZE];

    while (true) {

        while (is.available() > 0) {
            int bytesRead = is.read(buf, 0, 1024);

            if (bytesRead < 0)
                break;

            screenOutput.append(new String(buf, 0, bytesRead));
        }

        if (channel.isClosed()) {
            exitCode = channel.getExitStatus();
            break;
        }

        /**
         * sleep a while waiting for more outputs
         */
        try {
            Thread.sleep(THREAD_SLEEP_DURATION);
        } catch (InterruptedException e) {
            logger.error(e.getMessage());
        }
    }

    // disconnect
    channel.disconnect();

    return new CmdsExecResult(cmds, hostname, exitCode, screenOutput.toString());
}