⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deltamanager.java

📁 精通tomcat书籍原代码,希望大家共同学习
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * Copyright 1999,2004-2005 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.catalina.ha.session;import java.beans.PropertyChangeEvent;import java.io.BufferedOutputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.util.ArrayList;import java.util.Date;import java.util.Iterator;import org.apache.catalina.Cluster;import org.apache.catalina.Container;import org.apache.catalina.Context;import org.apache.catalina.Engine;import org.apache.catalina.Host;import org.apache.catalina.LifecycleException;import org.apache.catalina.LifecycleListener;import org.apache.catalina.Session;import org.apache.catalina.Valve;import org.apache.catalina.core.StandardContext;import org.apache.catalina.ha.CatalinaCluster;import org.apache.catalina.ha.ClusterMessage;import org.apache.catalina.ha.tcp.ReplicationValve;import org.apache.catalina.tribes.Member;import org.apache.catalina.tribes.io.ReplicationStream;import org.apache.catalina.util.LifecycleSupport;import org.apache.catalina.util.StringManager;/** * The DeltaManager manages replicated sessions by only replicating the deltas * in data. For applications written to handle this, the DeltaManager is the * optimal way of replicating data. *  * This code is almost identical to StandardManager with a difference in how it * persists sessions and some modifications to it. *  * <b>IMPLEMENTATION NOTE </b>: Correct behavior of session storing and * reloading depends upon external calls to the <code>start()</code> and * <code>stop()</code> methods of this class at the correct times. *  * @author Filip Hanik * @author Craig R. McClanahan * @author Jean-Francois Arcand * @author Peter Rossbach * @version $Revision: 380100 $ $Date: 2006-02-23 06:08:14 -0600 (Thu, 23 Feb 2006) $ */public class DeltaManager extends ClusterManagerBase{    // ---------------------------------------------------- Security Classes    public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(DeltaManager.class);    /**     * The string manager for this package.     */    protected static StringManager sm = StringManager.getManager(Constants.Package);    // ----------------------------------------------------- Instance Variables    /**     * The descriptive information about this implementation.     */    private static final String info = "DeltaManager/2.1";    /**     * Has this component been started yet?     */    private boolean started = false;    /**     * The descriptive name of this Manager implementation (for logging).     */    protected static String managerName = "DeltaManager";    protected String name = null;    protected boolean defaultMode = false;    private CatalinaCluster cluster = null;    /**     * cached replication valve cluster container!     */    private ReplicationValve replicationValve = null ;        /**     * The lifecycle event support for this component.     */    protected LifecycleSupport lifecycle = new LifecycleSupport(this);    /**     * The maximum number of active Sessions allowed, or -1 for no limit.     */    private int maxActiveSessions = -1;    private boolean expireSessionsOnShutdown = false;    private boolean notifyListenersOnReplication = true;    private boolean notifySessionListenersOnReplication = true;    private boolean stateTransfered = false ;    private int stateTransferTimeout = 60;    private boolean sendAllSessions = true;    private boolean sendClusterDomainOnly = true ;    private int sendAllSessionsSize = 1000 ;        /**     * wait time between send session block (default 2 sec)      */    private int sendAllSessionsWaitTime = 2 * 1000 ;     private ArrayList receivedMessageQueue = new ArrayList() ;    private boolean receiverQueue = false ;    private boolean stateTimestampDrop = true ;    private long stateTransferCreateSendTime;         // ------------------------------------------------------------------ stats attributes        int rejectedSessions = 0;    private long sessionReplaceCounter = 0 ;    long processingTime = 0;    private long counterReceive_EVT_GET_ALL_SESSIONS = 0 ;    private long counterSend_EVT_ALL_SESSION_DATA = 0 ;    private long counterReceive_EVT_ALL_SESSION_DATA = 0 ;    private long counterReceive_EVT_SESSION_CREATED = 0 ;    private long counterReceive_EVT_SESSION_EXPIRED = 0;    private long counterReceive_EVT_SESSION_ACCESSED = 0 ;    private long counterReceive_EVT_SESSION_DELTA = 0;    private long counterSend_EVT_GET_ALL_SESSIONS = 0 ;    private long counterSend_EVT_SESSION_CREATED = 0;    private long counterSend_EVT_SESSION_DELTA = 0 ;    private long counterSend_EVT_SESSION_ACCESSED = 0;    private long counterSend_EVT_SESSION_EXPIRED = 0;    private int counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;    private int counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE = 0 ;    private int counterNoStateTransfered = 0 ;    // ------------------------------------------------------------- Constructor    public DeltaManager() {        super();    }    // ------------------------------------------------------------- Properties        /**     * Return descriptive information about this Manager implementation and the     * corresponding version number, in the format     * <code>&lt;description&gt;/&lt;version&gt;</code>.     */    public String getInfo() {        return info;    }    public void setName(String name) {        this.name = name;    }    /**     * Return the descriptive short name of this Manager implementation.     */    public String getName() {        return name;    }    /**     * @return Returns the counterSend_EVT_GET_ALL_SESSIONS.     */    public long getCounterSend_EVT_GET_ALL_SESSIONS() {        return counterSend_EVT_GET_ALL_SESSIONS;    }        /**     * @return Returns the counterSend_EVT_SESSION_ACCESSED.     */    public long getCounterSend_EVT_SESSION_ACCESSED() {        return counterSend_EVT_SESSION_ACCESSED;    }        /**     * @return Returns the counterSend_EVT_SESSION_CREATED.     */    public long getCounterSend_EVT_SESSION_CREATED() {        return counterSend_EVT_SESSION_CREATED;    }    /**     * @return Returns the counterSend_EVT_SESSION_DELTA.     */    public long getCounterSend_EVT_SESSION_DELTA() {        return counterSend_EVT_SESSION_DELTA;    }    /**     * @return Returns the counterSend_EVT_SESSION_EXPIRED.     */    public long getCounterSend_EVT_SESSION_EXPIRED() {        return counterSend_EVT_SESSION_EXPIRED;    }     /**     * @return Returns the counterSend_EVT_ALL_SESSION_DATA.     */    public long getCounterSend_EVT_ALL_SESSION_DATA() {        return counterSend_EVT_ALL_SESSION_DATA;    }    /**     * @return Returns the counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE.     */    public int getCounterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE() {        return counterSend_EVT_ALL_SESSION_TRANSFERCOMPLETE;    }     /**     * @return Returns the counterReceive_EVT_ALL_SESSION_DATA.     */    public long getCounterReceive_EVT_ALL_SESSION_DATA() {        return counterReceive_EVT_ALL_SESSION_DATA;    }        /**     * @return Returns the counterReceive_EVT_GET_ALL_SESSIONS.     */    public long getCounterReceive_EVT_GET_ALL_SESSIONS() {        return counterReceive_EVT_GET_ALL_SESSIONS;    }        /**     * @return Returns the counterReceive_EVT_SESSION_ACCESSED.     */    public long getCounterReceive_EVT_SESSION_ACCESSED() {        return counterReceive_EVT_SESSION_ACCESSED;    }        /**     * @return Returns the counterReceive_EVT_SESSION_CREATED.     */    public long getCounterReceive_EVT_SESSION_CREATED() {        return counterReceive_EVT_SESSION_CREATED;    }        /**     * @return Returns the counterReceive_EVT_SESSION_DELTA.     */    public long getCounterReceive_EVT_SESSION_DELTA() {        return counterReceive_EVT_SESSION_DELTA;    }        /**     * @return Returns the counterReceive_EVT_SESSION_EXPIRED.     */    public long getCounterReceive_EVT_SESSION_EXPIRED() {        return counterReceive_EVT_SESSION_EXPIRED;    }            /**     * @return Returns the counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE.     */    public int getCounterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE() {        return counterReceive_EVT_ALL_SESSION_TRANSFERCOMPLETE;    }        /**     * @return Returns the processingTime.     */    public long getProcessingTime() {        return processingTime;    }     /**     * @return Returns the sessionReplaceCounter.     */    public long getSessionReplaceCounter() {        return sessionReplaceCounter;    }        /**     * Number of session creations that failed due to maxActiveSessions     *      * @return The count     */    public int getRejectedSessions() {        return rejectedSessions;    }    public void setRejectedSessions(int rejectedSessions) {        this.rejectedSessions = rejectedSessions;    }    /**     * @return Returns the counterNoStateTransfered.     */    public int getCounterNoStateTransfered() {        return counterNoStateTransfered;    }        public int getReceivedQueueSize() {        return receivedMessageQueue.size() ;    }        /**     * @return Returns the stateTransferTimeout.     */    public int getStateTransferTimeout() {        return stateTransferTimeout;    }    /**     * @param timeoutAllSession The timeout     */    public void setStateTransferTimeout(int timeoutAllSession) {        this.stateTransferTimeout = timeoutAllSession;    }    /**     * is session state transfered complete?     *      */    public boolean getStateTransfered() {        return stateTransfered;    }    /**     * set that state ist complete transfered       * @param stateTransfered     */    public void setStateTransfered(boolean stateTransfered) {        this.stateTransfered = stateTransfered;    }        /**     * @return Returns the sendAllSessionsWaitTime in msec     */    public int getSendAllSessionsWaitTime() {        return sendAllSessionsWaitTime;    }        /**     * @param sendAllSessionsWaitTime The sendAllSessionsWaitTime to set at msec.     */    public void setSendAllSessionsWaitTime(int sendAllSessionsWaitTime) {        this.sendAllSessionsWaitTime = sendAllSessionsWaitTime;    }        /**     * @return Returns the sendClusterDomainOnly.     */    public boolean isSendClusterDomainOnly() {        return sendClusterDomainOnly;    }        /**     * @param sendClusterDomainOnly The sendClusterDomainOnly to set.     */    public void setSendClusterDomainOnly(boolean sendClusterDomainOnly) {        this.sendClusterDomainOnly = sendClusterDomainOnly;    }    /**     * @return Returns the stateTimestampDrop.     */    public boolean isStateTimestampDrop() {        return stateTimestampDrop;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -