mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Remove case path from auto ingest job log lock
This commit is contained in:
parent
19ef658bfc
commit
2c1c255c5c
@ -50,6 +50,7 @@ import org.sleuthkit.autopsy.coreutils.NetworkUtils;
|
|||||||
@Immutable
|
@Immutable
|
||||||
final class AutoIngestJobLogger {
|
final class AutoIngestJobLogger {
|
||||||
|
|
||||||
|
private static final String LOG_LOCK_NAME_FORMAT_STRING = "%s_auto_ingest_log";
|
||||||
private static final String LOG_FILE_NAME = "auto_ingest_log.txt";
|
private static final String LOG_FILE_NAME = "auto_ingest_log.txt";
|
||||||
private static final int LOCK_TIME_OUT = 15;
|
private static final int LOCK_TIME_OUT = 15;
|
||||||
private static final TimeUnit LOCK_TIME_OUT_UNIT = TimeUnit.MINUTES;
|
private static final TimeUnit LOCK_TIME_OUT_UNIT = TimeUnit.MINUTES;
|
||||||
@ -59,6 +60,7 @@ final class AutoIngestJobLogger {
|
|||||||
private final String manifestFileName;
|
private final String manifestFileName;
|
||||||
private final String dataSourceFileName;
|
private final String dataSourceFileName;
|
||||||
private final Path caseDirectoryPath;
|
private final Path caseDirectoryPath;
|
||||||
|
private final String logLockName;
|
||||||
private final String hostName;
|
private final String hostName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,14 +106,17 @@ final class AutoIngestJobLogger {
|
|||||||
* Advanced users doing troubleshooting of an automated ingest cluster
|
* Advanced users doing troubleshooting of an automated ingest cluster
|
||||||
* should also consult the Autopsy and system logs as needed.
|
* should also consult the Autopsy and system logs as needed.
|
||||||
*
|
*
|
||||||
* @param manifestPath The manifest for the auto ingest job.
|
* @param manifestPath The manifest for the auto ingest job.
|
||||||
* @param caseDirectoryPath The case directory.
|
* @param dataSourceFileName The file name of the data source for the auto
|
||||||
|
* ingest job.
|
||||||
|
* @param caseDirectoryPath The absolute path to the case directory.
|
||||||
*/
|
*/
|
||||||
AutoIngestJobLogger(Path manifestPath, String dataSourceFileName, Path caseDirectoryPath) {
|
AutoIngestJobLogger(Path manifestPath, String dataSourceFileName, Path caseDirectoryPath) {
|
||||||
this.manifestPath = manifestPath;
|
this.manifestPath = manifestPath;
|
||||||
manifestFileName = manifestPath.getFileName().toString();
|
manifestFileName = manifestPath.getFileName().toString();
|
||||||
this.dataSourceFileName = dataSourceFileName;
|
this.dataSourceFileName = dataSourceFileName;
|
||||||
this.caseDirectoryPath = caseDirectoryPath;
|
this.caseDirectoryPath = caseDirectoryPath;
|
||||||
|
this.logLockName = String.format(LOG_LOCK_NAME_FORMAT_STRING, caseDirectoryPath.getFileName());
|
||||||
hostName = NetworkUtils.getLocalHostName();
|
hostName = NetworkUtils.getLocalHostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,30 +197,34 @@ final class AutoIngestJobLogger {
|
|||||||
void logDataSourceProcessorCancelled() throws AutoIngestJobLoggerException, InterruptedException {
|
void logDataSourceProcessorCancelled() throws AutoIngestJobLoggerException, InterruptedException {
|
||||||
log(MessageCategory.WARNING, "Cancelled adding data source to case");
|
log(MessageCategory.WARNING, "Cancelled adding data source to case");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs selection of a data source processor
|
* Logs selection of a data source processor
|
||||||
* @param dsp Name of the data source processor
|
*
|
||||||
|
* @param dsp Name of the data source processor
|
||||||
|
*
|
||||||
* @throws AutoIngestJobLoggerException if there is an error writing the log
|
* @throws AutoIngestJobLoggerException if there is an error writing the log
|
||||||
* message.
|
* message.
|
||||||
* @throws InterruptedException if interrupted while blocked waiting
|
* @throws InterruptedException if interrupted while blocked waiting
|
||||||
* to acquire an exclusive lock on the
|
* to acquire an exclusive lock on the
|
||||||
* log file.
|
* log file.
|
||||||
*/
|
*/
|
||||||
void logDataSourceProcessorSelected(String dsp) throws AutoIngestJobLoggerException, InterruptedException{
|
void logDataSourceProcessorSelected(String dsp) throws AutoIngestJobLoggerException, InterruptedException {
|
||||||
log(MessageCategory.INFO, "Using data source processor: " + dsp);
|
log(MessageCategory.INFO, "Using data source processor: " + dsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the failure of the selected data source processor.
|
* Logs the failure of the selected data source processor.
|
||||||
* @param dsp Name of the data source processor
|
*
|
||||||
|
* @param dsp Name of the data source processor
|
||||||
|
*
|
||||||
* @throws AutoIngestJobLoggerException if there is an error writing the log
|
* @throws AutoIngestJobLoggerException if there is an error writing the log
|
||||||
* message.
|
* message.
|
||||||
* @throws InterruptedException if interrupted while blocked waiting
|
* @throws InterruptedException if interrupted while blocked waiting
|
||||||
* to acquire an exclusive lock on the
|
* to acquire an exclusive lock on the
|
||||||
* log file.
|
* log file.
|
||||||
*/
|
*/
|
||||||
void logDataSourceProcessorError(String dsp) throws AutoIngestJobLoggerException, InterruptedException{
|
void logDataSourceProcessorError(String dsp) throws AutoIngestJobLoggerException, InterruptedException {
|
||||||
log(MessageCategory.ERROR, "Error processing with data source processor: " + dsp);
|
log(MessageCategory.ERROR, "Error processing with data source processor: " + dsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +437,7 @@ final class AutoIngestJobLogger {
|
|||||||
* log file.
|
* log file.
|
||||||
*/
|
*/
|
||||||
private void log(MessageCategory category, String message) throws AutoIngestJobLoggerException, InterruptedException {
|
private void log(MessageCategory category, String message) throws AutoIngestJobLoggerException, InterruptedException {
|
||||||
try (Lock lock = CoordinationService.getServiceForNamespace(CoordinationServiceNamespace.getRoot()).tryGetExclusiveLock(CoordinationService.CategoryNode.CASES, getLogPath(caseDirectoryPath).toString(), LOCK_TIME_OUT, LOCK_TIME_OUT_UNIT)) {
|
try (Lock lock = CoordinationService.getServiceForNamespace(CoordinationServiceNamespace.getRoot()).tryGetExclusiveLock(CoordinationService.CategoryNode.CASES, logLockName, LOCK_TIME_OUT, LOCK_TIME_OUT_UNIT)) {
|
||||||
if (null != lock) {
|
if (null != lock) {
|
||||||
File logFile = getLogPath(caseDirectoryPath).toFile();
|
File logFile = getLogPath(caseDirectoryPath).toFile();
|
||||||
try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(logFile, logFile.exists())), true)) {
|
try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(logFile, logFile.exists())), true)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user