source: DCWoRMS/branches/coolemall/src/test/thermal/recs/plugins/scheduling/RecsSP.java @ 1301

Revision 1301, 2.2 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.thermal.recs.plugins.scheduling;
2
3import java.io.FileInputStream;
4import java.io.FileNotFoundException;
5import java.io.IOException;
6import java.util.PropertyResourceBundle;
7import java.util.ResourceBundle;
8
9import schedframe.resources.computing.Node;
10import schedframe.resources.computing.Processor;
11import schedframe.scheduling.tasks.TaskInterface;
12import test.thermal.recs.utils.AppType;
13import test.thermal.recs.utils.TaskToApp;
14import dcworms.schedframe.scheduling.Executable;
15import example.localplugin.BaseLocalSchedulingPlugin;
16
17public abstract class RecsSP extends BaseLocalSchedulingPlugin {
18
19        private static String EXEC_DATA_FILE_NAME = "src/test/thermal/recs/data/executiveness_data.properties";
20       
21        private ResourceBundle execBundle;
22       
23        protected TaskToApp taskToApp = new TaskToApp();
24       
25        protected void initApplicationType(TaskInterface<?> task){
26                 taskToApp.getAppType(task);
27        }
28       
29        protected String createExecutivenessQuery(TaskInterface<?> task, Node node) {
30                Executable exec = (Executable)task;
31                String query = getApplicationType(exec) + "." + getNodeCategory(node);
32                return query;
33        }
34
35        protected String getApplicationType(TaskInterface<?> task){     
36                AppType appType = taskToApp.getAppType(task);
37                return appType.toString();
38        }
39       
40        protected String getNodeCategory(Node node){
41                return node.getCategory();
42        }
43
44        protected int getCoreCnt(TaskInterface<?> task){       
45                double cpuReq;
46                try {
47                        cpuReq = task.getCpuCntRequest();
48                } catch (NoSuchFieldException e) {
49                                cpuReq = 1;
50                }
51                return Double.valueOf(cpuReq).intValue();
52        }
53       
54        protected int getFrequency(Node node){
55                Processor proc = (Processor) node.getProcessors().get(0);
56                double freq = proc.getPowerInterface().getFrequency();
57                return Double.valueOf(freq).intValue();
58        }
59       
60        protected boolean getExecutiveness(String query) throws FileNotFoundException, IOException{
61                ResourceBundle execBundle = getExecBundle();
62                return Boolean.valueOf(execBundle.getString(query)).booleanValue();
63        }
64       
65        private ResourceBundle getExecBundle() throws FileNotFoundException, IOException{
66                if(execBundle == null){
67                        execBundle = new PropertyResourceBundle(new FileInputStream(EXEC_DATA_FILE_NAME));
68                }
69                return execBundle;
70        }
71}
Note: See TracBrowser for help on using the repository browser.