8202 ingest prog bars on EDT; job cancel off EDT

This commit is contained in:
Richard Cordovano 2021-11-29 15:13:14 -05:00
parent 087c70d492
commit 280580042e

View File

@ -795,38 +795,31 @@ final class IngestJobExecutor {
* processed. * processed.
*/ */
estimatedFilesToProcess = dataSource.accept(new GetFilesCountVisitor()); estimatedFilesToProcess = dataSource.accept(new GetFilesCountVisitor());
if (usingNetBeansGUI) { switchFileIngestProgressBarToDeterminate();
SwingUtilities.invokeLater(() -> {
if (fileIngestProgressBar != null) {
fileIngestProgressBar.switchToDeterminate((int) estimatedFilesToProcess);
}
});
}
} }
if (usingNetBeansGUI) { currentDataSourceIngestPipeline = highPriorityDataSourceIngestPipeline;
if (hasHighPriorityDataSourceIngestModules()) {
/* /*
* Start a data source level ingest progress bar in the lower * Start a data source level ingest progress bar in the lower
* right hand corner of the main application window. The file * right hand corner of the main application window. The file
* and data artifact ingest progress bars were already started * and data artifact ingest progress bars were already started
* in startStreamingModeAnalysis(). * in startStreamingModeAnalysis().
*/ */
if (hasHighPriorityDataSourceIngestModules()) {
startDataSourceIngestProgressBar(); startDataSourceIngestProgressBar();
}
}
currentDataSourceIngestPipeline = highPriorityDataSourceIngestPipeline; /*
if (hasHighPriorityDataSourceIngestModules()) { * Schedule a task for the data source.
*/
IngestJobExecutor.taskScheduler.scheduleDataSourceIngestTask(this); IngestJobExecutor.taskScheduler.scheduleDataSourceIngestTask(this);
} else { } else {
/* /*
* If no data source level ingest task is scheduled at this time * If no data source level ingest task is scheduled at this
* and all of the file level and artifact ingest tasks scheduled * time, and all of the file level and artifact ingest tasks
* during the initial file streaming stage have already * scheduled during the initial file streaming stage have
* executed, there will never be a stage completion check in an * already been executed, there will never be a stage completion
* ingest thread executing an ingest task, so such a job would * check in an ingest thread executing an ingest task, so such a
* run forever without a check here. * job would run forever without a check here.
*/ */
checkForStageCompleted(); checkForStageCompleted();
} }
@ -839,13 +832,9 @@ final class IngestJobExecutor {
private void startLowPriorityDataSourceAnalysis() { private void startLowPriorityDataSourceAnalysis() {
synchronized (stageTransitionLock) { synchronized (stageTransitionLock) {
if (hasLowPriorityDataSourceIngestModules()) { if (hasLowPriorityDataSourceIngestModules()) {
logInfoMessage(String.format("Starting low priority data source analysis for %s (objID=%d, jobID=%d)", dataSource.getName(), dataSource.getId(), ingestJob.getId())); //NON-NLS logInfoMessage("Starting low priority data source analysis"); //NON-NLS
stage = IngestJobExecutor.IngestJobStage.LOW_PRIORITY_DATA_SRC_LEVEL_ANALYSIS; stage = IngestJobExecutor.IngestJobStage.LOW_PRIORITY_DATA_SRC_LEVEL_ANALYSIS;
if (usingNetBeansGUI) {
startDataSourceIngestProgressBar(); startDataSourceIngestProgressBar();
}
currentDataSourceIngestPipeline = lowPriorityDataSourceIngestPipeline; currentDataSourceIngestPipeline = lowPriorityDataSourceIngestPipeline;
taskScheduler.scheduleDataSourceIngestTask(this); taskScheduler.scheduleDataSourceIngestTask(this);
} }
@ -853,14 +842,13 @@ final class IngestJobExecutor {
} }
/** /**
* Starts a data artifacts analysis NetBeans progress bar in the lower right * Starts a NetBeans progress bar for data artifacts analysis in the lower
* hand corner of the main application window. The progress bar provides the * right hand corner of the main application window. The progress bar
* user with a task cancellation button. Pressing it cancels the ingest job. * provides the user with a task cancellation button. Pressing it cancels
* Analysis already completed at the time that cancellation occurs is NOT * the ingest job. Analysis already completed at the time that cancellation
* discarded. * occurs is NOT discarded.
*/ */
private void startArtifactIngestProgressBar() { private void startArtifactIngestProgressBar() {
if (usingNetBeansGUI) {
if (usingNetBeansGUI) { if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
String displayName = NbBundle.getMessage(this.getClass(), "IngestJob.progress.dataArtifactIngest.displayName", this.dataSource.getName()); String displayName = NbBundle.getMessage(this.getClass(), "IngestJob.progress.dataArtifactIngest.displayName", this.dataSource.getName());
@ -878,13 +866,12 @@ final class IngestJobExecutor {
}); });
} }
} }
}
/** /**
* Starts a data source level analysis NetBeans progress bar in the lower * Starts a NetBeans progress bar for data source level analysis in the
* right hand corner of the main application window. The progress bar * lower right hand corner of the main application window. The progress bar
* provides the user with a task cancellation button. Pressing it cancels * provides the user with a task cancellation button. Pressing it cancels
* either the currently running data source level ingest module or the * either the currently running data source level ingest module, or the
* entire ingest job. Analysis already completed at the time that * entire ingest job. Analysis already completed at the time that
* cancellation occurs is NOT discarded. * cancellation occurs is NOT discarded.
*/ */
@ -924,29 +911,8 @@ final class IngestJobExecutor {
} }
} }
private void finishProgressIndicators() {
if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> {
if (dataSourceIngestProgressBar != null) {
dataSourceIngestProgressBar.finish();
dataSourceIngestProgressBar = null;
}
if (fileIngestProgressBar != null) {
fileIngestProgressBar.finish();
fileIngestProgressBar = null;
}
if (artifactIngestProgressBar != null) {
artifactIngestProgressBar.finish();
artifactIngestProgressBar = null;
}
});
}
}
/** /**
* Starts a file analysis NetBeans progress bar in the lower right hand * Starts a NetBeans progress bar for file analysis in the lower right hand
* corner of the main application window. The progress bar provides the user * corner of the main application window. The progress bar provides the user
* with a task cancellation button. Pressing it cancels the ingest job. * with a task cancellation button. Pressing it cancels the ingest job.
* Analysis already completed at the time that cancellation occurs is NOT * Analysis already completed at the time that cancellation occurs is NOT
@ -971,6 +937,49 @@ final class IngestJobExecutor {
} }
} }
/**
* Finishes the first stage progress bars.
*/
private void finishFirstStageProgressBars() {
if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> {
if (dataSourceIngestProgressBar != null) {
dataSourceIngestProgressBar.finish();
dataSourceIngestProgressBar = null;
}
if (fileIngestProgressBar != null) {
fileIngestProgressBar.finish();
fileIngestProgressBar = null;
}
});
}
}
/**
* Finishes all current progress bars.
*/
private void finishProgressBars() {
if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> {
if (dataSourceIngestProgressBar != null) {
dataSourceIngestProgressBar.finish();
dataSourceIngestProgressBar = null;
}
if (fileIngestProgressBar != null) {
fileIngestProgressBar.finish();
fileIngestProgressBar = null;
}
if (artifactIngestProgressBar != null) {
artifactIngestProgressBar.finish();
artifactIngestProgressBar = null;
}
});
}
}
/** /**
* Checks to see if the ingest tasks for the current stage of this job are * Checks to see if the ingest tasks for the current stage of this job are
* completed and does a stage transition if they are. * completed and does a stage transition if they are.
@ -1008,19 +1017,7 @@ final class IngestJobExecutor {
shutDownIngestModulePipeline(pipeline); shutDownIngestModulePipeline(pipeline);
} }
if (usingNetBeansGUI) { finishFirstStageProgressBars();
SwingUtilities.invokeLater(() -> {
if (dataSourceIngestProgressBar != null) {
dataSourceIngestProgressBar.finish();
dataSourceIngestProgressBar = null;
}
if (fileIngestProgressBar != null) {
fileIngestProgressBar.finish();
fileIngestProgressBar = null;
}
});
}
if (!jobCancelled && hasLowPriorityDataSourceIngestModules()) { if (!jobCancelled && hasLowPriorityDataSourceIngestModules()) {
startLowPriorityDataSourceAnalysis(); startLowPriorityDataSourceAnalysis();
@ -1041,7 +1038,7 @@ final class IngestJobExecutor {
shutDownIngestModulePipeline(currentDataSourceIngestPipeline); shutDownIngestModulePipeline(currentDataSourceIngestPipeline);
shutDownIngestModulePipeline(artifactIngestPipeline); shutDownIngestModulePipeline(artifactIngestPipeline);
finishProgressIndicators(); finishProgressBars();
if (ingestJobInfo != null) { if (ingestJobInfo != null) {
if (jobCancelled) { if (jobCancelled) {
@ -1363,6 +1360,20 @@ final class IngestJobExecutor {
} }
} }
/**
* Switches the file ingest progress bar to determinate mode, using the
* estimated number of files to process as the number of work units.
*/
private void switchFileIngestProgressBarToDeterminate() {
if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> {
if (fileIngestProgressBar != null) {
fileIngestProgressBar.switchToDeterminate((int) estimatedFilesToProcess);
}
});
}
}
/** /**
* Queries whether or not a temporary cancellation of data source level * Queries whether or not a temporary cancellation of data source level
* ingest in order to stop the currently executing data source level ingest * ingest in order to stop the currently executing data source level ingest
@ -1383,7 +1394,6 @@ final class IngestJobExecutor {
void currentDataSourceIngestModuleCancellationCompleted(String moduleDisplayName) { void currentDataSourceIngestModuleCancellationCompleted(String moduleDisplayName) {
currentDataSourceIngestModuleCancelled = false; currentDataSourceIngestModuleCancelled = false;
cancelledDataSourceIngestModules.add(moduleDisplayName); cancelledDataSourceIngestModules.add(moduleDisplayName);
if (usingNetBeansGUI) { if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
/** /**
@ -1433,7 +1443,6 @@ final class IngestJobExecutor {
void cancel(IngestJob.CancellationReason reason) { void cancel(IngestJob.CancellationReason reason) {
jobCancelled = true; jobCancelled = true;
cancellationReason = reason; cancellationReason = reason;
IngestJobExecutor.taskScheduler.cancelPendingFileTasksForIngestJob(this);
if (usingNetBeansGUI) { if (usingNetBeansGUI) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
@ -1446,9 +1455,16 @@ final class IngestJobExecutor {
fileIngestProgressBar.setDisplayName(NbBundle.getMessage(getClass(), "IngestJob.progress.fileIngest.displayName", dataSource.getName())); fileIngestProgressBar.setDisplayName(NbBundle.getMessage(getClass(), "IngestJob.progress.fileIngest.displayName", dataSource.getName()));
fileIngestProgressBar.progress(NbBundle.getMessage(getClass(), "IngestJob.progress.cancelling")); fileIngestProgressBar.progress(NbBundle.getMessage(getClass(), "IngestJob.progress.cancelling"));
} }
if (artifactIngestProgressBar != null) {
artifactIngestProgressBar.setDisplayName(NbBundle.getMessage(getClass(), "IngestJob.progress.dataArtifactIngest.displayName", dataSource.getName()));
artifactIngestProgressBar.progress(NbBundle.getMessage(getClass(), "IngestJob.progress.cancelling"));
}
}); });
} }
IngestJobExecutor.taskScheduler.cancelPendingFileTasksForIngestJob(this);
synchronized (threadRegistrationLock) { synchronized (threadRegistrationLock) {
for (Thread thread : pausedIngestThreads) { for (Thread thread : pausedIngestThreads) {
thread.interrupt(); thread.interrupt();