Skip to content

Commit

Permalink
Simulate variable blocking behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabby Anandan committed Aug 17, 2020
1 parent 49afa5f commit 70b5006
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import javax.imageio.ImageIO;
import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

@EnableTask
Expand All @@ -32,6 +34,9 @@ public class ThumbinatorApplication {

String READY_THUMBNAIL_IMG = "/tmp/ready/dataflow-icon-thumb-ready.png";

static List<Integer> SLEEP_TIMERS = Arrays
.asList(1000, 20000, 5000, 7000, 8000, 10000, 10000, 12000, 9900);

Random random = new Random();

@Autowired
Expand Down Expand Up @@ -89,7 +94,8 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon
.println("##### THUMBNAIL DRAFT is: [" + draftThumbnail.length()
+ "] bytes #####");

Thread.sleep(random.nextInt(10000));
// simulate variable wait timer, so metrics can be captured in Prometheus
Thread.sleep(SLEEP_TIMERS.get(random.nextInt(SLEEP_TIMERS.size())));

System.out.println("Job-1 + Step-2 FINISHED");
return RepeatStatus.FINISHED;
Expand Down Expand Up @@ -117,7 +123,8 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon

thumbnailFrom.renameTo(thumbnailTo);

Thread.sleep(random.nextInt(10000));
// simulate variable wait timer, so metrics can be captured in Prometheus
Thread.sleep(SLEEP_TIMERS.get(random.nextInt(SLEEP_TIMERS.size())));

System.out.println(
"##### THUMBNAIL DRAFT is: [" + thumbnailFromSize
Expand All @@ -142,7 +149,8 @@ public Job statusImage() {
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
throws Exception {

Thread.sleep(random.nextInt(10000));
// simulate variable wait timer, so metrics can be captured in Prometheus
Thread.sleep(SLEEP_TIMERS.get(random.nextInt(SLEEP_TIMERS.size())));

System.out.println(
"##### ORIGINAL is: [" + new File(ORIGINAL_IMG).length()
Expand Down

0 comments on commit 70b5006

Please sign in to comment.