source: DCWoRMS/trunk/src/test/article2/recs/plugins/scheduling/RecsSP.java @ 828

Revision 828, 1.8 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.article2.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.ComputingNode;
10import schedframe.scheduling.tasks.TaskInterface;
11import test.article2.recs.utils.AppType;
12import test.article2.recs.utils.TaskToApp;
13import dcworms.schedframe.scheduling.ExecTask;
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/article2/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, ComputingNode node) {
30                Executable exec = (Executable)task;
31                String query = getApplicationType(exec) + "." + getNodeCategory(node);
32                return query;
33        }
34
35        private String getApplicationType(ExecTask task){       
36                AppType appType = taskToApp.getAppType(task);
37                return appType.toString();
38        }
39       
40        private String getNodeCategory(ComputingNode node){
41                return node.getCategory();
42        }
43
44        protected boolean getExecutiveness(String query) throws FileNotFoundException, IOException{
45                ResourceBundle execBundle = getExecBundle();
46                return Boolean.valueOf(execBundle.getString(query)).booleanValue();
47        }
48       
49        private ResourceBundle getExecBundle() throws FileNotFoundException, IOException{
50                if(execBundle == null){
51                        execBundle = new PropertyResourceBundle(new FileInputStream(EXEC_DATA_FILE_NAME));
52                }
53                return execBundle;
54        }
55}
Note: See TracBrowser for help on using the repository browser.