1 | package test.local.db.loader; |
---|
2 | |
---|
3 | import java.io.FileInputStream; |
---|
4 | import java.io.FileNotFoundException; |
---|
5 | import java.io.IOException; |
---|
6 | import java.util.MissingResourceException; |
---|
7 | import java.util.PropertyResourceBundle; |
---|
8 | import java.util.ResourceBundle; |
---|
9 | |
---|
10 | import simulator.ConfigurationOptions; |
---|
11 | |
---|
12 | /** |
---|
13 | * |
---|
14 | * @author Marcin Krystek |
---|
15 | * |
---|
16 | */ |
---|
17 | public class PropertiesReader extends StatsReader { |
---|
18 | |
---|
19 | protected ResourceBundle resourceBoundle; |
---|
20 | protected int cnt = 3; |
---|
21 | |
---|
22 | public PropertiesReader(String fileName) throws FileNotFoundException, IOException{ |
---|
23 | super(null); |
---|
24 | |
---|
25 | this.resourceBoundle = new PropertyResourceBundle(new FileInputStream(fileName)); |
---|
26 | } |
---|
27 | |
---|
28 | protected PropertiesReader(StatsParser p) { |
---|
29 | super(p); |
---|
30 | } |
---|
31 | |
---|
32 | public String getGridSchedulingPlugin(){ |
---|
33 | return getValue( |
---|
34 | ConfigurationOptions.GRID_SCHEDULING_PLUGIN_NAME_MODIFIER); |
---|
35 | } |
---|
36 | |
---|
37 | public String getLocalSchedulingPlugin(){ |
---|
38 | return getValue( |
---|
39 | ConfigurationOptions.LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER); |
---|
40 | } |
---|
41 | |
---|
42 | public String getTimeEstimationPlugin(){ |
---|
43 | return getValue( |
---|
44 | ConfigurationOptions.EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER); |
---|
45 | |
---|
46 | } |
---|
47 | |
---|
48 | public String getUserDN(){ |
---|
49 | return getValue( |
---|
50 | ConfigurationOptions.USER_DN); |
---|
51 | } |
---|
52 | |
---|
53 | public String getExperimentId(){ |
---|
54 | return getValue( |
---|
55 | ConfigurationOptions.EXPERIMENT_ID); |
---|
56 | } |
---|
57 | |
---|
58 | public boolean next(){ |
---|
59 | /* |
---|
60 | * This simulates one read for skipping file header |
---|
61 | * and one read for reading file content |
---|
62 | */ |
---|
63 | cnt--; |
---|
64 | return (cnt > 0); |
---|
65 | } |
---|
66 | |
---|
67 | protected String getValue(String key){ |
---|
68 | try { |
---|
69 | return this.resourceBoundle.getString(key); |
---|
70 | } catch (MissingResourceException e){ |
---|
71 | return null; |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|