in black and white
Main menu
Share a book About us Home
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 70 71 72 73 74 75 < 76 > 77 78 79 80 81 82 .. 166 >> Next

02:# This is the directory on disk where caches will be stored.
03:# it will be created if it doesn't already exist, but OSCache
04:# must be able to write to here.
06: cache.path=c:\\cachetagscache
10:# set this to true if you want to see log4j debugging messages
16:# Use unlimited disk cache or not
Listing 23.2
204 Item 23
File Edit Run Report Options Help
|i Root
9 ? Test Plan
? Thread Group Automobile Dealers
; Cache Test lor Alabama(id=Automobile Dealers) Cache Test torAlaska(id=Automobite Dealers)
\> Cache Test torArizona(ld=Automohle Dealers) Cache Test forArfcansas(id=Automobite Dealers) \/ Cache Test torCalfornia(id=Automoblte Dealers) \; Cache Test forCotorado(id*Aiiomotoile Deaters) '. Cache Test torConr>ecticut(id=Automobite Dealers 0; Cache Test forDetaware(idAutomobile Dealers) \%! Cache Test torFlorida(id=Automobite Dealers)
9 Cache Test forGeorgia(idAutomoble Dealers) Cache Test forHawaii(id=Automobite Dealers)
9 Cache Test fortdaho(id*Automoble Dealers)
/ Cache Test for1lirtois(id=Automobile Deaters)
',' Cache Test fortncfana(id"Automobite Dealers)
\; Cache Test tortowa(id=Automoble Dealers)
*9 Cache Test torKansas(id-Automobie Dealers)
9 Cache Test forKentuckyOd=Automobile Dealers) 0: Cache Test forLouisianaQd-Automobite Dealers) 9 Cache Test forMaine(id=Automobile Deaters)
9 Cache Test forMarytartd(id-Automobile Dealers) '9 Cache Test forWassacbusetts<id=Automobie Deal 9 Cache Test lorMichtgan(idAutomobile Deaters) 9 Cache Test forMinnesota(id=Automobie Dealers) --I--': f X
HTTP Request
Names |Cache TestforAlaska(id=Automobile Dealers) 3b Server
Server Name or IP: ocalhost Port Number: [8080
HTTP Request
Protocol: HTTP HTTPS Method: GET POST Path: :ache/home.jsp Send Parameters VWh the Request
Name: Value
state Alaska
topicId Automobile Dealers

Add Delete .
Send a FHe With the Request:
Parameter Name:
gjc. | sac.. |
C '-A...
] 8:35 AM
Figure 23.2 Run of Apache JMeter.
After properly inserting the cache tag library tags in the source code, we generated JMeter ThreadGroup scripts to replicate a user hitting each page with the state and topicId parameters.
The JMeter application, as shown in Figure 23.2, is a Java desktop tool that performs automated load testing and user activity measurements, and it comes with visualization tools that provide test feedback and performance metrics. Our application uses this tool to hit all possible user selections so that these pages could be cached. By caching these pages, user queries do not have to go to the back end to draw back data.
Users can generate these ThreadGroup tests manually using the JMeter GUI, but we felt that a more efficient option was to write a program called to build these tests automatically. Listing 23.3 hard-codes the state and topicId data, but an optimal solution would use a file or a database to store these values so that the data would not be tightly coupled with the application and changes could be accommodated more easily. In the program, lines 81 to 85 show a constant timer tag that will kick off a test every second or 1,000 milliseconds. Once these tests are generated, users can use the JMeter GUI to execute these tests, or they can run them manually from the command line using the nongui script:
prompt> nongui -o my_test.jmx -h <servername> -p <port #>
Cache, It's Money 205
01 import*;
02 import java.util.*;
04 class generateTests
05 {
06 public static void main(String[] args) throws IOException
07 {
08 if (args.length != 0) {
09 System.out.println("USAGE: java generateTests");
10 } else {
11 String[] states = { "Alabama", "Alaska", "Arizona", "Arkansas",
12 "California", "Colorado", "Connecticut", "Delaware",
13 "Florida", "Georgia", "Hawaii", "Idaho", "Illinois",
14 "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana",
15 "Maine", "Maryland", "Massachusetts", "Michigan",
16 "Minnesota", "Mississippi", "Missouri", "Montana",
17 "Nebraska", "Nevada", "New Hampshire", "New Jersey",
18 "New Mexico", "New York", "North Carolina", "North Dakota",
19 "Ohio", "Oklahoma", "Oregon", "Pennsylvania",
20 "Rhode Island", "South Carolina", "South Dakota",
21 "Tennessee", "Texas", "Utah", "Vermont", "Virginia",
22 "Washington", "West Virginia", "Wisconsin", "Wyoming" };
24 String[] topicIds = { "Automobile Dealers", "Bike Trails",
25 "Gyms", "Hospitals", "Laundromats", "Parks",
26 "Physicians", "Pet Stores", "Restaurants",
27 "Rest Areas", "Supermarkets" };
29 for (int x=0; x < topicIds.length; x++) {
31 PrintWriter pw = new PrintWriter(new
32 FileOutputStream("Cache_Test_" + topicIds[x] + ".jmx"));
Previous << 1 .. 70 71 72 73 74 75 < 76 > 77 78 79 80 81 82 .. 166 >> Next