org.apache.catalina.tribes.transport.ReplicationTransmitter Java Examples

The following examples show how to use org.apache.catalina.tribes.transport.ReplicationTransmitter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestGroupChannelSenderConnections.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testKeepAliveCount() throws Exception {
    log.info("Setting keep alive count to 0");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveCount(0);
    }
    sendMessages(1000,15000);
}
 
Example #2
Source File: TestGroupChannelSenderConnections.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testKeepAliveTime() throws Exception {
    log.info("Setting keep alive count to 1 second");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveTime(1000);
    }
    sendMessages(2000,15000);
}
 
Example #3
Source File: TestMulticastPackages.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_MULTICAST);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    Assert.assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #4
Source File: TestUdpPackages.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_UDP);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    Assert.assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #5
Source File: TestGroupChannelSenderConnections.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeepAliveCount() throws Exception {
    log.info("Setting keep alive count to 0");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveCount(0);
    }
    sendMessages(1000,15000);
}
 
Example #6
Source File: TestGroupChannelSenderConnections.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeepAliveTime() throws Exception {
    log.info("Setting keep alive count to 1 second");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveTime(1000);
    }
    sendMessages(2000,15000);
}
 
Example #7
Source File: TestMulticastPackages.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_MULTICAST);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #8
Source File: TestUdpPackages.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_UDP);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #9
Source File: TestGroupChannelSenderConnections.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeepAliveCount() throws Exception {
    log.info("Setting keep alive count to 0");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveCount(0);
    }
    sendMessages(1000,15000);
}
 
Example #10
Source File: TestGroupChannelSenderConnections.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testKeepAliveTime() throws Exception {
    log.info("Setting keep alive count to 1 second");
    for (int i = 0; i < channels.length; i++) {
        ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
        t.getTransport().setKeepAliveTime(1000);
    }
    sendMessages(2000,15000);
}
 
Example #11
Source File: TestMulticastPackages.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_MULTICAST);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #12
Source File: TestUdpPackages.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleDataSendNO_ACK() throws Exception {
    AbstractSender s1 =(AbstractSender) ((ReplicationTransmitter)channel1.getChannelSender()).getTransport();
    AbstractSender s2 =(AbstractSender) ((ReplicationTransmitter)channel2.getChannelSender()).getTransport();
    s1.setTimeout(Long.MAX_VALUE); //for debugging
    s2.setTimeout(Long.MAX_VALUE); //for debugging

    System.err.println("Starting Single package NO_ACK");
    channel1.send(new Member[] {channel2.getLocalMember(false)}, Data.createRandomData(1024),Channel.SEND_OPTIONS_UDP);
    Thread.sleep(500);
    System.err.println("Finished Single package NO_ACK ["+listener1.count+"]");
    assertEquals("Checking success messages.",1,listener1.count.get());
}
 
Example #13
Source File: ChannelCoordinator.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
public ChannelCoordinator() {
    this(new NioReceiver(), new ReplicationTransmitter(),
            new McastService());
}
 
Example #14
Source File: ChannelCoordinator.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Starts up the channel. This can be called multiple times for individual services to start
 * The svc parameter can be the logical or value of any constants
 * @param svc int value of <BR>
 * DEFAULT - will start all services <BR>
 * MBR_RX_SEQ - starts the membership receiver <BR>
 * MBR_TX_SEQ - starts the membership broadcaster <BR>
 * SND_TX_SEQ - starts the replication transmitter<BR>
 * SND_RX_SEQ - starts the replication receiver<BR>
 * @throws ChannelException if a startup error occurs or the service is already started.
 */
protected synchronized void internalStart(int svc) throws ChannelException {
    try {
        boolean valid = false;
        //make sure we don't pass down any flags that are unrelated to the bottom layer
        svc = svc & Channel.DEFAULT;

        if (startLevel == Channel.DEFAULT) return; //we have already started up all components
        if (svc == 0 ) return;//nothing to start
        
        if (svc == (svc & startLevel)) throw new ChannelException("Channel already started for level:"+svc);

        //must start the receiver first so that we can coordinate the port it
        //listens to with the local membership settings
        if ( Channel.SND_RX_SEQ==(svc & Channel.SND_RX_SEQ) ) {
            clusterReceiver.setMessageListener(this);
            if (clusterReceiver instanceof ReceiverBase) {
                ((ReceiverBase)clusterReceiver).setChannel(getChannel());
            }
            clusterReceiver.start();
            //synchronize, big time FIXME
            Member localMember = getChannel().getLocalMember(false);
            if (localMember instanceof StaticMember) {
                // static member
                StaticMember staticMember = (StaticMember)localMember;
                staticMember.setHost(getClusterReceiver().getHost());
                staticMember.setPort(getClusterReceiver().getPort());
                staticMember.setSecurePort(getClusterReceiver().getSecurePort());
            } else {
                // multicast member
                membershipService.setLocalMemberProperties(getClusterReceiver().getHost(),
                        getClusterReceiver().getPort(),
                        getClusterReceiver().getSecurePort(),
                        getClusterReceiver().getUdpPort());
               
            }
            valid = true;
        }
        if ( Channel.SND_TX_SEQ==(svc & Channel.SND_TX_SEQ) ) {
            if (clusterSender instanceof ReplicationTransmitter) {
                ((ReplicationTransmitter)clusterSender).setChannel(getChannel());
            }
            valid = true;
            clusterSender.start();
        }
        
        if ( Channel.MBR_RX_SEQ==(svc & Channel.MBR_RX_SEQ) ) {
            membershipService.setMembershipListener(this);
            if (membershipService instanceof McastService) {
                ((McastService)membershipService).setMessageListener(this);
                ((McastService)membershipService).setChannel(getChannel());
            }
            membershipService.start(MembershipService.MBR_RX);
            valid = true;
        }
        if ( Channel.MBR_TX_SEQ==(svc & Channel.MBR_TX_SEQ) ) {
            if (membershipService instanceof McastService) {
                ((McastService)membershipService).setChannel(getChannel());
            }
            membershipService.start(MembershipService.MBR_TX);
            valid = true;
        }
        
        if ( !valid) {
            throw new IllegalArgumentException("Invalid start level, valid levels are:SND_RX_SEQ,SND_TX_SEQ,MBR_TX_SEQ,MBR_RX_SEQ");
        }
        startLevel = (startLevel | svc);
    }catch ( ChannelException cx ) {
        throw cx;
    }catch ( Exception x ) {
        throw new ChannelException(x);
    }
}
 
Example #15
Source File: SenderSF.java    From Tomcat8-Source-Read with MIT License 3 votes vote down vote up
/**
 * Store the specified Sender child.
 *
 * @param aWriter
 *            PrintWriter to which we are storing
 * @param indent
 *            Number of spaces to indent this element
 * @param aSender
 *            Channel whose properties are being stored
 *
 * @exception Exception
 *                if an exception occurs while storing
 */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aSender,
        StoreDescription parentDesc) throws Exception {
    if (aSender instanceof ReplicationTransmitter) {
        ReplicationTransmitter transmitter = (ReplicationTransmitter) aSender;
        // Store nested <Transport> element
        MultiPointSender transport = transmitter.getTransport();
        if (transport != null) {
            storeElement(aWriter, indent, transport);
        }
   }
}