Search in sources :

Example 1 with RouterStubManager

use of org.jgroups.stack.RouterStubManager in project JGroups by belaban.

the class TCPGOSSIP method handleConnect.

public void handleConnect() {
    if (cluster_name == null || local_addr == null)
        log.error(Util.getMessage("GroupaddrOrLocaladdrIsNullCannotRegisterWithGossipRouterS"));
    else {
        InetAddress bind_addr = getTransport().getBindAddress();
        log.trace("registering " + local_addr + " under " + cluster_name + " with GossipRouter");
        stubManager.destroyStubs();
        PhysicalAddress physical_addr = (PhysicalAddress) down_prot.down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
        stubManager = new RouterStubManager(this, cluster_name, local_addr, NameCache.get(local_addr), physical_addr, reconnect_interval).useNio(this.use_nio);
        for (InetSocketAddress host : initial_hosts) {
            RouterStub stub = stubManager.createAndRegisterStub(new IpAddress(bind_addr, 0), new IpAddress(host.getAddress(), host.getPort()));
            stub.socketConnectionTimeout(sock_conn_timeout);
        }
        stubManager.connectStubs();
    }
}
Also used : RouterStub(org.jgroups.stack.RouterStub) RouterStubManager(org.jgroups.stack.RouterStubManager) InetSocketAddress(java.net.InetSocketAddress) Event(org.jgroups.Event) PhysicalAddress(org.jgroups.PhysicalAddress) IpAddress(org.jgroups.stack.IpAddress) InetAddress(java.net.InetAddress)

Example 2 with RouterStubManager

use of org.jgroups.stack.RouterStubManager in project JGroups by belaban.

the class TUNNEL method handleDownEvent.

public Object handleDownEvent(Event evt) {
    Object retEvent = super.handleDownEvent(evt);
    switch(evt.getType()) {
        case Event.CONNECT:
        case Event.CONNECT_WITH_STATE_TRANSFER:
        case Event.CONNECT_USE_FLUSH:
        case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
            String group = evt.getArg();
            Address local = local_addr;
            if (stubManager != null)
                stubManager.destroyStubs();
            PhysicalAddress physical_addr = getPhysicalAddressFromCache(local);
            String logical_name = org.jgroups.util.NameCache.get(local);
            stubManager = new RouterStubManager(this, group, local, logical_name, physical_addr, getReconnectInterval()).useNio(this.use_nio);
            for (InetSocketAddress gr : gossip_router_hosts) {
                stubManager.createAndRegisterStub(new IpAddress(bind_addr, bind_port), new IpAddress(gr.getAddress(), gr.getPort())).receiver(this).set("tcp_nodelay", tcp_nodelay);
            }
            stubManager.connectStubs();
            break;
        case Event.DISCONNECT:
            disconnectStub();
            break;
    }
    return retEvent;
}
Also used : RouterStubManager(org.jgroups.stack.RouterStubManager) InetSocketAddress(java.net.InetSocketAddress) IpAddress(org.jgroups.stack.IpAddress) PhysicalAddress(org.jgroups.PhysicalAddress) Address(org.jgroups.Address) InetSocketAddress(java.net.InetSocketAddress) PhysicalAddress(org.jgroups.PhysicalAddress) IpAddress(org.jgroups.stack.IpAddress)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)2 PhysicalAddress (org.jgroups.PhysicalAddress)2 IpAddress (org.jgroups.stack.IpAddress)2 RouterStubManager (org.jgroups.stack.RouterStubManager)2 InetAddress (java.net.InetAddress)1 Address (org.jgroups.Address)1 Event (org.jgroups.Event)1 RouterStub (org.jgroups.stack.RouterStub)1