All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.blocks.cs.TcpBaseServer Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

The newest version!
package org.jgroups.blocks.cs;

import org.jgroups.Address;
import org.jgroups.util.SocketFactory;
import org.jgroups.util.ThreadFactory;

/**
 * Common base class for TCP based clients and servers
 * @author Bela Ban
 * @since  3.6.5
 */
public abstract class TcpBaseServer extends BaseServer {
    protected int     peer_addr_read_timeout=2000; // max time in milliseconds to block on reading peer address
    protected int     buffered_inputstream_size=8192;
    protected int     buffered_outputstream_size=8192;
    protected boolean non_blocking_sends;       // https://issues.redhat.com/browse/JGRP-2759
    protected int     max_send_queue=128; // when non_blocking, how many messages to queue max?

    protected TcpBaseServer(ThreadFactory f, SocketFactory sf, int recv_buf_size) {
        super(f, sf, recv_buf_size);
    }

    @Override
    protected TcpConnection createConnection(Address dest) throws Exception {
        return non_blocking_sends? new TcpConnectionNonBlocking(dest, this).maxSize(max_send_queue)
          : new TcpConnection(dest, this);
    }


    public int           peerAddressReadTimeout()           {return peer_addr_read_timeout;}
    public TcpBaseServer peerAddressReadTimeout(int t)      {this.peer_addr_read_timeout=t; return this;}
    public int           getBufferedInputStreamSize()       {return buffered_inputstream_size;}
    public TcpBaseServer setBufferedInputStreamSize(int s)  {this.buffered_inputstream_size=s; return this;}
    public int           getBufferedOutputStreamSize()      {return buffered_outputstream_size;}
    public TcpBaseServer setBufferedOutputStreamSize(int s) {this.buffered_outputstream_size=s; return this;}
    public boolean       nonBlockingSends()                 {return non_blocking_sends;}
    public TcpBaseServer nonBlockingSends(boolean b)        {this.non_blocking_sends=b; return this;}
    public int           maxSendQueue()                     {return max_send_queue;}
    public TcpBaseServer maxSendQueue(int s)                {this.max_send_queue=s; return this;}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy