Search in sources :

Example 11 with PhysicalAddress

use of org.jgroups.PhysicalAddress in project JGroups by belaban.

the class FILE_PING method findMembers.

public void findMembers(final List<Address> members, final boolean initial_discovery, Responses responses) {
    try {
        readAll(members, cluster_name, responses);
        if (responses.isEmpty()) {
            PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
            PingData coord_data = new PingData(local_addr, true, NameCache.get(local_addr), physical_addr).coord(is_coord);
            write(Collections.singletonList(coord_data), cluster_name);
            return;
        }
        PhysicalAddress phys_addr = (PhysicalAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
        PingData data = responses.findResponseFrom(local_addr);
        // the logical addr *and* IP address:port have to match
        if (data != null && data.getPhysicalAddr().equals(phys_addr)) {
            if (data.isCoord() && initial_discovery)
                responses.clear();
            else
                // use case #1 if we have predefined files: most members join but are not coord
                ;
        } else {
            sendDiscoveryResponse(local_addr, phys_addr, NameCache.get(local_addr), null, false);
        }
    } finally {
        responses.done();
    }
}
Also used : Event(org.jgroups.Event) PhysicalAddress(org.jgroups.PhysicalAddress)

Example 12 with PhysicalAddress

use of org.jgroups.PhysicalAddress in project JGroups by belaban.

the class PING method sendDiscoveryRequest.

protected void sendDiscoveryRequest(String cluster_name, List<Address> members_to_find, boolean initial_discovery) throws Exception {
    PingData data = null;
    if (!use_ip_addrs || !initial_discovery) {
        PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
        // https://issues.jboss.org/browse/JGRP-1670
        data = new PingData(local_addr, false, NameCache.get(local_addr), physical_addr);
        if (members_to_find != null && members_to_find.size() <= max_members_in_discovery_request)
            data.mbrs(members_to_find);
    }
    // message needs to have DONT_BUNDLE flag: if A sends message M to B, and we need to fetch B's physical
    // address, then the bundler thread blocks until the discovery request has returned. However, we cannot send
    // the discovery *request* until the bundler thread has returned from sending M
    PingHeader hdr = new PingHeader(PingHeader.GET_MBRS_REQ).clusterName(cluster_name).initialDiscovery(initial_discovery);
    Message msg = new Message(null).putHeader(getId(), hdr).setFlag(Message.Flag.INTERNAL, Message.Flag.DONT_BUNDLE, Message.Flag.OOB).setTransientFlag(Message.TransientFlag.DONT_LOOPBACK);
    if (data != null)
        msg.setBuffer(marshal(data));
    sendMcastDiscoveryRequest(msg);
}
Also used : Message(org.jgroups.Message) Event(org.jgroups.Event) PhysicalAddress(org.jgroups.PhysicalAddress)

Example 13 with PhysicalAddress

use of org.jgroups.PhysicalAddress in project JGroups by belaban.

the class GossipRouter method handleRegister.

protected void handleRegister(Address sender, DataInput in) {
    GossipData req = readRequest(in, GossipType.REGISTER);
    if (req != null) {
        String group = req.getGroup();
        Address addr = req.getAddress();
        PhysicalAddress phys_addr = req.getPhysicalAddress();
        String logical_name = req.getLogicalName();
        addAddressMapping(sender, group, addr, phys_addr, logical_name);
    }
}
Also used : InetAddress(java.net.InetAddress) PhysicalAddress(org.jgroups.PhysicalAddress) Address(org.jgroups.Address) PhysicalAddress(org.jgroups.PhysicalAddress)

Aggregations

PhysicalAddress (org.jgroups.PhysicalAddress)13 Address (org.jgroups.Address)9 Event (org.jgroups.Event)9 InetAddress (java.net.InetAddress)4 IpAddress (org.jgroups.stack.IpAddress)4 Message (org.jgroups.Message)3 InetSocketAddress (java.net.InetSocketAddress)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 PingData (org.jgroups.protocols.PingData)2 RouterStubManager (org.jgroups.stack.RouterStubManager)2 java.io (java.io)1 FileChannel (java.nio.channels.FileChannel)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 View (org.jgroups.View)1 LocalAddress (org.jgroups.annotations.LocalAddress)1