mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
Add node data version checks to AIM
This commit is contained in:
parent
261a8d950f
commit
0aa5557b34
@ -74,6 +74,16 @@ final class AutoIngestJobNodeData {
|
|||||||
private String processingStageDetailsDescription; // 'byte' length used in byte array
|
private String processingStageDetailsDescription; // 'byte' length used in byte array
|
||||||
private long processingStageDetailsStartDate;
|
private long processingStageDetailsStartDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current version of the auto ingest job coordination service node
|
||||||
|
* data.
|
||||||
|
*
|
||||||
|
* @return The version number.
|
||||||
|
*/
|
||||||
|
static int getCurrentVersion() {
|
||||||
|
return AutoIngestJobNodeData.CURRENT_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses an auto ingest job to construct an object that converts auto ingest
|
* Uses an auto ingest job to construct an object that converts auto ingest
|
||||||
* job data for an auto ingest job coordination service node to and from
|
* job data for an auto ingest job coordination service node to and from
|
||||||
|
@ -1123,33 +1123,47 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
* shutting down.
|
* shutting down.
|
||||||
*/
|
*/
|
||||||
private void addPendingJob(Manifest manifest, AutoIngestJobNodeData nodeData) throws InterruptedException {
|
private void addPendingJob(Manifest manifest, AutoIngestJobNodeData nodeData) throws InterruptedException {
|
||||||
AutoIngestJob job = new AutoIngestJob(manifest);
|
AutoIngestJob job;
|
||||||
job.setPriority(nodeData.getPriority());
|
if (nodeData.getVersion() == AutoIngestJobNodeData.getCurrentVersion()) {
|
||||||
|
job = new AutoIngestJob(nodeData);
|
||||||
|
Path caseDirectory = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
||||||
|
if (null != caseDirectory) {
|
||||||
|
job.setCaseDirectoryPath(caseDirectory);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
job = new AutoIngestJob(manifest);
|
||||||
|
job.setPriority(nodeData.getPriority()); // Retain priority, present in all versions of the node data.
|
||||||
|
Path caseDirectory = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
||||||
|
if (null != caseDirectory) {
|
||||||
|
job.setCaseDirectoryPath(caseDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to upgrade/update the coordination service node data for
|
||||||
|
* the job.
|
||||||
|
*
|
||||||
|
* An exclusive lock is obtained before doing so because another
|
||||||
|
* host may have already found the job, obtained an exclusive
|
||||||
|
* lock, and started processing it. However, this locking does
|
||||||
|
* make it possible that two processing hosts will both try to
|
||||||
|
* obtain the lock to do the upgrade operation at the same time.
|
||||||
|
* If this happens, the host that is holding the lock will
|
||||||
|
* complete the upgrade operation, so there is nothing more for
|
||||||
|
* this host to do.
|
||||||
|
*/
|
||||||
|
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
||||||
|
if (null != manifestLock) {
|
||||||
|
updateCoordinationServiceNode(job);
|
||||||
|
}
|
||||||
|
} catch (CoordinationServiceException ex) {
|
||||||
|
SYS_LOGGER.log(Level.SEVERE, String.format("Error attempting to set node data for %s", manifest.getFilePath()), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
Path caseDirectory = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
Path caseDirectory = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
||||||
if (null != caseDirectory) {
|
if (null != caseDirectory) {
|
||||||
job.setCaseDirectoryPath(caseDirectory);
|
job.setCaseDirectoryPath(caseDirectory);
|
||||||
}
|
}
|
||||||
newPendingJobsList.add(job);
|
newPendingJobsList.add(job);
|
||||||
|
|
||||||
/*
|
|
||||||
* Try to upgrade/update the coordination service node data for the
|
|
||||||
* job.
|
|
||||||
*
|
|
||||||
* An exclusive lock is obtained before doing so because another
|
|
||||||
* host may have already found the job, obtained an exclusive lock,
|
|
||||||
* and started processing it. However, this locking does make it
|
|
||||||
* possible that two hosts will both try to obtain the lock to do
|
|
||||||
* the upgrade/update operation at the same time. If this happens,
|
|
||||||
* the host that is holding the lock will complete the
|
|
||||||
* update/upgrade operation, so there is nothing more to do.
|
|
||||||
*/
|
|
||||||
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
|
||||||
if (null != manifestLock) {
|
|
||||||
AutoIngestManager.this.updateCoordinationServiceNode(job);
|
|
||||||
}
|
|
||||||
} catch (CoordinationServiceException ex) {
|
|
||||||
SYS_LOGGER.log(Level.SEVERE, String.format("Error attempting to set node data for %s", manifest.getFilePath()), ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1180,7 +1194,7 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
||||||
if (null != manifestLock) {
|
if (null != manifestLock) {
|
||||||
AutoIngestJob job = new AutoIngestJob(manifest);
|
AutoIngestJob job = new AutoIngestJob(manifest);
|
||||||
AutoIngestManager.this.updateCoordinationServiceNode(job);
|
updateCoordinationServiceNode(job);
|
||||||
newPendingJobsList.add(job);
|
newPendingJobsList.add(job);
|
||||||
}
|
}
|
||||||
} catch (CoordinationServiceException ex) {
|
} catch (CoordinationServiceException ex) {
|
||||||
@ -1303,13 +1317,21 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
private void addCompletedJob(Manifest manifest, AutoIngestJobNodeData nodeData) throws CoordinationServiceException, InterruptedException {
|
private void addCompletedJob(Manifest manifest, AutoIngestJobNodeData nodeData) throws CoordinationServiceException, InterruptedException {
|
||||||
Path caseDirectoryPath = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
Path caseDirectoryPath = PathUtils.findCaseDirectory(rootOutputDirectory, manifest.getCaseName());
|
||||||
if (null != caseDirectoryPath) {
|
if (null != caseDirectoryPath) {
|
||||||
|
AutoIngestJob job;
|
||||||
|
if (nodeData.getVersion() == AutoIngestJobNodeData.getCurrentVersion()) {
|
||||||
|
job = new AutoIngestJob(nodeData);
|
||||||
|
job.setCaseDirectoryPath(caseDirectoryPath);
|
||||||
|
} else {
|
||||||
/**
|
/**
|
||||||
* We use the manifest rather than the nodeData here to create
|
* Use the manifest rather than the node data here to create
|
||||||
* a new AutoIngestJob instance because the AutoIngestJob
|
* a new AutoIngestJob instance because the AutoIngestJob
|
||||||
* constructor that takes a nodeData expects the nodeData to
|
* constructor that takes a node data object expects the
|
||||||
* have fields that do not exist in earlier versions.
|
* node data to have fields that do not exist in earlier
|
||||||
|
* versions.
|
||||||
*/
|
*/
|
||||||
AutoIngestJob job = new AutoIngestJob(manifest);
|
job = new AutoIngestJob(manifest);
|
||||||
|
job.setCaseDirectoryPath(caseDirectoryPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the job with the fields that exist in all versions
|
* Update the job with the fields that exist in all versions
|
||||||
* of the nodeData.
|
* of the nodeData.
|
||||||
@ -1319,22 +1341,14 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
job.setPriority(nodeData.getPriority());
|
job.setPriority(nodeData.getPriority());
|
||||||
job.setNumberOfCrashes(nodeData.getNumberOfCrashes());
|
job.setNumberOfCrashes(nodeData.getNumberOfCrashes());
|
||||||
job.setProcessingStage(AutoIngestJob.Stage.COMPLETED, nodeData.getCompletedDate());
|
job.setProcessingStage(AutoIngestJob.Stage.COMPLETED, nodeData.getCompletedDate());
|
||||||
|
|
||||||
job.setCaseDirectoryPath(caseDirectoryPath);
|
|
||||||
job.setProcessingStatus(AutoIngestJob.ProcessingStatus.COMPLETED);
|
job.setProcessingStatus(AutoIngestJob.ProcessingStatus.COMPLETED);
|
||||||
newCompletedJobsList.add(job);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to upgrade/update the coordination service node data for
|
* Try to upgrade/update the coordination service node data
|
||||||
* the job.
|
* for the job. It is possible that two hosts will both try
|
||||||
*
|
* to obtain the lock to do the upgrade operation at the
|
||||||
* An exclusive lock is obtained before doing so because another
|
* same time. If this happens, the host that is holding the
|
||||||
* host may have already found the job, obtained an exclusive
|
* lock will complete the upgrade operation.
|
||||||
* lock, and started processing it. However, this locking does
|
|
||||||
* make it possible that two hosts will both try to obtain the
|
|
||||||
* lock to do the upgrade/update operation at the same time. If
|
|
||||||
* this happens, the host that is holding the lock will complete
|
|
||||||
* the update/upgrade operation, so there is nothing more to do.
|
|
||||||
*/
|
*/
|
||||||
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
try (Lock manifestLock = coordinationService.tryGetExclusiveLock(CoordinationService.CategoryNode.MANIFESTS, manifest.getFilePath().toString())) {
|
||||||
if (null != manifestLock) {
|
if (null != manifestLock) {
|
||||||
@ -1343,6 +1357,8 @@ public final class AutoIngestManager extends Observable implements PropertyChang
|
|||||||
} catch (CoordinationServiceException ex) {
|
} catch (CoordinationServiceException ex) {
|
||||||
SYS_LOGGER.log(Level.SEVERE, String.format("Error attempting to set node data for %s", manifest.getFilePath()), ex);
|
SYS_LOGGER.log(Level.SEVERE, String.format("Error attempting to set node data for %s", manifest.getFilePath()), ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
newCompletedJobsList.add(job);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SYS_LOGGER.log(Level.WARNING, String.format("Job completed for %s, but cannot find case directory, ignoring job", nodeData.getManifestFilePath()));
|
SYS_LOGGER.log(Level.WARNING, String.format("Job completed for %s, but cannot find case directory, ignoring job", nodeData.getManifestFilePath()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user