Search in sources :

Example 1 with TCP

use of org.jgroups.protocols.TCP in project fabric8 by jboss-fuse.

the class TestBase method setUp.

@Before
public void setUp() throws Exception {
    for (int i = 0; i < NUM; i++) {
        Protocol ping = createPing();
        channels[i] = new JChannel(new TCP(), ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS());
        channels[i].setName(Character.toString((char) ('A' + i)));
        channels[i].connect(CLUSTER_NAME);
        channels[i].setReceiver(receivers[i] = new MyReceiver());
    }
}
Also used : TCP(org.jgroups.protocols.TCP) NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) STABLE(org.jgroups.protocols.pbcast.STABLE) Protocol(org.jgroups.stack.Protocol) GMS(org.jgroups.protocols.pbcast.GMS) UNICAST3(org.jgroups.protocols.UNICAST3) Before(org.junit.Before)

Example 2 with TCP

use of org.jgroups.protocols.TCP in project JGroups by belaban.

the class NAKACK2 method init.

public void init() throws Exception {
    if (xmit_from_random_member && discard_delivered_msgs) {
        discard_delivered_msgs = false;
        log.debug("%s: xmit_from_random_member set to true: changed discard_delivered_msgs to false", local_addr);
    }
    TP transport = getTransport();
    // UDP and TCP_NIO2 won't block
    sends_can_block = transport instanceof TCP;
    transport.registerProbeHandler(this);
    if (!transport.supportsMulticasting()) {
        if (use_mcast_xmit) {
            log.debug(Util.getMessage("NoMulticastTransport"), "use_mcast_xmit", transport.getName(), "use_mcast_xmit");
            use_mcast_xmit = false;
        }
        if (use_mcast_xmit_req) {
            log.debug(Util.getMessage("NoMulticastTransport"), "use_mcast_xmit_req", transport.getName(), "use_mcast_xmit_req");
            use_mcast_xmit_req = false;
        }
    }
    if (become_server_queue_size > 0)
        become_server_queue = new BoundedList<>(become_server_queue_size);
    if (suppress_time_non_member_warnings > 0)
        suppress_log_non_member = new SuppressLog<>(log, "MsgDroppedNak", "SuppressMsg");
    // max bundle size (minus overhead) divided by <long size> times bits per long
    int estimated_max_msgs_in_xmit_req = (transport.getBundler().getMaxSize() - 50) * Global.LONG_SIZE;
    int old_max_xmit_size = max_xmit_req_size;
    if (max_xmit_req_size <= 0)
        max_xmit_req_size = estimated_max_msgs_in_xmit_req;
    else
        max_xmit_req_size = Math.min(max_xmit_req_size, estimated_max_msgs_in_xmit_req);
    if (old_max_xmit_size != max_xmit_req_size)
        log.trace("%s: set max_xmit_req_size from %d to %d", local_addr, old_max_xmit_size, max_xmit_req_size);
    if (resend_last_seqno)
        setResendLastSeqno(resend_last_seqno);
}
Also used : TCP(org.jgroups.protocols.TCP) TP(org.jgroups.protocols.TP)

Example 3 with TCP

use of org.jgroups.protocols.TCP in project JGroups by belaban.

the class DNSDiscoveryTester method runTestAndCheckIfViewWasReceived.

public boolean runTestAndCheckIfViewWasReceived(String dnsQuery, String recordType) throws Exception {
    List<JChannel> channels = new ArrayList<>();
    CountDownLatch waitForViewToForm = new CountDownLatch(1);
    for (int i = 0; i < numberOfTestedInstances; ++i) {
        DNS_PING ping = new DNS_PING();
        ping.dns_resolver = dnsResolverBuilder.build();
        ping.dns_query = dnsQuery;
        ping.dns_record_type = recordType;
        ping.dns_address = "fake.com";
        Protocol[] protocols = { new TCP().setBindAddress(InetAddress.getLoopbackAddress()).setBindPort(portStart).setPortRange(1), ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS().setJoinTimeout(timeout) };
        JChannel c = new JChannel(protocols).name(String.valueOf(i + 1));
        channels.add(c);
        c.setReceiver(new Receiver() {

            @Override
            public void viewAccepted(View view) {
                if (view.getMembers().size() == numberOfTestedInstances) {
                    waitForViewToForm.countDown();
                }
            }
        });
        c.connect("TEST");
    }
    boolean viewReceived = waitForViewToForm.await(timeout, unit);
    channels.forEach(JChannel::close);
    return viewReceived;
}
Also used : TCP(org.jgroups.protocols.TCP) JChannel(org.jgroups.JChannel) ArrayList(java.util.ArrayList) Receiver(org.jgroups.Receiver) CountDownLatch(java.util.concurrent.CountDownLatch) GMS(org.jgroups.protocols.pbcast.GMS) View(org.jgroups.View) UNICAST3(org.jgroups.protocols.UNICAST3) NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) STABLE(org.jgroups.protocols.pbcast.STABLE) Protocol(org.jgroups.stack.Protocol)

Aggregations

TCP (org.jgroups.protocols.TCP)3 JChannel (org.jgroups.JChannel)2 UNICAST3 (org.jgroups.protocols.UNICAST3)2 GMS (org.jgroups.protocols.pbcast.GMS)2 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)2 STABLE (org.jgroups.protocols.pbcast.STABLE)2 Protocol (org.jgroups.stack.Protocol)2 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Receiver (org.jgroups.Receiver)1 View (org.jgroups.View)1 TP (org.jgroups.protocols.TP)1 Before (org.junit.Before)1