mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Merge remote-tracking branch 'upstream/custom-release-may-2018' into develop
This commit is contained in:
commit
69147e14ec
@ -190,7 +190,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
|
|||||||
stopTimer();
|
stopTimer();
|
||||||
|
|
||||||
healthMonitorOutputTimer = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat("health_monitor_timer").build());
|
healthMonitorOutputTimer = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat("health_monitor_timer").build());
|
||||||
healthMonitorOutputTimer.scheduleWithFixedDelay(new PeriodicHealthMonitorTask(), DATABASE_WRITE_INTERVAL, DATABASE_WRITE_INTERVAL, TimeUnit.MINUTES);
|
healthMonitorOutputTimer.scheduleWithFixedDelay(new PeriodicHealthMonitorTask(false), DATABASE_WRITE_INTERVAL, DATABASE_WRITE_INTERVAL, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,12 +356,17 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect metrics at a scheduled time.
|
* Collect metrics at a scheduled time.
|
||||||
|
* @param caseIsClosing True if this was triggered from a case closed event
|
||||||
* @throws HealthMonitorException
|
* @throws HealthMonitorException
|
||||||
*/
|
*/
|
||||||
private void gatherTimerBasedMetrics() throws HealthMonitorException {
|
private void gatherTimerBasedMetrics(boolean caseIsClosing) throws HealthMonitorException {
|
||||||
// Time a database query
|
// Time a database query. If this was triggered from a case close event
|
||||||
|
// it will fail - since we're on a new thread the case database will
|
||||||
|
// be in the process of closing. In that case, skip collecting the metric.
|
||||||
|
if( ! caseIsClosing) {
|
||||||
performDatabaseQuery();
|
performDatabaseQuery();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the collected metrics to the database.
|
* Write the collected metrics to the database.
|
||||||
@ -806,17 +811,23 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
|
|||||||
*/
|
*/
|
||||||
static final class PeriodicHealthMonitorTask implements Runnable {
|
static final class PeriodicHealthMonitorTask implements Runnable {
|
||||||
|
|
||||||
|
boolean caseIsClosing;
|
||||||
|
|
||||||
|
PeriodicHealthMonitorTask(boolean caseIsClosing) {
|
||||||
|
this.caseIsClosing = caseIsClosing;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform all periodic tasks:
|
* Perform all periodic tasks:
|
||||||
* - Check if monitoring has been enabled / disabled in the database
|
* - Check if monitoring has been enabled / disabled in the database
|
||||||
* - Gather any additional metrics
|
* - Calculate any final metrics
|
||||||
* - Write current metric data to the database
|
* - Write current metric data to the database
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
getInstance().updateFromGlobalEnabledStatus();
|
getInstance().updateFromGlobalEnabledStatus();
|
||||||
getInstance().gatherTimerBasedMetrics();
|
getInstance().gatherTimerBasedMetrics(caseIsClosing);
|
||||||
getInstance().writeCurrentStateToDatabase();
|
getInstance().writeCurrentStateToDatabase();
|
||||||
} catch (HealthMonitorException ex) {
|
} catch (HealthMonitorException ex) {
|
||||||
logger.log(Level.SEVERE, "Error performing periodic task", ex); //NON-NLS
|
logger.log(Level.SEVERE, "Error performing periodic task", ex); //NON-NLS
|
||||||
@ -832,7 +843,7 @@ public final class EnterpriseHealthMonitor implements PropertyChangeListener {
|
|||||||
case CURRENT_CASE:
|
case CURRENT_CASE:
|
||||||
if ((null == evt.getNewValue()) && (evt.getOldValue() instanceof Case)) {
|
if ((null == evt.getNewValue()) && (evt.getOldValue() instanceof Case)) {
|
||||||
// When a case is closed, write the current metrics to the database
|
// When a case is closed, write the current metrics to the database
|
||||||
healthMonitorExecutor.submit(new EnterpriseHealthMonitor.PeriodicHealthMonitorTask());
|
healthMonitorExecutor.submit(new EnterpriseHealthMonitor.PeriodicHealthMonitorTask(true));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user