Status Worker Ant Tasks

Introduction

Since version 1.2.19 the JK release contains additional ant tasks. They can be used to manage the JK web server plugins via the special status worker.

Manage JK with remote Ant Tasks

Simple antlib integration

<?xml version="1.0" encoding="UTF-8"?>

<project name="modjk-status" 
         xmlns:jk="urn:org-apache-jk-status"
         default="status" basedir=".">

	<property name="profile" value=""/>
	<property file="jkstatus${profile}.properties"/>
	<property file="jkstatus.properties.default"/>

    <path id="jkstatus.classpath">
      <fileset dir="${catalina.home}/bin">
          <include name="commons-logging-api-*.jar"/>
      </fileset>
      <pathelement location="${catalina.home}/server/lib/catalina-ant.jar"/>
      <pathelement location="../dist/tomcat-jkstatus-ant.jar"/>
      <pathelement location="${catalina.home}/server/lib/tomcat-util.jar"/>
    </path>

    <typedef resource="org/apache/jk/status/antlib.xml"       
           uri="urn:org-apache-jk-status" classpathref="jkstatus.classpath"/> 
           
    <target name="status" >       
 	    <jk:status url="${jkstatus.url}" 
	                username="${jkstatus.username}"
	                password="${jkstatus.password}"
	                resultproperty="worker"
	      	        echo="off"
	                failOnError="off"/>
	    <echoproperties prefix="worker" />
    </target>
</project>    

Test Result

[echoproperties] #Ant properties
[echoproperties] #Sun Dec 10 20:40:21 CET 2006
[echoproperties] worker.node01.lbmult=1
[echoproperties] worker.loadbalancer.lock=Optimistic
[echoproperties] worker.node02.transferred=0
[echoproperties] worker.loadbalancer.sticky_session=false
[echoproperties] worker.node01.distance=0
[echoproperties] worker.node01.client_errors=0
[echoproperties] worker.node02.lbmult=1
[echoproperties] worker.node01.port=7309
[echoproperties] worker.node01.elected=0
[echoproperties] worker.loadbalancer.good=2
[echoproperties] worker.loadbalancer.method=Sessions
[echoproperties] worker.server.port=2090
[echoproperties] worker.loadbalancer.map.2.type=Wildchar
[echoproperties] worker.node02.route=node02
[echoproperties] worker.node01.route=node01
[echoproperties] worker.node01.lbvalue=0
[echoproperties] worker.node01.lbfactor=1
[echoproperties] worker.node01.max_busy=0
[echoproperties] worker.node01.busy=0
[echoproperties] worker.node01.redirect=
[echoproperties] worker.node02.distance=0
[echoproperties] worker.loadbalancer.name=loadbalancer
[echoproperties] worker.loadbalancer.sticky_session_force=false
[echoproperties] worker.node02.state=N/A
[echoproperties] worker.node01.state=N/A
[echoproperties] worker.node01.transferred=0
[echoproperties] worker.loadbalancer.map.length=2
[echoproperties] worker.node01.type=ajp13
[echoproperties] worker.node01.address=127.0.0.1\:7309
[echoproperties] worker.result.type=OK
[echoproperties] worker.loadbalancer.member_count=2
[echoproperties] worker.loadbalancer.map_count=2
[echoproperties] worker.loadbalancer.mtime_to_maintenance_min=12
[echoproperties] worker.loadbalancer.mtime_to_maintenance_max=75
[echoproperties] worker.node02.lbfactor=1
[echoproperties] worker.node02.max_busy=0
[echoproperties] worker.jk_version=mod_jk/1.2.21-dev
[echoproperties] worker.loadbalancer.bad=0
[echoproperties] worker.node02.redirect=
[echoproperties] worker.node01.host=localhost
[echoproperties] worker.node02.activation=ACT
[echoproperties] worker.loadbalancer.map.1.source=JkMount
[echoproperties] worker.loadbalancer.retries=2
[echoproperties] worker.node02.elected=0
[echoproperties] worker.loadbalancer.map.2.source=JkMount
[echoproperties] worker.node02.port=7409
[echoproperties] worker.loadbalancer.length=2
[echoproperties] worker.node02.lbvalue=0
[echoproperties] worker.loadbalancer.degraded=0
[echoproperties] worker.loadbalancer.map.1.type=Wildchar
[echoproperties] worker.loadbalancer.map.2.uri=/myapps*
[echoproperties] worker.node02.client_errors=0
[echoproperties] worker.length=1
[echoproperties] worker.node01.domain=d20
[echoproperties] worker.loadbalancer.recover_time=60
[echoproperties] worker.server.name=localhost
[echoproperties] worker.node02.domain=
[echoproperties] worker.result.message=Action finished
[echoproperties] worker.node02.busy=0
[echoproperties] worker.node01.readed=0
[echoproperties] worker.node01.errors=0
[echoproperties] worker.node02.address=127.0.0.1\:7409
[echoproperties] worker.node02.readed=0
[echoproperties] worker.loadbalancer.busy=0
[echoproperties] worker.web_server=Apache/2.0.59 (Unix) mod_jk/1.2.21-dev
[echoproperties] worker.node02.errors=0
[echoproperties] worker.node02.type=ajp13
[echoproperties] worker.loadbalancer.map.1.uri=/ClusterTest*
[echoproperties] worker.node01.activation=ACT
[echoproperties] worker.loadbalancer.max_busy=0
[echoproperties] worker.loadbalancer.type=lb
[echoproperties] worker.node02.host=localhost

Update Load Balancer

<target name="updatelb" >       
<jk:updateloadbalancer url="${jkstatus.url}" 
            username="${jkstatus.username}"
            password="${jkstatus.password}"
            loadbalancer="loadbalancer"
            method="Busyness"
            retries="2"
            recoverWaitTime="60"
            lock="Optimistic"
            forceStickySession="false"
            stickySession="false"/>
</target>

Update Worker

<target name="updatew" >       
<jk:updateworker url="${jkstatus.url}" 
            username="${jkstatus.username}"
            password="${jkstatus.password}"
            loadbalancer="loadbalancer"
  	        worker="node01"
            lbfactor="2"
            activation="Active"
            redirect=""
            domain=""
            route="node01"
            distance="0"/>
</target>

Reset Worker

<target name="reset" >       
<jk:reset url="${jkstatus.url}" 
            username="${jkstatus.username}"
            password="${jkstatus.password}"
            loadbalancer="loadbalancer"
  	        worker="node01"
            />
</target>

Comments

Notice: This comments section collects your suggestions on improving documentation for Apache Tomcat.

If you have trouble and need help, read Find Help page and ask your question on the tomcat-users mailing list. Do not ask such questions here. This is not a Q&A section.

The Apache Comments System is explained here. Comments may be removed by our moderators if they are either implemented or considered invalid/off-topic.