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.cloudera.branchreduce.impl.thrift.ClientTest.java

@Before
public void setup() throws InterruptedException, IOException {
    conf.setInt("yarn.scheduler.fifo.minimum-allocation-mb", 128);
    conf.set("yarn.nodemanager.vmem-pmem-ratio", "20.0");
    if (yarnCluster == null) {
        yarnCluster = new MiniYARNCluster(ClientTest.class.getName(), 1, 1, 1);
        yarnCluster.init(conf);//from w w  w . ja v a2 s . com
        yarnCluster.start();
        conf = yarnCluster.getConfig();
    }
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        LOG.info("setup thread sleep interrupted. message=" + e.getMessage());
    }
}

From source file:cn.wanghaomiao.seimi.core.SeimiContext.java

protected void waitToEnd() {
    workersPool.shutdown();//from ww  w  .j  av  a  2s.co  m
    try {
        workersPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:org.psikeds.common.services.AbstractRESTService.java

protected Response buildResponse(final InterruptedException iex) {
    return buildResponse(Status.REQUEST_TIMEOUT, iex.getMessage());
}

From source file:com.github.horrorho.inflatabledonkey.DownloadAssistant.java

public void execute(HttpClient httpClient, FileAssembler fileAssembler, List<Set<Asset>> batchedAssets) {
    logger.debug("-- execute() - threads: {} batch count: {}", forkJoinPool.getParallelism(),
            batchedAssets.size());/*  ww w .  ja  v  a  2s .co m*/
    try {
        forkJoinPool.submit(() -> batchedAssets.parallelStream()
                .forEach(u -> donkey.apply(httpClient, forkJoinPoolAux, u, fileAssembler))).get();

    } catch (InterruptedException ex) {
        logger.warn("-- execute() - InterruptedException: {}", ex.getMessage());
        Thread.currentThread().interrupt();

    } catch (ExecutionException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:be.apsu.extremon.probes.ocsp.OCSPProbe.java

public void probe_forever() {
    log("running");
    for (;;) {//from  w  w  w  .jav a 2 s  .  c o m
        double start = System.currentTimeMillis();

        try {
            this.certificatePathValidator.validate(this.certificatePath, this.pkixParams);
            put(RESULT_SUFFIX, STATE.OK);
            put(RESULT_COMMENT_SUFFIX, "responder validates ok");
        } catch (CertPathValidatorException ex) {
            put(RESULT_SUFFIX, STATE.ALERT);
            put(RESULT_COMMENT_SUFFIX, "ocsp responder does not validate cert:" + ex.getMessage());
        } catch (InvalidAlgorithmParameterException ex) {
            put(RESULT_SUFFIX, STATE.ALERT);
            put(RESULT_COMMENT_SUFFIX, "ocsp responder finds invalid algorithm parameter:" + ex.getMessage());
        }

        double end = System.currentTimeMillis();

        put("responsetime", (end - start));

        try {
            Thread.sleep(this.delay);
        } catch (InterruptedException iex) {
            log("Interrupted During Sleep:" + iex.getMessage());
            return;
        }
    }
}

From source file:gsn.wrappers.general.HttpGetWrapper.java

public void run() {
    ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(1024 * 20);
    byte[] buffer = new byte[16 * 1024];
    BufferedInputStream content;//from  www .  j  a  va  2s . com
    while (isActive()) {
        try {
            Thread.sleep(rate);
            httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.connect();
            if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_ACCEPTED)
                continue;
            content = new BufferedInputStream(httpURLConnection.getInputStream(), 4096);
            arrayOutputStream.reset();
            int readIndex = -1;
            while ((readIndex = content.read(buffer)) != -1)
                arrayOutputStream.write(buffer, 0, readIndex);
            postStreamElement(arrayOutputStream.toByteArray());
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

From source file:it.infn.ct.futuregateway.apiserver.inframanager.state.Running.java

@Override
public final void action(final ExecutorService anExecutorService, final BlockingQueue<Task> aBlockingQueue,
        final Storage aStorage) {

    try {//w  ww.  ja  v a  2  s.co m
        final Job job = CustomJobFactory.createJob(this.task, aStorage);
        final State state = job.getState();

        this.task.updateCheckTime();
        switch (state) {
        case DONE:
            this.task.setState(Task.STATE.DONE);
            break;
        case RUNNING:
            try {
                aBlockingQueue.put(this.task);
            } catch (InterruptedException ex) {
                this.log.error(ex.getMessage());
                this.task.setState(Task.STATE.ABORTED);
            }
            break;
        case CANCELED:
            this.task.setState(Task.STATE.CANCELLED);
            break;
        case FAILED:
        case NEW:
        case SUSPENDED:
            this.task.setState(Task.STATE.ABORTED);
            break;
        default:
            this.log.error("Task: " + this.task.getId() + " is in a invalid state: " + state);
            this.task.setState(Task.STATE.ABORTED);
            break;
        }
    } catch (InfrastructureException | BadParameterException | DoesNotExistException | NotImplementedException
            | TimeoutException | NoSuccessException ex) {
        final String msg = ex.getMessage();
        this.log.error("Error checking job status: " + msg);
    }

}

From source file:ke.co.pixie.daemon.JavaDaemon.java

/**
 * Runs the thread. The application runs inside an "infinite" loop.
 *//*from w ww . j a  va2 s .c  o m*/
@Override
@SuppressWarnings({ "SleepWhileHoldingLock", "SleepWhileInLoop" })
public void run() {
    int i = 0;
    while (working) {
        try {
            DaemonLogger.log(Level.SEVERE, "Test: " + i);
            i++;
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            DaemonLogger.log(Level.SEVERE, ex.getMessage());
        }
    }
}

From source file:com.ikon.servlet.TextToSpeechServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    String cmd = "espeak -v mb-es1 -f input.txt | mbrola -e /usr/share/mbrola/voices/es1 - -.wav "
            + "| oggenc -Q - -o output.ogg";
    String text = WebUtils.getString(request, "text");
    String docPath = WebUtils.getString(request, "docPath");
    response.setContentType("audio/ogg");
    FileInputStream fis = null;//  w w w  . jav  a 2  s .co  m
    OutputStream os = null;

    try {
        if (!text.equals("")) {
            FileUtils.writeStringToFile(new File("input.txt"), text);
        } else if (!docPath.equals("")) {
            InputStream is = OKMDocument.getInstance().getContent(null, docPath, false);
            Document doc = OKMDocument.getInstance().getProperties(null, docPath);
            DocConverter.getInstance().doc2txt(is, doc.getMimeType(), new File("input.txt"));
        }

        // Convert to voice
        ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", cmd);
        Process process = pb.start();
        process.waitFor();
        String info = IOUtils.toString(process.getInputStream());
        process.destroy();

        if (process.exitValue() == 1) {
            log.warn(info);
        }

        // Send to client
        os = response.getOutputStream();
        fis = new FileInputStream("output.ogg");
        IOUtils.copy(fis, os);
        os.flush();
    } catch (InterruptedException e) {
        log.warn(e.getMessage(), e);
    } catch (IOException e) {
        log.warn(e.getMessage(), e);
    } catch (PathNotFoundException e) {
        log.warn(e.getMessage(), e);
    } catch (AccessDeniedException e) {
        log.warn(e.getMessage(), e);
    } catch (RepositoryException e) {
        log.warn(e.getMessage(), e);
    } catch (DatabaseException e) {
        log.warn(e.getMessage(), e);
    } catch (ConversionException e) {
        log.warn(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(fis);
        IOUtils.closeQuietly(os);
    }
}

From source file:com.ironiacorp.http.impl.httpclient3.HttpJobRunnerHttpClient3.java

public void run() {
    ExecutorService executor = Executors.newFixedThreadPool(maxThreadsCount);
    ExecutorCompletionService<HttpJob> queue = new ExecutorCompletionService<HttpJob>(executor);
    List<Future<?>> workers = new ArrayList<Future<?>>();

    for (HttpJob job : jobs) {
        if (HttpMethod.GET == job.getMethod()) {
            GetRequest request = new GetRequest(httpClient, job);
            Future<HttpJob> jobStatus = queue.submit(request);
            workers.add(jobStatus);/*from  ww w  .ja  v a 2s.  co m*/
            continue;
        }
        if (HttpMethod.POST == job.getMethod()) {
            PostRequest request = new PostRequest(httpClient, job);
            Future<HttpJob> jobStatus = queue.submit(request);
            workers.add(jobStatus);
            continue;
        }
        // TODO: job cannot be handled, what to do?
    }

    while (!workers.isEmpty()) {
        Iterator<Future<?>> i = workers.iterator();
        while (i.hasNext()) {
            try {
                Future<?> future = i.next();
                // future.get(timeout, TimeUnit.MILLISECONDS);
                future.get();
                i.remove();
                // } catch (TimeoutException e) {
            } catch (InterruptedException ie) {
                System.out.println(ie.getMessage());
            } catch (ExecutionException ee) {
                System.out.println(ee.getMessage());
                i.remove();
            }
        }
    }

    executor.shutdown();
}