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:VerboseGC.java

public void dump(long interval, long samples) {
    try {/*from w  w  w.  ja v  a  2  s  .c om*/
        PrintGCStat pstat = new PrintGCStat(server);
        for (int i = 0; i < samples; i++) {
            pstat.printVerboseGc();
            try {
                Thread.sleep(interval);
            } catch (InterruptedException e) {
                System.exit(1);
            }
        }
    } catch (IOException e) {
        System.err.println("\nCommunication error: " + e.getMessage());
        System.exit(1);
    }
}

From source file:org.jdal.util.concurrent.DispatcherQueue.java

/**
 * Dispatch incomming objects to a Executor
 */// w w  w  .ja v a 2s . c  o  m
private void dispatch() {
    while (running) {
        T t = null;
        try {
            t = queue.take();

            if (log.isDebugEnabled())
                log.debug("Dispatching object: " + t.toString());

            dispatcher.dispatch(t);

        } catch (InterruptedException e) {
            log.error(e);
            break;
        } catch (Exception e) {
            log.error("Dispather failed. Readding object to queue again.");
            log.error(e.getMessage());
            queue.offer(t);
        }
    }
}

From source file:mvm.rya.accumulo.pig.AccumuloStorage.java

@Override
public Tuple getNext() throws IOException {
    try {/* ww  w  .j  a v a2 s . c om*/
        // load the next pair
        if (!reader.nextKeyValue()) {
            logger.info("Reached end of results");
            return null;
        }

        Key key = (Key) reader.getCurrentKey();
        Value value = (Value) reader.getCurrentValue();
        assert key != null && value != null;

        if (logger.isTraceEnabled()) {
            logger.trace("Found key[" + key + "] and value[" + value + "]");
        }

        // and wrap it in a tuple
        Tuple tuple = TupleFactory.getInstance().newTuple(6);
        tuple.set(0, new DataByteArray(key.getRow().getBytes()));
        tuple.set(1, new DataByteArray(key.getColumnFamily().getBytes()));
        tuple.set(2, new DataByteArray(key.getColumnQualifier().getBytes()));
        tuple.set(3, new DataByteArray(key.getColumnVisibility().getBytes()));
        tuple.set(4, key.getTimestamp());
        tuple.set(5, new DataByteArray(value.get()));
        if (logger.isTraceEnabled()) {
            logger.trace("Output tuple[" + tuple + "]");
        }
        return tuple;
    } catch (InterruptedException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:me.mast3rplan.phantombot.cache.ChannelUsersCache.java

@Override
@SuppressWarnings("SleepWhileInLoop")
public void run() {
    try {//from w w  w  . j  av a2 s.co  m
        Thread.sleep(30 * 1000);
    } catch (InterruptedException e) {
        com.gmt2001.Console.out.println(
                "ChannelUsersCache.run>>Failed to initial sleep: [InterruptedException] " + e.getMessage());
        com.gmt2001.Console.err.logStackTrace(e);
    }

    while (!killed) {
        try {
            try {
                if (new Date().after(timeoutExpire)) {
                    this.updateCache();
                }
            } catch (Exception e) {
                if (e.getMessage().startsWith("[SocketTimeoutException]")
                        || e.getMessage().startsWith("[IOException]")) {
                    Calendar c = Calendar.getInstance();

                    if (lastFail.after(new Date())) {
                        numfail++;
                    } else {
                        numfail = 1;
                    }

                    c.add(Calendar.MINUTE, 1);

                    lastFail = c.getTime();

                    if (numfail >= 5) {
                        timeoutExpire = c.getTime();
                    }
                }

                com.gmt2001.Console.out
                        .println("ChannelUsersCache.run>>Failed to update users: " + e.getMessage());
                com.gmt2001.Console.err.logStackTrace(e);
            }
        } catch (Exception e) {
            com.gmt2001.Console.err.printStackTrace(e);
        }

        try {
            Thread.sleep(30 * 1000);
        } catch (InterruptedException e) {
            com.gmt2001.Console.out.println(
                    "ChannelUsersCache.run>>Failed to sleep: [InterruptedException] " + e.getMessage());
            com.gmt2001.Console.err.logStackTrace(e);
        }
    }
}

From source file:eagle.jobrunning.crawler.RunningJobCrawlerImpl.java

private void startJobConfigProcessThread() {
    int configThreadCount = DEFAULT_CONFIG_THREAD_COUNT;
    LOG.info("Job Config crawler main thread started, pool size: " + DEFAULT_CONFIG_THREAD_COUNT);

    ThreadFactory factory = new ThreadFactory() {
        private final AtomicInteger count = new AtomicInteger(0);

        public Thread newThread(Runnable runnable) {
            count.incrementAndGet();/*from  www .j  ava2  s. co  m*/
            Thread thread = Executors.defaultThreadFactory().newThread(runnable);
            thread.setName("config-crawler-workthread-" + count.get());
            return thread;
        }
    };

    ThreadPoolExecutor pool = new ThreadPoolExecutor(configThreadCount, configThreadCount, 0L,
            TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);

    while (true) {
        JobContext context;
        try {
            context = queueOfConfig.take();
            LOG.info("queueOfConfig size: " + queueOfConfig.size());
            Runnable configCrawlerThread = new ConfigWorkTask(new JobContext(context), fetcher, callback, this);
            pool.execute(configCrawlerThread);
        } catch (InterruptedException e) {
            LOG.warn("Got an InterruptedException: " + e.getMessage());
        } catch (RejectedExecutionException e2) {
            LOG.warn("Got RejectedExecutionException: " + e2.getMessage());
        } catch (Throwable t) {
            LOG.warn("Got an throwable t, " + t.getMessage());
        }
    }
}

From source file:com.bt.aloha.media.testing.mockphones.ConvediaMockphoneBean.java

private void processDtmfGenerationRequest(final String dialogId, final String commandId,
        MsmlDtmfGenerationRequest req) {
    log.info("Pretending to generate DTMF digits");
    try {//w w  w  .  ja  va  2 s .c  om
        Thread.sleep(FIVE_HUNDRED);
    } catch (InterruptedException e) {
        log.error(e.getMessage(), e);
    }

    String dtmfGenValue = req.getDigits().contains(DTMFGEN_FAILURE_DIGIT_SEQUENCE)
            || req.getDigits().contains(DTMFGEN_TERMINATION_DIGIT_SEQUENCE) ? DTMFGEN_FAILED
                    : "dtmfgen.complete";
    final String content = new MsmlDtmfGenerationResponse(commandId, dtmfGenValue).getXml();
    sendMediaResponse(dialogId, commandId, content);
}

From source file:com.samknows.measurement.ManualTest.java

@Override
public void run() {
    isExecuting = true;//from w  w w.  jav a2  s. co m
    // Start collectors for the passive metrics
    // Start tests
    long startTime = System.currentTimeMillis();
    JSONObject batch = new JSONObject();
    TestContext tc = TestContext.create(ctx);
    TestExecutor te = new TestExecutor(tc);
    List<JSONObject> testsResults = new ArrayList<JSONObject>();
    List<JSONObject> passiveMetrics = new ArrayList<JSONObject>();
    te.startInBackGround();
    Message msg;
    long testsBytes = 0;
    for (TestDescription td : mTestDescription) {
        // check if a stop command has been received
        if (!run.get()) {
            Logger.d(this, "Manual test interrupted by the user.");
            break;
        }
        com.samknows.measurement.test.TestResult tr = new com.samknows.measurement.test.TestResult();
        ObservableExecutor oe = new ObservableExecutor(te, td, tr);
        Thread t = new Thread(oe);
        t.start();
        while (true) {
            try {
                t.join(100);
                if (!t.isAlive())
                    break;
            } catch (InterruptedException ie) {
                Logger.e(this, ie.getMessage());
            }
            for (JSONObject pm : progressMessage(td, te)) {
                msg = new Message();
                msg.obj = pm;
                mHandler.sendMessage(msg);
            }

        }
        testsBytes += te.getLastTestByte();

        List<JSONObject> currResults = new ArrayList<JSONObject>();
        for (String out : tr.results) {
            currResults.addAll(TestResult.testOutput(out));
        }
        for (JSONObject cr : currResults) {
            // publish results
            msg = new Message();
            msg.obj = cr;
            mHandler.sendMessage(msg);
        }
        testsResults.addAll(currResults);
    }
    Logger.d(this, "bytes used by the tests: " + testsBytes);
    AppSettings.getInstance().appendUsedBytes(testsBytes);
    // stops collectors
    te.stop();

    te.save(JSON_MANUAL_TEST);

    // Gather data from collectors
    for (BaseDataCollector collector : tc.config.dataCollectors) {
        if (collector.isEnabled) {
            for (JSONObject o : collector.getPassiveMetric()) {
                // update interface
                msg = new Message();
                msg.obj = PassiveMetric.passiveMetricToCurrentTest(o);
                mHandler.sendMessage(msg);
                // save metric
                passiveMetrics.add(o);
            }
        }
    }
    // insert batch in the database
    try {
        batch.put(TestBatch.JSON_DTIME, startTime);
        batch.put(TestBatch.JSON_RUNMANUALLY, "1");
    } catch (JSONException je) {
        Logger.e(this, "Error in creating test batch object: " + je.getMessage());
    }

    // insert the results in the database only if we didn't receive a stop
    // command
    if (run.get()) {
        DBHelper db = new DBHelper(ctx);

        db.insertTestBatch(batch, testsResults, passiveMetrics);

    }
    // Send completed message to the interface
    msg = new Message();
    JSONObject jtc = new JSONObject();
    try {
        Thread.sleep(1000);
        jtc.put(TestResult.JSON_TYPE_ID, "completed");
        msg.obj = jtc;

    } catch (JSONException je) {
        Logger.e(this, "Error in creating json object: " + je.getMessage());
    } catch (InterruptedException e) {
        Logger.e(this, "Sleep interrupted in the manual test view: " + e.getMessage());
    }
    mHandler.sendMessage(msg);

    try {
        // Submitting test results
        if (AppSettings.getInstance().anonymous) {
            new SubmitTestResultsAnonymousAction(ctx).execute();
        } else {
            new SubmitTestResultsAction(ctx).execute();
        }
    } catch (Throwable t) {
        Logger.e(this, "Submit result. ", t);
    }

    Logger.d(this, "Exiting manual test");

    isExecuting = false;
}

From source file:net.refractions.udig.style.sld.editor.raster.PredefinedColorRules.java

private ColorMap parseRulesValuesList(final String[][] colorRules) throws IOException {

    ColorMap cm = new ColorMapImpl();
    ExpressionBuilder builder = new ExpressionBuilder();
    if (colorRules[0].length == 3) {
        if (dataMin == null && dataMax == null) {
            minMaxJob.schedule();/*from   w w w  .j a v a 2  s.  c o  m*/
            try {
                minMaxJob.join();
            } catch (InterruptedException e) {
                SLDPlugin.log(e.getMessage(), e);
                return null;
            }
        }
        /*
         * the colorrules are without values, so we ramp through them over
         * the range.
         */
        if (dataMin == null) {
            dataMin = -100.0;
        }
        if (dataMax == null) {
            dataMax = 5000.0;
        }

        // calculate the color increment
        float rinc = (float) (dataMax - dataMin) / (float) (colorRules.length - 1);

        for (int i = 0; i < colorRules.length - 1; i++) {
            try {
                double to = dataMin + ((i + 1) * rinc);
                Color toColor = new Color(Integer.parseInt(colorRules[i + 1][0]),
                        Integer.parseInt(colorRules[i + 1][1]), Integer.parseInt(colorRules[i + 1][2]));
                if (i == 0) {
                    double from = dataMin + (i * rinc);
                    Color fromColor = new Color(Integer.parseInt(colorRules[i][0]),
                            Integer.parseInt(colorRules[i][1]), Integer.parseInt(colorRules[i][2]));

                    ColorMapEntryImpl cme = new ColorMapEntryImpl();
                    cme.setColor((Expression) builder.literal(fromColor).build());
                    cme.setQuantity((Expression) builder.literal(from).build());
                    cm.addColorMapEntry(cme);
                }
                ColorMapEntryImpl cme = new ColorMapEntryImpl();
                cme.setColor((Expression) builder.literal(toColor).build());
                cme.setQuantity((Expression) builder.literal(to).build());
                cm.addColorMapEntry(cme);

            } catch (NumberFormatException e) {
                SLDPlugin.log(e.getMessage(), e);
                continue;
            }
        }

    } else {
        /*
         * in this case we have also the values for the range defined and
         * the color rule has to be "v1 r1 g1 b1 v2 r2 g2 b2".
         */
        if (colorRules[0].length != 8) {
            throw new IOException("The colortable can have records of 3 or 8 columns. Check your colortables."); //$NON-NLS-1$
        }

        for (int i = 0; i < colorRules.length; i++) {
            try {
                double to = Double.parseDouble(colorRules[i][4]);
                Color toColor = new Color(Integer.parseInt(colorRules[i][5]),
                        Integer.parseInt(colorRules[i][6]), Integer.parseInt(colorRules[i][7]));
                if (i == 0) {
                    double from = Double.parseDouble(colorRules[i][0]);
                    Color fromColor = new Color(Integer.parseInt(colorRules[i][1]),
                            Integer.parseInt(colorRules[i][2]), Integer.parseInt(colorRules[i][3]));

                    ColorMapEntryImpl cme = new ColorMapEntryImpl();
                    cme.setColor((Expression) builder.literal(fromColor).build());
                    cme.setQuantity((Expression) builder.literal(from).build());
                    cm.addColorMapEntry(cme);
                }
                ColorMapEntryImpl cme = new ColorMapEntryImpl();
                cme.setColor((Expression) builder.literal(toColor).build());
                cme.setQuantity((Expression) builder.literal(to).build());
                cm.addColorMapEntry(cme);
            } catch (NumberFormatException e) {
                SLDPlugin.log(e.getMessage(), e);
                continue;
            }
        }

    }
    return cm;

}

From source file:com.epam.dlab.backendapi.core.commands.CommandExecutorMockAsync.java

private void sleep(int ms) {
    try {//  w w  w.j a  v a2  s .  c om
        Thread.sleep(ms);
    } catch (InterruptedException e) {
        log.error("InterruptedException occurred: {}", e.getMessage());
        Thread.currentThread().interrupt();
    }
}

From source file:me.mast3rplan.phantombot.cache.ChannelHostCache.java

@Override
@SuppressWarnings("SleepWhileInLoop")
public void run() {

    try {//from  ww  w  .java2  s. c  o  m
        Thread.sleep(30 * 1000);
    } catch (InterruptedException e) {
        com.gmt2001.Console.out.println(
                "ChannelHostCache.run>>Failed to initial sleep: [InterruptedException] " + e.getMessage());
        com.gmt2001.Console.err.logStackTrace(e);
    }

    while (!killed) {
        try {
            try {
                if (new Date().after(timeoutExpire)) {
                    this.updateCache();
                }
            } catch (Exception e) {
                if (e.getMessage().startsWith("[SocketTimeoutException]")
                        || e.getMessage().startsWith("[IOException]")) {
                    Calendar c = Calendar.getInstance();

                    if (lastFail.after(new Date())) {
                        numfail++;
                    } else {
                        numfail = 1;
                    }

                    c.add(Calendar.MINUTE, 1);

                    lastFail = c.getTime();

                    if (numfail >= 5) {
                        timeoutExpire = c.getTime();
                    }
                }

                com.gmt2001.Console.out
                        .println("ChannelHostCache.run>>Failed to update hosts: " + e.getMessage());
                com.gmt2001.Console.err.logStackTrace(e);
            }
        } catch (Exception e) {
            com.gmt2001.Console.err.printStackTrace(e);
        }

        try {
            Thread.sleep(30 * 1000);
        } catch (InterruptedException e) {
            com.gmt2001.Console.out
                    .println("ChannelHostCache.run>>Failed to sleep: [InterruptedException] " + e.getMessage());
            com.gmt2001.Console.err.logStackTrace(e);
        }
    }
}