Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a comprehensive job management system that supports asynchronous job execution, dynamic file handling, and progress tracking. Key changes include enhancements to job execution via new annotations and an aspect, new services for file storage and job management, and a set of extensive tests covering these new features.
Reviewed Changes
Copilot reviewed 20 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| common/src/test/java/stirling/software/common/service/*.java | Unit tests for TaskManager, ResourceMonitor, JobQueue, JobExecutorService, and FileStorage. |
| common/src/main/java/stirling/software/common/annotations/*.java | Integration and annotation-based job execution (AutoJobPostMapping and AutoJobAspect). |
| common/src/main/java/stirling/software/common/util/*.java | Utility classes for Spring context and executor service. |
| common/src/main/java/stirling/software/common/model/job/*.java | New job model classes for progress, result, response, and statistics. |
| common/src/main/java/stirling/software/common/model/api/PDFFile.java | Updated PDFFile model to support server-side file references. |
| common/build.gradle | Added AOP dependency to support aspect‐oriented programming. |
common/src/main/java/stirling/software/common/service/ResourceMonitor.java
Outdated
Show resolved
Hide resolved
| // Use Spring's BeanUtils to copy all properties, avoiding missed fields if PDFFile grows | ||
| BeanUtils.copyProperties(pdfFile, pdfFileCopy); |
There was a problem hiding this comment.
[nitpick] The use of BeanUtils.copyProperties to deep copy PDFFile objects might introduce performance overhead for large file payloads. It is worth evaluating whether this copying is necessary or if the file data can be managed more efficiently.
| // Use Spring's BeanUtils to copy all properties, avoiding missed fields if PDFFile grows | |
| BeanUtils.copyProperties(pdfFile, pdfFileCopy); | |
| // Manually copy necessary properties to avoid performance overhead | |
| pdfFileCopy.setFileId(pdfFile.getFileId()); | |
| pdfFileCopy.setFileInput(pdfFile.getFileInput()); | |
| pdfFileCopy.setFileName(pdfFile.getFileName()); | |
| pdfFileCopy.setFileSize(pdfFile.getFileSize()); |
…Monitor.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| try { | ||
| isTestEnvironment = Class.forName("org.junit.jupiter.api.Test") != null; | ||
| } catch (ClassNotFoundException e) { | ||
| // Not in a test environment |
There was a problem hiding this comment.
Could have a debug message to say it's not a test env here. Up to you though ;)
Description of Changes
This pull request introduces a job management system with enhanced capabilities for handling asynchronous tasks, file operations, and progress tracking. Key changes include the addition of new annotations and aspects for job execution, file management services, and models for job progress and results.
Job Execution Enhancements:
common/src/main/java/stirling/software/common/annotations/AutoJobPostMapping.java: Added a custom annotation to simplify job handling for POST requests, including support for retries, progress tracking, and resource management.common/src/main/java/stirling/software/common/aop/AutoJobAspect.java: Implemented an aspect to integrate job execution logic, handling retries, asynchronous processing, and file management seamlessly.File Management:
common/src/main/java/stirling/software/common/service/FileStorage.java: Added a service for storing, retrieving, and managing files using unique IDs, enabling persistent file handling for jobs.common/src/main/java/stirling/software/common/service/FileOrUploadService.java: Added utility methods for converting files toMultipartFileand resolving file paths.Job Models:
common/src/main/java/stirling/software/common/model/job/JobProgress.java: Introduced a model to represent job progress, including completion percentage and status messages.common/src/main/java/stirling/software/common/model/job/JobResult.java: Added a model to encapsulate job results, supporting both file-based and object-based outcomes.common/src/main/java/stirling/software/common/model/job/JobResponse.java: Created a model for job responses, including async execution details and job IDs.common/src/main/java/stirling/software/common/model/job/JobStats.java: Added a model for tracking job statistics, such as total jobs, success rates, and average processing times.Other Changes:
common/src/main/java/stirling/software/common/model/api/PDFFile.java: Updated thePDFFilemodel to include afileIdfield for server-side file references, enhancing flexibility in file handling.common/build.gradle: Added thespring-boot-starter-aopdependency to enable aspect-oriented programming.