From 9a8562bf65bbaf0cb2974e132ed3867c8728fae8 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 22 Jun 2015 17:03:52 -0400 Subject: [PATCH] Fixed service failed/restored msg sequence --- .../autopsy/casemodule/Bundle.properties | 4 ++-- .../casemodule/CollaborationMonitor.java | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties index 28b49a15c1..1bf692cac0 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Bundle.properties @@ -242,11 +242,11 @@ LocalFilesPanel.errorLabel.text=Error Label NewCaseVisualPanel1.errorLabel.text=Error Label CollaborationMonitor.addingDataSourceStatus.msg={0} adding data source CollaborationMonitor.analyzingDataSourceStatus.msg={0} analyzing {1} -CollaborationMonitor.failedService.notify.title=Collaboration Service Failed +CollaborationMonitor.failedService.notify.title={0} Collaboration Service Failed CollaborationMonitor.failedDbService.notify.msg=Lost connection to database server CollaborationMonitor.failedSolrService.notify.msg=Lost connection to keyword search server CollaborationMonitor.failedMessageService.notify.msg=Lost connection to messaging server -CollaborationMonitor.restoredService.notify.title=Collaboration Service Restored +CollaborationMonitor.restoredService.notify.title={0} Collaboration Service Restored CollaborationMonitor.restoredDbService.notify.msg=Connection to database server restored CollaborationMonitor.restoredSolrService.notify.msg=Connection to keyword search server restored CollaborationMonitor.restoredMessageService.notify.msg=Connection to messaging server restored diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/CollaborationMonitor.java b/Core/src/org/sleuthkit/autopsy/casemodule/CollaborationMonitor.java index 76efcb21f3..ba09716a92 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/CollaborationMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/CollaborationMonitor.java @@ -24,9 +24,11 @@ import java.beans.PropertyChangeListener; import java.io.Serializable; import java.net.URISyntaxException; import java.net.UnknownHostException; +import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; import java.util.Arrays; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -75,6 +77,7 @@ final class CollaborationMonitor { private static final long STALE_TASKS_DETECTION_INTERVAL_MINUTES = 2; private static final long CRASH_DETECTION_INTERVAL_MINUTES = 2; private static final long EXECUTOR_TERMINATION_WAIT_SECS = 30; + private static final SimpleDateFormat SERVICE_MSG_DATE_FORMAT = new SimpleDateFormat("MM/dd HH:mm:ss z"); private static final Logger logger = Logger.getLogger(CollaborationMonitor.class.getName()); private final String hostName; private final LocalTasksManager localTasksManager; @@ -176,7 +179,7 @@ final class CollaborationMonitor { eventPublisher.removeSubscriber(COLLABORATION_MONITOR_EVENT, remoteTasksManager); eventPublisher.closeRemoteEventChannel(); } - + remoteTasksManager.shutdown(); } @@ -333,7 +336,7 @@ final class CollaborationMonitor { void shutdown() { finishAllTasks(); } - + /** * Updates the remote tasks to reflect a collaboration event received * from another node. @@ -537,13 +540,13 @@ final class CollaborationMonitor { if (!dbServerIsRunning) { dbServerIsRunning = true; logger.log(Level.INFO, "Connection to PostgreSQL server restored"); //NON-NLS - MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredDbService.notify.msg")); + MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredDbService.notify.msg")); } } else { if (dbServerIsRunning) { dbServerIsRunning = false; logger.log(Level.SEVERE, "Failed to connect to PostgreSQL server"); //NON-NLS - MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedDbService.notify.msg")); + MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedDbService.notify.msg")); } } @@ -562,13 +565,13 @@ final class CollaborationMonitor { // if (!solrServerIsRunning) { // solrServerIsRunning = true; // logger.log(Level.INFO, "Connection to Solr server restored"); //NON-NLS -// MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredSolrService.notify.msg")); +// MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredSolrService.notify.msg")); // } // } catch (SolrServerException | IOException ex) { // if (solrServerIsRunning) { // solrServerIsRunning = false; // logger.log(Level.SEVERE, "Failed to connect to Solr server", ex); //NON-NLS -// MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedSolrService.notify.msg")); +// MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedSolrService.notify.msg")); // } // } // @@ -581,13 +584,13 @@ final class CollaborationMonitor { if (!messageServerIsRunning) { messageServerIsRunning = true; logger.log(Level.INFO, "Connection to ActiveMQ server restored"); //NON-NLS - MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredMessageService.notify.msg")); + MessageNotifyUtil.Notify.info(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.restoredMessageService.notify.msg")); } } catch (URISyntaxException | JMSException ex) { if (messageServerIsRunning) { messageServerIsRunning = false; logger.log(Level.SEVERE, "Failed to connect to ActiveMQ server", ex); //NON-NLS - MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title"), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedMessageService.notify.msg")); + MessageNotifyUtil.Notify.error(NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedService.notify.title", SERVICE_MSG_DATE_FORMAT.format(new Date())), NbBundle.getMessage(CollaborationMonitor.class, "CollaborationMonitor.failedMessageService.notify.msg")); } } }