List of usage examples for java.lang InterruptedException getMessage
public String getMessage()
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private boolean buildNotificationIcons(final int iconResId, final String imageIconUrl, final String imageSmallIconUrl, final Object notificationBuilder) { try {/*from w ww. j a va 2s . co m*/ if (imageIconUrl != null) { try { setLargeIconMethod.invoke(notificationBuilder, new DownloadImageTask().execute(imageIconUrl).get()); } catch (final InterruptedException e) { log.error("Interrupted when downloading image : " + e.getMessage(), e); } catch (final ExecutionException e) { log.error("Failed execute download image thread : " + e.getMessage(), e); } } if (imageSmallIconUrl != null && iconClass != null && android.os.Build.VERSION.SDK_INT >= ANDROID_MARSHMALLOW) { try { final Bitmap iconBitmap = new DownloadImageTask().execute(imageSmallIconUrl).get(); setSmallIconMethod.invoke(notificationBuilder, createWithBitmapMethod.invoke(iconClass, iconBitmap)); } catch (final InterruptedException e) { log.error("Interrupted when downloading small icon : " + e.getMessage(), e); setSmallIconResIdMethod.invoke(notificationBuilder, iconResId); } catch (final ExecutionException e) { log.error("Failed execute download image small icon thread : " + e.getMessage(), e); setSmallIconResIdMethod.invoke(notificationBuilder, iconResId); } } else { setSmallIconResIdMethod.invoke(notificationBuilder, iconResId); } return true; } catch (final InvocationTargetException ex) { log.debug("Can't invoke notification builder methods. : " + ex.getMessage(), ex); return false; } catch (final IllegalAccessException ex) { log.debug("Can't access notification builder methods. : " + ex.getMessage(), ex); return false; } }
From source file:gda.scan.ConcurrentScan.java
@Override public void doCollection() throws Exception { try {/*from w w w .j a v a 2 s . c o m*/ if (!this.isChild) { logger.info("Starting scan: '" + getName() + "' (" + getCommand() + ")"); } reportDetectorsThatWillBeMovedConcurrentlyWithSomeOtherScannables(); logger.info("Concurrency: " + reportDevicesByLevel()); // if true, then make a note of current position of all scannables to use at the end if (!isChild && isReturnScannablesToOrginalPositions()) { recordOriginalPositions(); } // *** First point in this scan *** setPointPositionInLine(PointPositionInLine.FIRST); if (getChild() == null) { callAtPointStartHooks(); // move to initial movements currentPointCount++; acquirePoint(true, true); // start point, collect detectors checkThreadInterrupted(); readDevicesAndPublishScanDataPoint(); callAtPointEndHooks(); sendScanEvent(ScanEvent.EventType.UPDATED); checkThreadInterrupted(); waitIfPaused(); if (isFinishEarlyRequested()) { return; } } else { // move the Scannable operated by this scan and then run the child scan ScanObject principleScanObject = this.allScanObjects.get(0); // There will only be one scannable moved in this parent scan, so no // need to sort by level! principleScanObject.scannable.atLevelStart(); principleScanObject.scannable.atLevelMoveStart(); stepId = principleScanObject.moveToStart(); checkThreadInterrupted(); checkAllMovesComplete(); waitIfPaused(); if (isFinishEarlyRequested()) { return; } principleScanObject.scannable.atLevelEnd(); runChildScan(); checkThreadInterrupted(); // note that some scan hooks not called (atPointStart,atLevelMoveStart,atPointEnd) as this scannable is ot part of the child scan } // *** Subsequent points in this scan *** for (int step = 0; step < numberSteps; step++) { waitIfPaused(); if (isFinishEarlyRequested()) { return; } setPointPositionInLine( (step == (numberSteps - 1)) ? PointPositionInLine.LAST : PointPositionInLine.MIDDLE); if (getChild() == null) { callAtPointStartHooks(); // make all these increments currentPointCount++; acquirePoint(false, true); // step point, collect detectors checkThreadInterrupted(); readDevicesAndPublishScanDataPoint(); checkThreadInterrupted(); callAtPointEndHooks(); sendScanEvent(ScanEvent.EventType.UPDATED); } else { ScanObject principleScanObject = this.allScanObjects.get(0); principleScanObject.scannable.atLevelStart(); principleScanObject.scannable.atLevelMoveStart(); stepId = principleScanObject.moveStep(); checkAllMovesComplete(); checkThreadInterrupted(); principleScanObject.scannable.atLevelEnd(); runChildScan(); checkThreadInterrupted(); } } } catch (InterruptedException e) { setStatus(ScanStatus.TIDYING_UP_AFTER_STOP); throw new ScanInterruptedException(e.getMessage(), e.getStackTrace()); } catch (Exception e) { setStatus(ScanStatus.TIDYING_UP_AFTER_FAILURE); throw e; } }
From source file:com.clustercontrol.agent.ReceiveTopic.java
/** * ??/* ww w .j a v a 2 s . c om*/ */ @Override public void run() { m_log.info("run start"); while (true) { /* * ?????????sleep? * */ try { int interval = m_topicInterval; countDownLatch = new CountDownLatch(1); if (!countDownLatch.await(interval, TimeUnit.MILLISECONDS)) m_log.debug("waiting is over"); } catch (InterruptedException e) { m_log.warn("Interrupt " + e.getMessage()); } catch (Exception e) { m_log.error("run() : " + e.getMessage(), e); } try { List<RunInstructionInfo> runInstructionList = new ArrayList<RunInstructionInfo>(); m_log.info("getTopic " + Agent.getAgentStr() + " start"); HinemosTopicInfo hinemosTopicInfo = null; List<TopicInfo> topicInfoList = null; SettingUpdateInfo updateInfo = null; try { // ???????????topic?????????????synchronized? synchronized (lockTopicReceiveTiming) { if (isTerminated == true) { // ????????????? return; } hinemosTopicInfo = AgentEndPointWrapper.getHinemosTopic(); } } catch (Exception e) { /* * ????????????????????? * ????? */ if (disconnectCounter < Long.MAX_VALUE) { disconnectCounter++; } // ??????????? if (disconnectCounter * m_topicInterval > m_runhistoryClearDelay) { clearJobHistory(); } /* * ????????????? * StackTrace?????????????? * StackTrace????? * ????????debug?? */ String message = "run() getTopic : " + ", " + disconnectCounter + "*" + m_topicInterval + ":" + m_runhistoryClearDelay + ", " + e.getClass().getSimpleName() + ", " + e.getMessage(); m_log.warn(message); m_log.debug(message, e); continue; // while?? } // ???????? topicInfoList = hinemosTopicInfo.getTopicInfoList(); updateInfo = hinemosTopicInfo.getSettingUpdateInfo(); Agent.setAwakePort(hinemosTopicInfo.getAwakePort()); // Hinemos HinemosTime.setTimeOffsetMillis(updateInfo.getHinemosTimeOffset()); // Hinemos HinemosTime.setTimeZoneOffset(updateInfo.getHinemosTimeZoneOffset()); /* * ???????????Windows????? * ?? */ m_log.debug("run : disconnectCounter=" + disconnectCounter); if (disconnectCounter != 0 || isReloadFlg()) { reloadLogfileMonitor(updateInfo, true); reloadCustomMonitor(updateInfo, true); reloadWinEventMonitor(updateInfo, true); reloadJobFileCheck(updateInfo, true); UpdateModuleUtil.setAgentLibMd5(); setReloadFlg(false); } disconnectCounter = 0; setHistoryClear(false); m_log.debug("run : topicInfoList.size=" + topicInfoList.size()); for (TopicInfo topicInfo : topicInfoList) { m_log.info("getTopic flag=" + topicInfo.getFlag()); RunInstructionInfo runInstructionInfo = topicInfo.getRunInstructionInfo(); if (runInstructionInfo != null) { runInstructionList.add(runInstructionInfo); } long topicFlag = topicInfo.getFlag(); if (topicInfo.getAgentCommand() != 0) { int agentCommand = topicInfo.getAgentCommand(); m_log.debug("agentCommand : " + agentCommand); if (agentCommand == AgentCommandConstant.UPDATE) { // 1????????????? if (!UpdateModuleUtil.update()) { agentCommand = 0; } } if (agentCommand != 0) { Agent.restart(agentCommand); } } if ((topicFlag & TopicFlagConstant.NEW_FACILITY) != 0) { UpdateModuleUtil.setAgentLibMd5(); } if (newTopicMode) { continue; } // ????? // topic.mode=4.0????? if ((topicFlag & TopicFlagConstant.REPOSITORY_CHANGED) != 0 || (topicFlag & TopicFlagConstant.NEW_FACILITY) != 0 || (topicFlag & TopicFlagConstant.CALENDAR_CHANGED) != 0 || (topicFlag & TopicFlagConstant.LOGFILE_CHANGED) != 0) { reloadLogfileMonitor(updateInfo, true); } if ((topicFlag & TopicFlagConstant.REPOSITORY_CHANGED) != 0 || (topicFlag & TopicFlagConstant.NEW_FACILITY) != 0 || (topicFlag & TopicFlagConstant.CALENDAR_CHANGED) != 0 || (topicFlag & TopicFlagConstant.CUSTOM_CHANGED) != 0) { reloadCustomMonitor(updateInfo, true); } if ((topicFlag & TopicFlagConstant.REPOSITORY_CHANGED) != 0 || (topicFlag & TopicFlagConstant.NEW_FACILITY) != 0 || (topicFlag & TopicFlagConstant.CALENDAR_CHANGED) != 0 || (topicFlag & TopicFlagConstant.WINEVENT_CHANGED) != 0) { reloadWinEventMonitor(updateInfo, true); } if ((topicFlag & TopicFlagConstant.REPOSITORY_CHANGED) != 0 || (topicFlag & TopicFlagConstant.NEW_FACILITY) != 0 || (topicFlag & TopicFlagConstant.CALENDAR_CHANGED) != 0 || (topicFlag & TopicFlagConstant.FILECHECK_CHANGED) != 0) { reloadJobFileCheck(updateInfo, true); } } reloadLogfileMonitor(updateInfo, false); reloadCustomMonitor(updateInfo, false); reloadWinEventMonitor(updateInfo, false); reloadJobFileCheck(updateInfo, false); settingLastUpdateInfo = updateInfo; m_log.debug("getTopic " + Agent.getAgentStr() + " end"); if (runInstructionList.size() > 0) { m_log.info("infoList.size() = " + runInstructionList.size()); } else { m_log.debug("infoList.size() = 0"); } for (RunInstructionInfo info : runInstructionList) { runJob(info); } } catch (Throwable e) { m_log.error("run() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } } }
From source file:edu.stanford.cfuller.colocalization3d.Colocalization3DMain.java
/** * Fits all the image objects in a single image specified by a supplied mask and image set. * <p>//from www. j a v a 2 s . co m * Does not check for whether the fitting was successful. * * @param iams a {@link ImageAndMaskSet } specifying the image whose objects will be fit. * @return a List<ImageObject> containing an ImageObject for each object in the image that has been fit. */ protected List<ImageObject> fitObjectsInSingleImage(ImageAndMaskSet iams) { Image im = this.loadAndCorrectImageFromSet(iams); Image mask = this.loadMaskFromSet(iams); if (im == null || mask == null) { java.util.logging.Logger.getLogger(LOGGER_NAME) .warning("unable to load image and mask for " + iams.getImageFilename()); return new java.util.ArrayList<ImageObject>(); } Histogram h = new Histogram(mask); int maxRegionId = h.getMaxValue(); List<FittingThread> startedThreads = new java.util.ArrayList<FittingThread>(); List<FittingThread> finishedThreads = new java.util.ArrayList<FittingThread>(); int maxThreadCount = Colocalization3DMain.DEFAULT_MAX_THREADS; if (this.parameters.hasKey(THREAD_COUNT_PARAM)) { maxThreadCount = this.parameters.getIntValueForKey(THREAD_COUNT_PARAM); } java.util.logging.Logger.getLogger(LOGGER_NAME).fine("Image: " + iams.getImageFilename()); for (int i = 1; i < maxRegionId + 1; i++) { ImageObject obj = new edu.stanford.cfuller.imageanalysistools.fitting.GaussianImageObject(i, ImageFactory.createShallow(mask), ImageFactory.createShallow(im), this.parameters); obj.setImageID(iams.getImageFilename()); FittingThread nextThread = new FittingThread(obj, this.parameters); try { while (startedThreads.size() >= maxThreadCount) { Thread.sleep(Colocalization3DMain.DEFAULT_THREAD_WAIT_MS); checkAllRunningThreadsAndRemoveFinished(startedThreads, finishedThreads); } } catch (InterruptedException e) { java.util.logging.Logger.getLogger(LOGGER_NAME) .severe("Interrupted while waiting for completion of fitting thread: " + e.getMessage()); } nextThread.start(); startedThreads.add(nextThread); } while (startedThreads.size() > 0) { try { Thread.sleep(Colocalization3DMain.DEFAULT_THREAD_WAIT_MS); } catch (InterruptedException e) { java.util.logging.Logger.getLogger(LOGGER_NAME) .severe("Interrupted while waiting for completion of fitting thread: " + e.getMessage()); } checkAllRunningThreadsAndRemoveFinished(startedThreads, finishedThreads); } List<ImageObject> output = new java.util.ArrayList<ImageObject>(); for (FittingThread ft : finishedThreads) { output.add(ft.getFitObject()); } return output; }
From source file:com.att.nsa.mr.client.impl.MRSimplerBatchPublisher.java
@Override public void close() { try {//from w w w. j a v a 2s. co m final List<message> remains = close(Long.MAX_VALUE, TimeUnit.MILLISECONDS); if (remains.size() > 0) { getLog().warn("Closing publisher with " + remains.size() + " messages unsent. " + "Consider using MRBatchingPublisher.close( long timeout, TimeUnit timeoutUnits ) to recapture unsent messages on close."); } } catch (InterruptedException e) { getLog().warn("Possible message loss. " + e.getMessage(), e); } catch (IOException e) { getLog().warn("Possible message loss. " + e.getMessage(), e); } }
From source file:com.bigjob.ApplicationMaster.java
private void finish() { // Join all launched threads // needed for when we time out // and we need to release containers for (Thread launchThread : launchThreads) { try {/*w ww .ja va 2 s. c o m*/ launchThread.join(10000); } catch (InterruptedException e) { LOG.info("Exception thrown in thread join: " + e.getMessage()); e.printStackTrace(); } } // When the application completes, it should stop all running containers LOG.info("Application completed. Stopping running containers"); nmClientAsync.stop(); // When the application completes, it should send a finish application // signal to the RM LOG.info("Application completed. Signalling finish to RM"); FinalApplicationStatus appStatus; String appMessage = null; success = true; if (numFailedContainers.get() == 0 && numCompletedContainers.get() == numTotalContainers) { appStatus = FinalApplicationStatus.SUCCEEDED; } else { appStatus = FinalApplicationStatus.FAILED; appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed=" + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed=" + numFailedContainers.get(); success = false; } try { amRMClient.unregisterApplicationMaster(appStatus, appMessage, null); } catch (YarnException ex) { LOG.error("Failed to unregister application", ex); } catch (IOException e) { LOG.error("Failed to unregister application", e); } amRMClient.stop(); }
From source file:com.bt.aloha.testing.mockphones.NoAnswerDialogBean.java
@Override public void processInitialInvite(final Request request, final ServerTransaction serverTransaction, final String dialogId) { DialogInfo dialogInfo = getDialogCollection().get(dialogId); try {/* w w w . j a v a 2 s . com*/ Thread.sleep(SLEEP_INTERVAL); } catch (InterruptedException e) { log.info("Unable to sleep full interval", e); } log.info("sending RINGING..."); getDialogBeanHelper().sendResponse(request, serverTransaction, Response.RINGING); int maxCallDuration = dialogInfo.getIntProperty(MAX_CALL_DURATION_PROPERTY_KEY, MAX_CALL_DURATION); log.debug(String.format("Sending Temporarily Unavailable in %s milliseconds", maxCallDuration)); getScheduledExecutorService().schedule(new Runnable() { public void run() { try { log.info("sending TEMPORARILY_UNAVAILABLE..."); getDialogBeanHelper().sendResponse(request, serverTransaction, Response.TEMPORARILY_UNAVAILABLE); } catch (Exception e) { log.info("Exception occured in NoAnswerPhone " + e.getMessage()); } } }, maxCallDuration, TimeUnit.MILLISECONDS); }
From source file:com.zqh.hadoop.moya.core.yarn.ApplicationMaster.java
private void finish() { // Join all launched threads // needed for when we time out // and we need to release containers for (Thread launchThread : launchThreads) { try {/*from w ww .j a v a 2 s . com*/ launchThread.join(10000); } catch (InterruptedException e) { LOG.info("Exception thrown in thread join: " + e.getMessage()); e.printStackTrace(); } } // When the application completes, it should stop all running containers LOG.info("Application completed. Stopping running containers"); nmClientAsync.stop(); // When the application completes, it should send a finish application // signal to the RM LOG.info("Application completed. Signalling finish to RM"); //TODO Remove MOYA NODE try { DeleteGroup.main(new String[] { ZKHosts, "moya" }); } catch (Exception e1) { e1.printStackTrace(); } FinalApplicationStatus appStatus; String appMessage = null; success = true; if (numFailedContainers.get() == 0 && numCompletedContainers.get() == numTotalContainers) { appStatus = FinalApplicationStatus.SUCCEEDED; } else { appStatus = FinalApplicationStatus.FAILED; appMessage = "Diagnostics." + ", total=" + numTotalContainers + ", completed=" + numCompletedContainers.get() + ", allocated=" + numAllocatedContainers.get() + ", failed=" + numFailedContainers.get(); success = false; } try { resourceManager.unregisterApplicationMaster(appStatus, appMessage, null); } catch (YarnException ex) { LOG.error("Failed to unregister application", ex); } catch (IOException e) { LOG.error("Failed to unregister application", e); } done = true; resourceManager.stop(); }
From source file:com.algolia.search.saas.Index.java
/** * Wait the publication of a task on the server. * All server task are asynchronous and you can check with this method that the task is published. * // w w w .j a va 2 s. c o m * @param taskID the id of the task returned by server * @param timeToWait time to sleep seed */ public void waitTask(String taskID, long timeToWait) throws AlgoliaException { try { while (true) { JSONObject obj = client.getRequest( "/1/indexes/" + encodedIndexName + "/task/" + URLEncoder.encode(taskID, "UTF-8"), true); if (obj.getString("status").equals("published")) return; try { Thread.sleep(timeToWait > MAX_TIME_MS_TO_WAIT ? MAX_TIME_MS_TO_WAIT : timeToWait); } catch (InterruptedException e) { } timeToWait *= 2; } } catch (JSONException e) { throw new AlgoliaException(e.getMessage()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private Notification createNotification(final int iconResId, final String title, final String contentText, final String imageUrl, final String imageIconUrl, final String imageSmallIconUrl, final PendingIntent contentIntent) { log.info("Create Notification:" + title + ", Content:" + contentText); if (android.os.Build.VERSION.SDK_INT < ANDROID_JELLYBEAN) { return createLegacyNotification(iconResId, title, contentText, contentIntent); }/*from w w w .j a v a 2 s .com*/ if (!initClassesAndMethodsByReflection()) { // fall back to creating the legacy notification. return createLegacyNotification(iconResId, title, contentText, contentIntent); } final Object notificationBuilder; final Object bigTextStyle; final Object bigPictureStyle; try { notificationBuilder = notificationBuilderConstructor .newInstance(pinpointContext.getApplicationContext()); bigTextStyle = notificationBigTextStyleClass.newInstance(); bigPictureStyle = notificationBigPictureStyleClass.newInstance(); } catch (final InvocationTargetException ex) { log.debug("Can't invoke notification builder constructor. : " + ex.getMessage(), ex); return createLegacyNotification(iconResId, title, contentText, contentIntent); } catch (final IllegalAccessException ex) { log.debug("Can't access notification builder or bigTextStyle or bigPictureStyle classes. : " + ex.getMessage(), ex); return createLegacyNotification(iconResId, title, contentText, contentIntent); } catch (final InstantiationException ex) { log.debug( "Exception while instantiating notification builder or bigTextStyle or bigPictureStyle classes. : " + ex.getMessage(), ex); return createLegacyNotification(iconResId, title, contentText, contentIntent); } try { setContentTitleMethod.invoke(notificationBuilder, title); setContentTextMethod.invoke(notificationBuilder, contentText); setContentIntent.invoke(notificationBuilder, contentIntent); setPriorityMethod.invoke(notificationBuilder, 1); final Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); setSoundMethod.invoke(notificationBuilder, defaultSoundUri); if (!buildNotificationIcons(iconResId, imageIconUrl, imageSmallIconUrl, notificationBuilder)) { return createLegacyNotification(iconResId, title, contentText, contentIntent); } if (imageUrl != null) { try { notificationImage = new DownloadImageTask().execute(imageUrl).get(); if (notificationImage != null) { bigPictureMethod.invoke(bigPictureStyle, notificationImage); setSummaryMethod.invoke(bigPictureStyle, contentText); setStyleMethod.invoke(notificationBuilder, bigPictureStyle); } else { bigTextMethod.invoke(bigTextStyle, contentText); setStyleMethod.invoke(notificationBuilder, bigTextStyle); } } catch (final InterruptedException e) { log.error("Interrupted when downloading image : " + e.getMessage(), e); } catch (final ExecutionException e) { log.error("Failed execute download image thread : " + e.getMessage(), e); } } return (Notification) buildMethod.invoke(notificationBuilder); } catch (final InvocationTargetException ex) { log.debug("Can't invoke notification builder methods. : " + ex.getMessage(), ex); return createLegacyNotification(iconResId, title, contentText, contentIntent); } catch (final IllegalAccessException ex) { log.debug("Can't access notification builder methods. : " + ex.getMessage(), ex); return createLegacyNotification(iconResId, title, contentText, contentIntent); } }