FileDocCategorySizeDatePackage
JKStatusUpdateTask.javaAPI DocApache Tomcat 6.0.1412359Fri Jul 20 04:20:36 BST 2007org.apache.catalina.ant

JKStatusUpdateTask

public class JKStatusUpdateTask extends AbstractCatalinaTask
Ant task that implements the /status command, supported by the mod_jk status (1.2.9) application.
author
Peter Rossbach
version
$Revision: 467222 $
since
5.5.9

Fields Summary
private String
worker
private String
workerType
private int
internalid
private Integer
lbRetries
private Integer
lbRecovertime
private Boolean
lbStickySession
private Boolean
lbForceSession
private Integer
workerLoadFactor
private String
workerRedirect
private String
workerClusterDomain
private Boolean
workerDisabled
private Boolean
workerStopped
private boolean
isLBMode
private String
workerLb
Constructors Summary
public JKStatusUpdateTask()


           
      
        super();
        setUrl("http://localhost/status");
    
Methods Summary
protected voidcheckParameter()
check correct lb and worker pararmeter

        if (worker == null) {
            throw new BuildException("Must specify 'worker' attribute");
        }
        if (workerType == null) {
            throw new BuildException("Must specify 'workerType' attribute");
        }
        if ("lb".equals(workerType)) {
            if (lbRecovertime == null && lbRetries == null) {
                throw new BuildException(
                        "Must specify at a lb worker either 'lbRecovertime' or"
                                + "'lbRetries' attribute");
            }
            if (lbStickySession == null || lbForceSession == null) {
                throw new BuildException("Must specify at a lb worker either"
                        + "'lbStickySession' and 'lbForceSession' attribute");
            }
            if (null != lbRecovertime && 60 < lbRecovertime.intValue()) {
                throw new BuildException(
                        "The 'lbRecovertime' must be greater than 59");
            }
            if (null != lbRetries && 1 < lbRetries.intValue()) {
                throw new BuildException(
                        "The 'lbRetries' must be greater than 1");
            }
            isLBMode = true;
        } else if ("worker".equals(workerType)) {
            if (workerDisabled == null) {
                throw new BuildException(
                        "Must specify at a node worker 'workerDisabled' attribute");
            }
            if (workerStopped == null) {
                throw new BuildException(
                        "Must specify at a node worker 'workerStopped' attribute");
            }
            if (workerLoadFactor == null ) {
                throw new BuildException(
                        "Must specify at a node worker 'workerLoadFactor' attribute");
            }
            if (workerClusterDomain == null) {
                throw new BuildException(
                        "Must specify at a node worker 'workerClusterDomain' attribute");
            }
            if (workerRedirect == null) {
                throw new BuildException(
                        "Must specify at a node worker 'workerRedirect' attribute");
            }
            if (workerLb == null) {
                throw new BuildException("Must specify 'workerLb' attribute");
            }
            if (workerLoadFactor.intValue() < 1) {
                throw new BuildException(
                        "The 'workerLoadFactor' must be greater or equal 1");
            }
            isLBMode = false;
        } else {
            throw new BuildException(
                    "Only 'lb' and 'worker' supported as workerType attribute");
        }
    
private java.lang.StringBuffercreateLink()
Create JkStatus link
  • load balance example: http://localhost/status?cmd=update&mime=txt&w=lb&lf=false&ls=true
  • worker example: http://localhost/status?cmd=update&mime=txt&w=node1&l=lb&wf=1&wd=false&ws=false

return
create jkstatus link

        // Building URL
        StringBuffer sb = new StringBuffer();
        try {
            sb.append("?cmd=update&mime=txt");
            sb.append("&w=");
            sb.append(URLEncoder.encode(worker, getCharset()));

            if (isLBMode) {
                //http://localhost/status?cmd=update&mime=txt&w=lb&lf=false&ls=true
                if ((lbRetries != null)) { // > 0
                    sb.append("&lr=");
                    sb.append(lbRetries);
                }
                if ((lbRecovertime != null)) { // > 59
                    sb.append("<=");
                    sb.append(lbRecovertime);
                }
                if ((lbStickySession != null)) {
                    sb.append("&ls=");
                    sb.append(lbStickySession);
                }
                if ((lbForceSession != null)) {
                    sb.append("&lf=");
                    sb.append(lbForceSession);
                }
            } else {
                //http://localhost/status?cmd=update&mime=txt&w=node1&l=lb&wf=1&wd=false&ws=false
                if ((workerLb != null)) { // must be configured
                    sb.append("&l=");
                    sb.append(URLEncoder.encode(workerLb, getCharset()));
                }
                if ((workerLoadFactor != null)) { // >= 1
                    sb.append("&wf=");
                    sb.append(workerLoadFactor);
                }
                if ((workerDisabled != null)) {
                    sb.append("&wd=");
                    sb.append(workerDisabled);
                }
                if ((workerStopped != null)) {
                    sb.append("&ws=");
                    sb.append(workerStopped);
                }
                if ((workerRedirect != null)) { // other worker conrecte lb's
                    sb.append("&wr=");
                }
                if ((workerClusterDomain != null)) {
                    sb.append("&wc=");
                    sb.append(URLEncoder.encode(workerClusterDomain,
                            getCharset()));
                }
            }

        } catch (UnsupportedEncodingException e) {
            throw new BuildException("Invalid 'charset' attribute: "
                    + getCharset());
        }
        return sb;
    
public voidexecute()
Execute the requested operation.

exception
BuildException if an error occurs


        super.execute();
        checkParameter();
        StringBuffer sb = createLink();
        execute(sb.toString(), null, null, -1);

    
public intgetInternalid()

return
Returns the internalid.

        return internalid;
    
public java.lang.BooleangetLbForceSession()

return
Returns the lbForceSession.

        return lbForceSession;
    
public java.lang.IntegergetLbRecovertime()

return
Returns the lbRecovertime.

        return lbRecovertime;
    
public java.lang.IntegergetLbRetries()

return
Returns the lbRetries.

        return lbRetries;
    
public java.lang.BooleangetLbStickySession()

return
Returns the lbStickySession.

        return lbStickySession;
    
public java.lang.StringgetWorker()

return
Returns the worker.

        return worker;
    
public java.lang.StringgetWorkerClusterDomain()

return
Returns the workerClusterDomain.

        return workerClusterDomain;
    
public java.lang.BooleangetWorkerDisabled()

return
Returns the workerDisabled.

        return workerDisabled;
    
public java.lang.StringgetWorkerLb()

return
Returns the workerLb.

        return workerLb;
    
public java.lang.IntegergetWorkerLoadFactor()

return
Returns the workerLoadFactor.

        return workerLoadFactor;
    
public java.lang.StringgetWorkerRedirect()

return
Returns the workerRedirect.

        return workerRedirect;
    
public java.lang.BooleangetWorkerStopped()

return
Returns the workerStopped.

        return workerStopped;
    
public java.lang.StringgetWorkerType()

return
Returns the workerType.

        return workerType;
    
public voidsetInternalid(int internalid)

param
internalid The internalid to set.

        this.internalid = internalid;
    
public voidsetLbForceSession(java.lang.Boolean lbForceSession)

param
lbForceSession The lbForceSession to set.

        this.lbForceSession = lbForceSession;
    
public voidsetLbRecovertime(java.lang.Integer lbRecovertime)

param
lbRecovertime The lbRecovertime to set.

        this.lbRecovertime = lbRecovertime;
    
public voidsetLbRetries(java.lang.Integer lbRetries)

param
lbRetries The lbRetries to set.

        this.lbRetries = lbRetries;
    
public voidsetLbStickySession(java.lang.Boolean lbStickySession)

param
lbStickySession The lbStickySession to set.

        this.lbStickySession = lbStickySession;
    
public voidsetWorker(java.lang.String worker)

param
worker The worker to set.

        this.worker = worker;
    
public voidsetWorkerClusterDomain(java.lang.String workerClusterDomain)

param
workerClusterDomain The workerClusterDomain to set.

        this.workerClusterDomain = workerClusterDomain;
    
public voidsetWorkerDisabled(java.lang.Boolean workerDisabled)

param
workerDisabled The workerDisabled to set.

        this.workerDisabled = workerDisabled;
    
public voidsetWorkerLb(java.lang.String workerLb)

param
workerLb The workerLb to set.

        this.workerLb = workerLb;
    
public voidsetWorkerLoadFactor(java.lang.Integer workerLoadFactor)

param
workerLoadFactor The workerLoadFactor to set.

        this.workerLoadFactor = workerLoadFactor;
    
public voidsetWorkerRedirect(java.lang.String workerRedirect)

param
workerRedirect The workerRedirect to set.

        this.workerRedirect = workerRedirect;
    
public voidsetWorkerStopped(java.lang.Boolean workerStopped)

param
workerStopped The workerStopped to set.

        this.workerStopped = workerStopped;
    
public voidsetWorkerType(java.lang.String workerType)

param
workerType The workerType to set.

        this.workerType = workerType;