List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.qwazr.server.GenericServer.java
@Override public synchronized void close() { LOGGER.info("The server is stopping..."); executeListener(shutdownListeners, LOGGER); if (udpServer != null) { try {/*from w ww .j a v a 2 s . c om*/ udpServer.shutdown(); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } } for (final DeploymentManager manager : deploymentManagers) { try { if (manager.getState() == DeploymentManager.State.STARTED) manager.stop(); if (manager.getState() == DeploymentManager.State.DEPLOYED) manager.undeploy(); } catch (Exception e) { LOGGER.log(Level.WARNING, e, () -> "Cannot stop the manager: " + e.getMessage()); } } for (final Undertow undertow : undertows) { try { undertow.stop(); } catch (Exception e) { LOGGER.log(Level.WARNING, e, () -> "Cannot stop Undertow: " + e.getMessage()); } } if (!executorService.isTerminated()) { if (!executorService.isShutdown()) executorService.shutdown(); try { executorService.awaitTermination(2, TimeUnit.MINUTES); } catch (InterruptedException e) { LOGGER.log(Level.WARNING, e, () -> "Executor shutdown failed: " + e.getMessage()); } } // Unregister MBeans if (registeredObjectNames != null && !registeredObjectNames.isEmpty()) { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (ObjectName objectName : registeredObjectNames) { try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException | MBeanRegistrationException e) { LOGGER.log(Level.WARNING, e, e::getMessage); } } registeredObjectNames.clear(); } LOGGER.info("The server is stopped."); }
From source file:org.openbaton.autoscaling.core.execution.ExecutionEngine.java
public VirtualNetworkFunctionRecord scaleOut(VirtualNetworkFunctionRecord vnfr, int numberOfInstances) throws SDKException, NotFoundException { log.info("[EXECUTOR] START_SCALE_OUT " + new Date().getTime()); log.info("Executing scaling-out of VNFR with id: " + vnfr.getId()); for (int i = 1; i <= numberOfInstances; i++) { log.info("[EXECUTOR] ALLOCATE_INSTANCE " + new Date().getTime()); if (actionMonitor.isTerminating(vnfr.getId())) { actionMonitor.finishedAction(vnfr.getId(), org.openbaton.autoscaling.catalogue.Action.TERMINATED); return vnfr; }/*ww w. j a va 2 s . c o m*/ log.debug("Adding new VNFCInstance -> number " + i + " " + new Date().getTime()); VNFCInstance vnfcInstance = null; for (VirtualDeploymentUnit vdu : vnfr.getVdu()) { VimInstance vimInstance = null; if (vdu.getVnfc_instance().size() < vdu.getScale_in_out() && (vdu.getVnfc().iterator().hasNext())) { if (autoScalingProperties.getPool().isActivate()) { log.trace("Getting VNFCInstance from pool"); //log.info("[EXECUTOR] REQUEST_RESOURCES_POOL " + new Date().getTime()); vnfcInstance = poolManagement.getReservedInstance(vnfr.getParent_ns_id(), vnfr.getId(), vdu.getId()); //log.info("[EXECUTOR] FINISH_REQUEST_RESOURCES_POOL " + new Date().getTime()); if (vnfcInstance != null) { log.debug("Got VNFCInstance from pool -> " + vnfcInstance); } else { log.debug("No VNFCInstance available in pool"); } } else { log.debug("Pool is deactivated"); } if (vnfcInstance == null) { if (vimInstance == null) { vimInstance = Utils.getVimInstance(vdu.getVimInstanceName(), nfvoRequestor); } VNFComponent vnfComponent = vdu.getVnfc().iterator().next(); try { //log.info("[EXECUTOR] ALLOCATE_RESOURCES " + new Date().getTime()); vnfcInstance = mediaServerResourceManagement .allocate(vimInstance, vdu, vnfr, vnfComponent).get(); //log.info("[EXECUTOR] FINISH_ALLOCATE_RESOURCES " + new Date().getTime()); } catch (InterruptedException e) { log.warn(e.getMessage(), e); } catch (ExecutionException e) { log.warn(e.getMessage(), e); } catch (VimException e) { log.warn(e.getMessage(), e); } } } else { log.warn("Maximum size of VDU with id: " + vdu.getId() + " reached..."); } if (vnfcInstance != null) { vdu.getVnfc_instance().add(vnfcInstance); actionMonitor.finishedAction(vnfr.getId(), org.openbaton.autoscaling.catalogue.Action.SCALED); log.debug("Added new VNFCInstance -> number " + i + " " + new Date().getTime()); break; } } if (vnfcInstance == null) { log.warn("Not found any VDU to scale out a VNFComponent. Limits are reached."); return vnfr; } vnfr = updateVNFR(vnfr); for (VirtualDeploymentUnit vdu : vnfr.getVdu()) { int cores = 1; try { cores = Utils.getCpuCoresOfFlavor(vnfr.getDeployment_flavour_key(), vdu.getVimInstanceName(), nfvoRequestor); } catch (NotFoundException e) { log.warn(e.getMessage(), e); } int maxCapacity = cores * mediaServerProperties.getCapacity().getMax(); for (VNFCInstance vnfcInstance_new : vdu.getVnfc_instance()) { if (vnfcInstance_new.getHostname().equals(vnfcInstance.getHostname())) { mediaServerManagement.add(vnfr.getId(), vnfcInstance_new, maxCapacity); } } } log.info("[EXECUTOR] ADDED_INSTANCE " + new Date().getTime()); } log.info("Executed scaling-out of VNFR with id: " + vnfr.getId()); log.info("[EXECUTOR] FINISH_SCALE_OUT " + new Date().getTime()); return vnfr; }
From source file:me.mast3rplan.phantombot.cache.SubscribersCache.java
@Override @SuppressWarnings("SleepWhileInLoop") public void run() { try {/*from w w w . j av a 2 s . com*/ Thread.sleep(30 * 1000); } catch (InterruptedException e) { com.gmt2001.Console.out.println( "SubscribersCache.run>>Failed to initial sleep: [InterruptedException] " + e.getMessage()); com.gmt2001.Console.err.logStackTrace(e); } while (!killed) { try { try { if (new Date().after(timeoutExpire) && run && TwitchAPIv3.instance().HasOAuth()) { int newCount = getCount(channel); if (new Date().after(timeoutExpire) && newCount != count) { this.updateCache(newCount); } } } catch (Exception e) { if (e.getMessage().startsWith("[SocketTimeoutException]") || e.getMessage().startsWith("[IOException]")) { Calendar c = Calendar.getInstance(); if (lastFail.after(new Date())) { numfail++; } else { numfail = 1; } c.add(Calendar.MINUTE, 1); lastFail = c.getTime(); if (numfail >= 5) { timeoutExpire = c.getTime(); } } com.gmt2001.Console.out .println("SubscribersCache.run>>Failed to update subscribers: " + e.getMessage()); com.gmt2001.Console.err.logStackTrace(e); } } catch (Exception e) { com.gmt2001.Console.err.printStackTrace(e); } try { Thread.sleep(30 * 1000); } catch (InterruptedException e) { com.gmt2001.Console.out .println("SubscribersCache.run>>Failed to sleep: [InterruptedException] " + e.getMessage()); com.gmt2001.Console.err.logStackTrace(e); } } }
From source file:com.ottogroup.bi.spqr.pipeline.component.operator.DirectResponseOperatorRuntimeEnvironment.java
/** * @see java.lang.Runnable#run()//from w w w. jav a 2 s . c o m */ public void run() { while (running) { try { StreamingDataMessage message = this.consumerQueueWaitStrategy.waitFor(this.queueConsumer); if (message != null && message.getBody() != null) { @SuppressWarnings("resource") // context#close() calls context#stop -> avoid additional call, thus accept warning Timer.Context timerContext = (this.messageProcessingTimer != null ? this.messageProcessingTimer.time() : null); StreamingDataMessage[] responseMessages = this.directResponseOperator.onMessage(message); if (responseMessages != null && responseMessages.length > 0) { for (final StreamingDataMessage responseMessage : responseMessages) { this.queueProducer.insert(responseMessage); } this.destinationQueueWaitStrategy.forceLockRelease(); } if (timerContext != null) timerContext.stop(); 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.nridge.connector.fs.con_fs.core.RunTransformFS.java
/** * When an object implementing interface <code>Runnable</code> is used * to create a thread, starting the thread causes the object's * <code>run</code> method to be called in that separately executing * thread.//w w w.ja v a 2s .co m * * The general contract of the method <code>run</code> is that it may * take any action whatsoever. * * @see Thread#run() */ @Override public void run() { DocumentXML documentXML; Document srcDoc, dstDoc; String docId, queueItem, srcPathFileName; Logger appLogger = mAppMgr.getLogger(this, "run"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); Pipeline pipeline = new Pipeline(mAppMgr, Constants.CFG_PROPERTY_PREFIX); BlockingQueue extractQueue = (BlockingQueue) mAppMgr.getProperty(Connector.QUEUE_EXTRACT_NAME); BlockingQueue transformQueue = (BlockingQueue) mAppMgr.getProperty(Connector.QUEUE_TRANSFORM_NAME); long queueWaitTimeout = mAppMgr.getLong(Constants.CFG_PROPERTY_PREFIX + ".queue.wait_timeout", Constants.QUEUE_POLL_TIMEOUT_DEFAULT); do { try { queueItem = (String) extractQueue.poll(queueWaitTimeout, TimeUnit.SECONDS); if (mCrawlQueue.isQueueItemDocument(queueItem)) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); docId = Connector.docIdFromQueueItem(queueItem); appLogger.debug(String.format("Extract Queue Item: %s", docId)); srcPathFileName = mCrawlQueue.docPathFileName(Connector.QUEUE_EXTRACT_NAME, docId); try { documentXML = new DocumentXML(); documentXML.load(srcPathFileName); srcDoc = documentXML.getDocument(); dstDoc = pipeline.execute(srcDoc); mCrawlQueue.transition(Connector.QUEUE_EXTRACT_NAME, Connector.QUEUE_TRANSFORM_NAME, dstDoc, docId); stopWatch.stop(); queueItem = Connector.queueItemIdPhaseTime(queueItem, Connector.PHASE_TRANSFORM, stopWatch.getTime()); try { // If queue is full, this thread may block. transformQueue.put(queueItem); } catch (InterruptedException e) { // Restore the interrupted status so parent can handle (if it wants to). Thread.currentThread().interrupt(); } } catch (Exception e) { String msgStr = String.format("%s: %s", docId, e.getMessage()); appLogger.error(msgStr, e); MailManager mailManager = (MailManager) mAppMgr.getProperty(Connector.PROPERTY_MAIL_NAME); mailManager.addMessage(Connector.PHASE_TRANSFORM, Connector.STATUS_MAIL_ERROR, msgStr, Constants.MAIL_DETAIL_MESSAGE); } } } catch (InterruptedException e) { queueItem = StringUtils.EMPTY; } } while (!mCrawlQueue.isPhaseComplete(Connector.PHASE_EXTRACT, queueItem)); // Forward the marker queue item to the next queue. if (mCrawlQueue.isQueueItemMarker(queueItem)) { try { // If queue is full, this thread may block. transformQueue.put(queueItem); } catch (InterruptedException e) { // Restore the interrupted status so parent can handle (if it wants to). Thread.currentThread().interrupt(); } } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); }
From source file:com.flicklib.folderscanner.AdvancedFolderScanner.java
/** * Scans the folders/*w w w . j av a2 s. c om*/ * * @param folders * @return a List of MovieInfo * * TODO get rid of the synchronized and create a factory or pass all state data */ @Override public synchronized List<FileGroup> scan(final Set<FileObject> folders, AsyncMonitor monitor) { movies = new ArrayList<FileGroup>(); if (monitor != null) { monitor.start(); } for (FileObject folder : folders) { try { URL url = folder.getURL(); if (folder.exists()) { currentLabel = folder.getName().getBaseName(); LOGGER.info("scanning " + url); try { browse(folder, monitor); } catch (InterruptedException ie) { LOGGER.info("task is cancelled!" + ie.getMessage()); return null; } } else { LOGGER.warn("folder " + folder.getURL() + " does not exist!"); } } catch (FileSystemException e) { LOGGER.error("error during checking " + folder + ", " + e.getMessage(), e); } } if (monitor != null) { monitor.finish(); } return movies; }
From source file:au.org.ala.layers.stats.ObjectsStatsGenerator.java
@Override public void run() { try {/*from w ww. java 2 s. c o m*/ while (true) { String pid = ""; double area = 0; try { String data = lbq.take(); pid = data; String sql = "SELECT ST_AsText(the_geom) as wkt from objects where pid = '" + pid + "';"; ResultSet rs = s.executeQuery(sql); String wkt = ""; while (rs.next()) { wkt = rs.getString("wkt"); } area = SpatialUtil.calculateArea(wkt) / 1000.0 / 1000.0; sql = "UPDATE objects SET area_km = " + area + " WHERE pid='" + pid + "'"; int update = s.executeUpdate(sql); logger.info(pid + " has area " + area + " sq km"); rs.close(); } catch (InterruptedException e) { break; } catch (Exception e) { logger.debug("ERROR PROCESSING PID " + pid); logger.debug("AREA CALCULATION IS " + area); s.cancel(); logger.error(e.getMessage(), e); } cdl.countDown(); } } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:com.kurento.kmf.test.client.BrowserClient.java
public boolean color(Color expectedColor, final double seconds, int x, int y) { // Wait to be in the right time (new WebDriverWait(driver, timeout)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { double time = Double.parseDouble(d.findElement(By.id("currentTime")).getAttribute("value")); return time > seconds; }//from ww w . j a v a 2 s.com }); setColorCoordinates(x, y); // Guard time to wait JavaScript function to detect the color (otherwise // race conditions could appear) try { Thread.sleep(200); } catch (InterruptedException e) { log.trace("InterruptedException in guard condition ({})", e.getMessage()); } return colorSimilarTo(expectedColor); }
From source file:com.daon.identityx.samplefidoapp.SplashActivity.java
/*** * Retrieve the set of authenticators from the FIDO clients by using the FIDO discovery * * The list of authenticators is cached within this class so if authenticators can be * dynamically added or removed from the device, they will not be picked up after the * app is initialized.//from w w w . j av a2s. c o m * */ protected void retrieveAvailableAuthenticatorAaids() { if (!aaidRetrievalAttempted) { LogUtils.logAaidRetrievalStart(); List<ResolveInfo> clientList = getUafClientList(); this.setCurrentFidoOperation(FidoOperation.Discover); Intent intent = getUafClientUtils().getDiscoverIntent(); if (clientList != null && clientList.size() > 0) { intent.setComponent(new ComponentName(clientList.get(uafClientIdx).activityInfo.packageName, clientList.get(uafClientIdx).activityInfo.name)); UafClientLogUtils.logUafDiscoverRequest(intent); UafClientLogUtils.logUafClientDetails(clientList.get(uafClientIdx)); startActivityForResult(intent, AndroidClientIntentParameters.requestCode); return; } else { // End now if there are no clients LogUtils.logDebug(LogUtils.TAG, (String) getText(R.string.no_fido_client_found)); LogUtils.logAaidRetrievalEnd(); aaidRetrievalAttempted = true; } } if (System.currentTimeMillis() < (start + SPLASH_DISPLAY)) { try { Thread.sleep(start + SPLASH_DISPLAY - System.currentTimeMillis()); } catch (InterruptedException ex) { // ignore and carry on } } finish(); try { Intent newIntent = new Intent(this, IntroActivity.class); startActivity(newIntent); } catch (Throwable ex) { displayError(ex.getMessage()); } }
From source file:com.thoughtworks.go.task.rpmbuild.RPMBuildTask.java
@Override public TaskExecutor executor() { return new TaskExecutor() { @Override/* w w w . ja v a 2 s. c o m*/ public ExecutionResult execute(TaskConfig taskConfig, TaskExecutionContext taskExecutionContext) { String targetArch = taskConfig.getValue(TARGET_ARCH); String specFilePath = taskConfig.getValue(SPEC_FILE); List<String> command = Arrays.asList("rpmbuild", "--target", targetArch, "-bb", "-v", "--clean", specFilePath); try { taskExecutionContext.console().printLine("[exec] " + StringUtils.join(command, " ")); Process process = runProcess(taskExecutionContext, command); taskExecutionContext.console().readOutputOf(process.getInputStream()); taskExecutionContext.console().readErrorOf(process.getErrorStream()); try { process.waitFor(); } catch (InterruptedException e) { // continue } int exitValue = process.exitValue(); if (exitValue != 0) { return ExecutionResult.failure("[exec] FAILED with return code " + exitValue); } } catch (IOException e) { return ExecutionResult.failure("[exec] Exception: " + e.getMessage(), e); } return ExecutionResult.success( String.format("[exec] Successfully executed command [%s]", StringUtils.join(command, " "))); } }; }