Project

General

Profile

« Previous | Next » 

Revision 3280

Added by Jing Tao over 17 years ago

Add code restart postgresql and tomcat, and code to check those servers are ready or not

View differences:

measure-metacat-query-performance.sh
1 1
#!/bin/bash
2 2
#Call a java client class to query metacat automatically and metacat server
3
#will record the performance data into a file.
3
#will record the performance data into a file. Since we need restart postgres,
4
#this script should be run as root user
4 5
#Note: before running the script, user should run both "ant jar" and "ant clientjar"
5 6
#in Metacat to get metaca-client.jar and metacat.jar in build directory. 
6 7

  
......
11 12
UTILITIES=../lib/utilities.jar
12 13
METACATURL=http://chico.dyndns.org:8081/knb/metacat
13 14
QUERY=../test/performance_measure_query
14
TIME=3;
15
TIME=2
16
TOMCATUSER=tao
15 17

  
16 18
#copy the java client to build directory
17 19
rm -rf ../build/tests/
......
25 27
#compile the class
26 28
javac -classpath $JUNIT:$METACAT:$METACAT_CLIENT:$UTILITIES ../build/tests/edu/ucsb/nceas/metacattest/MetaCatQueryPerformanceTest.java 
27 29

  
30

  
31

  
32

  
28 33
#Iterate to restart postgres and tomcat, and call java client class
29 34
for (( i = 0; i < $TIME; i++))
30 35
do
36
    #retart postgres
37
    /etc/init.d/postgresql-8.2 restart
38
    #Check if posgres restart successfully
39
    successPQL=false;
40
    while [ $successPQL = false ]
41
    do
42
      #if found netstat command has posgres lisenter is ready,
43
      #reset the success value to jump the while loop.
44
      for fn in `netstat -plt | grep postgres`
45
      do
46
        #reset success value
47
        successPQL=true
48
      done
49
    done
50
    echo "success value for restarting postgres is $successPQL"
31 51

  
52
    #stop tomcat
53
    su - $TOMCATUSER /usr/local/devtools/apache-tomcat-5.5.23/bin/shutdown.sh
54
     #Check if tomcat start successfully
55
    successStop=false;
56
    tomcatRunning=false
57
    while [ $successStop = false ]
58
    do
59
      #if found netstat command still has tcomat lisenter (port 8005) ,
60
      #reset the tomcatRunning value to true
61
      for fn in `netstat -plt | grep 8005`
62
      do
63
        #reset success value
64
        tomcatRunning=true;
65
      done
66
      if [ $tomcatRunning = true ]
67
         then
68
           successStop=false
69
         else
70
           successStop=true
71
      fi
72
    done
73
    echo "success value for stoping tomcat is $successStop"
74
     
75
    #start tomcat
76
   su - $TOMCATUSER  /usr/local/devtools/apache-tomcat-5.5.23/bin/startup.sh
77
    #Check if tomcat start successfully
78
    successStart=false;
79
    while [ $successStart = false ]
80
    do
81
      #if found netstat command has tcomat lisenter (port 8005) is ready,
82
      #reset the success value to jump the while loop.
83
      for fn in `netstat -plt | grep 8005`
84
      do
85
        #reset success value
86
        successStart=true
87
      done
88
    done
89
    echo "success value for starting tomcat is $successStart"
90

  
91

  
32 92
    #run the class -- query the remote metacat
33 93
    java -cp $JUNIT:$METACAT:$METACAT_CLIENT:$UTILITIES:../build/tests edu.ucsb.nceas.metacattest.MetaCatQueryPerformanceTest $METACATURL $QUERY
94
    echo "Successfully query the metacat"
34 95
done

Also available in: Unified diff