Search in sources :

Example 1 with EventListener

use of io.stargate.db.EventListener in project stargate by stargate.

the class DefaultQueryInterceptor method leaveCluster.

private void leaveCluster(InetAddress endpoint) {
    if (!liveStargateNodes.remove(endpoint)) {
        return;
    }
    StargateSystemKeyspace.removeEndpoint(endpoint);
    InetAddress nativeAddress = getNativeAddress(endpoint);
    for (EventListener listener : listeners) {
        listener.onLeaveCluster(nativeAddress, EventListener.NO_PORT);
    }
}
Also used : EventListener(io.stargate.db.EventListener) InetAddress(java.net.InetAddress)

Example 2 with EventListener

use of io.stargate.db.EventListener in project stargate by stargate.

the class DefaultQueryInterceptor method leaveCluster.

private void leaveCluster(InetAddress endpoint) {
    if (!liveStargateNodes.remove(endpoint)) {
        return;
    }
    StargateSystemKeyspace.instance.getPeers().remove(endpoint);
    InetAddress nativeAddress = getNativeAddress(endpoint);
    for (EventListener listener : listeners) {
        listener.onLeaveCluster(nativeAddress, EventListener.NO_PORT);
    }
}
Also used : EventListener(io.stargate.db.EventListener) InetAddress(java.net.InetAddress)

Example 3 with EventListener

use of io.stargate.db.EventListener in project stargate by stargate.

the class ProxyProtocolQueryInterceptor method resolvePeers.

private Set<InetAddress> resolvePeers(String dnsName, Set<InetAddress> current) throws UnknownHostException {
    Set<InetAddress> resolved = resolver.resolve(dnsName);
    if (!current.equals(resolved)) {
        // Generate listener events based on the differences between this and the previous
        // resolved peers.
        Sets.SetView<InetAddress> added = Sets.difference(resolved, current);
        Sets.SetView<InetAddress> removed = Sets.difference(current, resolved);
        for (EventListener listener : listeners) {
            for (InetAddress peer : added) {
                listener.onJoinCluster(peer, proxyPort);
                listener.onUp(peer, proxyPort);
            }
            for (InetAddress peer : removed) {
                tokensCache.remove(peer);
                listener.onLeaveCluster(peer, proxyPort);
            }
        }
    }
    return resolved;
}
Also used : Sets(com.datastax.oss.driver.shaded.guava.common.collect.Sets) EventListener(io.stargate.db.EventListener) InetAddress(java.net.InetAddress)

Example 4 with EventListener

use of io.stargate.db.EventListener in project stargate by stargate.

the class DefaultQueryInterceptor method leaveCluster.

private void leaveCluster(InetAddressAndPort endpoint) {
    if (!liveStargateNodes.remove(endpoint)) {
        return;
    }
    StargateSystemKeyspace.removeEndpoint(endpoint);
    InetAddressAndPort nativeAddress = getNativeAddress(endpoint);
    for (EventListener listener : listeners) {
        listener.onLeaveCluster(nativeAddress.address, nativeAddress.port);
    }
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) EventListener(io.stargate.db.EventListener)

Aggregations

EventListener (io.stargate.db.EventListener)4 InetAddress (java.net.InetAddress)3 Sets (com.datastax.oss.driver.shaded.guava.common.collect.Sets)1 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)1