Search in sources :

Example 1 with ReplicationValve

use of org.apache.catalina.ha.tcp.ReplicationValve 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 ReplicationValve

use of org.apache.catalina.ha.tcp.ReplicationValve in project ofbiz-framework by apache.

the class CatalinaContainer method prepareClusterValve.

private ReplicationValve prepareClusterValve(Property clusterProp) {
    ReplicationValve clusterValve = new ReplicationValve();
    String defaultValveFilter = ".*\\.gif;.*\\.js;.*\\.jpg;.*\\.htm;.*\\.html;.*\\.txt;.*\\.png;.*\\.css;.*\\.ico;.*\\.htc;";
    clusterValve.setFilter(ContainerConfig.getPropertyValue(clusterProp, "rep-valve-filter", defaultValveFilter));
    return clusterValve;
}
Also used : ReplicationValve(org.apache.catalina.ha.tcp.ReplicationValve)

Aggregations

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