List of usage examples for java.lang InterruptedException toString
public String toString()
From source file:com.mindquarry.desktop.client.dialog.conflict.ContentConflictDialog.java
private void mergeWordDocumentsManually(Status status, String basePath) throws IOException { File localVersion = new File(status.getPath()); File serverVersion = new File(basePath, status.getConflictNew()); log.debug("merge: serverVersion: " + serverVersion); log.debug("merge: localVersion: " + localVersion); // use the correct filename suffix: String suffix = FilenameUtils.getExtension(localVersion.getName()); File tmpServerVersion = File.createTempFile("mindquarry-merge-server", "." + suffix); FileUtils.copyFile(serverVersion, tmpServerVersion); tempFiles.add(tmpServerVersion);//from w w w .j av a2s. c o m mergedVersion = File.createTempFile("mindquarry-merge-local", "." + suffix); FileUtils.copyFile(localVersion, mergedVersion); tempFiles.add(mergedVersion); File tmpScriptFile = File.createTempFile("mindquarry-merge-script", ".js"); tempFiles.add(tmpScriptFile); // // FIXME: delete temp files also in case of 'cancel' // // load script from JAR and save as temp file to avoid path problems: InputStream is = getClass().getResourceAsStream("/scripts/merge-doc.js"); String script = loadInputStream(is); FileWriter fw = new FileWriter(tmpScriptFile); fw.write(script); fw.close(); String mergeScript = tmpScriptFile.getAbsolutePath(); String[] cmdArray = new String[] { "wscript", mergeScript, mergedVersion.getAbsolutePath(), tmpServerVersion.getAbsolutePath() }; log.debug("Calling merge script: " + Arrays.toString(cmdArray)); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(cmdArray); int exitValue = -1; try { exitValue = proc.waitFor(); } catch (InterruptedException e) { throw new RuntimeException(e.toString(), e); } log.debug("Exit value " + exitValue); if (exitValue != 0) { mergeOptionButton.setEnabled(false); mergeButton.setEnabled(false); okButton.setEnabled(true); // let user continue with other option MessageDialog .openError( getShell(), I18N.getString("Error executing MS Word"), I18N .getString("The script used to merge documents " + "using MS Word could not be started. The exit " + "code was ") + exitValue); } }
From source file:org.openhab.binding.stiebelheatpump.internal.StiebelHeatPumpBinding.java
/** * @{inheritDoc/* ww w.j a va 2 s .c o m*/ */ @Override protected void internalReceiveCommand(String itemName, Command command) { logger.debug("Received command {} for item {}", command, itemName); int retry = 0; while (communicationInUse & (retry < DEFAULT_SERIAL_TIMEOUT)) { try { Thread.sleep(CommunicationService.WAITING_TIME_BETWEEN_REQUESTS); } catch (InterruptedException e) { logger.debug("Could not get access to heatpump ! : {}", e.toString()); } retry++; } if (communicationInUse) { return; } for (StiebelHeatPumpBindingProvider provider : providers) { for (String name : provider.getItemNames()) { if (!name.equals(itemName)) { continue; } String parameter = provider.getParameter(name); logger.debug("Found item {} with heat pump parameter {} in providers", itemName, parameter); try { Map<String, String> data = new HashMap<String, String>(); communicationInUse = true; CommunicationService communicationService = new CommunicationService(connector, heatPumpConfiguration); data = communicationService.setData(command.toString(), parameter); communicationService.finalizer(); publishValues(data); } catch (StiebelHeatPumpException e) { logger.error("Could not set new value!"); } finally { communicationInUse = false; } } } }
From source file:com.github.stephanarts.cas.ticket.registry.support.JSONRPCServer.java
/** * Close.//from www.j a v a 2 s . c o m */ public final void cleanup() { this.interrupt(); try { this.join(); } catch (final InterruptedException e) { // It's fine if join throws an InterruptedException logger.debug(e.toString()); } }
From source file:com.grendelscan.ui.MainWindow.java
public Listener getCloseListener() { Listener l = new Listener() { @Override//from w ww . ja va 2 s.c o m public void handleEvent(final Event event) { event.doit = false; if (promptExit()) { exiting = true; Scan.getInstance().shutdown("Exit requested"); // synchronized(this) { while (!Scan.getInstance().isShutdownComplete()) { try { Thread.sleep(100); } catch (InterruptedException e) { LOGGER.debug("Scan shutdown interupted: " + e.toString(), e); break; } } } event.doit = true; } } }; return l; }
From source file:org.kuali.test.runner.execution.TestExecutionParameterOperationExecution.java
/** * /*from www.j av a 2 s .c o m*/ * @param configuration * @param platform * @param testWrapper * @throws TestException */ @Override public void execute(KualiTestConfigurationDocument.KualiTestConfiguration configuration, Platform platform, KualiTestWrapper testWrapper) throws TestException { String key = Utils .buildCheckpointPropertyKey(getOperation().getTestExecutionParameter().getValueProperty()); TestExecutionContext tec = getTestExecutionContext(); tec.setCurrentOperationIndex(Integer.valueOf(getOperation().getIndex())); tec.setCurrentTest(testWrapper); TestExecutionParameter tep = getOperation().getTestExecutionParameter(); ParameterHandler ph = tec.getParameterHandler(tep.getParameterHandler()); if (StringUtils.isNotBlank(key)) { long start = System.currentTimeMillis(); while (StringUtils.isBlank(getOperation().getTestExecutionParameter().getValue()) && ((System.currentTimeMillis() - start) < Constants.HTML_TEST_RETRY_TIMESPAN) && !tec.isHaltTest()) { Document doc = Utils.cleanHtml(tec.getWebClient().getCurrentWindow().getEnclosedPage() .getWebResponse().getContentAsString()); if (doc != null) { if (ph instanceof SelectEditDocumentLookupHandler) { tep.setValue(ph.getValue(tec, tep, doc, null)); tec.addTestExecutionParameter(tep); } else { CheckpointProperty cpmatch = null; HtmlDomProcessor.DomInformation dominfo = HtmlDomProcessor.getInstance() .processDom(platform, doc); for (CheckpointProperty cp : dominfo.getCheckpointProperties()) { String curkey = Utils.buildCheckpointPropertyKey(cp); if (StringUtils.equals(key, curkey)) { cpmatch = cp; break; } } // if we found a matching html element then set the parameter value if (cpmatch != null) { tep.setValue(ph.getValue(tec, tep, doc, cpmatch)); tec.addTestExecutionParameter(tep); } } } if (StringUtils.isBlank(tep.getValue())) { try { Thread.sleep(Constants.HTML_TEST_RETRY_SLEEP_INTERVAL); } catch (InterruptedException ex) { } try { if (ph.isResubmitRequestAllowed()) { tec.resubmitLastGetRequest(); } } catch (IOException ex) { throw new TestException(ex.toString(), tec.getCurrentTestOperation().getOperation(), ex); } } else { break; } } if (StringUtils.isBlank(tep.getValue())) { throw new TestException("failed to find value for test execution parameter[" + tep.getName() + "]", getOperation(), FailureAction.ERROR_HALT_TEST); } else { String comment = ph.getCommentText(); if (StringUtils.isNotBlank(comment)) { tec.writeCommentEntry(buildCommentOperation(tep.getName(), comment), true); } } } }
From source file:uk.co.modularaudio.util.pooling.common.Pool.java
public void shutdown() { log.trace("Pool shutdown commencing."); // First stop the threads. if (sizingThread != null) { //log.debug( "About to stop pool sizing thread."); sizingThread.halt();/* w ww.j a v a2s. c o m*/ sizingThread.interrupt(); try { sizingThread.join(); } catch (final InterruptedException ie) { if (log.isErrorEnabled()) { log.error("Error joining sizing thread: " + ie.toString()); } } } if (expiryThread != null) { //log.debug( "About to stop pool expiry thread."); expiryThread.halt(); expiryThread.interrupt(); try { expiryThread.join(); } catch (final InterruptedException ie) { if (log.isErrorEnabled()) { log.error("Error joining sizing thread: " + ie.toString()); } } } poolLock.lock(); try { // Get all resources in the pool structure, and // call removeResource on them. final Collection<Resource> allRes = structure.getAllResources(); final Iterator<Resource> iter = allRes.iterator(); while (iter.hasNext()) { final Resource res = iter.next(); removeResource(res); } // We call a notify all on the pool semaphore to wake up any threads waiting // on obtaining a resource. notEmpty.signal(); } finally { poolLock.unlock(); } log.info("Pool shutdown complete."); }
From source file:com.verigreen.common.concurrency.timeboundedexecuter.TimeBoundedExecuter.java
private <T> T loopWhileStillNotFinished(final Action<T> actionDelegate, long timeBoundInMillis, Future<T> future, TimeBoundedPolicy policy) { int times = 1; while (true) { try {/*from w w w .jav a2 s . co m*/ return future.get(timeBoundInMillis, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { // was interrupted; should cancel the execution. future.cancel(true); throw new CancellationException(); } catch (ExecutionException e) { // execution ended with an exception. _logger.error("Catastrophic failure when executing a TimeBoundedThread! Exception details: " + e.toString(), e); throw new RuntimeException(e); } catch (TimeoutException e) { // timed out reportAndActAccordingToTimeoutOption(actionDelegate, timeBoundInMillis, future, times, policy); times += 1; } catch (CancellationException e) { // was canceled throw e; } } }
From source file:org.apache.hadoop.registry.server.services.RegistryAdminService.java
/** * Create the home path for a user if it does not exist. * * This uses {@link #initUserRegistryAsync(String)} and then waits for the * result ... the code path is the same as the async operation; this just * picks up and relays/converts exceptions * @param username username/*from w w w . ja va 2 s . c o m*/ * @return the path created * @throws IOException any failure * */ public String initUserRegistry(final String username) throws IOException { try { Future<Boolean> future = initUserRegistryAsync(username); future.get(); } catch (InterruptedException e) { throw (InterruptedIOException) (new InterruptedIOException(e.toString()).initCause(e)); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) (cause); } else { throw new IOException(cause.toString(), cause); } } return homeDir(username); }
From source file:ffx.numerics.fft.Complex3DCuda.java
/** * Notify the CUDA thread and then wait until the requested operation * completes.//from w ww. j a v a 2s . c o m * * @return Returns 0 upon success. */ private int execute() { // Notify the CUDA thread and then wait until it notifies us back. synchronized (this) { notify(); while (mode != null) { try { wait(); } catch (InterruptedException e) { logger.severe(e.toString()); } } } return 0; }
From source file:ffx.numerics.fft.Complex3DCuda.java
/** * Blocking free method.//from w w w. j a v a 2 s . c o m * * @return A status flag (0 for success, -1 for failure). */ public int free() { if (dead || mode != null) { return -1; } free = true; // Notify the CUDA thread and then block until it notifies us back. synchronized (this) { notify(); while (!dead) { try { wait(); } catch (InterruptedException e) { logger.severe(e.toString()); } } } return 0; }