List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.ottogroup.bi.asap.operator.webtrends.consumer.WebtrendsStreamsConsumer.java
/** * Executed by web socket implementation when receiving a message from the * streams api. The message will be directly handed over to the configured * {@link ActorRef message receiver} /*from w w w . java2s . c om*/ * @param message */ @OnWebSocketMessage public void onMessage(String message) { try { this.streamMessageQueue.offer(message, 1000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.error("Failed to offer element to internal queue. Ignoring event. Error: " + e.getMessage()); } }
From source file:org.apache.manifoldcf.agents.output.opensearchserver.OpenSearchServerConnection.java
protected void call(HttpRequestBase method) throws ManifoldCFException { CallThread ct = new CallThread(httpClient, method); try {// ww w. j a v a 2 s.co m ct.start(); try { ct.finishUp(); if (!checkResultCode(ct.getResultCode())) throw new ManifoldCFException(getResultDescription()); response = ct.getResponse(); } catch (InterruptedException e) { ct.interrupt(); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } } catch (java.net.SocketTimeoutException e) { setResult(e.getClass().getSimpleName().toUpperCase(Locale.ROOT), Result.ERROR, e.getMessage()); throw new ManifoldCFException( "SocketTimeoutException while calling " + method.getURI() + ": " + e.getMessage(), e); } catch (InterruptedIOException e) { setResult(e.getClass().getSimpleName().toUpperCase(Locale.ROOT), Result.ERROR, e.getMessage()); throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (HttpException e) { setResult(e.getClass().getSimpleName().toUpperCase(Locale.ROOT), Result.ERROR, e.getMessage()); throw new ManifoldCFException("HttpException while calling " + method.getURI() + ": " + e.getMessage(), e); } catch (IOException e) { setResult(e.getClass().getSimpleName().toUpperCase(Locale.ROOT), Result.ERROR, e.getMessage()); throw new ManifoldCFException("IOException while calling " + method.getURI() + ": " + e.getMessage(), e); } }
From source file:API.amazon.mws.feeds.actions.SubmitFeedProcess.java
private void requestThrottledExceptionHandler(long throttlingLimit) { try {//ww w . ja v a 2 s. com log.info("Request throttled. Sleeping for " + throttlingLimit + " milliseconds."); Thread.sleep(throttlingLimit); } catch (InterruptedException e) { log.error(e.getMessage(), e); return; } }
From source file:com.mirth.connect.connectors.jdbc.DatabaseDispatcher.java
@Override public Response send(ConnectorProperties connectorProperties, ConnectorMessage message) throws InterruptedException { DatabaseDispatcherProperties databaseDispatcherProperties = (DatabaseDispatcherProperties) connectorProperties; String info = "URL: " + databaseDispatcherProperties.getUrl(); eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(), getDestinationName(), ConnectionStatusEventType.READING, info)); try {/*from w w w . j a va 2 s .c o m*/ Response response = delegate.send(databaseDispatcherProperties, message); response.setValidate( databaseDispatcherProperties.getDestinationConnectorProperties().isValidateResponse()); return response; } catch (InterruptedException e) { throw e; } catch (DatabaseDispatcherException e) { String logMessage = "An error occurred in channel \"" + ChannelController.getInstance().getDeployedChannelById(getChannelId()).getName() + "\": " + e.getMessage(); if (isQueueEnabled()) { logger.warn(logMessage, ExceptionUtils.getRootCause(e)); } else { logger.error(logMessage, ExceptionUtils.getRootCause(e)); } eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(), message.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(), e.getMessage(), e)); return new Response(Status.QUEUED, null, ErrorMessageBuilder.buildErrorResponse("Error writing to database.", e), ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(), e.getMessage(), e)); } finally { eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(), getDestinationName(), ConnectionStatusEventType.IDLE)); } }
From source file:gridool.mapred.dht.task.DhtMapShuffleTask.java
private void shuffleAndCollectKeys(final ArrayQueue<byte[]> queue) { if (jobConf == null) { LOG.warn("jobConf was not set. Use the default OutputKeyCollectionName for collecting keys: " + DhtMapReduceJobConf.OutputKeyCollectionName); }/*from ww w .j a v a 2 s .c om*/ final AddOperation ops1; final AddOperation ops2; { // #1. shuffle key/values ops1 = new AddOperation(destTableName); ops1.setMaxNumReplicas(0); final int size = queue.size(); final byte[][] shuffledKeys = new byte[size / 2][]; for (int i = 0, j = 0; i < size; i += 2, j++) { byte[] k = queue.get(i); shuffledKeys[j] = k; byte[] v = queue.get(i + 1); ops1.addMapping(k, v); } // #2. collect keys String collectKeyDest = (jobConf == null) ? DhtMapReduceJobConf.OutputKeyCollectionName : jobConf.getOutputKeyCollectionName(); byte[] key = StringUtils.getBytes(destTableName); byte[] value = GridUtils.compressOutputKeys(shuffledKeys); ops2 = new AddOperation(collectKeyDest, key, value); ops2.setMaxNumReplicas(0); } shuffleExecPool.execute(new Runnable() { public void run() { final GridJobFuture<Serializable> future1 = kernel.execute(DirectoryAddJob.class, ops1); final GridJobFuture<Serializable> future2 = kernel.execute(DirectoryAddJob.class, ops2); try {// TODO REVIEWME order of waiting future2.get(); // wait for execution future1.get(); // wait for execution } catch (InterruptedException ie) { LOG.error(ie.getMessage(), ie); } catch (ExecutionException ee) { LOG.error(ee.getMessage(), ee); } } }); }
From source file:edu.harvard.i2b2.pm.ws.PMService.java
/** * This function is main webservice interface to get pulmonary data from * pulmonary report. It uses AXIOM elements(OMElement) to conveniently parse * xml messages./*from w w w. j a va2 s . co m*/ * * It excepts incoming request in i2b2 message format, which wraps PFT * report inside patientdata object. The response is also will be in i2b2 * message, which will wrap patientdata object. Patient data object will * have all the extracted pft concepts from the report. * * * @param getServices * @return OMElement in i2b2message format * @throws PortletServiceNotFoundException * @throws PortletServiceUnavailableException * @throws Exception */ public OMElement getServices(OMElement getPMDataElement) throws I2B2Exception { /* OMElement returnElement = null; String pmDataResponse = null; String unknownErrorMessage = "Error message delivered from the remote server \n" + "You may wish to retry your last action"; if (getPMDataElement == null) { log.error("Incoming PM request is null"); ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null, unknownErrorMessage); pmDataResponse = MessageFactory.convertToXMLString(responseMsgType); return MessageFactory.createResponseOMElementFromString(pmDataResponse); } ServicesMessage servicesMsg = new ServicesMessage(getPMDataElement.toString()); // String requestElementString = getPMDataElement.toString(); // childrenDataMsg.setRequestMessageType(requestElementString); long waitTime = 0; if (servicesMsg.getRequestMessageType() != null) { if (servicesMsg.getRequestMessageType().getRequestHeader() != null) { waitTime = servicesMsg.getRequestMessageType() .getRequestHeader() .getResultWaittimeMs(); } } //do Workplace query processing inside thread, so that // service could send back message with timeout error. ExecutorRunnable er = new ExecutorRunnable(); return er.execute(new ServicesHandler(servicesMsg), waitTime); */ OMElement returnElement = null; if (getPMDataElement == null) { log.error("Incoming PM request is null"); throw new I2B2Exception("Incoming PM request is null"); } Pattern p = Pattern.compile("<password>.+</password>"); Matcher m = p.matcher(getPMDataElement.toString()); String outString = m.replaceAll("<password>*********</password>"); p = Pattern.compile(">.+</ns9:set_password>"); m = p.matcher(outString); outString = m.replaceAll(">*********</ns9:set_password>"); log.debug("Received Request PM Element " + outString); log.debug("Begin getting servicesMsg"); ServicesMessage servicesMsg = new ServicesMessage(getPMDataElement.toString()); long waitTime = 0; if (servicesMsg.getRequestMessageType() != null) { if (servicesMsg.getRequestMessageType().getRequestHeader() != null) { waitTime = servicesMsg.getRequestMessageType().getRequestHeader().getResultWaittimeMs(); } } log.debug("Completed getting servicesMsg, waittime is: " + waitTime); //do PM processing inside thread, so that // service could sends back message with timeout error. String pmDataResponse = null; try { ExecutorRunnable er = new ExecutorRunnable(); //er.setInputString(requestElementString); log.debug("begin setRequestHandler, my servicesMsg: " + servicesMsg); er.setRequestHandler(new ServicesHandler(servicesMsg)); log.debug("middle setRequestHandler"); log.debug("end setRequestHandler"); Thread t = new Thread(er); ResponseMessageType responseMsgType = null; synchronized (t) { t.start(); try { //if (waitTime > 0) { // t.wait(waitTime); //} else { // t.wait(); //} long startTime = System.currentTimeMillis(); long deltaTime = -1; while ((er.isJobCompleteFlag() == false) && (deltaTime < waitTime)) { if (waitTime > 0) { t.wait(waitTime - deltaTime); deltaTime = System.currentTimeMillis() - startTime; } else { t.wait(); } } pmDataResponse = er.getOutputString(); if (pmDataResponse == null) { if (er.getJobException() != null) { pmDataResponse = ""; throw new I2B2Exception("Portal is not property configured."); } else if (er.isJobCompleteFlag() == false) { String timeOuterror = "Result waittime millisecond <result_waittime_ms> :" + waitTime + " elapsed, try again with increased value"; log.debug(timeOuterror); responseMsgType = MessageFactory.doBuildErrorResponse(null, timeOuterror); pmDataResponse = MessageFactory.convertToXMLString(responseMsgType); } } } catch (InterruptedException e) { log.error("Error in thread: " + e.getMessage()); e.printStackTrace(); throw new I2B2Exception("Thread error while running PM job " + getPMDataElement, e); } finally { t.interrupt(); er = null; t = null; } } } catch (Exception e) { log.error("Error: " + e.getMessage()); e.printStackTrace(); } try { returnElement = MessageFactory.createResponseOMElementFromString(pmDataResponse); log.debug("my pm repsonse is: " + pmDataResponse); log.debug("my return is: " + returnElement); } catch (XMLStreamException e) { log.error("Error creating OMElement from response string " + pmDataResponse, e); } return returnElement; }
From source file:pl.edu.agh.iosr.lsf.RootController.java
@RequestMapping(value = "/delayTest", method = RequestMethod.GET) public String delayTest(@RequestParam(value = "keyword") String key, @RequestParam(value = "category") String cat) { try {//from w ww . j a va 2 s . c om dh.deleteKeyword(key); dh.insertKeyword(key, cat); long start = System.currentTimeMillis(); int c = 0; while (!dh.tagKeywordUsage(key) && c < 60) { try { Thread.sleep(1000); ++c; } catch (InterruptedException e) { } } return "" + (System.currentTimeMillis() - start); } catch (SQLException e) { return e.getMessage(); } }
From source file:com.blazemeter.bamboo.plugin.TaskType.java
@Override public TaskResult execute(TaskContext context) throws TaskException { final BuildLogger logger = context.getBuildLogger(); TaskResultBuilder resultBuilder = TaskResultBuilder.create(context); ConfigurationMap configMap = context.getConfigurationMap(); logger.addBuildLogEntry("Executing BlazeMeter task..."); logger.addBuildLogEntry("BlazemeterBamboo plugin v." + ServiceManager.getVersion()); PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings(); String userKey = (String) pluginSettings.get(Config.class.getName() + AdminServletConst.DOT_USER_KEY); String serverUrl = (String) pluginSettings.get(Config.class.getName() + AdminServletConst.DOT_SERVER_URL); this.testId = configMap.get(Constants.SETTINGS_SELECTED_TEST_ID); this.jmeterProps = configMap.get(Constants.SETTINGS_JMETER_PROPERTIES); this.jtlReport = configMap.getAsBoolean(Constants.SETTINGS_JTL_REPORT); this.junitReport = configMap.getAsBoolean(Constants.SETTINGS_JUNIT_REPORT); this.notes = configMap.get(Constants.SETTINGS_NOTES); this.jtlPath = configMap.get(Constants.SETTINGS_JTL_PATH); this.junitPath = configMap.get(Constants.SETTINGS_JUNIT_PATH); if (StringUtils.isBlank(userKey)) { logger.addErrorLogEntry("BlazeMeter user key not defined!"); return resultBuilder.failed().build(); }/*from w ww.ja va 2s . c om*/ File dd = new File(context.getWorkingDirectory().getAbsolutePath() + "/build # " + context.getBuildContext().getBuildNumber()); String httpLog = dd + File.separator + Constants.HTTP_LOG; HttpUtility.setHttpLog(httpLog); this.api = new ApiV3Impl(userKey, serverUrl); rootDirectory = context.getRootDirectory(); logger.addBuildLogEntry("Attempting to start test with id:" + testId); logger.addBuildLogEntry("Http log will be available at " + httpLog); this.masterId = ServiceManager.startTest(api, testId, logger); long testInitStart = System.currentTimeMillis(); String reportUrl = null; if (masterId == null || masterId.length() == 0) { logger.addErrorLogEntry("Failed to start test."); return resultBuilder.failed().build(); } else { reportUrl = ServiceManager.getReportUrl(api, masterId, logger); HashMap<String, String> reportUrls = StaticAccessor.getReportUrls(); reportUrls.put(context.getBuildContext().getBuildResultKey(), reportUrl); context.getBuildContext().getBuildResult().getCustomBuildData().put(Constants.REPORT_URL, reportUrl); } ServiceManager.notes(this.api, masterId, this.notes, logger); TestStatus status; boolean initTimeOutPassed = false; if (!StringUtils.isBlank(this.jmeterProps)) { JSONArray props = ServiceManager.prepareSessionProperties(this.jmeterProps, logger); ServiceManager.properties(this.api, props, masterId, logger); } do { status = this.api.testStatus(masterId); try { Thread.currentThread().sleep(CHECK_INTERVAL); } catch (InterruptedException e) { logger.addErrorLogEntry("BlazeMeter Interrupted Exception: " + e.getMessage()); logger.addBuildLogEntry("Stopping test..."); ServiceManager.stopTestMaster(this.api, this.masterId, logger); break; } logger.addBuildLogEntry("Check if the test is initialized..."); initTimeOutPassed = System.currentTimeMillis() > testInitStart + INIT_TEST_TIMEOUT; } while (!(initTimeOutPassed | status.equals(TestStatus.Running))); if (status.equals(TestStatus.NotRunning)) { logger.addErrorLogEntry("Test was not initialized, marking build as failed."); return resultBuilder.failedWithError().build(); } logger.addBuildLogEntry("Test was initialized on server, testId=" + testId); logger.addBuildLogEntry("Test report is available via link: " + reportUrl); long timeOfStart = System.currentTimeMillis(); while (status.equals(TestStatus.Running)) { try { Thread.currentThread().sleep(CHECK_INTERVAL); } catch (InterruptedException e) { logger.addErrorLogEntry("Received interrupted Exception: " + e.getMessage()); logger.addBuildLogEntry("Stopping test..."); ServiceManager.stopTestMaster(this.api, this.masterId, logger); break; } logger.addBuildLogEntry("Check if the test is still running. Time passed since start:" + ((System.currentTimeMillis() - timeOfStart) / 1000 / 60) + " minutes."); status = this.api.testStatus(masterId); if (status.equals(TestStatus.NotRunning)) { logger.addBuildLogEntry("Test is finished earlier then estimated! Time passed since start:" + ((System.currentTimeMillis() - timeOfStart) / 1000 / 60) + " minutes."); break; } else if (status.equals(TestStatus.NotFound)) { logger.addErrorLogEntry("BlazeMeter test not found!"); return resultBuilder.failed().build(); } } boolean active = true; int activeCheck = 1; while (active && activeCheck < 11) { try { Thread.currentThread().sleep(CHECK_INTERVAL); } catch (InterruptedException e) { logger.addErrorLogEntry("Thread was interrupted during sleep()"); logger.addErrorLogEntry("Received interrupted Exception: " + e.getMessage()); break; } logger.addBuildLogEntry( "Checking, if test is active, testId=" + this.testId + ", retry # " + activeCheck); active = this.api.active(this.testId); activeCheck++; } //BlazeMeter test stopped due to user test duration setup reached TestResult result = ServiceManager.getReport(this.api, this.masterId, logger); if (this.jtlReport) { File jtl = null; try { jtl = ServiceManager.resolvePath(context, this.jtlPath, logger); } catch (Exception e) { logger.addBuildLogEntry("Failed to create directory for downloading jtl report."); jtl = dd; logger.addBuildLogEntry("Default directory " + jtl.getAbsolutePath() + " will be used."); } logger.addBuildLogEntry("Requesting JTL report for test with masterId=" + this.masterId); ServiceManager.downloadJtlReports(this.api, this.masterId, jtl, logger); } else { logger.addBuildLogEntry("JTL report won't be requested for test with masterId=" + this.masterId); } if (this.junitReport) { File junit = null; logger.addBuildLogEntry("Requesting Junit report for test with masterId=" + this.masterId); try { junit = ServiceManager.resolvePath(context, this.junitPath, logger); } catch (Exception e) { logger.addBuildLogEntry("Failed to create directory for downloading junit report."); junit = dd; logger.addBuildLogEntry("Default directory " + junit.getAbsolutePath() + " will be used."); } logger.addBuildLogEntry("Requesting JTL report for test with masterId=" + this.masterId); ServiceManager.downloadJunitReport(this.api, this.masterId, junit, logger); } else { logger.addBuildLogEntry("Junit report won't be requested for test with masterId=" + this.masterId); } TaskState ciStatus = ServiceManager.ciStatus(this.api, this.masterId, logger); switch (ciStatus) { case FAILED: return resultBuilder.failed().build(); case ERROR: return resultBuilder.failedWithError().build(); case SUCCESS: return resultBuilder.success().build(); default: return resultBuilder.success().build(); } }
From source file:edu.hawaii.soest.pacioos.text.FileTextSource.java
protected boolean execute() { log.debug("FileTextSource.execute() called."); boolean failed = false; // indicates overall success of execute() // do not execute the stream if there is no connection if (!isConnected()) return false; try {//from ww w . j a v a2s. c o m // open the data file for monitoring FileReader reader = new FileReader(new File(getDataFilePath())); this.fileReader = new BufferedReader(reader); // add channels of data that will be pushed to the server. // Each sample will be sent to the Data Turbine as an rbnb frame. int channelIndex = 0; long lastSampleTimeAsSecondsSinceEpoch = getLastSampleTime(); // poll the data file for new lines of data and insert them into the RBNB while (true) { String line = fileReader.readLine(); if (line == null) { Thread.currentThread().sleep(this.pollInterval); } else { // test the line for the expected data pattern boolean valid = this.validateSample(line); // if the line matches the data pattern, insert it into the DataTurbine if (valid) { log.debug("This line matches the data line pattern: " + line); Date sampleDate = getSampleDate(line); if (this.dateFormats == null || this.dateFields == null) { log.warn("Using the default datetime format and field for sample data. " + "Use the -f and -d options to explicitly set date time fields."); } log.debug("Sample date is: " + sampleDate.toString()); // convert the sample date to seconds since the epoch long sampleTimeAsSecondsSinceEpoch = (sampleDate.getTime() / 1000L); // only insert samples newer than the last sample seen at startup // and that are not in the future (> 1 hour since the CTD clock // may have drifted) Calendar currentCal = Calendar.getInstance(); this.tz = TimeZone.getTimeZone(this.timezone); currentCal.setTimeZone(this.tz); currentCal.add(Calendar.HOUR, 1); Date currentDate = currentCal.getTime(); if (lastSampleTimeAsSecondsSinceEpoch < sampleTimeAsSecondsSinceEpoch && sampleTimeAsSecondsSinceEpoch < currentDate.getTime() / 1000L) { int numberOfChannelsFlushed = 0; try { //insert into the DataTurbine numberOfChannelsFlushed = this.sendSample(line); } catch (SAPIException sapie) { // reconnect if an exception is thrown on Flush() log.error("Error while flushing the source: " + sapie.getMessage()); failed = true; } // reset the last sample time to the sample just inserted lastSampleTimeAsSecondsSinceEpoch = sampleTimeAsSecondsSinceEpoch; log.debug("Last sample time is now: " + (new Date(lastSampleTimeAsSecondsSinceEpoch * 1000L).toString())); log.info(getRBNBClientName() + " Sample sent to the DataTurbine: " + line.trim()); } else { log.info("The current line is earlier than the last entry " + "in the Data Turbine or is a date in the future. " + "Skipping it. The line was: " + line); } } else { log.info("The current line doesn't match an expected " + "data line pattern. Skipping it. The line was: " + line); } } // end if() } // end while } catch (ParseException pe) { log.info("There was a problem parsing the sample date string. The message was: " + pe.getMessage()); failed = true; return !failed; } catch (SAPIException sapie) { log.info("There was a problem communicating with the DataTurbine. The message was: " + sapie.getMessage()); failed = true; return !failed; } catch (InterruptedException ie) { log.info("There was a problem while polling the data file. The message was: " + ie.getMessage()); failed = true; return !failed; } catch (IOException ioe) { log.info("There was a problem opening the data file. The message was: " + ioe.getMessage()); failed = true; return !failed; } finally { try { this.fileReader.close(); } catch (IOException ioe2) { log.error("There was a problem closing the data file. The message was: " + ioe2.getMessage()); } } }
From source file:de.huberlin.wbi.cuneiform.core.actormodel.Actor.java
@Override public void run() { try {/*from w w w .j ava 2 s . c o m*/ if (log.isDebugEnabled()) log.debug("Starting actor: " + getClass().getSimpleName()); while (true) { Thread.sleep(DELAY); if (log.isDebugEnabled()) log.debug(getClass() + " is alive."); preRec(); processQueue(); postRec(); } } catch (InterruptedException e) { if (log.isDebugEnabled()) log.debug(getClass() + " caught InterruptedException. Shutting down."); } catch (Throwable e) { if (log.isDebugEnabled()) log.debug(getClass() + " caught unexpected throwable: " + e.getMessage()); e.printStackTrace(); } finally { if (log.isDebugEnabled()) log.debug("Downing " + getClass() + "."); shutdown(); } }