• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClusterManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.catalina.ha.ClusterManager的典型用法代码示例。如果您正苦于以下问题:Java ClusterManager类的具体用法?Java ClusterManager怎么用?Java ClusterManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClusterManager类属于org.apache.catalina.ha包,在下文中一共展示了ClusterManager类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invoke

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover 
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager)))
             handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:JvmRouteBinderValve.java


示例2: sendSessionReplicationMessage

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Send Cluster Replication Request
 * @param request current request
 * @param manager session manager
 * @param cluster replication cluster
 */
protected void sendSessionReplicationMessage(Request request,
        ClusterManager manager, CatalinaCluster cluster) {
    Session session = request.getSessionInternal(false);
    if (session != null) {
        String uri = request.getDecodedRequestURI();
        // request without session change
        if (!isRequestWithoutSessionChange(uri)) {
            if (log.isDebugEnabled())
                log.debug(sm.getString("ReplicationValve.invoke.uri", uri));
            sendMessage(session,manager,cluster);
        } else
            if(doStatistics())
                nrOfFilterRequests++;
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:ReplicationValve.java


示例3: invoke

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

	if (getEnabled() && request.getContext() != null && request.getContext().getDistributable()
			&& !request.isAsyncDispatching()) {
		// valve cluster can access manager - other cluster handle turnover
		// at host level - hopefully!
		Manager manager = request.getContext().getManager();

		if (manager != null && ((manager instanceof ClusterManager && getCluster() != null
				&& getCluster().getManager(((ClusterManager) manager).getName()) != null)
				|| (manager instanceof PersistentManager)))
			handlePossibleTurnover(request);
	}
	// Pass this request on to the next valve in our pipeline
	getNext().invoke(request, response);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:JvmRouteBinderValve.java


示例4: applyDiff

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Applies a diff to an existing object.
 * @param diff byte[]
 * @param offset int
 * @param length int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
    try {
        lock();
        ReplicationStream stream = ( (ClusterManager) getManager()).getReplicationStream(diff, offset, length);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        try {
            ClassLoader[] loaders = getClassLoaders();
            if (loaders != null && loaders.length > 0)
                Thread.currentThread().setContextClassLoader(loaders[0]);
            getDeltaRequest().readExternal(stream);
            getDeltaRequest().execute(this, ((ClusterManager)getManager()).isNotifyListenersOnReplication());
            stream.close();
        } finally {
            Thread.currentThread().setContextClassLoader(contextLoader);
        }
    }finally {
        unlock();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:DeltaSession.java


示例5: sendReplicationMessage

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * @param request
 * @param totalstart
 * @param isCrossContext
 * @param clusterManager
 * @param containerCluster
 */
protected void sendReplicationMessage(Request request, long totalstart, boolean isCrossContext, ClusterManager clusterManager, CatalinaCluster containerCluster) {
    //this happens after the request
    long start = 0;
    if(doStatistics()) {
        start = System.currentTimeMillis();
    }
    try {
        // send invalid sessions
        // DeltaManager returns String[0]
        if (!(clusterManager instanceof DeltaManager))
            sendInvalidSessions(clusterManager, containerCluster);
        // send replication
        sendSessionReplicationMessage(request, clusterManager, containerCluster);
        if(isCrossContext)
            sendCrossContextSession(containerCluster);
    } catch (Exception x) {
        // FIXME we have a lot of sends, but the trouble with one node stops the correct replication to other nodes!
        log.error(sm.getString("ReplicationValve.send.failure"), x);
    } finally {
        // FIXME this stats update are not cheap!!
        if(doStatistics()) {
            updateStats(totalstart,start);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:ReplicationValve.java


示例6: sendCrossContextSession

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Send all changed cross context sessions to backups
 * @param containerCluster
 */
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
    List<DeltaSession> sessions = crossContextSessions.get();
    if(sessions != null && sessions.size() >0) {
        for(Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext() ;) {          
            Session session = iter.next();
            if(log.isDebugEnabled())
                log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",  
                        session.getManager().getContainer().getName() ));
            sendMessage(session,(ClusterManager)session.getManager(),containerCluster);
            if(doStatistics()) {
                nrOfCrossContextSendRequests++;
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:ReplicationValve.java


示例7: createManager

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Create new Manager without add to cluster (comes with start the manager)
 * 
 * @param name
 *            Context Name of this manager
 * @see org.apache.catalina.Cluster#createManager(java.lang.String)
 * @see DeltaManager#start()
 */
@Override
public synchronized Manager createManager(String name) {
    if (log.isDebugEnabled()) {
        log.debug("Creating ClusterManager for context " + name +
                " using class " + getManagerTemplate().getClass().getName());
    }
    ClusterManager manager = null;
    try {
        manager = managerTemplate.cloneFromTemplate();
        manager.setName(name);
    } catch (Exception x) {
        log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if ( manager != null) manager.setCluster(this);
    }
    return manager;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:SimpleTcpCluster.java


示例8: registerManager

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager;
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);    
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:SimpleTcpCluster.java


示例9: applyDiff

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Applies a diff to an existing object.
 * 
 * @param diff
 *            byte[]
 * @param offset
 *            int
 * @param length
 *            int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
	try {
		lock();
		ReplicationStream stream = ((ClusterManager) getManager()).getReplicationStream(diff, offset, length);
		ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
		try {
			ClassLoader[] loaders = getClassLoaders();
			if (loaders != null && loaders.length > 0)
				Thread.currentThread().setContextClassLoader(loaders[0]);
			getDeltaRequest().readExternal(stream);
			getDeltaRequest().execute(this, ((ClusterManager) getManager()).isNotifyListenersOnReplication());
			stream.close();
		} finally {
			Thread.currentThread().setContextClassLoader(contextLoader);
		}
	} finally {
		unlock();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:DeltaSession.java


示例10: sendCrossContextSession

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Send all changed cross context sessions to backups
 * 
 * @param containerCluster
 */
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
	List<DeltaSession> sessions = crossContextSessions.get();
	if (sessions != null && sessions.size() > 0) {
		for (Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext();) {
			Session session = iter.next();
			if (log.isDebugEnabled())
				log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
						session.getManager().getContainer().getName()));
			sendMessage(session, (ClusterManager) session.getManager(), containerCluster);
			if (doStatistics()) {
				nrOfCrossContextSendRequests++;
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:ReplicationValve.java


示例11: sendSessionReplicationMessage

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Send Cluster Replication Request
 * 
 * @param request
 *            current request
 * @param manager
 *            session manager
 * @param cluster
 *            replication cluster
 */
protected void sendSessionReplicationMessage(Request request, ClusterManager manager, CatalinaCluster cluster) {
	Session session = request.getSessionInternal(false);
	if (session != null) {
		String uri = request.getDecodedRequestURI();
		// request without session change
		if (!isRequestWithoutSessionChange(uri)) {
			if (log.isDebugEnabled())
				log.debug(sm.getString("ReplicationValve.invoke.uri", uri));
			sendMessage(session, manager, cluster);
		} else if (doStatistics())
			nrOfFilterRequests++;
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:ReplicationValve.java


示例12: createManager

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Create new Manager without add to cluster (comes with start the manager)
 * 
 * @param name
 *            Context Name of this manager
 * @see org.apache.catalina.Cluster#createManager(java.lang.String)
 * @see DeltaManager#start()
 */
@Override
public synchronized Manager createManager(String name) {
	if (log.isDebugEnabled()) {
		log.debug("Creating ClusterManager for context " + name + " using class "
				+ getManagerTemplate().getClass().getName());
	}
	ClusterManager manager = null;
	try {
		manager = managerTemplate.cloneFromTemplate();
		manager.setName(name);
	} catch (Exception x) {
		log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
		manager = new org.apache.catalina.ha.session.DeltaManager();
	} finally {
		if (manager != null)
			manager.setCluster(this);
	}
	return manager;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:28,代码来源:SimpleTcpCluster.java


示例13: registerManager

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
@Override
public void registerManager(Manager manager) {

	if (!(manager instanceof ClusterManager)) {
		log.warn("Manager [ " + manager
				+ "] does not implement ClusterManager, addition to cluster has been aborted.");
		return;
	}
	ClusterManager cmanager = (ClusterManager) manager;
	// Notify our interested LifecycleListeners
	fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
	String clusterName = getManagerName(cmanager.getName(), manager);
	cmanager.setName(clusterName);
	cmanager.setCluster(this);

	managers.put(clusterName, cmanager);
	// Notify our interested LifecycleListeners
	fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:20,代码来源:SimpleTcpCluster.java


示例14: applyDiff

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Applies a diff to an existing object.
 * @param diff byte[]
 * @param offset int
 * @param length int
 * @throws IOException
 */
@Override
public void applyDiff(byte[] diff, int offset, int length) throws IOException, ClassNotFoundException {
    try {
        lock();
        ReplicationStream stream = ( (ClusterManager) getManager()).getReplicationStream(diff, offset, length);
        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
        try {
            ClassLoader[] loaders = getClassLoaders();
            if (loaders != null && loaders.length > 0)
                Thread.currentThread().setContextClassLoader(loaders[0]);
            getDeltaRequest().readExternal(stream);
            getDeltaRequest().execute(this, ((ClusterManager)getManager()).isNotifyListenersOnReplication());
        } finally {
            Thread.currentThread().setContextClassLoader(contextLoader);
        }
    }finally {
        unlock();
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:DeltaSession.java


示例15: associate

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Notify the cluster of the addition of a Session to
 * an SSO session and associate the specified single
 * sign on identifier with the specified Session on the
 * local node.
 *
 * @param ssoId Single sign on identifier
 * @param session Session to be associated
 */
@Override
protected void associate(String ssoId, Session session) {

    if (cluster != null && cluster.getMembers().length > 0) {
        messageNumber++;
        SingleSignOnMessage msg =
            new SingleSignOnMessage(cluster.getLocalMember(),
                                    ssoId, session.getId());
        Manager mgr = session.getManager();
        if ((mgr != null) && (mgr instanceof ClusterManager))
            msg.setContextName(((ClusterManager) mgr).getName());

        msg.setAction(SingleSignOnMessage.ADD_SESSION);

        cluster.send(msg);

        if (containerLog.isDebugEnabled())
            containerLog.debug("SingleSignOnMessage Send with action "
                               + msg.getAction());
    }

    associateLocal(ssoId, session);

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:34,代码来源:ClusterSingleSignOn.java


示例16: deregister

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Notify the cluster of the removal of a Session from an
 * SSO session and deregister the specified session. If it is the last
 * session, then also get rid of the single sign on identifier on the
 * local node.
 *
 * @param ssoId Single sign on identifier
 * @param session Session to be deregistered
 */
@Override
protected void deregister(String ssoId, Session session) {

    if (cluster != null && cluster.getMembers().length > 0) {
        messageNumber++;
        SingleSignOnMessage msg =
            new SingleSignOnMessage(cluster.getLocalMember(),
                                    ssoId, session.getId());
        Manager mgr = session.getManager();
        if ((mgr != null) && (mgr instanceof ClusterManager))
            msg.setContextName(((ClusterManager) mgr).getName());

        msg.setAction(SingleSignOnMessage.DEREGISTER_SESSION);

        cluster.send(msg);
        if (containerLog.isDebugEnabled())
            containerLog.debug("SingleSignOnMessage Send with action "
                               + msg.getAction());
    }

    deregisterLocal(ssoId, session);

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:33,代码来源:ClusterSingleSignOn.java


示例17: removeSession

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
/**
 * Remove a single Session from a SingleSignOn and notify the cluster
 * of the removal. Called when a session is timed out and no longer active.
 *
 * @param ssoId Single sign on identifier from which to remove the session.
 * @param session the session to be removed.
 */
@Override
protected void removeSession(String ssoId, Session session) {

    if (cluster != null && cluster.getMembers().length > 0) {
        messageNumber++;
        SingleSignOnMessage msg =
            new SingleSignOnMessage(cluster.getLocalMember(),
                                    ssoId, session.getId());

        Manager mgr = session.getManager();
        if ((mgr != null) && (mgr instanceof ClusterManager))
            msg.setContextName(((ClusterManager) mgr).getName());

        msg.setAction(SingleSignOnMessage.REMOVE_SESSION);

        cluster.send(msg);
        if (containerLog.isDebugEnabled())
            containerLog.debug("SingleSignOnMessage Send with action "
                               + msg.getAction());
    }

    removeSessionLocal(ssoId, session);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:ClusterSingleSignOn.java


示例18: registerManager

import org.apache.catalina.ha.ClusterManager; //导入依赖的package包/类
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager ;
    cmanager.setDistributable(true);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);    
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:SimpleTcpCluster.java



注:本文中的org.apache.catalina.ha.ClusterManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SingularOps类代码示例发布时间:2022-05-23
下一篇:
Java JDBC4MysqlPooledConnection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap