source: DCWoRMS/trunk/src/test/article/recs/utils/TaskToApp.java @ 710

Revision 710, 1.2 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
RevLine 
[656]1package test.article.recs.utils;
2
3import java.util.HashMap;
4import java.util.Map;
5import java.util.Random;
6
[659]7import schedframe.scheduling.tasks.TaskInterface;
[656]8
9public class TaskToApp {
10       
[710]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;
[656]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
[659]20        public AppType getAppType(TaskInterface<?> task){
[656]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);
[710]33                if(n < ABINIT) {
34                        appType = AppType.abinit;
35                }else if(n < C_RAY){
36                        appType = AppType.c_ray;
37                }else if(n < TAR){
[656]38                        appType = AppType.tar;
[710]39                } else if (n < LIN_3GB){
40                        appType = AppType.lin_3gb;
[656]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.