Skip to content

Commit

Permalink
🚧 SiloIngestorJob progress
Browse files Browse the repository at this point in the history
  • Loading branch information
amengus87 committed May 30, 2024
1 parent 0ee1f44 commit b331ea7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@
import ai.dragon.repository.SiloRepository;

@Component
public class SiloIngestorJobHandler implements JobRequestHandler<SiloIngestorRequest> {
public class SiloIngestorJobHandler implements JobRequestHandler<SiloIngestorJobRequest> {
private final Logger logger = new JobRunrDashboardLogger(LoggerFactory.getLogger(this.getClass()));

@Autowired
private SiloRepository siloRepository;

@Override
@Job(name = "Silo Ingestor Job", retries = 10, labels = { "silo", "ingestor" })
public void run(SiloIngestorRequest jobRequest) {
public void run(SiloIngestorJobRequest jobRequest) {
JobDashboardProgressBar progressBar = jobContext().progressBar(100);
jobContext().logger().info(String.format("Running Job for Silo : %s", jobRequest.uuid()));
SiloEntity siloEntity = siloRepository.getByUuid(jobRequest.uuid())
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Entity not found"));
JobDashboardProgressBar progressBar = jobContext().progressBar(100);
ingestDataToSilo(siloEntity, progressBar);
}

private void ingestDataToSilo(SiloEntity siloEntity, JobDashboardProgressBar progressBar) {
jobContext().logger().info(String.format("Name : %s", siloEntity.getName()));
progressBar.setProgress(100);
jobContext().logger().info("Job is running");
throw new RuntimeException("test");

// TODO Loop => if (Thread.currentThread().isInterrupted()) throw new InterruptedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
@Accessors(fluent = true)
@Getter
@Setter
public class SiloIngestorRequest implements JobRequest {
public class SiloIngestorJobRequest implements JobRequest {
private UUID uuid;

@Override
public Class<SiloIngestorJobHandler> getJobRequestHandler() {
return SiloIngestorJobHandler.class;
}

public static SiloIngestorRequest create() {
return new SiloIngestorRequest();
public static SiloIngestorJobRequest create() {
return new SiloIngestorJobRequest();
}
}

0 comments on commit b331ea7

Please sign in to comment.