List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.zte.ums.zenap.itm.agent.plugin.linux.util.cli.TelnetSession.java
@Override protected String waitfor(String s) throws IOException { boolean flag = false; if (s.length() != 0) scriptHandler.setup(s);/*ww w. j av a 2 s .co m*/ else throw new IOException(" prompt may be empty"); byte abyte0[] = new byte[readBufferLength]; int i = 0; String s1 = ""; log("Parameter to match:" + s); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < timeout) { if (getInputStream().available() > 0) { try { i = getInputStream().read(abyte0); log("Message rcvd:" + new String(abyte0)); } catch (InterruptedIOException interruptedioexception) { if (i > 0) s1 = s1 + new String(abyte0, 0, i); if (!cmdEcho || !promptEcho) s1 = truncateResponse(s1); if (flag) { return s1; } else { partialData = s1; throw new IOException(interruptedioexception.getMessage()); } } s1 = s1 + new String(abyte0, 0, i, "UTF-8"); if (scriptHandler.match(s1, s)) { log("Parameter match SUCCESSFUL:" + s); partialData = null; if (getInputStream().available() > 0) { flag = true; } else { if (!cmdEcho || !promptEcho) s1 = truncateResponse(s1); return s1; } } } else { try { Thread.sleep(500); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } } } return null; }
From source file:de.hybris.platform.catalog.job.strategy.impl.AbstractRemoveStrategy.java
/** * Starts catalog version removal , returns true if wait for started import job needed *//* ww w . jav a 2s. co m*/ protected void removeCatalogVersionCollection(final Collection<CatalogVersionModel> catalogVersions, final RemoveCatalogVersionCronJobModel cronJob, final List<ComposedTypeModel> orderedComposedTypes) { ImportResult result = null; StringBuilder buffer = null; try { removeCallback.beforeRemove(cronJob, catalogVersions); for (final CatalogVersionModel catalogVersionModel : catalogVersions) { final int countBefore = catalogVersionDao.getItemInstanceCount(catalogVersionModel, orderedComposedTypes); if (countBefore > 0) { if (buffer == null) { buffer = new StringBuilder(1000); } buffer.append(removeScriptGenerator.generate(catalogVersionModel, orderedComposedTypes)); if (LOG.isDebugEnabled()) { LOG.debug("Generated script [" + CharUtils.LF + buffer.toString() + CharUtils.LF + "] for removing " + countBefore + " items from catalogversion " + catalogVersionModel); } } } if (buffer != null) { LOG.info("Starting impex based removing of the catalogversions " + catalogVersions); try { final ImportConfig config = getImpexConfig(buffer); result = importService.importData(config); //this code is because result seemed to be isRuninng = false //Thread.sleep(POLL_PERIOD);//sleep LOG.info(" Import is running " + result.isRunning() + " finished " + result.isFinished() + " status " + result.getCronJob().getStatus() + " cronjob " + result.getCronJob().getCode()); while (result.isRunning() && result.getCronJob() != null) { //this is only for presenting the progress to outside removeCallback.doRemove(cronJob, catalogVersions, result); Thread.sleep(POLL_PERIOD);//sleep if (result.getCronJob() != null) { modelService.refresh(result.getCronJob()); } } } catch (final InterruptedException e) { LOG.error("Current thread " + Thread.currentThread() + " was interrupted with message " + e.getMessage() + ", please set log level to debug for more details"); if (LOG.isDebugEnabled()) { LOG.error(e.getMessage(), e); } Thread.currentThread().interrupt(); } catch (final Exception e) { LOG.error(e.getMessage(), e); } } } finally { removeCallback.afterRemoved(cronJob, catalogVersions, result); if (result != null) { if (LOG.isDebugEnabled()) { LOG.debug("After job finished with result, unresolved lines " + result.hasUnresolvedLines() + ", is finished :" + result.isFinished() + ", is running :" + result.isRunning()); } } } }
From source file:com.ebay.jetstream.event.processor.esper.ESPTest.java
public void testProcessor() { EsperProcessor processor = getProcessor("ESPTestProcessor"); ESPTestSink sink = new ESPTestSink(); List<EventSink> sinks = new ArrayList<EventSink>(); sinks.add(sink);/*from w ww.java2 s. c o m*/ processor.setEventSinks(sinks); // TODO: start not exposed - processor.start(); // it was stopped while running previous test ExecutorService threadPool = Executors.newCachedThreadPool(new ESPTestThreadFactory()); Runnable runnables[] = new ESPTestRunnable[THREADS_NUM]; try { for (int i = 0; i < THREADS_NUM; i++) { runnables[i] = new ESPTestRunnable(processor, i); threadPool.submit(runnables[i]); } threadPool.shutdown(); threadPool.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { fail("InterruptedException: " + e.getMessage()); } assertTrue("ExecutorService failed to shut down properly", threadPool.isShutdown()); // processor.stop(); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertEquals(THREADS_NUM, sink.getCount()); testLogger.info("sink first, last = [" + sink.getIds().first() + "," + sink.getIds().last() + "]"); }
From source file:com.aliyun.oss.common.comm.ServiceClient.java
private void pause(int retries, RetryStrategy retryStrategy) throws ClientException { long delay = retryStrategy.getPauseDelay(retries); getLogger().debug("An retriable error request will be retried after " + delay + "(ms) with attempt times: " + retries);/*from www. j a v a 2 s .co m*/ try { Thread.sleep(delay); } catch (InterruptedException e) { throw new ClientException(e.getMessage(), e); } }
From source file:org.openbaton.autoscaling.core.features.pool.PoolManagement.java
@Async public Future<Boolean> stopPoolCheck(String nsr_id) { log.debug("Deactivating Pool size checking for NSR with id: " + nsr_id); if (poolTasks.containsKey(nsr_id)) { poolTasks.get(nsr_id).cancel(false); int i = 60; while (!actionMonitor.isTerminated(nsr_id) && actionMonitor.getAction(nsr_id) != Action.INACTIVE && i >= 0) {/*from w w w. ja v a2s. c o m*/ actionMonitor.terminate(nsr_id); log.debug("Waiting for finishing gracefully PoolTask for NSR with id: " + nsr_id + " (" + i + "s)"); log.debug(actionMonitor.toString()); try { Thread.sleep(1000); } catch (InterruptedException e) { log.error(e.getMessage(), e); } i--; if (i <= 0) { actionMonitor.removeId(nsr_id); log.error("Forced deactivation of poolTask for NSR with id: " + nsr_id); poolTasks.get(nsr_id).cancel(true); poolTasks.remove(nsr_id); return new AsyncResult<>(false); } } poolTasks.remove(nsr_id); actionMonitor.removeId(nsr_id); log.debug("Deactivated Pool size checking for NSR with id: " + nsr_id); } else { log.debug("Not Found PoolTask for NSR with id: " + nsr_id); } return new AsyncResult<>(true); }
From source file:au.org.ala.layers.stats.ObjectsStatsGenerator.java
@Override public void run() { try {//from ww w . ja v a 2 s . c om while (true) { try { String[] data = lbq.take(); String sql = "SELECT ST_AsText(ST_EXTENT(the_geom)) as bbox from objects where pid = '" + data[0] + "';"; ResultSet rs = s.executeQuery(sql); String bbox = ""; while (rs.next()) { bbox = rs.getString("bbox"); } sql = "UPDATE objects set bbox = '" + bbox + "' where pid = '" + data[0] + "';"; int update = s.executeUpdate(sql); } catch (InterruptedException e) { break; } catch (Exception e) { s.cancel(); logger.error(e.getMessage(), e); } cdl.countDown(); } } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:com.npower.dm.setup.task.DeviceGeneratorTask.java
@Override protected void process() throws SetupException { int totalThread = this.getTotalThread(); this.getSetup().getConsole().println("Starting total thread: " + totalThread); try {//from w w w.jav a2s . com ThreadGroup group = new ThreadGroup(this.getClass().getName()); List<Thread> threads = new ArrayList<Thread>(); for (int i = 0; i < totalThread; i++) { TaskThread runnable = new TaskThread(this); Thread t = new Thread(group, runnable, "Thread#" + i); threads.add(t); t.start(); this.getSetup().getConsole().println("Started thread: " + t.getName()); } /* try { Thread.sleep(1000 * 3600 * 12); } catch (InterruptedException e) { e.printStackTrace(); } */ for (Thread t : threads) { t.join(); } } catch (InterruptedException e) { throw new SetupException(e.getMessage(), e); } this.getSetup().getConsole().println("All of thread finished."); }
From source file:edu.harvard.i2b2.im.ws.IMService.java
private OMElement execute(RequestHandler handler, long waitTime) throws I2B2Exception { //do workplace processing inside thread, so that // service could send back message with timeout error. log.debug("In execute"); OMElement returnElement = null;/*from w ww .j ava 2s . c o m*/ String unknownErrorMessage = "Error message delivered from the remote server \n" + "You may wish to retry your last action"; ExecutorRunnable er = new ExecutorRunnable(); er.setRequestHandler(handler); Thread t = new Thread(er); String workplaceDataResponse = null; synchronized (t) { t.start(); // try { // if (waitTime > 0) { // t.wait(waitTime); // } else { // t.wait(); // } try { 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(); } } workplaceDataResponse = er.getOutputString(); if (workplaceDataResponse == null) { if (er.getJobException() != null) { log.error("er.jobException is " + er.getJobException().getMessage()); log.info("waitTime is " + waitTime); ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null, unknownErrorMessage); workplaceDataResponse = MessageFactory.convertToXMLString(responseMsgType); } else if (er.isJobCompleteFlag() == false) { //<result_waittime_ms>5000</result_waittime_ms> String timeOuterror = "Remote server timed out \n" + "Result waittime = " + waitTime + " ms elapsed,\nPlease try again"; log.error(timeOuterror); log.debug( "im waited " + deltaTime + "ms for " + er.getRequestHandler().getClass().getName()); ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null, timeOuterror); workplaceDataResponse = MessageFactory.convertToXMLString(responseMsgType); } else { log.error("im data response is null"); log.info("waitTime is " + waitTime); log.debug( "im waited " + deltaTime + "ms for " + er.getRequestHandler().getClass().getName()); ResponseMessageType responseMsgType = MessageFactory.doBuildErrorResponse(null, unknownErrorMessage); workplaceDataResponse = MessageFactory.convertToXMLString(responseMsgType); } } } catch (InterruptedException e) { log.error(e.getMessage()); throw new I2B2Exception("Thread error while running IM job "); } finally { t.interrupt(); er = null; t = null; } } returnElement = MessageFactory.createResponseOMElementFromString(workplaceDataResponse); return returnElement; }
From source file:co.turnus.analysis.buffers.util.AbstractTraceCutScheduler.java
private BuffersData quickCutSchedule() { // start the progress monitor ProgressTheadPrinter pPrinter = new ProgressTheadPrinter( "Trace Graph post-processing, heuristic " + heuristic + ", iteration " + iteration, traceLength); pPrinter.start();/*from www . j a v a 2 s . c o m*/ ArrayList<Step> predictionWindow = new ArrayList<Step>(); // start the algorithm for (long id = 0; id < traceLength; id++) { Step step = trace.getStep(id); predictionWindow.add(step); if (predictionWindow.size() == maxSteps) { for (Step s : getNextSteps(predictionWindow)) { fire(s); predictionWindow.remove(s); pPrinter.increment(); } } } // fire the remaining steps while (firings < traceLength) { for (Step s : getNextSteps(predictionWindow)) { fire(s); predictionWindow.remove(s); pPrinter.increment(); } } TurnusLogger.debug("fired steps: " + firings + " of " + traceLength); // stop the progress monitor try { pPrinter.finish(); pPrinter.join(); } catch (InterruptedException e) { TurnusLogger.warning("Progress monitor stopping error: " + e.getMessage()); } if (firings > traceLength) { throw new TurnusRuntimeException("The number of firings is bigger then the trace size!"); } boolean deadlockFree = firings == traceLength; if (!deadlockFree) { TurnusLogger.warning("Infeasible configuration:" + "deadlock free not guaranteed!!"); } return collectResults(deadlockFree); }
From source file:com.sec.ose.osi.thread.job.analysis.AnalyzeExecutionThread.java
@Override public String doInBackground() throws InterruptedIOException { try {/*from w ww . j a va 2 s. c om*/ for (OSIProjectInfo projectInfo : projectList) { projectName = projectInfo.getProjectName(); mediator.setProjectAnalysisStatus(projectName, ProjectAnalysisInfo.STATUS_PROCESSING); projectID = SDKInterfaceImpl.getInstance().getProjectID(projectName); log.debug("Analysis ProjectName : " + projectName + " , projectID : " + projectID); mediator.setStatusText("Checking " + projectName + " Directory ..."); if (checkTargetDirChanged(projectInfo)) { totalFileCnt = projectInfo.getTotalFileCount() + 2; // add 1 for Root Directory , add 1 for Finish setProgress(0); mediator.setStatusText("Analyzing " + projectName + " ..."); mediator.setProgressBarVisible(true); publish("<-- Start to analyze Project [" + projectName + "] total " + totalFileCnt + " files -->"); } else { mediator.setProjectAnalysisStatus(projectName, ProjectAnalysisInfo.STATUS_COMPLETE); publish("<-- Project [" + projectName + "] is not Changed -->"); continue; } IdentifiedController.setProjectStatus(projectName, AnalysisMonitorThread.STATUS_EXECUTING); ProjectAPIWrapper.analyzeProject(projectID); publish("Start assessing " + projectInfo.getSourcePath()); publish("Analyzing project " + projectName + " (" + projectID + ")"); int totalFileCount = -1; AnalysisPhase prePhase = null; int PrePhasePercent = -1; int curProgress = 0; boolean finished = false; while (!finished) { try { Thread.sleep(100); } catch (InterruptedException e) { System.err.println(e.getMessage()); } try { // TODO: if Source Location is changed, then have to change "AnalysisSourceLocation" AnalysisStatus status = ProtexSDKAPIManager.getProjectAPI().getAnalysisStatus(projectID); AnalysisPhase currPhase = status.getAnalysisPhase(); int currPhasePercent = status.getCurrentPhasePercentCompleted(); if (prePhase != currPhase || PrePhasePercent != currPhasePercent) { mediator.setStatusText(currPhase + " (" + currPhasePercent + "%)"); if (currPhase == AnalysisPhase.INITIALIZING || currPhase == AnalysisPhase.ASSESSING) { } else if (currPhase == AnalysisPhase.SCANNING) { curProgress = (int) (currPhasePercent * 0.5); if (totalFileCount == -1) { totalFileCount = status.getTotalFileCount(); publish("Files pending identification: " + totalFileCount); } StringBuffer sb = new StringBuffer(); sb.append(currPhase).append(" (").append(currPhasePercent).append("%) - ") .append(status.getCurrentFile()) .append(" (" + status.getAnalyzedFileCount()).append("/") .append(totalFileCount).append(")"); mediator.setStatusText(sb.toString()); } else if (currPhase == AnalysisPhase.ANALYZING) { if (prePhase != AnalysisPhase.SCANNING) { // After Scanning, still 100% curProgress = 50 + (int) (currPhasePercent * 0.5); } } setProgress(curProgress); } prePhase = currPhase; PrePhasePercent = currPhasePercent; finished = status.isFinished(); } catch (SdkFault e) { System.err.println(e.getMessage()); e.printStackTrace(); } } curProgress = 100; setProgress(curProgress); if (finished) { mediator.setStatusText("(" + totalFileCnt + "/" + totalFileCnt + ") " + "analyzed sucessfully and will identify string search automatically."); setProgress(100); IdentifyMediator.getInstance().refreshComboProjectName(projectName); projectInfo.updateAnalysisSuccessInfo(); mediator.setProjectAnalysisStatus(projectName, ProjectAnalysisInfo.STATUS_COMPLETE); IdentifiedController.setProjectStatus(projectName, AnalysisMonitorThread.STATUS_READY); projectInfo.setSourcePathChange(false); publish("<-- Finish project [" + projectName + "] Analyze -->"); log.debug("refesh loaded project START..."); ProjectDiscoveryControllerMap.loadProjectDiscoveryControllerFromProtexServer(projectName, null); CodeTreeAPIWrapper.refreshCodeTree(projectName, null); log.debug("refesh loaded project END..."); mediator.showPopupFrame("Finish project [" + projectName + "] Analyze"); } else { mediator.setProjectAnalysisStatus(projectName, ProjectAnalysisInfo.STATUS_READY); IdentifiedController.setProjectStatus(projectName, AnalysisMonitorThread.STATUS_READY); publish("<-- Error project [" + projectName + "] Analyze -->"); } } } catch (Exception e) { log.warn(e); } return "Analysis Completed"; }