1 package edu.rice.rubbos.client; 2 3 import java.io.BufferedReader ; 4 import java.io.FileReader ; 5 import java.io.RandomAccessFile ; 6 import java.util.ResourceBundle ; 7 import java.util.StringTokenizer ; 8 import java.util.Vector ; 9 10 17 18 public class RUBBoSProperties 19 { 20 private static ResourceBundle configuration = null; 21 private URLGenerator urlGen = null; 22 23 private String webSiteName; 25 private int webSitePort; 26 private String cjdbcSiteName; 27 private String EJBHTMLPath; 28 private String EJBScriptPath; 29 private String ServletsHTMLPath; 30 private String ServletsScriptPath; 31 private String PHPHTMLPath; 32 private String PHPScriptPath; 33 private String useVersion; 34 35 private Vector remoteClients; 37 private String remoteCommand; 38 private int nbOfClients; 39 private String userTransitionTable; 40 private String authorTransitionTable; 41 private int nbOfColumns; 42 private int nbOfRows; 43 private int maxNbOfTransitions; 44 private boolean useTPCWThinkTime; 45 private int nbOfStoriesPerPage; 46 private int upTime; 47 private float upSlowdown; 48 private int sessionTime; 49 private int downTime; 50 private float downSlowdown; 51 private int percentOfAuthors; 52 53 54 private String dbServerName; 56 57 private Integer nbOfAuthors; 58 private Integer nbOfUsers; 59 60 private String storyDictionary; 61 private Integer storyMaxLength; 62 private Integer oldestStoryYear; 63 private Integer oldestStoryMonth; 64 65 private Integer maxCommentsPerStory; 66 private Integer commentMaxLength; 67 68 69 private Integer monitoringDebug; 71 private String monitoringProgram; 72 private String monitoringOptions; 73 private Integer monitoringSampling; 74 private String monitoringRsh; 75 private String monitoringScp; 76 private String monitoringGnuPlot; 77 78 83 public RUBBoSProperties() 84 { 85 System.out.println("Looking for rubbos.properties in classpath ("+System.getProperty("java.class.path",".")+")<p>"); 87 try 88 { 89 configuration = ResourceBundle.getBundle("rubbos"); 90 } 91 catch (java.util.MissingResourceException e) 92 { 93 System.err.println("No rubbos.properties file has been found in your classpath.<p>"); 94 Runtime.getRuntime().exit(1); 95 } 96 } 97 98 99 105 protected String getProperty(String property) 106 { 107 String s = configuration.getString(property); 108 return s; 109 } 110 111 112 118 public URLGenerator checkPropertiesFileAndGetURLGenerator() 119 { 120 try 121 { 122 System.out.println("\n<h3>### HTTP server information ###</h3>"); 124 System.out.print("Server name : "); 125 webSiteName = getProperty("httpd_hostname"); 126 System.out.println(webSiteName+"<br>"); 127 System.out.print("Server port : "); 128 Integer foo = new Integer (getProperty("httpd_port")); 129 webSitePort = foo.intValue(); 130 System.out.println(webSitePort+"<br>"); 131 System.out.print("CJDBC server name : "); 132 cjdbcSiteName = getProperty("cjdbc_hostname"); 133 System.out.println(cjdbcSiteName+"<br>"); 134 System.out.print("EJB HTML files path : "); 135 EJBHTMLPath = getProperty("ejb_html_path"); 136 System.out.println(EJBHTMLPath+"<br>"); 137 System.out.print("EJB Script files path : "); 138 EJBScriptPath = getProperty("ejb_script_path"); 139 System.out.println(EJBScriptPath+"<br>"); 140 System.out.print("Servlets HTML files path : "); 141 ServletsHTMLPath = getProperty("servlets_html_path"); 142 System.out.println(ServletsHTMLPath+"<br>"); 143 System.out.print("Servlets Script files path : "); 144 ServletsScriptPath = getProperty("servlets_script_path"); 145 System.out.println(ServletsScriptPath+"<br>"); 146 System.out.print("Servlets HTML files path : "); 147 PHPHTMLPath = getProperty("php_html_path"); 148 System.out.println(PHPHTMLPath+"<br>"); 149 System.out.print("PHP Script files path : "); 150 PHPScriptPath = getProperty("php_script_path"); 151 System.out.println(PHPScriptPath+"<br>"); 152 153 System.out.println("\n<h3><br>### Workload ###</h3>"); 155 System.out.print("Remote client nodes : "); 156 StringTokenizer nodes = new StringTokenizer (getProperty("workload_remote_client_nodes"),","); 157 remoteClients = new Vector (nodes.countTokens()); 158 while (nodes.hasMoreTokens()) 159 remoteClients.add(nodes.nextToken().trim()); 160 nbOfClients = remoteClients.size(); 161 System.out.println(nbOfClients+"<br>"); 162 System.out.print("Remote client command : "); 163 remoteCommand = getProperty("workload_remote_client_command"); 164 System.out.println(remoteCommand+"<br>"); 165 System.out.print("Number of clients : "); 166 foo = new Integer (getProperty("workload_number_of_clients_per_node")); 167 nbOfClients = foo.intValue(); 168 System.out.println(nbOfClients+"<br>"); 169 170 System.out.print("User transition table : "); 171 userTransitionTable = getProperty("workload_user_transition_table"); 172 System.out.println(userTransitionTable+"<br>"); 173 System.out.print("Author transition table : "); 174 authorTransitionTable = getProperty("workload_author_transition_table"); 175 System.out.println(authorTransitionTable+"<br>"); 176 System.out.print("Number of columns : "); 177 foo = new Integer (getProperty("workload_number_of_columns")); 178 nbOfColumns = foo.intValue(); 179 System.out.println(nbOfColumns+"<br>"); 180 System.out.print("Number of rows : "); 181 foo = new Integer (getProperty("workload_number_of_rows")); 182 nbOfRows = foo.intValue(); 183 System.out.println(nbOfRows+"<br>"); 184 System.out.print("Maximum number of transitions : "); 185 foo = new Integer (getProperty("workload_maximum_number_of_transitions")); 186 maxNbOfTransitions = foo.intValue(); 187 System.out.println(maxNbOfTransitions+"<br>"); 188 System.out.print("Number of stories per page : "); 189 foo = new Integer (getProperty("workload_number_of_stories_per_page")); 190 nbOfStoriesPerPage = foo.intValue(); 191 System.out.println(nbOfStoriesPerPage+"<br>"); 192 System.out.print("Think time : "); 193 useTPCWThinkTime = getProperty("workload_use_tpcw_think_time").compareTo("yes") == 0; 194 if (useTPCWThinkTime) 195 System.out.println("TPCW compatible with 7s mean<br>"); 196 else 197 System.out.println("Using Transition Matrix think time information<br>"); 198 System.out.print("Up ramp time in ms : "); 199 foo = new Integer (getProperty("workload_up_ramp_time_in_ms")); 200 upTime = foo.intValue(); 201 System.out.println(upTime+"<br>"); 202 System.out.print("Up ramp slowdown factor : "); 203 Float floo = new Float (getProperty("workload_up_ramp_slowdown_factor")); 204 upSlowdown = floo.intValue(); 205 System.out.println(upSlowdown+"<br>"); 206 System.out.print("Session run time in ms : "); 207 foo = new Integer (getProperty("workload_session_run_time_in_ms")); 208 sessionTime = foo.intValue(); 209 System.out.println(sessionTime+"<br>"); 210 System.out.print("Down ramp time in ms : "); 211 foo = new Integer (getProperty("workload_down_ramp_time_in_ms")); 212 downTime = foo.intValue(); 213 System.out.println(downTime+"<br>"); 214 System.out.print("Down ramp slowdown factor : "); 215 floo = new Float (getProperty("workload_down_ramp_slowdown_factor")); 216 downSlowdown = floo.intValue(); 217 System.out.println(downSlowdown+"<br>"); 218 System.out.print("Percentage of authors : "); 219 foo = new Integer (getProperty("workload_percentage_of_author")); 220 percentOfAuthors = foo.intValue(); 221 System.out.println(percentOfAuthors+"<br>"); 222 223 System.out.println("\n<h3><br>### Database Information ###</h3>"); 225 System.out.print("Database server : "); 226 dbServerName = getProperty("database_server"); 227 System.out.println(dbServerName+"<br>"); 228 229 System.out.println("\n<h3><br>### Users policy ###</h3>"); 231 System.out.print("Number of authors : "); 232 nbOfAuthors = new Integer (getProperty("database_number_of_authors")); 233 System.out.println(nbOfAuthors+"<br>"); 234 System.out.print("Number of users : "); 235 nbOfUsers = new Integer (getProperty("database_number_of_users")); 236 System.out.println(nbOfUsers+"<br>"); 237 238 239 System.out.println("\n<h3><br>### Stories policy ###</h3>"); 241 System.out.print("Stories dictionary : "); 242 storyDictionary = getProperty("database_story_dictionnary"); 243 System.out.println(storyDictionary+"<br>"); 244 try 246 { 247 RandomAccessFile f = new RandomAccessFile (storyDictionary, "r"); 248 String useless = f.readLine(); 249 f.close(); 250 } 251 catch (Exception e) 252 { 253 System.err.println("Unable to read dictionary file '"+storyDictionary+"' (got exception: "+e.getMessage()+")"); 254 return null; 255 } 256 System.out.print("Stories maximum lenth : "); 257 storyMaxLength = new Integer (getProperty("database_story_maximum_length")); 258 System.out.println(storyMaxLength+"<br>"); 259 System.out.print("Oldest story year : "); 260 oldestStoryYear = new Integer (getProperty("database_oldest_story_year")); 261 System.out.println(oldestStoryYear+"<br>"); 262 System.out.print("Oldest story month : "); 263 oldestStoryMonth = new Integer (getProperty("database_oldest_story_month")); 264 System.out.println(oldestStoryMonth+"<br>"); 265 266 System.out.println("\n<h3><br>### Comments policy ###</h3>"); 268 System.out.print("Comment maximum length : "); 269 commentMaxLength = new Integer (getProperty("database_comment_max_length")); 270 System.out.println(commentMaxLength+"<br>"); 271 272 System.out.println("\n<h3><br>### Database Information ###</h3>"); 274 System.out.print("Monitoring debugging level : "); 275 monitoringDebug = new Integer (getProperty("monitoring_debug_level")); 276 System.out.println(monitoringDebug+"<br>"); 277 System.out.print("Monitoring program : "); 278 monitoringProgram = getProperty("monitoring_program"); 279 System.out.println(monitoringProgram+"<br>"); 280 System.out.print("Monitoring options : "); 281 monitoringOptions = getProperty("monitoring_options"); 282 System.out.println(monitoringOptions+"<br>"); 283 System.out.print("Monitoring sampling in seconds : "); 284 monitoringSampling = new Integer (getProperty("monitoring_sampling_in_seconds")); 285 System.out.println(monitoringSampling+"<br>"); 286 System.out.print("Monitoring rsh : "); 287 monitoringRsh = getProperty("monitoring_rsh"); 288 System.out.println(monitoringRsh+"<br>"); 289 System.out.print("Monitoring scp : "); 290 monitoringScp = getProperty("monitoring_scp"); 291 System.out.println(monitoringScp+"<br>"); 292 System.out.print("Monitoring Gnuplot Terminal : "); 293 monitoringGnuPlot = getProperty("monitoring_gnuplot_terminal"); 294 System.out.println(monitoringGnuPlot+"<br>"); 295 296 System.out.println("\n"); 298 useVersion = getProperty("httpd_use_version"); 299 if (useVersion.compareTo("PHP") == 0) 300 urlGen = new URLGeneratorPHP(webSiteName, webSitePort, PHPHTMLPath, PHPScriptPath); 301 else if (useVersion.compareTo("Servlets") == 0) 304 urlGen = new URLGeneratorServlets(webSiteName, webSitePort, ServletsHTMLPath, ServletsScriptPath); 305 else 306 { 307 System.err.println("Sorry but '"+useVersion+"' is not supported. Only PHP, EJB and Servlets are accepted."); 308 return null; 309 } 310 System.out.println("Using "+useVersion+" version.<br>"); 311 } 312 catch (Exception e) 313 { 314 System.err.println("Error while checking database.properties: "+e.getMessage()); 315 return null; 316 } 317 return urlGen; 318 } 319 320 321 326 public String getWebServerName() 327 { 328 return webSiteName; 329 } 330 331 336 public String getCJDBCServerName() 337 { 338 return cjdbcSiteName; 339 } 340 341 342 347 public String getDBServerName() 348 { 349 return dbServerName; 350 } 351 352 353 358 public int getNbOfAuthors() 359 { 360 return nbOfAuthors.intValue(); 361 } 362 363 364 369 public int getNbOfUsers() 370 { 371 return nbOfUsers.intValue(); 372 } 373 374 375 380 public int getPercentageOfAuthors() 381 { 382 return percentOfAuthors; 383 } 384 385 386 392 public String getStoryDictionary() 393 { 394 return storyDictionary; 395 } 396 397 398 403 public int getStoryMaximumLength() 404 { 405 return storyMaxLength.intValue(); 406 } 407 408 409 414 public int getOldestStoryYear() 415 { 416 return oldestStoryYear.intValue(); 417 } 418 419 420 425 public int getOldestStoryMonth() 426 { 427 return oldestStoryMonth.intValue(); 428 } 429 430 431 436 public int getCommentMaxLength() 437 { 438 return commentMaxLength.intValue(); 439 } 440 441 442 447 public String getUserTransitionTable() 448 { 449 return userTransitionTable; 450 } 451 452 453 458 public String getAuthorTransitionTable() 459 { 460 return authorTransitionTable; 461 } 462 463 464 469 public int getNbOfColumns() 470 { 471 return nbOfColumns; 472 } 473 474 475 480 public int getNbOfRows() 481 { 482 return nbOfRows; 483 } 484 485 486 492 public boolean useTPCWThinkTime() 493 { 494 return useTPCWThinkTime; 495 } 496 497 498 503 public int getNbOfStoriesPerPage() 504 { 505 return nbOfStoriesPerPage; 506 } 507 508 509 514 public int getNbOfClients() 515 { 516 return nbOfClients; 517 } 518 519 520 525 public Vector getRemoteClients() 526 { 527 return remoteClients; 528 } 529 530 531 536 public String getClientsRemoteCommand() 537 { 538 return remoteCommand; 539 } 540 541 542 547 public int getMaxNbOfTransitions() 548 { 549 return maxNbOfTransitions; 550 } 551 552 553 558 public int getUpRampTime() 559 { 560 return upTime; 561 } 562 563 564 569 public float getUpRampSlowdown() 570 { 571 return upSlowdown; 572 } 573 574 575 580 public int getSessionTime() 581 { 582 return sessionTime; 583 } 584 585 586 591 public int getDownRampTime() 592 { 593 return downTime; 594 } 595 596 597 602 public float getDownRampSlowdown() 603 { 604 return downSlowdown; 605 } 606 607 608 618 public int getMonitoringDebug() 619 { 620 return monitoringDebug.intValue(); 621 } 622 623 624 629 public String getMonitoringProgram() 630 { 631 return monitoringProgram; 632 } 633 634 635 640 public String getMonitoringOptions() 641 { 642 return monitoringOptions; 643 } 644 645 646 651 public Integer getMonitoringSampling() 652 { 653 return monitoringSampling; 654 } 655 656 657 662 public String getMonitoringRsh() 663 { 664 return monitoringRsh; 665 } 666 667 672 public String getMonitoringScp() 673 { 674 return monitoringScp; 675 } 676 677 678 683 public String getGnuPlotTerminal() 684 { 685 return monitoringGnuPlot; 686 } 687 688 } 689 | Popular Tags |