From 49afa5f66f4ace6e33001c4417c467c317fcf6df Mon Sep 17 00:00:00 2001 From: Sabby Anandan Date: Mon, 17 Aug 2020 13:07:28 -0700 Subject: [PATCH] Simulate longer task runs with sleep --- .../springone/thumbinator/ThumbinatorApplication.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/thumbinator/src/main/java/com/springone/thumbinator/ThumbinatorApplication.java b/thumbinator/src/main/java/com/springone/thumbinator/ThumbinatorApplication.java index e4c0a51..8a46147 100644 --- a/thumbinator/src/main/java/com/springone/thumbinator/ThumbinatorApplication.java +++ b/thumbinator/src/main/java/com/springone/thumbinator/ThumbinatorApplication.java @@ -19,6 +19,7 @@ import javax.imageio.ImageIO; import java.io.File; import java.net.URL; +import java.util.Random; @EnableTask @EnableBatchProcessing @@ -31,6 +32,8 @@ public class ThumbinatorApplication { String READY_THUMBNAIL_IMG = "/tmp/ready/dataflow-icon-thumb-ready.png"; + Random random = new Random(); + @Autowired public JobBuilderFactory jobBuilderFactory; @@ -86,6 +89,8 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon .println("##### THUMBNAIL DRAFT is: [" + draftThumbnail.length() + "] bytes #####"); + Thread.sleep(random.nextInt(10000)); + System.out.println("Job-1 + Step-2 FINISHED"); return RepeatStatus.FINISHED; } @@ -112,6 +117,8 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon thumbnailFrom.renameTo(thumbnailTo); + Thread.sleep(random.nextInt(10000)); + System.out.println( "##### THUMBNAIL DRAFT is: [" + thumbnailFromSize + "] bytes / THUMBNAIL READY is: [" @@ -135,6 +142,8 @@ public Job statusImage() { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { + Thread.sleep(random.nextInt(10000)); + System.out.println( "##### ORIGINAL is: [" + new File(ORIGINAL_IMG).length() + "] bytes / THUMBNAIL is: ["