[infinispan-dev] XSite route status listener in server - ISPN-7230/ISPN-7231

Paul Ferraro paul.ferraro at redhat.com
Sat Jan 14 13:22:14 EST 2017


Hi Galder,

Sorry for the delay.  For server-mode, we'd need to set the
RouteStatusListener in the jgroups subsystem before the RELAY2
protocol is initialized.
e.g.
public class DefaultRouteStatusListener implements
RouteStatusListener, Supplier<Set<String>> {
    private final Set<String> view = new ConcurrentSkipListSet<>();
    @Override
    public void sitesUp(String... sites) {
        this.view.addAll(Arrays.asList(sites));
        log.receivedXSiteClusterView(view);
    }
    @Override
    public void sitesDown(String... sites) {
        this.view.removeAll(Arrays.asList(sites));
        log.receivedXSiteClusterView(view);
    }
    @Override
    public Set<String> get() {
        return Collections.unmodifiableSet(this.view);
    }
}

We would set the RouteStatusListener following this line from JChannelFactory:
https://github.com/infinispan/infinispan/blob/master/server/integration/jgroups/src/main/java/org/infinispan/server/jgroups/JChannelFactory.java#L136
e.g.
RELAY2 relay = new RELAY2().site(localSite);
relay.setRouteStatusListener(new DefaultRouteStatusListener());

JGroupsTransport can then obtain the site view via:
@Override
public Set<String> getSitesView() {
    RELAY2 relay = channel.getProtocolStack().findProtocol(RELAY2.class);
    RouteStatusListener listener = (relay != null) ?
relay.getRouteStatusListener() : null;
    return (listener instanceof Supplier) ? ((Supplier<Set<String>>)
listener).get() : null;
}

On Thu, Jan 12, 2017 at 6:10 AM, Galder Zamarreño <galder at redhat.com> wrote:
> Hi Paul,
>
> Sorry to bother you again :)
>
> Re: https://issues.jboss.org/browse/ISPN-7230 & https://issues.jboss.org/browse/ISPN-7231
>
> The aim of these JIRAs is to have a x-site view exposed as an INFO message as well as JMX and DMR operation.
>
> To do that, following Bela's advice, I've extracted RELAY2 protocol of the stack and on Infinispan's JGroupsTransport start() method, call setRouteStatusListener() with a relay RouteStatusListener implementation that allows the x-site view to be tracked [1].
>
> This works fine in library mode, but in server, on startup setRouteStatusListener() sometimes gets called after the Relayer's viewAccepted() method has been already called (which is the one that calls into RouteStatusListener). These means that the inital x-site view might not be registered.
>
> So, what would be the correct place to add the setRouteStatusListener() call so that all views are captured? Or given how the server works, do I need to avoid using setRouteStatusListener() and use my own, Infinispan level, listener for tracking somehow?
>
> Cheers,
>
> [1] https://github.com/galderz/infinispan/blob/t_7230/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsTransport.java#L926
> --
> Galder Zamarreño
> Infinispan, Red Hat
>



More information about the infinispan-dev mailing list