Changeset 14
- Timestamp:
- 08/22/11 10:42:49 (14 years ago)
- Location:
- gssim/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
gssim/trunk/build.xml
r5 r14 180 180 </target> 181 181 182 <target name="genWorkload"> 183 <available property="properties.file" type="file" file="${config}" value="${config}"/> 184 <antcall target="generateWorkload"/> 185 </target> 186 187 <target name="generateWorkload" depends="compile" if="properties.file"> 188 <echo message="Generating workload described in: ${properties.file}"/> 189 190 <java classname="simulator.workload.generator.WorkloadGenerator" classpath="${build}/classes" fork="true"> 191 <arg file="${properties.file}"/> 192 <classpath> 193 <path refid="class.path"/> 194 <pathelement path="${jars}/commons-beanutils.jar"/> 195 <pathelement path="${jars}/commons-digester-1.7.jar"/> 196 <pathelement path="${jars}/junit-4.4.jar"/> 197 <pathelement path="${jars}/log4j-1.2.13.jar"/> 198 <pathelement path="${jars}/xalan-2.6.jar"/> 199 <pathelement path="${jars}/xerces/xerces-2_9_0/xercesImpl.jar"/> 200 <pathelement path="${jars}/xerces/xerces-2_9_0/xml-apis.jar"/> 201 <dirset dir="properties" /> 202 </classpath> 203 </java> 204 </target> 205 182 206 </project> -
gssim/trunk/daemon/Daemon.cpp
r5 r14 28 28 #define EVENT_SIZE ( sizeof (struct inotify_event) ) 29 29 #define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) 30 #define RUNNING_DIR "/ opt/app/gssim/daemon"30 #define RUNNING_DIR "/home/mcichenski/daemon" 31 31 #define LOCK_FILE "daemon.lock" 32 32 #define LOG_FILE "daemon.log" … … 38 38 char gssimdir[255]; 39 39 char gssimexecfile[255]; 40 char gssimpropertyfile[255]; 40 41 char basedir[255]; 41 42 char msg[255]; … … 162 163 if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) 163 164 { 164 cerr << "Error while reading gssim dir" << endl; 165 exit(-1); 166 } 165 cerr << "Error while reading gssim dir " << gssimdir << endl; 166 cerr << "config file: " << config_file << endl; 167 exit(-1); 168 } 169 strcpy(msg, "Gssim directory found: "); 170 strcat(msg, gssimdir); 171 log_message(LOG_FILE, msg); 167 172 168 173 fin.getline(gssimexecfile, 255); … … 172 177 exit(-1); 173 178 } 174 179 strcpy(msg, "Gssim exec file found: "); 180 strcat(msg, gssimexecfile); 181 log_message(LOG_FILE, msg); 182 183 fin.getline(gssimpropertyfile, 255); 184 if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) 185 { 186 cerr << "Error while reading gssim property file name" << endl;; 187 exit(-1); 188 } 189 strcpy(msg, "Gssim property file found: "); 190 strcat(msg, gssimpropertyfile); 191 log_message(LOG_FILE, msg); 192 175 193 fin.getline(basedir, 255); 176 194 if ( (fin.rdstate() & (ifstream::failbit | ifstream::eofbit)) != 0 ) … … 179 197 exit(-1); 180 198 } 199 strcpy(msg, "Base watch directory found: "); 200 strcat(msg, basedir); 201 log_message(LOG_FILE, msg); 181 202 182 203 fin.close(); … … 202 223 203 224 strcpy(msg, "Directory "); 204 strcat(msg, basedir);225 strcat(msg, paths[wd]); 205 226 strcat(msg, " is added to watch list"); 206 227 log_message(LOG_FILE, msg); … … 228 249 strcat(msg, event->name); 229 250 strcat(msg, " created."); 230 log_message(LOG_FILE, msg); 231 232 char dir[255] = "\0";233 strc at(dir, paths[event->wd]);251 log_message(LOG_FILE, msg); 252 253 char dir[255]; 254 strcpy(dir, paths[event->wd]); 234 255 strcat(dir, "/"); 235 256 strcat(dir, event->name); 236 257 wd = inotify_add_watch(fd, dir, IN_CREATE 237 258 | IN_CLOSE_WRITE); 259 paths[wd] = dir; 238 260 239 261 strcpy(msg, "Directory "); … … 241 263 strcat(msg, " is added to watch list"); 242 264 log_message(LOG_FILE, msg); 243 244 paths[wd] = dir; 265 266 strcpy(msg, "wd: "); 267 char str[255] = "\0"; 268 sprintf(str, "%d", event->wd); 269 strcat(msg, str); 270 strcat(msg, " path: "); 271 strcat(msg, paths[event->wd]); 272 strcat(msg, " new_wd: "); 273 char str2[255] = "\0"; 274 sprintf(str2, "%d", wd); 275 strcat(msg, str2); 276 strcat(msg, " new_path: "); 277 strcat(msg, paths[wd]); 278 log_message(LOG_FILE, msg); 245 279 } 246 280 } else if (event->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { … … 280 314 strcat(gssim, "/"); 281 315 strcat(gssim, gssimexecfile); 316 char property[255] = "\0"; 317 strcpy(property, gssimdir); 318 strcat(property, "/"); 319 strcat(property, gssimpropertyfile); 282 320 strcat(path, "/"); 283 321 strcat(path, name.c_str()); 284 322 cout << gssim << endl << path << endl; 285 execl(gssim, "gssim", path, NULL);323 execl(gssim, "gssim", path, property, NULL); 286 324 } else { 287 325 waitpid(pid, NULL, 0); -
gssim/trunk/daemon/daemon.config
r5 r14 1 1 /opt/app/gssim/ 2 2 start-db-analyzer.sh 3 properties.config 3 4 /opt/app/gssim/results/ 4 5 ------------------------------ … … 6 7 1) directory in which gssim is installed 7 8 2) name of file that should be executed 8 3) base directory which should be watched 9 3) name of property file that should be loaded for db access 10 4) base directory which should be watched 9 11 10 12 Path to daemon running directory is precompiled -
gssim/trunk/db/gssim/db/analyzer/Analyzer.java
r5 r14 133 133 private Experiment experiment; 134 134 private String userDN; 135 private Integer expNoInSeries; 136 137 public Analyzer(int n) throws InstantiationException, 135 private Integer totalSimulationRuns; 136 private Integer currentSimulationRun; 137 138 public Analyzer() throws InstantiationException, 138 139 IllegalAccessException, ClassNotFoundException { 139 140 140 expNoInSeries = n;141 141 jobID = new HashMap<Integer, Integer>(); 142 142 taskID = new HashMap<Pair<Integer, Integer>, Integer>(); … … 154 154 userDN = null; 155 155 factory = new MySQLDAOFactory(); 156 totalSimulationRuns = 1; 156 157 } 157 158 … … 170 171 InstantiationException, IllegalAccessException, 171 172 ClassNotFoundException { 172 Analyzer analyzer = new Analyzer( 1);173 Analyzer analyzer = new Analyzer(); 173 174 analyzer.run(args); 174 175 } … … 206 207 if (args.length < 1 || args.length > 3) 207 208 throw new RuntimeException( 208 "Program should be run with 1- 4arguments: "209 "Program should be run with 1-3 arguments: " 209 210 + "*.tar file or directory with experiment results, " 210 211 + "encrypted or unencrypted properties file, " … … 217 218 try { 218 219 219 if (gssimResults.getName().endsWith(".tar")) {220 221 FileInputStream fileStream = new FileInputStream(gssimResults);222 tarInputStream = new TarArchiveInputStream(fileStream);223 prepareStreams(tarInputStream, config);224 225 } else if (gssimResults.isDirectory()) {226 227 PrepareStreams(gssimResults, config);228 229 } else230 throw new RuntimeException(231 "This program should be run with one argument: "232 + "*.tar file or directory with experiment results");233 234 checkFilesPresence(config);235 236 220 connection = factory.createDBConnection(config.getDb(), config 237 221 .getUser(), config.getPassword()); … … 239 223 connection.setAutoCommit(false); 240 224 241 setup(inputStreams.get("propertiesInputStream"), config); 242 process(); 243 225 currentSimulationRun = 0; 226 227 while (currentSimulationRun != totalSimulationRuns) 228 { 229 currentSimulationRun++; 230 config.initFileNames(currentSimulationRun); 231 if (gssimResults.getName().endsWith(".tar")) { 232 233 FileInputStream fileStream = new FileInputStream(gssimResults); 234 tarInputStream = new TarArchiveInputStream(fileStream); 235 prepareStreams(tarInputStream, config); 236 237 } else if (gssimResults.isDirectory()) { 238 239 PrepareStreams(gssimResults, config); 240 241 } else 242 throw new RuntimeException( 243 "This program should be run with one argument: " 244 + "*.tar file or directory with experiment results"); 245 246 checkFilesPresence(config); 247 248 setup(inputStreams.get("propertiesInputStream"), config); 249 process(); 250 } 244 251 connection.commit(); 245 252 log.info("Database operations are commited"); … … 582 589 } 583 590 584 if (properties.containsKey("experiment.id")) { 591 if (properties.containsKey("numberofsimulations")) 592 { 593 totalSimulationRuns = Integer.parseInt((String) properties.get("numberofsimulations")); 594 } 595 596 if (properties.containsKey("experiment.id") && currentSimulationRun == 1) { 585 597 experiment = new Experiment(); 586 598 experiment.setPK(Integer.parseInt((String) properties.get("experiment.id"))); … … 596 608 597 609 configuration = new Configuration(); 598 configurationDAO.insert(configuration, false);599 610 600 611 user = new User(); 601 612 user.setDN("unknown_user"); 602 userDAO.insert(user, false); 603 613 614 Integer metaExpId = null; 615 String name = "experiment"; 616 617 if (properties.containsKey("experiment.id")) 618 { 619 experiment = new Experiment(); 620 experiment.setPK(Integer.parseInt((String) properties.get("experiment.id"))); 621 experiment = experimentDAO.select(experiment); 622 623 metaExpId = experiment.getMetaexpId(); 624 name = experiment.getName(); 625 user.setId(experiment.getUserId()); 626 configuration.setId(experiment.getConfigId()); 627 } 628 else 629 { 630 userDAO.insert(user, false); 631 configurationDAO.insert(configuration, false); 632 } 633 604 634 experiment = new Experiment(); 605 635 experiment.setConfigId(configuration.getId()); 606 636 experiment.setUserId(user.getId()); 607 637 experiment.setCommissionDate(new Timestamp((new Date()).getTime())); 608 experiment.setName("default-name"); 638 experiment.setMetaexpId(metaExpId); 639 experiment.setName(name+ "_" + currentSimulationRun.toString()); 609 640 experiment.setStatus("FINISHED"); 610 641 experimentDAO.insert(experiment, false); -
gssim/trunk/db/gssim/db/config/Config.java
r5 r14 94 94 } 95 95 96 public void initFileNames(Integer simulationRun) 97 { 98 statsFile = "Stats_Simulation " + simulationRun.toString() + "_Simulation.txt"; 99 jobsFile = "Stats_Simulation " + simulationRun.toString() + "_Jobs.txt"; 100 tasksFile = "Stats_Simulation " + simulationRun.toString() + "_Raw_Tasks.txt"; 101 resourcesFile = "Stats_Simulation " + simulationRun.toString() + "_Raw_Resources.txt"; 102 energyFile = "Stats_Simulation " + simulationRun.toString() + "_Energy.txt"; 103 resourceLoadFile = "Stats_Simulation " + simulationRun.toString() + "_Resource_Load.txt"; 104 accumulatedResourcesFile = "Stats_Simulation " + simulationRun.toString() + "_Accumulated_Resources.txt"; 105 networkFile = "Stats_Simulation " + simulationRun.toString() + "_Network.txt"; 106 propertiesFile = "experiment.properties"; 107 } 108 96 109 /** 97 110 * Gets the stats file. -
gssim/trunk/db/gssim/db/config/MySQLConfig.java
r5 r14 12 12 super(propertiesPath); 13 13 14 init OtherConfigParameters();14 initParameters(1); 15 15 } 16 16 … … 20 20 super(encryptedPropertiesPath, keyPath); 21 21 22 init OtherConfigParameters();22 initParameters(1); 23 23 24 24 System.out.println(user); … … 32 32 db = "localhost:3306/gssim_results"; 33 33 34 init OtherConfigParameters();34 initParameters(1); 35 35 } 36 36 37 private void initOtherConfigParameters() { 38 statsFile = "Stats_Simulation 1_Simulation.txt"; 39 jobsFile = "Stats_Simulation 1_Jobs.txt"; 40 tasksFile = "Stats_Simulation 1_Raw_Tasks.txt"; 41 resourcesFile = "Stats_Simulation 1_Raw_Resources.txt"; 42 energyFile = "Stats_Simulation 1_Energy.txt"; 43 resourceLoadFile = "Stats_Simulation 1_Resource_Load.txt"; 44 accumulatedResourcesFile = "Stats_Simulation 1_Accumulated_Resources.txt"; 45 networkFile = "Stats_Simulation 1_Network.txt"; 46 propertiesFile = "experiment.properties"; 37 private void initParameters(Integer simulationRun) { 38 initFileNames(simulationRun); 47 39 48 40 extractDirectoryPath = null; … … 50 42 propertiesIgnoreKeys = new ArrayList<String>(); 51 43 44 //why this is specific to MySQLConfig implementation? 52 45 propertiesIgnoreKeys.add("createstatistics.formatoutput"); 53 46 propertiesIgnoreKeys.add("printhistory"); 54 propertiesIgnoreKeys.add("readscenario.workloadfilename");55 47 propertiesIgnoreKeys.add("readscenario.inputfolder"); 56 propertiesIgnoreKeys.add("resdesc");57 48 propertiesIgnoreKeys.add("stats.outputfolder"); 58 49 propertiesIgnoreKeys.add("user.dn"); -
gssim/trunk/db/gssim/db/mysql/ExperimentStatsDAO.java
r5 r14 51 51 @Override 52 52 protected PreparedStatementAdapter createSelectStmt() throws SQLException { 53 String sql = "SELECT * FROM unit_details WHERE id = ? AND name = ?";53 String sql = "SELECT * FROM experiment_stats WHERE id = ? AND name = ?"; 54 54 PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 55 55 .getConnection().prepareStatement(sql)); -
gssim/trunk/db/gssim/db/mysql/ResourceAllTimelineDAO.java
r5 r14 64 64 } 65 65 66 protected PreparedStatementAdapter createSumStmt() throws SQLException { 67 String sql = "SELECT timestamp, SUM(`usage`) as 'usage'" + 68 " FROM resource_allocation_timeline rat" + 69 " JOIN resource r ON r.PK = rat.fk_resource_id" + 70 " WHERE exp_id = ?" + 71 " AND (timestamp between ? AND ?)" + 72 " GROUP BY TIMESTAMP"; 73 PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 74 .getConnection().prepareStatement(sql)); 75 return stmt; 76 } 77 66 78 @Override 67 79 public boolean delete(ResourceAllTimeline obj, boolean commit) … … 204 216 throw new NotImplemented(); 205 217 } 218 219 public List<ResourceAllTimeline> sum(Finder finder) throws SQLException { 220 221 PreparedStatementAdapter stmt = createSumStmt(); 222 List<ResourceAllTimeline> list = new ArrayList<ResourceAllTimeline>(); 223 224 stmt.setInt(1, finder.getInteger("fkResourceId")); 225 stmt.setTimestamp(2, finder.getMinTimestamp("timestamp")); 226 stmt.setTimestamp(3, finder.getMaxTimestamp("timestamp")); 227 ResultSetAdapter result = new ResultSetAdapter(stmt.executeQuery()); 228 229 while (result.next()) { 230 ResourceAllTimeline obj = new ResourceAllTimeline(); 231 232 Timestamp timestamp = result.getTimestamp("timestamp"); 233 Float usage = result.getFloatObj("usage"); 234 235 obj.setTimestamp(timestamp); 236 obj.setUsage(usage); 237 238 list.add(obj); 239 } 240 241 return list; 242 } 206 243 207 244 } -
gssim/trunk/db/gssim/db/mysql/ResourceEnTimelineDAO.java
r5 r14 1 1 package gssim.db.mysql; 2 2 3 import gssim.db.dao.data.ResourceAllTimeline; 3 4 import gssim.db.dao.data.ResourceEnTimeline; 4 5 import gssim.db.find.Finder; … … 63 64 return null; 64 65 } 66 67 protected PreparedStatementAdapter createSumStmt() throws SQLException { 68 String sql = "SELECT timestamp, SUM(`usage`) as 'usage'" + 69 " FROM resource_energy_timeline rat" + 70 " JOIN resource r ON r.PK = rat.fk_resource_id" + 71 " WHERE exp_id = ?" + 72 " AND (timestamp between ? AND ?)" + 73 " GROUP BY TIMESTAMP"; 74 PreparedStatementAdapter stmt = new PreparedStatementAdapter(this 75 .getConnection().prepareStatement(sql)); 76 return stmt; 77 } 65 78 66 79 @Override … … 204 217 throw new NotImplemented(); 205 218 } 219 220 public List<ResourceEnTimeline> sum(Finder finder) throws SQLException { 221 222 PreparedStatementAdapter stmt = createSumStmt(); 223 List<ResourceEnTimeline> list = new ArrayList<ResourceEnTimeline>(); 224 225 stmt.setInt(1, finder.getInteger("fkResourceId")); 226 stmt.setTimestamp(2, finder.getMinTimestamp("timestamp")); 227 stmt.setTimestamp(3, finder.getMaxTimestamp("timestamp")); 228 ResultSetAdapter result = new ResultSetAdapter(stmt.executeQuery()); 229 230 while (result.next()) { 231 ResourceEnTimeline obj = new ResourceEnTimeline(); 232 233 Timestamp timestamp = result.getTimestamp("timestamp"); 234 Float usage = result.getFloatObj("usage"); 235 236 obj.setTimestamp(timestamp); 237 obj.setUsage(usage); 238 239 list.add(obj); 240 } 241 242 return list; 243 } 206 244 207 245 }
Note: See TracChangeset
for help on using the changeset viewer.