19 package org.sleuthkit.autopsy.core;
22 import com.google.common.util.concurrent.ThreadFactoryBuilder;
23 import java.beans.PropertyChangeListener;
25 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.concurrent.ScheduledThreadPoolExecutor;
27 import java.util.concurrent.TimeUnit;
28 import java.util.logging.Level;
29 import java.util.stream.Collectors;
30 import java.util.stream.Stream;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
67 this.displayName = displayName;
101 if (servicesMonitor == null) {
114 statusByService =
new ConcurrentHashMap<>();
125 periodicTasksExecutor =
new ScheduledThreadPoolExecutor(NUMBER_OF_PERIODIC_TASK_THREADS,
new ThreadFactoryBuilder().setNameFormat(PERIODIC_TASK_THREAD_NAME).build());
126 periodicTasksExecutor.scheduleWithFixedDelay(
new ServicesMonitoringTask(), CRASH_DETECTION_INTERVAL_MINUTES, CRASH_DETECTION_INTERVAL_MINUTES, TimeUnit.MINUTES);
139 if (statusByService.containsKey(service) && status.equals(statusByService.get(service))) {
143 statusByService.put(service, status);
145 String serviceDisplayName;
148 }
catch (IllegalArgumentException ignore) {
149 serviceDisplayName = service;
153 logger.log(Level.INFO,
"Connection to {0} is up", serviceDisplayName);
155 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.restoredService.notify.title"),
156 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.restoredService.notify.msg", serviceDisplayName));
158 logger.log(Level.SEVERE,
"Failed to connect to {0}. Reason: {1}",
new Object[]{serviceDisplayName, details});
160 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.failedService.notify.title"),
161 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.failedService.notify.msg", serviceDisplayName));
163 logger.log(Level.INFO,
"Status for {0} is {1} ({2})",
new Object[]{serviceDisplayName, status});
165 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.statusChange.notify.title"),
166 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.statusChange.notify.msg",
new Object[]{serviceDisplayName, status, details}));
184 if (service == null || service.isEmpty()) {
192 if (coreServices.contains(service)) {
196 String status = statusByService.get(service);
197 if (status == null) {
219 public void addSubscriber(Set<String> services, PropertyChangeListener subscriber) {
230 public void addSubscriber(String service, PropertyChangeListener subscriber) {
276 for (String service : coreServices) {
293 }
catch (Exception ex) {
294 logger.log(Level.SEVERE,
"An error occurred during services monitoring", ex);
311 super(message, cause);
334 CaseDbConnectionInfo info;
338 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
343 SleuthkitCase.tryConnect(info);
345 }
catch (TskCoreException ex) {
356 if (kwsService != null) {
360 if (!kwsHostName.isEmpty()) {
375 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.KeywordSearchNull"));
377 }
catch (NumberFormatException ex) {
378 String rootCause = NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.InvalidPortNumber");
379 logger.log(Level.SEVERE,
"Unable to connect to Keyword Search server: " + rootCause, ex);
382 String rootCause = ex.getMessage();
383 logger.log(Level.SEVERE,
"Unable to connect to Keyword Search server: " + rootCause, ex);
396 logger.log(Level.SEVERE,
"Error accessing messaging service connection info", ex);
405 String rootCause = ex.getMessage();
406 logger.log(Level.SEVERE,
"Unable to connect to messaging server: " + rootCause, ex);
void addSubscriber(Set< String > services, PropertyChangeListener subscriber)
String getServiceStatus(String service)
void removeSubscriber(Set< String > services, PropertyChangeListener subscriber)
void publishLocally(AutopsyEvent event)
void setServiceStatus(String service, String status, String details)
void checkDatabaseConnectionStatus()
static String getSolr4ServerPort()
void addSubscriber(String service, PropertyChangeListener subscriber)
void tryConnect(String host, int port)
static String getIndexingServerPort()
void checkMessagingServerConnectionStatus()
void addSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
void checkServiceStatus(String service)
static ServicesMonitor servicesMonitor
final ConcurrentHashMap< String, String > statusByService
ServicesMonitorException(String message, Throwable cause)
static final String PERIODIC_TASK_THREAD_NAME
static boolean getIsMultiUserModeEnabled()
static CaseDbConnectionInfo getDatabaseConnectionInfo()
void addSubscriber(PropertyChangeListener subscriber)
final ScheduledThreadPoolExecutor periodicTasksExecutor
static synchronized ServicesMonitor getInstance()
static void info(String title, String message)
static final Logger logger
final AutopsyEventPublisher eventPublisher
ServicesMonitorException(String message)
void removeSubscriber(PropertyChangeListener subscriber)
static final long CRASH_DETECTION_INTERVAL_MINUTES
static String getSolr4ServerHost()
static final int NUMBER_OF_PERIODIC_TASK_THREADS
void removeSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
Service(String displayName)
void removeSubscriber(String service, PropertyChangeListener subscriber)
static void error(String title, String message)
static final Set< String > coreServices
synchronized static Logger getLogger(String name)
static String getIndexingServerHost()
static final long serialVersionUID
void checkKeywordSearchServerConnectionStatus()
static MessageServiceConnectionInfo getMessageServiceConnectionInfo()