package test.article.recs.utils; import java.util.HashMap; import java.util.Map; import java.util.Random; import schedframe.scheduling.tasks.TaskInterface; public class TaskToApp { private static int TAR = 20; private static int LIN_TINY = 40; private static int LIN_3GB = 60; private static int LIN_1GB = 80; private static int FFT = 100; private static Random rand = new Random(5); private static Map mapping = new HashMap(); public AppType getAppType(TaskInterface task){ AppType appType = null; if(mapping.get(task.getJobId())!= null){ appType = mapping.get(task.getJobId()); }else{ appType = randomAppType(); mapping.put(task.getJobId(), appType); }return appType; } private AppType randomAppType(){ AppType appType = null; int n = rand.nextInt(100); if(n < TAR){ appType = AppType.tar; } else if (n < LIN_TINY){ appType = AppType.lin_tiny; } else if (n < LIN_3GB){ appType = AppType.lin_3gb; } else if (n < LIN_1GB){ appType = AppType.lin_1gb; } else if (n < FFT){ appType = AppType.fft; } return appType; } }