Revision 710,
1.2 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 ABINIT = 20; |
---|
12 | private static int C_RAY = 40; |
---|
13 | private static int TAR = 60; |
---|
14 | private static int LIN_3GB = 70; |
---|
15 | private static int LIN_TINY = 80; |
---|
16 | private static int FFT = 100; |
---|
17 | private static Random rand = new Random(5); |
---|
18 | private static Map<String, AppType> mapping = new HashMap<String, AppType>(); |
---|
19 | |
---|
20 | public AppType getAppType(TaskInterface<?> task){ |
---|
21 | AppType appType = null; |
---|
22 | if(mapping.get(task.getJobId())!= null){ |
---|
23 | appType = mapping.get(task.getJobId()); |
---|
24 | }else{ |
---|
25 | appType = randomAppType(); |
---|
26 | mapping.put(task.getJobId(), appType); |
---|
27 | }return appType; |
---|
28 | } |
---|
29 | |
---|
30 | private AppType randomAppType(){ |
---|
31 | AppType appType = null; |
---|
32 | int n = rand.nextInt(100); |
---|
33 | if(n < ABINIT) { |
---|
34 | appType = AppType.abinit; |
---|
35 | }else if(n < C_RAY){ |
---|
36 | appType = AppType.c_ray; |
---|
37 | }else if(n < TAR){ |
---|
38 | appType = AppType.tar; |
---|
39 | } else if (n < LIN_3GB){ |
---|
40 | appType = AppType.lin_3gb; |
---|
41 | } else if (n < LIN_TINY){ |
---|
42 | appType = AppType.lin_tiny; |
---|
43 | } else if (n < FFT){ |
---|
44 | appType = AppType.fft; |
---|
45 | } |
---|
46 | return appType; |
---|
47 | } |
---|
48 | |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.