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.groupon.jenkins.dynamic.build.execution.DynamicBuildExection.java

public Result doRun(BuildListener listener) throws IOException, InterruptedException {
    try {//from   www.  j  ava2  s . c  o  m
        if (!buildEnvironment.initialize()) {
            return Result.FAILURE;
        }

        if (getBuildConfiguration().isSkipped()) {
            build.skip();
            return Result.SUCCESS;
        }
        build.setDescription(build.getCause().getBuildDescription());
        return dynamicBuildRunner.runBuild(listener);
    } catch (InterruptedException e) {
        Executor x = Executor.currentExecutor();
        x.recordCauseOfInterruption(build, listener);
        return x.abortResult();
    } catch (InvalidDotCiYmlException e) {
        throw e;
    } catch (Exception e) {
        PrintStream logger = listener.getLogger();
        logger.println(e.getMessage());
        logger.println(ExceptionUtils.getStackTrace(e));
        Executor x = Executor.currentExecutor();
        x.recordCauseOfInterruption(build, listener);
        x.doStop();
        return Result.FAILURE;
    } finally {
        if (buildEnvironment.tearDownBuildEnvironments(listener)) {
            return Result.FAILURE;
        }
    }
}

From source file:com.streamsets.pipeline.stage.origin.maprjson.MapRJsonOriginSource.java

private void takeANap() throws StageException {

    long latency = Math.abs(System.currentTimeMillis() - noMoreRecordsTime);
    long napTime;
    if (latency > 0 && latency < conf.basic.maxWaitTime) {
        napTime = Math.min(conf.basic.maxWaitTime, conf.basic.maxWaitTime - latency);
    } else {/*from  w  w w. j  a v a2 s.  c  om*/
        napTime = conf.basic.maxWaitTime;
    }

    noMoreRecordsTime = 0;

    if (napTime > 0) {
        try {
            Thread.sleep(napTime);
        } catch (InterruptedException ex) {
            LOG.error("Thread.sleep() failed ", ex.getMessage(), ex);
            Thread.currentThread().interrupt();
            throw new StageException(Errors.MAPR_JSON_ORIGIN_07, ex);
        }
    }
}

From source file:com.bt.aloha.util.ConcurrentUpdateManagerTest.java

@Test
public void testConcurrentUpdateConflictAwawreGetsCalled() throws Exception {
    // setup//from w w w  .java  2s.  c o m
    final CountDownLatch firstWriterRead = new CountDownLatch(1);
    final CountDownLatch secondWriterWrote = new CountDownLatch(1);
    final AtomicInteger failuresCounter = new AtomicInteger();

    ConcurrentUpdateBlock concurrentUpdateBlock = new ConflictAwareConcurrentUpdateBlock() {
        public void execute() {
            DialogInfo di = dialogCollection.get(dialogId);
            log.debug("First writer read");
            firstWriterRead.countDown();
            log.debug("Waiting for second writer to write");
            try {
                secondWriterWrote.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
            dialogCollection.replace(di);
            log.debug("First writer replaced");
        }

        public String getResourceId() {
            return dialogId;
        }

        public void onConcurrentUpdateConflict() {
            failuresCounter.incrementAndGet();
        }
    };

    Runnable competingWriter = new Runnable() {
        public void run() {
            log.debug("Waiting for first writer to read");
            try {
                firstWriterRead.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
            DialogInfo di = dialogCollection.get(dialogId);
            dialogCollection.replace(di);
            log.debug("Second writer replaced");
            secondWriterWrote.countDown();
        }
    };

    // act
    new Thread(competingWriter).start();
    concurrentUpdateManager.executeConcurrentUpdate(concurrentUpdateBlock);

    // assert
    assertEquals(1, failuresCounter.get());
}

From source file:gov.va.vinci.leo.listener.BaseListener.java

/**
 * @see org.apache.uima.aae.client.UimaAsBaseCallbackListener#collectionProcessComplete(org.apache.uima.collection.EntityProcessStatus)
 * @param aStatus   the status of the processing. This object contains a record of any Exception that occurred, as well as timing information.
 */// www.  ja  v a 2s . co  m
@Override
public void collectionProcessComplete(EntityProcessStatus aStatus) {
    super.collectionProcessComplete(aStatus);
    //Ensure all CAS have come back before continuing
    int count = 0;
    while (numSent != numReceived && count < 10) {
        LOG.warn("Have not recieved all CAS's from the Service, sleeping for 2 seconds");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            LOG.error(e.getMessage(), e);
        }
        count++;
    } //while
    if (numSent != numReceived)
        LOG.warn("Did not recieve all CAS's back from the service.");

    LOG.info("Collection Processing Stats: \n" + "Sent CAS Count: " + numSent + "\n" + "Received CAS Count: "
            + numReceived);
}

From source file:com.josescalia.tumblr.app.MainFrame.java

private void executeMenu(final String beanName) {
    mainPanel.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    progressBar.setIndeterminate(true);/*from   w ww .j  a  v a  2 s . c o m*/
    new SwingWorker<BaseForm, BaseForm>() {
        @Override
        protected BaseForm doInBackground() throws Exception {
            return (BaseForm) context.getBean(beanName);
        }

        @Override
        protected void done() {
            BaseForm frm;
            try {
                removePanelFromMain();
                frm = get();
                frm.showForm();
                frm.setVisible(true);
                mainPanel.setLayout(new BorderLayout());
                mainPanel.add(frm);
                mainPanel.validate();

            } catch (InterruptedException ex) {
                logger.error(ex.getMessage());
                UIAlert.showError(mainPanel, "No Such Form Defined");
            } catch (ExecutionException ex) {
                logger.error(ex.getMessage());
                UIAlert.showError(mainPanel, "Something wrong with the system");
            }
            progressBar.setIndeterminate(false);
            mainPanel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    }.execute();

    //this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:com.bt.aloha.util.ConcurrentUpdateManagerTest.java

@Test
public void testConcurrentUpdateConflictAwawreExceptionAbsorbed() throws Exception {
    // setup//from   w  w w. ja v a  2s . c om
    final CountDownLatch firstWriterRead = new CountDownLatch(1);
    final CountDownLatch secondWriterWrote = new CountDownLatch(1);
    final AtomicInteger failuresCounter = new AtomicInteger();

    ConcurrentUpdateBlock concurrentUpdateBlock = new ConflictAwareConcurrentUpdateBlock() {
        public void execute() {
            DialogInfo di = dialogCollection.get(dialogId);
            log.debug("First writer read");
            firstWriterRead.countDown();

            di.setApplicationData("first");
            log.debug("Waiting for second writer to write");
            try {
                secondWriterWrote.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
            dialogCollection.replace(di);
            log.debug("First writer replaced");
        }

        public String getResourceId() {
            return dialogId;
        }

        public void onConcurrentUpdateConflict() {
            failuresCounter.incrementAndGet();
            throw new RuntimeException("bugger off");
        }
    };

    Runnable competingWriter = new Runnable() {
        public void run() {
            log.debug("Waiting for first writer to read");
            try {
                firstWriterRead.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
            DialogInfo di = dialogCollection.get(dialogId);
            di.setApplicationData("second");
            dialogCollection.replace(di);
            log.debug("Second writer replaced");
            secondWriterWrote.countDown();
        }
    };

    // act
    new Thread(competingWriter).start();
    concurrentUpdateManager.executeConcurrentUpdate(concurrentUpdateBlock);

    // assert
    assertEquals(1, failuresCounter.get());
    assertEquals("first", dialogCollection.get(dialogId).getApplicationData());
}

From source file:gsn.wrappers.TetraedreNMCWrapper.java

public void run() {
    DataEnumerator data;//from  w ww  .  j  a v a2 s.  c o  m

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }

    Connection conn = null;
    ResultSet resultSet = null;

    while (isActive()) {
        try {
            conn = sm.getConnection();
            StringBuilder query = new StringBuilder("select * from ").append(table_name).append(
                    " where timestamp*1000 > " + latest_timed + "  order by timestamp limit 0," + buffer_size);

            resultSet = sm.executeQueryWithResultSet(query, conn);

            //logger.debug(query);

            while (resultSet.next()) {
                Serializable[] output = new Serializable[this.getOutputFormat().length];

                //long pk = resultSet.getLong(1);
                long timed = resultSet.getLong(1) * 1000;

                //logger.warn("pk => "+ pk);
                //logger.warn("timed => "+ timed);

                for (int i = 0; i < dataFieldsLength; i++) {

                    switch (dataFieldTypes[i]) {
                    case DataTypes.VARCHAR:
                    case DataTypes.CHAR:
                        output[i] = resultSet.getString(i + 1);
                        break;
                    case DataTypes.INTEGER:
                        output[i] = resultSet.getInt(i + 1);
                        break;
                    case DataTypes.TINYINT:
                        output[i] = resultSet.getByte(i + 1);
                        break;
                    case DataTypes.SMALLINT:
                        output[i] = resultSet.getShort(i + 1);
                        break;
                    case DataTypes.DOUBLE:
                        output[i] = resultSet.getDouble(i + 1);
                        break;
                    case DataTypes.FLOAT:
                        output[i] = resultSet.getFloat(i + 1);
                        break;
                    case DataTypes.BIGINT:
                        output[i] = resultSet.getLong(i + 1);
                        break;
                    case DataTypes.BINARY:
                        output[i] = resultSet.getBytes(i + 1);
                        break;
                    }
                    //logger.warn(i+" (type: "+dataFieldTypes[i]+" ) => "+output[i]);
                }

                StreamElement se = new StreamElement(dataFieldNames, dataFieldTypes, output, timed);
                latest_timed = se.getTimeStamp();

                //logger.warn(" Latest => " + latest_timed);

                this.postStreamElement(se);

                updateCheckPointFile(latest_timed);

                //logger.warn(se);
            }

        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        } finally {
            sm.close(resultSet);
            sm.close(conn);
        }

        try {
            Thread.sleep(rate);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

From source file:gov.ca.cwds.cals.service.ComplaintsService.java

@SuppressWarnings("squid:S2142") //Logging and informing client instead of shutdown
private List<ComplaintDto> aggregateComplaintsFromDifferentSources(String facilityNumber) {
    List<ComplaintDto> complaints = new ArrayList<>();

    ExecutorService executorService = Executors.newFixedThreadPool(3);
    try {/*from   w  w w. j ava  2s. c  o m*/
        List<Future<List<ComplaintDto>>> futures = executorService.invokeAll(prepareListOfTasks(facilityNumber),
                1, TimeUnit.MINUTES);
        for (Future<List<ComplaintDto>> future : futures) {
            complaints.addAll(future.get());
        }
    } catch (InterruptedException e) {
        String message = "One of complaints execution threads has been interrupted";
        LOGGER.error(message, e);
        throw new ServiceException(message, e);
    } catch (ExecutionException e) {
        LOGGER.error(e.getMessage(), e);
        throw new ServiceException(e.getMessage(), e);
    }

    shutdownExecutionService(executorService);

    return complaints;
}

From source file:gsn.wrappers.TetraedreFluoWrapper.java

public void run() {
    DataEnumerator data;//from   ww w  . j  a v  a2 s  .  c  om

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }

    Connection conn = null;
    ResultSet resultSet = null;

    while (isActive()) {
        try {
            conn = sm.getConnection();
            StringBuilder query = new StringBuilder("select * from ").append(table_name)
                    .append(" where physical_input=").append(physical_input).append(" AND timestamp*1000 > "
                            + latest_timed + "  order by timestamp limit 0," + buffer_size);

            resultSet = sm.executeQueryWithResultSet(query, conn);

            //logger.debug(query);

            while (resultSet.next()) {
                Serializable[] output = new Serializable[this.getOutputFormat().length];

                //long pk = resultSet.getLong(1);
                long timed = resultSet.getLong(3) * 1000;

                //logger.warn("pk => "+ pk);
                //logger.warn("timed => "+ timed);

                for (int i = 0; i < dataFieldsLength; i++) {

                    switch (dataFieldTypes[i]) {
                    case DataTypes.VARCHAR:
                    case DataTypes.CHAR:
                        output[i] = resultSet.getString(i + 1);
                        break;
                    case DataTypes.INTEGER:
                        output[i] = resultSet.getInt(i + 1);
                        break;
                    case DataTypes.TINYINT:
                        output[i] = resultSet.getByte(i + 1);
                        break;
                    case DataTypes.SMALLINT:
                        output[i] = resultSet.getShort(i + 1);
                        break;
                    case DataTypes.DOUBLE:
                        output[i] = resultSet.getDouble(i + 1);
                        break;
                    case DataTypes.FLOAT:
                        output[i] = resultSet.getFloat(i + 1);
                        break;
                    case DataTypes.BIGINT:
                        output[i] = resultSet.getLong(i + 1);
                        break;
                    case DataTypes.BINARY:
                        output[i] = resultSet.getBytes(i + 1);
                        break;
                    }
                    //logger.warn(i+" (type: "+dataFieldTypes[i]+" ) => "+output[i]);
                }

                StreamElement se = new StreamElement(dataFieldNames, dataFieldTypes, output, timed);
                latest_timed = se.getTimeStamp();

                //logger.warn(" Latest => " + latest_timed);

                this.postStreamElement(se);

                updateCheckPointFile(latest_timed);

                //logger.warn(se);
            }

        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        } finally {
            sm.close(resultSet);
            sm.close(conn);
        }

        try {
            Thread.sleep(rate);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

From source file:gsn.wrappers.JDBCWrapper.java

public void run() {
    DataEnumerator data;//from   w ww. ja v  a2s .  com

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        logger.error(e.getMessage(), e);
    }

    Connection conn = null;
    ResultSet resultSet = null;

    while (isActive()) {
        try {
            conn = sm.getConnection();
            StringBuilder query = new StringBuilder("select * from ").append(table_name)
                    .append(" where timed > " + latest_timed + " limit 0," + buffer_size);

            resultSet = sm.executeQueryWithResultSet(query, conn);

            //logger.debug(query);

            while (resultSet.next()) {
                Serializable[] output = new Serializable[this.getOutputFormat().length];

                long pk = resultSet.getLong(1);
                long timed = resultSet.getLong(2);

                //logger.warn("pk => "+ pk);
                //logger.warn("timed => "+ timed);

                for (int i = 0; i < dataFieldsLength; i++) {

                    switch (dataFieldTypes[i]) {
                    case DataTypes.VARCHAR:
                    case DataTypes.CHAR:
                        output[i] = resultSet.getString(i + 3);
                        break;
                    case DataTypes.INTEGER:
                        output[i] = resultSet.getInt(i + 3);
                        break;
                    case DataTypes.TINYINT:
                        output[i] = resultSet.getByte(i + 3);
                        break;
                    case DataTypes.SMALLINT:
                        output[i] = resultSet.getShort(i + 3);
                        break;
                    case DataTypes.DOUBLE:
                        output[i] = resultSet.getDouble(i + 3);
                        break;
                    case DataTypes.FLOAT:
                        output[i] = resultSet.getFloat(i + 3);
                        break;
                    case DataTypes.BIGINT:
                        output[i] = resultSet.getLong(i + 3);
                        break;
                    case DataTypes.BINARY:
                        output[i] = resultSet.getBytes(i + 3);
                        break;
                    }
                    //logger.warn(i+" (type: "+dataFieldTypes[i]+" ) => "+output[i]);
                }

                StreamElement se = new StreamElement(dataFieldNames, dataFieldTypes, output, timed);
                latest_timed = se.getTimeStamp();

                //logger.warn(" Latest => " + latest_timed);

                this.postStreamElement(se);

                updateCheckPointFile(latest_timed);

                //logger.warn(se);
            }

        } catch (java.io.IOException e) {
            logger.error(e.getMessage(), e);
        } catch (SQLException e) {
            logger.error(e.getMessage(), e);
        } finally {
            sm.close(resultSet);
            sm.close(conn);
        }

        try {
            Thread.sleep(rate);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }
    }
}