-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSolutionPaneerTikkaMasala.java
109 lines (87 loc) · 4.74 KB
/
SolutionPaneerTikkaMasala.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package none.cgutils.recipe.paneer.tikka;
import none.cgutils.recipe.paneer.tikka.parts.SolutionPart1CheckIngredients;
import none.cgutils.recipe.paneer.tikka.parts.SolutionPart2aMakePaneerTikka;
import none.cgutils.recipe.paneer.tikka.parts.SolutionPart2bMakeMasala;
import none.cgutils.recipe.paneer.tikka.parts.SolutionPart3Cooking;
import none.cgutils.recipe.paneer.tikka.utils.MyThreadFactory;
import none.cgutils.recipe.paneer.tikka.utils.Timer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class SolutionPaneerTikkaMasala {
private static final Logger LOGGER = LogManager.getLogger(PaneerTikkaMasala.class);
public static void main(String[] args) throws Exception {
System.setProperty("isThreadContextMapInheritable", "true");
System.setProperty("log4j2.isThreadContextMapInheritable", "true");
System.setProperty("log4j.configuration", "log4j2.xml");
final ExecutorService executor =
Executors.newFixedThreadPool(10, new MyThreadFactory());
Timer overallTimer = new Timer("Paneer Tikka Masala Timer");
overallTimer.start();
LOGGER.info("\n\nHere goes the Paneer Tikka Masala !!!" +
"\n--------------------------------------");
SolutionPart1CheckIngredients checkIngredients = new SolutionPart1CheckIngredients();
SolutionPart2aMakePaneerTikka makePaneerTikka = new SolutionPart2aMakePaneerTikka();
SolutionPart2bMakeMasala makeMasala = new SolutionPart2bMakeMasala(executor);
SolutionPart3Cooking cooking = new SolutionPart3Cooking(executor);
// TO DO:
// Uncomment the below line
checkIngredients.checkIngredients();
// TO DO:
// Prepare the Paneer Tikka and then marinate them using an executor.
// HINT:
// • Use an instance method thenComposeAsync() on makePaneerTikka.preparePaneerTikka(),
// to call the marinateMixedTkkas(), with the executor.
CompletableFuture<String> paneerTikka = makePaneerTikka.preparePaneerTikka()
.thenComposeAsync(s -> makePaneerTikka.marinateMixedTikkas(), executor);
// TO DO:
// Uncomment the below line
CompletableFuture<String> masala = makeMasala.prepareMasala();
// TO DO:
// Ensure that BOTH paneerTikka and masala parts are completed.
// HINT:
// • Use the static CompletableFuture.allOf() to ensure completion of:
// • paneerTikka
// • masala
// • Use the instance method join() on the 'makeRecipeParts'.
CompletableFuture<Void> makeRecipeParts = CompletableFuture.allOf(paneerTikka, masala);
makeRecipeParts.join();
// TO DO:
// Uncomment the below three lines. The logs help create the recipe part outputs.
// The Cooking part completes the cooking of the paneerTikka and masala parts together,
// hence ensure the completion of cooking should be done by using an instance method
// join() on the cooking.cook().
LOGGER.info(paneerTikka.get());
LOGGER.info(masala.get());
cooking.cook().join();
// TO DO:
// Comment/delete the next two lines. These just exist so we don't hang the program
// before we make the necessary changes.
// paneerTikka.get();
// makeRecipeParts.complete(null);
overallTimer.end();
LOGGER.info("Paneer Tikka Masala ready in {}", overallTimer.getDuration());
// TO DO:
// Comment/delete the next two lines. These just exit so we don't hang the program
// before we mae the necessary changes.
// paneerTikka.get(5L, TimeUnit.SECONDS);
// makeRecipeParts.get(5L, TimeUnit.SECONDS);
executor.awaitTermination(200, TimeUnit.MILLISECONDS);
System.exit(0);
}
}
/*
NOTES
For a vegan version, you can skip the butter and cream and use tofu in place of paneer.
The paneer should ideally by grilled so in case you have a grill use that to make the tikka.
Use 1/2 teaspoon paprika powder in the curry for a deep red/orange color.
I used paprika powder while marinating the paneer but forgot to add in the curry.
If you want, you can strain the pureed mixture before putting it back in the pan.
This will just make the curry totally smooth.
The quantity of butter and cream in the recipe depends on your taste and preference.
The original recipe had an additional tablespoon of butter which I didn't add.
You can also drizzle around 1/2 teaspoon of lemon juice on the curry once it's done.
*/