Revision 659,
1.1 KB
checked in by wojtekp, 12 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package test.article.recs.utils; |
---|
2 | |
---|
3 | import java.util.HashMap; |
---|
4 | import java.util.Map; |
---|
5 | import java.util.Random; |
---|
6 | |
---|
7 | import schedframe.scheduling.tasks.TaskInterface; |
---|
8 | |
---|
9 | public class TaskToApp { |
---|
10 | |
---|
11 | private static int TAR = 20; |
---|
12 | private static int LIN_TINY = 40; |
---|
13 | private static int LIN_3GB = 60; |
---|
14 | private static int LIN_1GB = 80; |
---|
15 | private static int FFT = 100; |
---|
16 | private static Random rand = new Random(5); |
---|
17 | private static Map<String, AppType> mapping = new HashMap<String, AppType>(); |
---|
18 | |
---|
19 | public AppType getAppType(TaskInterface<?> task){ |
---|
20 | AppType appType = null; |
---|
21 | if(mapping.get(task.getJobId())!= null){ |
---|
22 | appType = mapping.get(task.getJobId()); |
---|
23 | }else{ |
---|
24 | appType = randomAppType(); |
---|
25 | mapping.put(task.getJobId(), appType); |
---|
26 | }return appType; |
---|
27 | } |
---|
28 | |
---|
29 | private AppType randomAppType(){ |
---|
30 | AppType appType = null; |
---|
31 | int n = rand.nextInt(100); |
---|
32 | if(n < TAR){ |
---|
33 | appType = AppType.tar; |
---|
34 | } else if (n < LIN_TINY){ |
---|
35 | appType = AppType.lin_tiny; |
---|
36 | } else if (n < LIN_3GB){ |
---|
37 | appType = AppType.lin_3gb; |
---|
38 | } else if (n < LIN_1GB){ |
---|
39 | appType = AppType.lin_1gb; |
---|
40 | } else if (n < FFT){ |
---|
41 | appType = AppType.fft; |
---|
42 | } |
---|
43 | return appType; |
---|
44 | } |
---|
45 | |
---|
46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.