List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:nextflow.fs.dx.DxUploadOutputStream.java
private void dequeueAndSubmit() { log.trace("Entering received loop"); while (!closed || queue.size() > 0) { ByteBuffer buffer;//from www. j a va 2 s.c om try { buffer = queue.poll(1, TimeUnit.SECONDS); log.trace("File: {} > Received a buffer -- limit: ", fileId, buffer.limit()); executor.submit(consumeBuffer0(buffer, ++chunkCount)); } catch (InterruptedException e) { log.trace("File: {} > Got an interrupted exception while waiting new chunk to upload -- cause: {}", fileId, e.getMessage()); } } log.trace("Exiting received loop"); }
From source file:com.cws.esolutions.agent.processors.impl.ServiceCheckProcessorImpl.java
public ServiceCheckResponse runSystemCheck(final ServiceCheckRequest request) throws ServiceCheckException { final String methodName = IServiceCheckProcessor.CNAME + "#runSystemCheck(final ServiceCheckRequest request) throws ServiceCheckException"; if (DEBUG) {/*from w w w .j a va2 s . com*/ DEBUGGER.debug(methodName); DEBUGGER.debug("ServiceCheckRequest: {}", request); } int exitCode = -1; Socket socket = null; File sourceFile = null; CommandLine command = null; BufferedWriter writer = null; ExecuteStreamHandler streamHandler = null; ByteArrayOutputStream outputStream = null; ServiceCheckResponse response = new ServiceCheckResponse(); final DefaultExecutor executor = new DefaultExecutor(); final ExecuteWatchdog watchdog = new ExecuteWatchdog(CONNECT_TIMEOUT * 1000); final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); try { switch (request.getRequestType()) { case NETSTAT: sourceFile = scriptConfig.getScripts().get("netstat"); if (DEBUG) { DEBUGGER.debug("sourceFile: {}", sourceFile); } if (!(sourceFile.canExecute())) { throw new ServiceCheckException( "Script file either does not exist or cannot be executed. Cannot continue."); } command = CommandLine.parse(sourceFile.getAbsolutePath()); if (request.getPortNumber() != 0) { command.addArgument(String.valueOf(request.getPortNumber()), true); } if (DEBUG) { DEBUGGER.debug("CommandLine: {}", command); } outputStream = new ByteArrayOutputStream(); streamHandler = new PumpStreamHandler(outputStream); executor.setWatchdog(watchdog); executor.setStreamHandler(streamHandler); if (DEBUG) { DEBUGGER.debug("ExecuteStreamHandler: {}", streamHandler); DEBUGGER.debug("ExecuteWatchdog: {}", watchdog); DEBUGGER.debug("DefaultExecuteResultHandler: {}", resultHandler); DEBUGGER.debug("DefaultExecutor: {}", executor); } executor.execute(command, resultHandler); resultHandler.waitFor(); exitCode = resultHandler.getExitValue(); if (DEBUG) { DEBUGGER.debug("exitCode: {}", exitCode); } writer = new BufferedWriter(new FileWriter(LOGS_DIRECTORY + "/" + sourceFile.getName() + ".log")); writer.write(outputStream.toString()); writer.flush(); response.setResponseData(outputStream.toString()); if (executor.isFailure(exitCode)) { response.setRequestStatus(AgentStatus.FAILURE); } else { response.setRequestStatus(AgentStatus.SUCCESS); } break; case REMOTEDATE: response.setRequestStatus(AgentStatus.SUCCESS); response.setResponseData(System.currentTimeMillis()); break; case TELNET: response = new ServiceCheckResponse(); int targetPort = request.getPortNumber(); String targetServer = request.getTargetHost(); if (DEBUG) { DEBUGGER.debug("Target port: {}", targetPort); DEBUGGER.debug("Target server: {}", targetServer); } if (targetPort == 0) { throw new ServiceCheckException("Target port number was not assigned. Cannot action request."); } final String CRLF = "\r\n"; final String TERMINATE_TELNET = "^]"; synchronized (new Object()) { InetSocketAddress socketAddress = new InetSocketAddress(targetServer, targetPort); socket = new Socket(); socket.setSoTimeout(IServiceCheckProcessor.CONNECT_TIMEOUT); socket.setSoLinger(false, 0); socket.setKeepAlive(false); try { socket.connect(socketAddress, IServiceCheckProcessor.CONNECT_TIMEOUT); if (!(socket.isConnected())) { throw new ConnectException("Failed to connect to host " + targetServer + " on port " + request.getPortNumber()); } PrintWriter pWriter = new PrintWriter(socket.getOutputStream(), true); pWriter.println(TERMINATE_TELNET + CRLF); pWriter.flush(); pWriter.close(); response.setRequestStatus(AgentStatus.SUCCESS); response.setResponseData("Telnet connection to " + targetServer + " on port " + request.getPortNumber() + " successful."); } catch (ConnectException cx) { response.setRequestStatus(AgentStatus.FAILURE); response.setResponseData("Telnet connection to " + targetServer + " on port " + request.getPortNumber() + " failed with message: " + cx.getMessage()); } } break; case PROCESSLIST: sourceFile = scriptConfig.getScripts().get("processList"); if (DEBUG) { DEBUGGER.debug("sourceFile: {}", sourceFile); } if (!(sourceFile.canExecute())) { throw new ServiceCheckException( "Script file either does not exist or cannot be executed. Cannot continue."); } command = CommandLine.parse(sourceFile.getAbsolutePath()); if (request.getPortNumber() != 0) { command.addArgument(String.valueOf(request.getPortNumber()), true); } if (DEBUG) { DEBUGGER.debug("CommandLine: {}", command); } outputStream = new ByteArrayOutputStream(); streamHandler = new PumpStreamHandler(outputStream); executor.setWatchdog(watchdog); executor.setStreamHandler(streamHandler); if (DEBUG) { DEBUGGER.debug("ExecuteStreamHandler: {}", streamHandler); DEBUGGER.debug("ExecuteWatchdog: {}", watchdog); DEBUGGER.debug("DefaultExecuteResultHandler: {}", resultHandler); DEBUGGER.debug("DefaultExecutor: {}", executor); } executor.execute(command, resultHandler); resultHandler.waitFor(); exitCode = resultHandler.getExitValue(); if (DEBUG) { DEBUGGER.debug("exitCode: {}", exitCode); } writer = new BufferedWriter(new FileWriter(LOGS_DIRECTORY + "/" + sourceFile.getName() + ".log")); writer.write(outputStream.toString()); writer.flush(); response.setResponseData(outputStream.toString()); if (executor.isFailure(exitCode)) { response.setRequestStatus(AgentStatus.FAILURE); } else { response.setRequestStatus(AgentStatus.SUCCESS); } break; default: // unknown operation throw new ServiceCheckException("No valid operation was specified"); } } catch (UnknownHostException uhx) { ERROR_RECORDER.error(uhx.getMessage(), uhx); throw new ServiceCheckException(uhx.getMessage(), uhx); } catch (SocketException sx) { ERROR_RECORDER.error(sx.getMessage(), sx); throw new ServiceCheckException(sx.getMessage(), sx); } catch (IOException iox) { ERROR_RECORDER.error(iox.getMessage(), iox); throw new ServiceCheckException(iox.getMessage(), iox); } catch (InterruptedException ix) { ERROR_RECORDER.error(ix.getMessage(), ix); throw new ServiceCheckException(ix.getMessage(), ix); } finally { try { if (writer != null) { writer.close(); } if ((socket != null) && (!(socket.isClosed()))) { socket.close(); } } catch (IOException iox) { ERROR_RECORDER.error(iox.getMessage(), iox); } } return response; }
From source file:com.piketec.jenkins.plugins.tpt.TptPluginMasterJobExecutor.java
/** * It binds to the Tpt Api , check if the given Execution Configuration exists. Prepares the test- * and data-directories. Then it split all the test cases (the currently set test set or the * explicitly given test set) in smaller chunks of tests cases, then creates the workloads for the * slaves. After that by calling the retryable job , it schedules the builds for the slaves. Then * it joins all the threads from the slaves, collect the results and regenerate a new Overview * report with the data from the slaves. It publishes the Junit XML if configured and resets the * temporary settings to the original values. * //from w ww .ja v a 2 s. c o m * @return true if the execution from slaves and master were successful. */ boolean execute() { TptApi api = null; boolean success = true; try { api = Utils.getTptApi(build, launcher, logger, exePaths, tptPort, tptBindingName, tptStartupWaitTime); if (api == null) { return false; } for (JenkinsConfiguration ec : executionConfigs) { success &= executeOneConfig(ec, api); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.interrupt(e.getMessage()); return false; } finally { logger.info("Close open TPT project on master and slaves."); if (!CleanUpTask.cleanUp(build)) { logger.error("Could not close all open TPT files. " + "There is no guarantee next run will be be done with correct file version."); return false; } } return success; }
From source file:com.ottogroup.bi.spqr.pipeline.component.operator.DelayedResponseOperatorRuntimeEnvironment.java
/** * @see java.lang.Runnable#run()/* www .j a v a 2 s. com*/ */ public void run() { while (running) { try { StreamingDataMessage message = this.consumerQueueWaitStrategy.waitFor(this.queueConsumer); // this.queueConsumer.next(); if (message != null && message.getBody() != null) { // forward retrieved message to operator for further processing this.delayedResponseOperator.onMessage(message); // notify response wait strategy on retrieved message this.responseWaitStrategy.onMessage(message); if (this.messageCounter != null) this.messageCounter.inc(); } } catch (InterruptedException e) { // do nothing - waiting was interrupted } catch (Exception e) { logger.error("processing error [node=" + this.processingNodeId + ", pipeline=" + this.pipelineId + ", operator=" + this.operatorId + "]: " + e.getMessage(), e); // TODO add handler for responding to errors } } }
From source file:com.baifendian.swordfish.masterserver.quartz.FlowScheduleJob.java
/** * ?????/*from w w w. ja v a 2 s .c o m*/ */ private boolean checkWorkflowDep(int flowId, CronExpression cronExpression, Date fireTime, Date scheduleFireTime, int timeout) { while (true) { ExecutionFlow executionFlow = getLastExecFlow(flowId, cronExpression, scheduleFireTime); // ?? boolean isNotFinished = false; if (executionFlow != null) { // ???? FlowStatus flowStatus = executionFlow.getStatus(); if (flowStatus != null && flowStatus.typeIsSuccess()) { return true; } else if (flowStatus == null || flowStatus.typeIsNotFinished()) { isNotFinished = true; } } else { // ???? isNotFinished = true; } if (isNotFinished) { // ?, if (checkTimeout(fireTime.getTime(), timeout)) { logger.error("Wait for dependence workflow timeout"); return false; } try { Thread.sleep(checkInterval); } catch (InterruptedException e) { logger.error(e.getMessage(), e); return false; } } else { // ?, return false; } } }
From source file:com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.java
@Override public void run() { LOG.info(String.format("Started Stream Monitor for %s", config.getStreamName())); DateTime lastShardCapacityRefreshTime = new DateTime(System.currentTimeMillis()); // create a StreamMetricManager object StreamMetricManager metricManager = new StreamMetricManager(this.config.getStreamName(), this.config.getScaleOnOperations(), this.cloudWatchClient, this.kinesisClient); try {/*from www . j av a2s. c om*/ // load the current configured max capacity metricManager.loadMaxCapacity(); // configure the duration to request from cloudwatch int cwSampleDuration = Math.max(config.getScaleUp().getScaleAfterMins(), config.getScaleDown().getScaleAfterMins()); ScalingOperationReport report = null; do { DateTime now = new DateTime(System.currentTimeMillis()); DateTime metricEndTime = now; // fetch only the last N minutes metrics DateTime metricStartTime = metricEndTime.minusMinutes(cwSampleDuration); // load the current cloudwatch metrics for the stream via the // metrics manager @SuppressWarnings("rawtypes") Map currentUtilisationMetrics = metricManager.queryCurrentUtilisationMetrics(cwSampleDuration, metricStartTime, metricEndTime); // process the aggregated set of Cloudwatch Datapoints report = processCloudwatchMetrics(currentUtilisationMetrics, metricManager.getStreamMaxCapacity(), cwSampleDuration, now); if (report != null) { // refresh the current max capacity after the // modification metricManager.loadMaxCapacity(); lastShardCapacityRefreshTime = now; // notify all report listeners that we've completed a // scaling operation if (this.config.getScalingOperationReportListener() != null) { this.config.getScalingOperationReportListener().onReport(report); } if (report.getScaleDirection() != ScaleDirection.NONE) { LOG.info(report.toString()); } report = null; } // refresh shard stats every configured period, in case someone // has manually updated the number of shards manually if (now.minusMinutes(this.config.getRefreshShardsNumberAfterMin()) .isAfter(lastShardCapacityRefreshTime)) { metricManager.loadMaxCapacity(); lastShardCapacityRefreshTime = now; } try { LOG.debug("Sleep"); Thread.sleep(this.config.getCheckInterval() * 1000); } catch (InterruptedException e) { LOG.error(e.getMessage(), e); break; } } while (keepRunning); LOG.info(String.format("Stream Monitor for %s in %s Completed. Exiting.", this.config.getStreamName(), this.config.getRegion())); } catch (Exception e) { this.exception = e; } }
From source file:com.openmeap.model.ModelServiceImpl.java
@Override public <T extends ModelEntity> void refresh(T entity) throws PersistenceException { int numRetries = numberOfRefreshRetries; boolean notSuccessful = false; do {/*from w w w .j a v a2 s . com*/ try { if (entity != null) { this._refresh(entity); } } catch (Exception e) { Throwable t = ExceptionUtils.getRootCause(e); if (!(t instanceof SQLException)) { throw new PersistenceException(e); } logger.warn("Unable to refresh model entity, " + numRetries + " left. " + t.getMessage()); numRetries--; notSuccessful = true; try { Thread.sleep(refreshRetryInterval); } catch (InterruptedException e1) { throw new PersistenceException( "Thread sleep interrupted during the refresh retry interval: " + e1.getMessage(), e1); } } } while (notSuccessful && numRetries != 0); if (numRetries == 0) { throw new PersistenceException( "Unable to refresh model entity. " + numberOfRefreshRetries + " retries failed"); } }
From source file:com.amazonaws.http.HttpClient.java
/** * Exponential sleep on failed request to avoid flooding a service with * retries./*from w ww. j av a 2 s. c om*/ * * @param retries * Current retry count. * @param previousException * Exception information for the previous attempt, if any. */ private void pauseExponentially(int retries, AmazonServiceException previousException) { long scaleFactor = 300; if (isThrottlingException(previousException)) { scaleFactor = 500 + random.nextInt(100); } long delay = (long) (Math.pow(2, retries) * scaleFactor); delay = Math.min(delay, MAX_BACKOFF_IN_MILLISECONDS); log.debug("Retriable error detected, will retry in " + delay + "ms, attempt number: " + retries); try { Thread.sleep(delay); } catch (InterruptedException e) { throw new AmazonClientException(e.getMessage(), e); } }
From source file:com.fredhopper.core.connector.index.upload.impl.DefaultPublishingService.java
@Override public boolean publishZip(final InstanceConfig config, final File file) { try {/* w ww. java2s . co m*/ LOG.info("Uploading zip file to Fredhopper"); final String dataId = publishingStrategy.uploadDataSet(config, file); LOG.info("Triggering an index update '" + dataId + "'"); final URI triggerUrl = publishingStrategy.triggerDataLoad(config, dataId); LOG.info("Checking index update status..."); String status = publishingStrategy.checkStatus(config, triggerUrl); while (!status.contains("SUCCESS") && !status.contains("FAILURE")) { try { Thread.sleep(20000); status = publishingStrategy.checkStatus(config, triggerUrl); } catch (final InterruptedException ex) { LOG.error("The status check thread was interrupted while sleeping.", ex); Thread.currentThread().interrupt(); } } if (status.contains("SUCCESS")) { LOG.info("Index updated successfully."); return true; } else { LOG.error(status); } } catch (final ResponseStatusException ex) { LOG.error(ex.getMessage()); } return false; }