1 24 package edu.rice.rubis.client; 25 26 import java.io.BufferedReader ; 27 import java.io.FileReader ; 28 import java.util.ResourceBundle ; 29 import java.util.StringTokenizer ; 30 import java.util.Vector ; 31 32 39 40 public class RUBiSProperties 41 { 42 private static ResourceBundle configuration = null; 43 private URLGenerator urlGen = null; 44 45 private String webSiteName; 47 private int webSitePort; 48 private String cjdbcSiteName; 49 private Vector EJBServers; 50 private String EJBHTMLPath; 51 private String EJBScriptPath; 52 private Vector ServletsServers; 53 private String ServletsHTMLPath; 54 private String ServletsScriptPath; 55 private String PHPHTMLPath; 56 private String PHPScriptPath; 57 private String useVersion; 58 59 private Vector remoteClients; 61 private String remoteCommand; 62 private int nbOfClients; 63 private String transitionTable; 64 private int nbOfColumns; 65 private int nbOfRows; 66 private int maxNbOfTransitions; 67 private boolean useTPCWThinkTime; 68 private int nbOfItemsPerPage; 69 private int upTime; 70 private float upSlowdown; 71 private int sessionTime; 72 private int downTime; 73 private float downSlowdown; 74 75 private Vector dbServers; 77 78 private Integer nbOfUsers; 79 80 private int nbOfRegions; 81 private int nbOfCategories; 82 private Vector regions; 83 private Vector categories; 84 private int[] itemsPerCategory; 85 private int totalActiveItems; 86 87 private Integer nbOfOldItems; 88 private Float percentUniqueItems; 89 private Float percentReservePrice; 90 private Float percentBuyNow; 91 private Integer maxItemQty; 92 private Integer itemDescriptionLength; 93 94 private Integer maxBidsPerItem; 95 96 private Integer maxCommentsPerUser; 97 private Integer commentMaxLength; 98 99 100 private Integer monitoringDebug; 102 private String monitoringProgram; 103 private String monitoringOptions; 104 private Integer monitoringSampling; 105 private String monitoringRsh; 106 private String monitoringScp; 107 private String monitoringGnuPlot; 108 109 114 public RUBiSProperties() 115 { 116 System.out.println("Looking for rubis.properties in classpath ("+System.getProperty("java.class.path",".")+")<p>"); 118 try 119 { 120 configuration = ResourceBundle.getBundle("rubis"); 121 } 122 catch (java.util.MissingResourceException e) 123 { 124 System.err.println("No rubis.properties file has been found in your classpath.<p>"); 125 Runtime.getRuntime().exit(1); 126 } 127 } 128 129 130 137 public RUBiSProperties(String filename) 138 { 139 System.out.println("Looking for "+filename+".properties in classpath ("+System.getProperty("java.class.path",".")+")<p>"); 141 try 142 { 143 configuration = ResourceBundle.getBundle(filename); 144 } 145 catch (java.util.MissingResourceException e) 146 { 147 System.err.println("No "+filename+".properties file has been found in your classpath.<p>"); 148 Runtime.getRuntime().exit(1); 149 } 150 } 151 152 153 159 protected String getProperty(String property) 160 { 161 String s = configuration.getString(property); 162 return s; 163 } 164 165 166 172 public URLGenerator checkPropertiesFileAndGetURLGenerator() 173 { 174 try 175 { 176 System.out.println("\n<h3>### HTTP server information ###</h3>"); 178 System.out.print("Server name : "); 179 webSiteName = getProperty("httpd_hostname"); 180 System.out.println(webSiteName+"<br>"); 181 System.out.print("Server port : "); 182 Integer foo = new Integer (getProperty("httpd_port")); 183 webSitePort = foo.intValue(); 184 System.out.println(webSitePort+"<br><br>"); 185 System.out.print("CJDBC server name : "); 186 cjdbcSiteName = getProperty("cjdbc_hostname"); 187 System.out.println(cjdbcSiteName+"<br>"); 188 189 System.out.print("EJB Server : "); 190 StringTokenizer nodes = new StringTokenizer (getProperty("ejb_server"),","); 191 EJBServers = new Vector (nodes.countTokens()); 192 while (nodes.hasMoreTokens()) 193 { 194 String name = nodes.nextToken().trim(); 195 EJBServers.add(name); 196 System.out.print(name); 197 if (nodes.hasMoreTokens()) 198 System.out.print(", "); 199 } 200 System.out.println("<br>"); 201 System.out.print("EJB HTML files path : "); 202 EJBHTMLPath = getProperty("ejb_html_path"); 203 System.out.println(EJBHTMLPath+"<br>"); 204 System.out.print("EJB Script files path : "); 205 EJBScriptPath = getProperty("ejb_script_path"); 206 System.out.println(EJBScriptPath+"<br><br>"); 207 208 System.out.print("Servlets server : "); 209 nodes = new StringTokenizer (getProperty("servlets_server"),","); 210 ServletsServers = new Vector (nodes.countTokens()); 211 while (nodes.hasMoreTokens()) 212 { 213 String name = nodes.nextToken().trim(); 214 ServletsServers.add(name); 215 System.out.print(name); 216 if (nodes.hasMoreTokens()) 217 System.out.print(", "); 218 } 219 System.out.println("<br>"); 220 System.out.print("Servlets HTML files path : "); 221 ServletsHTMLPath = getProperty("servlets_html_path"); 222 System.out.println(ServletsHTMLPath+"<br>"); 223 System.out.print("Servlets Script files path : "); 224 ServletsScriptPath = getProperty("servlets_script_path"); 225 System.out.println(ServletsScriptPath+"<br><br>"); 226 227 System.out.print("PHP HTML files path : "); 228 PHPHTMLPath = getProperty("php_html_path"); 229 System.out.println(PHPHTMLPath+"<br>"); 230 System.out.print("PHP Script files path : "); 231 PHPScriptPath = getProperty("php_script_path"); 232 System.out.println(PHPScriptPath+"<br><br>"); 233 234 System.out.println("\n<h3><br>### Workload ###</h3>"); 236 System.out.print("Remote client nodes : "); 237 nodes = new StringTokenizer (getProperty("workload_remote_client_nodes"),","); 238 remoteClients = new Vector (nodes.countTokens()); 239 while (nodes.hasMoreTokens()) 240 { 241 String name = nodes.nextToken().trim(); 242 remoteClients.add(name); 243 System.out.print(name); 244 if (nodes.hasMoreTokens()) 245 System.out.print(", "); 246 } 247 System.out.println("<br>"); 248 System.out.print("Remote client command : "); 249 remoteCommand = getProperty("workload_remote_client_command"); 250 System.out.println(remoteCommand+"<br>"); 251 System.out.print("Number of clients : "); 252 foo = new Integer (getProperty("workload_number_of_clients_per_node")); 253 nbOfClients = foo.intValue(); 254 System.out.println(nbOfClients+"<br>"); 255 256 System.out.print("Transition Table : "); 257 transitionTable = getProperty("workload_transition_table"); 258 System.out.println(transitionTable+"<br>"); 259 System.out.print("Number of columns : "); 260 foo = new Integer (getProperty("workload_number_of_columns")); 261 nbOfColumns = foo.intValue(); 262 System.out.println(nbOfColumns+"<br>"); 263 System.out.print("Number of rows : "); 264 foo = new Integer (getProperty("workload_number_of_rows")); 265 nbOfRows = foo.intValue(); 266 System.out.println(nbOfRows+"<br>"); 267 System.out.print("Maximum number of transitions : "); 268 foo = new Integer (getProperty("workload_maximum_number_of_transitions")); 269 maxNbOfTransitions = foo.intValue(); 270 System.out.println(maxNbOfTransitions+"<br>"); 271 System.out.print("Number of items per page : "); 272 foo = new Integer (getProperty("workload_number_of_items_per_page")); 273 nbOfItemsPerPage = foo.intValue(); 274 System.out.println(nbOfItemsPerPage+"<br>"); 275 System.out.print("Think time : "); 276 useTPCWThinkTime = getProperty("workload_use_tpcw_think_time").compareTo("yes") == 0; 277 if (useTPCWThinkTime) 278 System.out.println("TPCW compatible with 7s mean<br>"); 279 else 280 System.out.println("Using Transition Matrix think time information<br>"); 281 System.out.print("Up ramp time in ms : "); 282 foo = new Integer (getProperty("workload_up_ramp_time_in_ms")); 283 upTime = foo.intValue(); 284 System.out.println(upTime+"<br>"); 285 System.out.print("Up ramp slowdown factor : "); 286 Float floo = new Float (getProperty("workload_up_ramp_slowdown_factor")); 287 upSlowdown = floo.intValue(); 288 System.out.println(upSlowdown+"<br>"); 289 System.out.print("Session run time in ms : "); 290 foo = new Integer (getProperty("workload_session_run_time_in_ms")); 291 sessionTime = foo.intValue(); 292 System.out.println(sessionTime+"<br>"); 293 System.out.print("Down ramp time in ms : "); 294 foo = new Integer (getProperty("workload_down_ramp_time_in_ms")); 295 downTime = foo.intValue(); 296 System.out.println(downTime+"<br>"); 297 System.out.print("Down ramp slowdown factor : "); 298 floo = new Float (getProperty("workload_down_ramp_slowdown_factor")); 299 downSlowdown = floo.intValue(); 300 System.out.println(downSlowdown+"<br>"); 301 302 System.out.println("\n<h3><br>### Database Information ###</h3>"); 304 System.out.print("Database server : "); 305 nodes = new StringTokenizer (getProperty("database_server"),","); 306 dbServers = new Vector (nodes.countTokens()); 307 while (nodes.hasMoreTokens()) 308 { 309 String name = nodes.nextToken().trim(); 310 dbServers.add(name); 311 System.out.print(name); 312 if (nodes.hasMoreTokens()) 313 System.out.print(", "); 314 } 315 System.out.println("<br>"); 316 317 System.out.println("\n<h3><br>### Users policy ###</h3>"); 319 System.out.print("Number of users : "); 320 nbOfUsers = new Integer (getProperty("database_number_of_users")); 321 System.out.println(nbOfUsers+"<br>"); 322 323 System.out.println("\n<h3><br>### Region & Category definition files ###</h3>"); 325 System.out.print("Regions description file : "); 326 BufferedReader regionsReader = new BufferedReader (new FileReader (getProperty("database_regions_file"))); 327 System.out.println(getProperty("database_regions_file")+"<br>"); 328 System.out.print("    Reading file ... "); 329 regions = new Vector (); 330 nbOfRegions = 0; 331 while (regionsReader.ready()) 332 { 333 nbOfRegions++; 334 regions.add(regionsReader.readLine()); 335 } 336 regionsReader.close(); 337 System.out.println(nbOfRegions+" regions found.<br>"); 338 339 System.out.print("Categories description file : "); 340 BufferedReader categoriesReader = new BufferedReader (new FileReader (getProperty("database_categories_file"))); 341 System.out.println(getProperty("database_categories_file")+"<br>"); 342 System.out.print("    Reading file ... "); 343 categories = new Vector (); 344 Vector itemsPerCategoryV = new Vector (); 345 nbOfCategories = 0; 346 totalActiveItems = 0; 347 while (categoriesReader.ready()) 348 { 349 String line = categoriesReader.readLine(); 350 int openParenthesis = line.lastIndexOf('('); 351 int closeParenthesis = line.lastIndexOf(')'); 352 nbOfCategories++; 353 if ((openParenthesis == -1) || (closeParenthesis == -1) || (openParenthesis > closeParenthesis)) 354 { 355 System.err.println("Syntax error in categories file on line "+nbOfCategories+": "+line); 356 return null; 357 } 358 Integer nbOfItems = new Integer (line.substring(openParenthesis+1, closeParenthesis)); 359 totalActiveItems += nbOfItems.intValue(); 360 categories.add(line.substring(0, openParenthesis-1)); 361 itemsPerCategoryV.add(nbOfItems); 362 } 363 categoriesReader.close(); 364 itemsPerCategory = new int[nbOfCategories]; 365 for (int i = 0 ; i < nbOfCategories ; i++) 366 itemsPerCategory[i] = ((Integer )itemsPerCategoryV.elementAt(i)).intValue(); 367 System.out.println(nbOfCategories+" categories found.<br>"); 368 System.out.println("Total number of items to generate: "+totalActiveItems+"<br>"); 369 370 System.out.println("\n<h3><br>### Items policy ###</h3>"); 372 System.out.print("Number of old items : "); 373 nbOfOldItems = new Integer (getProperty("database_number_of_old_items")); 374 System.out.println(nbOfOldItems+"<br>"); 375 System.out.print("Percentage of unique items : "); 376 percentUniqueItems = new Float (getProperty("database_percentage_of_unique_items")); 377 System.out.println(percentUniqueItems+"%"+"<br>"); 378 System.out.print("Percentage of items with reserve price : "); 379 percentReservePrice = new Float (getProperty("database_percentage_of_items_with_reserve_price")); 380 System.out.println(percentReservePrice+"%"+"<br>"); 381 System.out.print("Percentage of buy now items : "); 382 percentBuyNow = new Float (getProperty("database_percentage_of_buy_now_items")); 383 System.out.println(percentBuyNow+"%"+"<br>"); 384 System.out.print("Maximum quantity for multiple items : "); 385 maxItemQty = new Integer (getProperty("database_max_quantity_for_multiple_items")); 386 System.out.println(maxItemQty+"<br>"); 387 System.out.print("Item description maximum lenth : "); 388 itemDescriptionLength = new Integer (getProperty("database_item_description_length")); 389 System.out.println(itemDescriptionLength+"<br>"); 390 391 System.out.println("\n<h3><br>### Bids policy ###</h3>"); 393 System.out.print("Maximum number of bids per item : "); 394 maxBidsPerItem = new Integer (getProperty("database_max_bids_per_item")); 395 System.out.println(maxBidsPerItem+"<br>"); 396 397 System.out.println("\n<h3><br>### Comments policy ###</h3>"); 399 System.out.print("Maximum number of comments per user : "); 400 maxCommentsPerUser = new Integer (getProperty("database_max_comments_per_user")); 401 System.out.println(maxCommentsPerUser+"<br>"); 402 System.out.print("Comment maximum length : "); 403 commentMaxLength = new Integer (getProperty("database_comment_max_length")); 404 System.out.println(commentMaxLength+"<br>"); 405 406 System.out.println("\n<h3><br>### Database Information ###</h3>"); 408 System.out.print("Monitoring debugging level : "); 409 monitoringDebug = new Integer (getProperty("monitoring_debug_level")); 410 System.out.println(monitoringDebug+"<br>"); 411 System.out.print("Monitoring program : "); 412 monitoringProgram = getProperty("monitoring_program"); 413 System.out.println(monitoringProgram+"<br>"); 414 System.out.print("Monitoring options : "); 415 monitoringOptions = getProperty("monitoring_options"); 416 System.out.println(monitoringOptions+"<br>"); 417 System.out.print("Monitoring sampling in seconds : "); 418 monitoringSampling = new Integer (getProperty("monitoring_sampling_in_seconds")); 419 System.out.println(monitoringSampling+"<br>"); 420 System.out.print("Monitoring rsh : "); 421 monitoringRsh = getProperty("monitoring_rsh"); 422 System.out.println(monitoringRsh+"<br>"); 423 System.out.print("Monitoring scp : "); 424 monitoringScp = getProperty("monitoring_scp"); 425 System.out.println(monitoringScp+"<br>"); 426 System.out.print("Monitoring Gnuplot Terminal : "); 427 monitoringGnuPlot = getProperty("monitoring_gnuplot_terminal"); 428 System.out.println(monitoringGnuPlot+"<br>"); 429 430 System.out.println("\n"); 432 useVersion = getProperty("httpd_use_version"); 433 if (useVersion.compareTo("PHP") == 0) 434 urlGen = new URLGeneratorPHP(webSiteName, webSitePort, PHPHTMLPath, PHPScriptPath); 435 else if (useVersion.compareTo("EJB") == 0) 436 urlGen = new URLGeneratorEJB(webSiteName, webSitePort, EJBHTMLPath, EJBScriptPath); 437 else if (useVersion.compareTo("Servlets") == 0) 438 urlGen = new URLGeneratorServlets(webSiteName, webSitePort, ServletsHTMLPath, ServletsScriptPath); 439 else 440 { 441 System.err.println("Sorry but '"+useVersion+"' is not supported. Only PHP, EJB and Servlets are accepted."); 442 return null; 443 } 444 System.out.println("Using "+useVersion+" version.<br>"); 445 } 446 catch (Exception e) 447 { 448 System.err.println("Error while checking database.properties: "+e.getMessage()); 449 return null; 450 } 451 return urlGen; 452 } 453 454 455 460 public String getWebServerName() 461 { 462 return webSiteName; 463 } 464 465 470 public String getCJDBCServerName() 471 { 472 return cjdbcSiteName; 473 } 474 475 480 public Vector getDBServerNames() 481 { 482 return dbServers; 483 } 484 485 486 491 public Vector getEJBServerNames() 492 { 493 return EJBServers; 494 } 495 496 497 502 public Vector getServletsServerNames() 503 { 504 return ServletsServers; 505 } 506 507 508 513 public int getNbOfUsers() 514 { 515 return nbOfUsers.intValue(); 516 } 517 518 519 524 public int getNbOfRegions() 525 { 526 return nbOfRegions; 527 } 528 529 530 535 public int getNbOfCategories() 536 { 537 return nbOfCategories; 538 } 539 540 545 public Vector getRegions() 546 { 547 return regions; 548 } 549 550 551 556 public Vector getCategories() 557 { 558 return categories; 559 } 560 561 562 567 public int[] getItemsPerCategory() 568 { 569 return itemsPerCategory; 570 } 571 572 573 578 public int getTotalActiveItems() 579 { 580 return totalActiveItems; 581 } 582 583 584 589 public int getNbOfOldItems() 590 { 591 return nbOfOldItems.intValue(); 592 } 593 594 595 600 public float getPercentUniqueItems() 601 { 602 return percentUniqueItems.floatValue(); 603 } 604 605 606 611 public float getPercentReservePrice() 612 { 613 return percentReservePrice.floatValue(); 614 } 615 616 617 622 public float getPercentBuyNow() 623 { 624 return percentBuyNow.floatValue(); 625 } 626 627 628 633 public int getMaxItemQty() 634 { 635 return maxItemQty.intValue(); 636 } 637 638 643 public int getItemDescriptionLength() 644 { 645 return itemDescriptionLength.intValue(); 646 } 647 648 653 public int getMaxBidsPerItem() 654 { 655 return maxBidsPerItem.intValue(); 656 } 657 658 666 public int getMaxCommentsPerUser() 667 { 668 return maxCommentsPerUser.intValue(); 669 } 670 671 676 public int getCommentMaxLength() 677 { 678 return commentMaxLength.intValue(); 679 } 680 681 682 687 public String getTransitionTable() 688 { 689 return transitionTable; 690 } 691 692 693 698 public int getNbOfColumns() 699 { 700 return nbOfColumns; 701 } 702 703 704 709 public int getNbOfRows() 710 { 711 return nbOfRows; 712 } 713 714 715 721 public boolean useTPCWThinkTime() 722 { 723 return useTPCWThinkTime; 724 } 725 726 727 732 public int getNbOfItemsPerPage() 733 { 734 return nbOfItemsPerPage; 735 } 736 737 738 743 public int getNbOfClients() 744 { 745 return nbOfClients; 746 } 747 748 749 754 public Vector getRemoteClients() 755 { 756 return remoteClients; 757 } 758 759 760 765 public String getClientsRemoteCommand() 766 { 767 return remoteCommand; 768 } 769 770 771 776 public int getMaxNbOfTransitions() 777 { 778 return maxNbOfTransitions; 779 } 780 781 782 787 public int getUpRampTime() 788 { 789 return upTime; 790 } 791 792 793 798 public float getUpRampSlowdown() 799 { 800 return upSlowdown; 801 } 802 803 804 809 public int getSessionTime() 810 { 811 return sessionTime; 812 } 813 814 815 820 public int getDownRampTime() 821 { 822 return downTime; 823 } 824 825 826 831 public float getDownRampSlowdown() 832 { 833 return downSlowdown; 834 } 835 836 837 847 public int getMonitoringDebug() 848 { 849 return monitoringDebug.intValue(); 850 } 851 852 853 858 public String getMonitoringProgram() 859 { 860 return monitoringProgram; 861 } 862 863 864 869 public String getMonitoringOptions() 870 { 871 return monitoringOptions; 872 } 873 874 875 880 public Integer getMonitoringSampling() 881 { 882 return monitoringSampling; 883 } 884 885 886 891 public String getMonitoringRsh() 892 { 893 return monitoringRsh; 894 } 895 896 897 902 public String getMonitoringScp() 903 { 904 return monitoringScp; 905 } 906 907 908 913 public String getGnuPlotTerminal() 914 { 915 return monitoringGnuPlot; 916 } 917 918 } 919 | Popular Tags |