List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.github.ukase.web.UkaseController.java
@ExceptionHandler(InterruptedException.class) @ResponseBody//from www .j a v a 2 s.c o m public ResponseEntity<ExceptionMessage> handleInterruptedException(InterruptedException e) { HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR; ExceptionMessage message = new ExceptionMessage(e.getMessage(), status.value()); log.warn("Interrupted: {}", message); return new ResponseEntity<>(message, status); }
From source file:org.openbaton.autoscaling.core.detection.DetectionManagement.java
@Async public Future<Boolean> stop(String nsr_id, String vnfr_id, AutoScalePolicy autoScalePolicy) { log.debug("Deactivating Alarm Detection for AutoScalePolicy with id: " + autoScalePolicy.getId() + " for VNFR with id" + vnfr_id); if (detectionTasks.containsKey(nsr_id)) { if (detectionTasks.get(nsr_id).containsKey(vnfr_id)) { if (detectionTasks.get(nsr_id).get(vnfr_id).containsKey(autoScalePolicy.getId())) { detectionTasks.get(nsr_id).get(vnfr_id).get(autoScalePolicy.getId()).cancel(false); int i = 30; while (!actionMonitor.isTerminated(autoScalePolicy.getId()) && actionMonitor.getAction(autoScalePolicy.getId()) != Action.INACTIVE && i >= 0) { actionMonitor.terminate(autoScalePolicy.getId()); log.debug("Waiting for finishing DetectionTask for AutoScalePolicy with id: " + autoScalePolicy.getId() + " of VNFR with id: " + vnfr_id); log.debug("Waiting for finishing ExecutionTask/Cooldown for VNFR with id: " + vnfr_id + " (" + i + "s)"); log.debug(actionMonitor.toString()); if (i <= 0) { log.error("Forced deactivation of DetectionTask for AutoScalePolicy with id: " + autoScalePolicy.getId()); detectionTasks.get(nsr_id).get(vnfr_id).get(autoScalePolicy.getId()).cancel(true); detectionTasks.get(nsr_id).get(vnfr_id).remove(autoScalePolicy.getId()); actionMonitor.removeId(vnfr_id); return new AsyncResult<>(false); }/*from www . j ava2 s .c o m*/ try { Thread.sleep(1_000); } catch (InterruptedException e) { log.error(e.getMessage(), e); } i--; } actionMonitor.removeId(vnfr_id); detectionTasks.get(nsr_id).get(vnfr_id).remove(autoScalePolicy.getId()); log.debug("Deactivated Alarm Detection for AutoScalePolicy with id: " + autoScalePolicy.getId() + " of VNFR with id: " + vnfr_id + " of NSR with id: " + nsr_id); } else { log.debug("Not Found DetectionTask for AutoScalePolicy with id: " + autoScalePolicy.getId() + " of VNFR with id: " + vnfr_id + " of NSR with id: " + nsr_id); } } else { log.debug( "Not Found any DetectionTasks for VNFR with id: " + vnfr_id + " of NSR with id: " + nsr_id); } } else { log.debug("Not Found any DetectionTasks for NSR with id: " + nsr_id); } return new AsyncResult<>(true); }
From source file:org.codice.pubsub.server.SubscriptionServer.java
private void processSubscriptions() { while (!Thread.currentThread().isInterrupted()) { //Fetch Subscriptions Dictionary subMap = getSubscriptionMap(); if (subMap != null) { Enumeration e = subMap.keys(); while (e.hasMoreElements()) { String subscriptionId = (String) e.nextElement(); if (!subscriptionId.equals("service.pid")) { String subscriptionMsg = (String) subMap.get(subscriptionId); int status = checkProcessingStatus(subscriptionId); if (status == PROCESS_STATUS_COMPLETE) { Future<QueryControlInfo> future = processMap.get(subscriptionId); if (future != null) { boolean done = future.isDone(); if (done) { try { QueryControlInfo ctrlInfo = future.get(); processMap.remove(subscriptionId); runQuery(subscriptionMsg, ctrlInfo.getQueryEndDateTime()); } catch (InterruptedException ie) { LOGGER.error(ie.getMessage()); } catch (ExecutionException ee) { LOGGER.error(ee.getMessage()); }/*from w w w . ja v a 2 s . c o m*/ } } } else if (status == PROCESS_STATUS_NOT_EXIST) { runQuery(subscriptionMsg, new DateTime().minusSeconds(1)); } else if (status == PROCESS_STATUS_NOT_EXIST) { //Do Nothing For Now } } } } else { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
From source file:com.chess.genesis.net.SyncClient.java
private void trylock() { try {/*ww w .j a v a2 s. com*/ lock++; while (lock > 0 && !error) Thread.sleep(16); lock = 0; } catch (final InterruptedException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:fr.aliasource.webmail.proxy.impl.FolderServiceImpl.java
@Override public void unSubscribeFolder(IFolder folder) { List<IFolder> toUnsubscribed = new ArrayList<IFolder>(); toUnsubscribed.addAll(getChilds(folder)); for (IFolder f : toUnsubscribed) { template.update(f, new FolderServiceCallBack() { @Override/*from ww w.j ava 2 s . com*/ public void execute(IStoreConnection connection, IFolder f) throws IOException, StoreException { connection.unsubscribe(f.getName()); } }); try { deleteFromConversationCache(f); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } } }
From source file:ch.epfl.eagle.api.EagleFrontendClient.java
public boolean submitRequest(TSchedulingRequest request) { try {/*w w w. ja v a 2s . co m*/ Client client = clients.take(); client.submitJob(request); clients.put(client); } catch (InterruptedException e) { LOG.fatal(e); } catch (IncompleteRequestException e) { LOG.error(e); } catch (TException e) { LOG.error("Thrift exception when submitting job: " + e.getMessage()); return false; } return true; }
From source file:com.bt.aloha.collections.memory.InMemoryCollectionImpl.java
public T get(String infoId) { if (infoId == null) throw new IllegalArgumentException("Info id must not be null"); Semaphore semaphore = getSemaphores().get(infoId); if (semaphore == null) { log.debug(String.format("No info object for %s in %s, returning null ", infoId, this.getClass().getSimpleName())); return null; }/*from w w w . ja va 2s . c o m*/ // log.debug("semaphores.size: " + getSemaphores().size()); // log.debug("infos.size: " + infos.size()); // log.debug("semaphore: " + semaphore.toString()); try { semaphore.acquire(); } catch (InterruptedException e) { log.error(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(), e.getMessage())); throw new CollectionAccessInterruptedException(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(), e.getMessage()), e); } try { if (infos.containsKey(infoId)) { T result = (T) infos.get(infoId).cloneObject(); log.debug(String.format("Retrieved info %s with version %s", infoId, result.getVersionId())); return (T) result; } log.debug(String.format("No info object for %s in %s, returning null ", infoId, this.getClass().getSimpleName())); return null; } finally { semaphore.release(); } }
From source file:com.flipkart.flux.deploymentunit.ExecutableRegistryPopulator.java
@Override public void initialize() { //count down latch to parallelly populate executable registry from multiple deployment units CountDownLatch duCountDownLatch = new CountDownLatch(deploymentUnitsMap.size()); //for each deployment unit, start a new thread which populates executable registry for (Map.Entry<String, DeploymentUnit> deploymentUnitEntry : deploymentUnitsMap.entrySet()) { new Thread(new ExecutableRegistryLoader(deploymentUnitEntry.getKey(), deploymentUnitEntry.getValue(), duCountDownLatch)).start(); }//from w ww . j ava 2 s . c o m try { duCountDownLatch.await(); //wait until all deployment units' tasks are loaded into executable registry } catch (InterruptedException e) { LOGGER.error( "Unable to populate executable registry. Deployment unit count down latch has been interrupted. Exception: {}", e.getMessage()); throw new FluxError(FluxError.ErrorType.runtime, "Unable to populate executable registry. Deployment unit count down latch has been interrupted.", e); } }
From source file:com.threewks.thundr.http.service.gae.HttpResponseImpl.java
private HTTPResponse response() { if (response == null) { try {// w w w .ja v a2 s. c o m response = future.get(); headers = buildHeaderMap(response); headersLower = buildHeadersLowerMap(headers); cookies = buildCookieMap(headersLower); return response; } catch (InterruptedException e) { throw new HttpRequestException("Failed to wait for completion of asynchronous request: %s", e.getMessage()); } catch (ExecutionException e) { throw new HttpRequestException(e, "Failed to get result for asynchronous request: %s", e.getMessage()); } } return response; }
From source file:com.bt.aloha.collections.memory.InMemoryCollectionImpl.java
public void replace(T info) { if (info == null) throw new IllegalArgumentException(String.format( "Trying to replace element in collection %s with null info", this.getClass().getSimpleName())); String infoId = info.getId(); log.debug(String.format("InMemoryInfoCollection replacing %s", infoId)); Semaphore semaphore = getSemaphores().get(infoId); if (semaphore == null) throw new IllegalArgumentException( String.format("Trying to replace non-existing info %s in collection %s", infoId, this.getClass().getSimpleName())); try {/*from ww w . jav a 2 s . c om*/ semaphore.acquire(); } catch (InterruptedException e) { log.error(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(), e.getMessage()), e); throw new CollectionAccessInterruptedException(String.format(FAILED_TO_READ_OBJECT_MESSAGE, infoId, this.getClass().getSimpleName(), e.getMessage()), e); } try { T oldInfo = infos.get(infoId); if (!oldInfo.getVersionId().equals(info.getVersionId())) throw new ConcurrentUpdateException(infoId, String.format( "Info %s modified in collection %s, try again", infoId, this.getClass().getSimpleName())); T newInfo = info.cloneObject(); newInfo.updateVersionId(); doExtraUpdates(info, newInfo); infos.put(infoId, (T) newInfo); info.setVersionId(newInfo.getVersionId()); log.debug(String.format("Replaced info %s, new version %s", infoId, newInfo.getVersionId())); } finally { semaphore.release(); } }