Search in sources :

Example 1 with JvmRouteBinderValve

use of org.apache.catalina.ha.session.JvmRouteBinderValve in project cas by apereo.

the class CasTomcatEmbeddedServletContainerFactory method configureSessionClustering.

private void configureSessionClustering(final Tomcat tomcat) {
    if (!clusteringProperties.isSessionClusteringEnabled()) {
        LOGGER.debug("Tomcat session clustering/replication is turned off");
        return;
    }
    final SimpleTcpCluster cluster = new SimpleTcpCluster();
    cluster.setChannelSendOptions(clusteringProperties.getChannelSendOptions());
    final ClusterManagerBase manager = getClusteringManagerInstance();
    cluster.setManagerTemplate(manager);
    final GroupChannel channel = new GroupChannel();
    final NioReceiver receiver = new NioReceiver();
    receiver.setPort(clusteringProperties.getReceiverPort());
    receiver.setTimeout(clusteringProperties.getReceiverTimeout());
    receiver.setMaxThreads(clusteringProperties.getReceiverMaxThreads());
    receiver.setAddress(clusteringProperties.getReceiverAddress());
    receiver.setAutoBind(clusteringProperties.getReceiverAutoBind());
    channel.setChannelReceiver(receiver);
    final McastService membershipService = new McastService();
    membershipService.setPort(clusteringProperties.getMembershipPort());
    membershipService.setAddress(clusteringProperties.getMembershipAddress());
    membershipService.setFrequency(clusteringProperties.getMembershipFrequency());
    membershipService.setDropTime(clusteringProperties.getMembershipDropTime());
    membershipService.setRecoveryEnabled(clusteringProperties.isMembershipRecoveryEnabled());
    membershipService.setRecoveryCounter(clusteringProperties.getMembershipRecoveryCounter());
    membershipService.setLocalLoopbackDisabled(clusteringProperties.isMembershipLocalLoopbackDisabled());
    channel.setMembershipService(membershipService);
    final ReplicationTransmitter sender = new ReplicationTransmitter();
    sender.setTransport(new PooledParallelSender());
    channel.setChannelSender(sender);
    channel.addInterceptor(new TcpPingInterceptor());
    channel.addInterceptor(new TcpFailureDetector());
    channel.addInterceptor(new MessageDispatchInterceptor());
    final StaticMembershipInterceptor membership = new StaticMembershipInterceptor();
    final String[] memberSpecs = clusteringProperties.getClusterMembers().split(",", -1);
    for (final String spec : memberSpecs) {
        final ClusterMemberDesc memberDesc = new ClusterMemberDesc(spec);
        final StaticMember member = new StaticMember();
        member.setHost(memberDesc.getAddress());
        member.setPort(memberDesc.getPort());
        member.setDomain("CAS");
        member.setUniqueId(memberDesc.getUniqueId());
        membership.addStaticMember(member);
        channel.addInterceptor(membership);
        cluster.setChannel(channel);
    }
    cluster.addValve(new ReplicationValve());
    cluster.addValve(new JvmRouteBinderValve());
    cluster.addClusterListener(new ClusterSessionListener());
    tomcat.getEngine().setCluster(cluster);
}
Also used : NioReceiver(org.apache.catalina.tribes.transport.nio.NioReceiver) MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) StaticMembershipInterceptor(org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor) JvmRouteBinderValve(org.apache.catalina.ha.session.JvmRouteBinderValve) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) TcpFailureDetector(org.apache.catalina.tribes.group.interceptors.TcpFailureDetector) ToString(lombok.ToString) ReplicationTransmitter(org.apache.catalina.tribes.transport.ReplicationTransmitter) ReplicationValve(org.apache.catalina.ha.tcp.ReplicationValve) StaticMember(org.apache.catalina.tribes.membership.StaticMember) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) PooledParallelSender(org.apache.catalina.tribes.transport.nio.PooledParallelSender) TcpPingInterceptor(org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor) ClusterManagerBase(org.apache.catalina.ha.session.ClusterManagerBase) ClusterSessionListener(org.apache.catalina.ha.session.ClusterSessionListener) McastService(org.apache.catalina.tribes.membership.McastService)

Example 2 with JvmRouteBinderValve

use of org.apache.catalina.ha.session.JvmRouteBinderValve in project cas by apereo.

the class CasTomcatServletWebServerFactory method configureSessionClustering.

private void configureSessionClustering(final Tomcat tomcat) {
    val clusteringProperties = casProperties.getServer().getTomcat().getClustering();
    if (!clusteringProperties.isEnabled()) {
        LOGGER.trace("Tomcat session clustering/replication is turned off");
        return;
    }
    val cluster = new SimpleTcpCluster();
    val groupChannel = new GroupChannel();
    val receiver = new NioReceiver();
    receiver.setPort(clusteringProperties.getReceiverPort());
    receiver.setTimeout(clusteringProperties.getReceiverTimeout());
    receiver.setMaxThreads(clusteringProperties.getReceiverMaxThreads());
    receiver.setAddress(clusteringProperties.getReceiverAddress());
    receiver.setAutoBind(clusteringProperties.getReceiverAutoBind());
    groupChannel.setChannelReceiver(receiver);
    val sender = new ReplicationTransmitter();
    sender.setTransport(new PooledParallelSender());
    groupChannel.setChannelSender(sender);
    groupChannel.addInterceptor(new TcpPingInterceptor());
    groupChannel.addInterceptor(new TcpFailureDetector());
    groupChannel.addInterceptor(new MessageDispatchInterceptor());
    cluster.setChannelSendOptions(clusteringProperties.getChannelSendOptions());
    val manager = getClusteringManagerInstance();
    cluster.setManagerTemplate(manager);
    cluster.addValve(new ReplicationValve());
    cluster.addValve(new JvmRouteBinderValve());
    cluster.addClusterListener(new ClusterSessionListener());
    if ("CLOUD".equalsIgnoreCase(clusteringProperties.getClusteringType())) {
        val membershipService = new CloudMembershipService();
        membershipService.setMembershipProviderClassName(clusteringProperties.getCloudMembershipProvider());
        groupChannel.setMembershipService(membershipService);
        LOGGER.trace("Tomcat session clustering/replication configured using cloud membership provider [{}]", clusteringProperties.getCloudMembershipProvider());
    } else {
        val membershipService = new McastService();
        membershipService.setPort(clusteringProperties.getMembershipPort());
        membershipService.setAddress(clusteringProperties.getMembershipAddress());
        membershipService.setFrequency(clusteringProperties.getMembershipFrequency());
        membershipService.setDropTime(clusteringProperties.getMembershipDropTime());
        membershipService.setRecoveryEnabled(clusteringProperties.isMembershipRecoveryEnabled());
        membershipService.setRecoveryCounter(clusteringProperties.getMembershipRecoveryCounter());
        membershipService.setLocalLoopbackDisabled(clusteringProperties.isMembershipLocalLoopbackDisabled());
        groupChannel.setMembershipService(membershipService);
        val clusterMembers = clusteringProperties.getClusterMembers();
        if (StringUtils.isNotBlank(clusterMembers)) {
            val membership = new StaticMembershipInterceptor();
            val memberSpecs = clusterMembers.split(",", -1);
            for (val spec : memberSpecs) {
                val memberDesc = new ClusterMemberDesc(spec);
                val member = new StaticMember();
                member.setHost(memberDesc.getAddress());
                member.setPort(memberDesc.getPort());
                member.setDomain("CAS");
                member.setUniqueId(memberDesc.getUniqueId());
                membership.addStaticMember(member);
                groupChannel.addInterceptor(membership);
            }
        }
    }
    cluster.setChannel(groupChannel);
    tomcat.getEngine().setCluster(cluster);
}
Also used : lombok.val(lombok.val) NioReceiver(org.apache.catalina.tribes.transport.nio.NioReceiver) MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) JvmRouteBinderValve(org.apache.catalina.ha.session.JvmRouteBinderValve) StaticMembershipInterceptor(org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) TcpFailureDetector(org.apache.catalina.tribes.group.interceptors.TcpFailureDetector) ReplicationTransmitter(org.apache.catalina.tribes.transport.ReplicationTransmitter) ReplicationValve(org.apache.catalina.ha.tcp.ReplicationValve) StaticMember(org.apache.catalina.tribes.membership.StaticMember) SimpleTcpCluster(org.apache.catalina.ha.tcp.SimpleTcpCluster) PooledParallelSender(org.apache.catalina.tribes.transport.nio.PooledParallelSender) TcpPingInterceptor(org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor) ClusterSessionListener(org.apache.catalina.ha.session.ClusterSessionListener) CloudMembershipService(org.apache.catalina.tribes.membership.cloud.CloudMembershipService) McastService(org.apache.catalina.tribes.membership.McastService)

Example 3 with JvmRouteBinderValve

use of org.apache.catalina.ha.session.JvmRouteBinderValve in project tomcat70 by apache.

the class SimpleTcpCluster method checkDefaults.

protected void checkDefaults() {
    if (clusterListeners.size() == 0) {
        addClusterListener(new JvmRouteSessionIDBinderListener());
        if (managerTemplate instanceof DeltaManager) {
            addClusterListener(new ClusterSessionListener());
        }
    }
    if (valves.size() == 0) {
        addValve(new JvmRouteBinderValve());
        addValve(new ReplicationValve());
    }
    if (clusterDeployer != null)
        clusterDeployer.setCluster(this);
    if (channel == null)
        channel = new GroupChannel();
    if (channel instanceof GroupChannel && !((GroupChannel) channel).getInterceptors().hasNext()) {
        channel.addInterceptor(new MessageDispatch15Interceptor());
        channel.addInterceptor(new TcpFailureDetector());
    }
    if (heartbeatBackgroundEnabled)
        channel.setHeartbeat(false);
}
Also used : JvmRouteSessionIDBinderListener(org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener) JvmRouteBinderValve(org.apache.catalina.ha.session.JvmRouteBinderValve) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) MessageDispatch15Interceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor) TcpFailureDetector(org.apache.catalina.tribes.group.interceptors.TcpFailureDetector) DeltaManager(org.apache.catalina.ha.session.DeltaManager) ClusterSessionListener(org.apache.catalina.ha.session.ClusterSessionListener)

Example 4 with JvmRouteBinderValve

use of org.apache.catalina.ha.session.JvmRouteBinderValve in project tomcat by apache.

the class SimpleTcpCluster method checkDefaults.

protected void checkDefaults() {
    if (clusterListeners.size() == 0 && managerTemplate instanceof DeltaManager) {
        addClusterListener(new ClusterSessionListener());
    }
    if (valves.size() == 0) {
        addValve(new JvmRouteBinderValve());
        addValve(new ReplicationValve());
    }
    if (clusterDeployer != null) {
        clusterDeployer.setCluster(this);
    }
    if (channel == null) {
        channel = new GroupChannel();
    }
    if (channel instanceof GroupChannel && !((GroupChannel) channel).getInterceptors().hasNext()) {
        channel.addInterceptor(new MessageDispatchInterceptor());
        channel.addInterceptor(new TcpFailureDetector());
    }
    if (heartbeatBackgroundEnabled) {
        channel.setHeartbeat(false);
    }
}
Also used : JvmRouteBinderValve(org.apache.catalina.ha.session.JvmRouteBinderValve) MessageDispatchInterceptor(org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor) GroupChannel(org.apache.catalina.tribes.group.GroupChannel) TcpFailureDetector(org.apache.catalina.tribes.group.interceptors.TcpFailureDetector) DeltaManager(org.apache.catalina.ha.session.DeltaManager) ClusterSessionListener(org.apache.catalina.ha.session.ClusterSessionListener)

Aggregations

ClusterSessionListener (org.apache.catalina.ha.session.ClusterSessionListener)4 JvmRouteBinderValve (org.apache.catalina.ha.session.JvmRouteBinderValve)4 GroupChannel (org.apache.catalina.tribes.group.GroupChannel)4 TcpFailureDetector (org.apache.catalina.tribes.group.interceptors.TcpFailureDetector)4 MessageDispatchInterceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor)3 DeltaManager (org.apache.catalina.ha.session.DeltaManager)2 ReplicationValve (org.apache.catalina.ha.tcp.ReplicationValve)2 SimpleTcpCluster (org.apache.catalina.ha.tcp.SimpleTcpCluster)2 StaticMembershipInterceptor (org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor)2 TcpPingInterceptor (org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor)2 McastService (org.apache.catalina.tribes.membership.McastService)2 StaticMember (org.apache.catalina.tribes.membership.StaticMember)2 ReplicationTransmitter (org.apache.catalina.tribes.transport.ReplicationTransmitter)2 NioReceiver (org.apache.catalina.tribes.transport.nio.NioReceiver)2 PooledParallelSender (org.apache.catalina.tribes.transport.nio.PooledParallelSender)2 ToString (lombok.ToString)1 lombok.val (lombok.val)1 ClusterManagerBase (org.apache.catalina.ha.session.ClusterManagerBase)1 JvmRouteSessionIDBinderListener (org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener)1 MessageDispatch15Interceptor (org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor)1