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;
60 .map(Service::toString)
61 .collect(Collectors.toSet());
103 this.displayName = name;
127 if (instance == null) {
136 this.statusByService =
new ConcurrentHashMap<>();
145 periodicTasksExecutor =
new ScheduledThreadPoolExecutor(NUMBER_OF_PERIODIC_TASK_THREADS,
new ThreadFactoryBuilder().setNameFormat(PERIODIC_TASK_THREAD_NAME).build());
146 periodicTasksExecutor.scheduleWithFixedDelay(
new CrashDetectionTask(), CRASH_DETECTION_INTERVAL_MINUTES, CRASH_DETECTION_INTERVAL_MINUTES, TimeUnit.MINUTES);
161 if (statusByService.containsKey(service) && status.equals(statusByService.get(service))) {
166 String serviceDisplayName;
169 }
catch (IllegalArgumentException ignore) {
171 serviceDisplayName = service;
175 logger.log(Level.INFO,
"Connection to {0} is up", serviceDisplayName);
177 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.restoredService.notify.msg", serviceDisplayName));
179 logger.log(Level.SEVERE,
"Failed to connect to {0}. Reason: {1}",
new Object[]{serviceDisplayName, details});
181 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.failedService.notify.msg", serviceDisplayName));
183 logger.log(Level.INFO,
"Status for {0} is {1}",
new Object[]{serviceDisplayName, status});
185 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.statusChange.notify.msg",
new Object[]{serviceDisplayName, status}));
189 statusByService.put(service, status);
205 if (service == null) {
211 if (servicesList.contains(service)) {
215 String status = statusByService.get(service);
216 if (status == null) {
242 CaseDbConnectionInfo info;
246 logger.log(Level.SEVERE,
"Error accessing case database connection info", ex);
251 SleuthkitCase.tryConnect(info);
253 }
catch (TskCoreException ex) {
264 if (kwsService != null) {
270 NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.KeywordSearchNull"));
272 }
catch (NumberFormatException ex) {
273 String rootCause = NbBundle.getMessage(
ServicesMonitor.class,
"ServicesMonitor.InvalidPortNumber");
274 logger.log(Level.SEVERE,
"Unable to connect to messaging server: " + rootCause, ex);
277 String rootCause = ex.getMessage();
278 logger.log(Level.SEVERE,
"Unable to connect to messaging server: " + rootCause, ex);
291 logger.log(Level.SEVERE,
"Error accessing messaging service connection info", ex);
300 String rootCause = ex.getMessage();
301 logger.log(Level.SEVERE,
"Unable to connect to messaging server: " + rootCause, ex);
322 public void addSubscriber(Set<String> eventNames, PropertyChangeListener subscriber) {
332 public void addSubscriber(String eventName, PropertyChangeListener subscriber) {
374 for (String service : servicesList) {
394 }
catch (Exception ex) {
395 logger.log(Level.SEVERE,
"Unexpected exception in CrashDetectionTask", ex);
412 super(message, cause);
String getServiceStatus(String service)
void publishLocally(AutopsyEvent event)
void setServiceStatus(String service, String status, String details)
void checkDatabaseConnectionStatus()
void tryConnect(String host, int port)
static String getIndexingServerPort()
void checkMessagingServerConnectionStatus()
void removeSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
void addSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
void checkServiceStatus(String service)
static ServicesMonitor instance
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)
void addSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
final ScheduledThreadPoolExecutor periodicTasksExecutor
static synchronized ServicesMonitor getInstance()
static void info(String title, String message)
static final Logger logger
static final Set< String > servicesList
ServicesMonitorException(String message)
void removeSubscriber(PropertyChangeListener subscriber)
static final long CRASH_DETECTION_INTERVAL_MINUTES
void addSubscriber(String eventName, PropertyChangeListener subscriber)
static final int NUMBER_OF_PERIODIC_TASK_THREADS
void removeSubscriber(Set< String > eventNames, PropertyChangeListener subscriber)
static void error(String title, String message)
synchronized static Logger getLogger(String name)
void removeSubscriber(String eventName, PropertyChangeListener subscriber)
static String getIndexingServerHost()
static final long serialVersionUID
void checkKeywordSearchServerConnectionStatus()
AutopsyEventPublisher eventPublisher
static MessageServiceConnectionInfo getMessageServiceConnectionInfo()