Search in sources :

Example 1 with TcpDiscoverySpiState

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState in project ignite by apache.

the class ServerImpl method notifyDiscovery.

/**
 * Notify external listener on discovery event.
 *
 * @param type Discovery event type. See {@link org.apache.ignite.events.DiscoveryEvent} for more details.
 * @param topVer Topology version.
 * @param node Remote node this event is connected with.
 */
private void notifyDiscovery(int type, long topVer, TcpDiscoveryNode node) {
    assert type > 0;
    assert node != null;
    DiscoverySpiListener lsnr = spi.lsnr;
    TcpDiscoverySpiState spiState = spiStateCopy();
    DebugLogger log = type == EVT_NODE_METRICS_UPDATED ? traceLog : debugLog;
    if (lsnr != null && node.visible() && (spiState == CONNECTED || spiState == DISCONNECTING)) {
        if (log.isDebugEnabled())
            log.debug("Discovery notification [node=" + node + ", spiState=" + spiState + ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
        Collection<ClusterNode> top = upcast(ring.visibleNodes());
        Map<Long, Collection<ClusterNode>> hist = updateTopologyHistory(topVer, top);
        lsnr.onDiscovery(type, topVer, node, top, hist, null);
    } else {
        if (log.isDebugEnabled())
            log.debug("Skipped discovery notification [node=" + node + ", spiState=" + spiState + ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TcpDiscoverySpiState(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState) Collection(java.util.Collection) DiscoverySpiListener(org.apache.ignite.spi.discovery.DiscoverySpiListener)

Example 2 with TcpDiscoverySpiState

use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState in project ignite by apache.

the class ServerImpl method notifyDiscovery.

/**
 * Notify external listener on discovery event.
 *
 * @param type Discovery event type. See {@link org.apache.ignite.events.DiscoveryEvent} for more details.
 * @param topVer Topology version.
 * @param node Remote node this event is connected with.
 */
private boolean notifyDiscovery(int type, long topVer, TcpDiscoveryNode node, SpanContainer spanContainer) {
    assert type > 0;
    assert node != null;
    DiscoverySpiListener lsnr = spi.lsnr;
    TcpDiscoverySpiState spiState = spiStateCopy();
    DebugLogger log = type == EVT_NODE_METRICS_UPDATED ? traceLog : debugLog;
    if (lsnr != null && node.visible() && (spiState == CONNECTED || spiState == DISCONNECTING)) {
        if (log.isDebugEnabled())
            log.debug("Discovery notification [node=" + node + ", spiState=" + spiState + ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
        Collection<ClusterNode> top = upcast(ring.visibleNodes());
        Map<Long, Collection<ClusterNode>> hist = updateTopologyHistory(topVer, top);
        lsnr.onDiscovery(new DiscoveryNotification(type, topVer, node, top, hist, null, spanContainer));
        return true;
    } else {
        if (log.isDebugEnabled())
            log.debug("Skipped discovery notification [node=" + node + ", spiState=" + spiState + ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
    }
    return false;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) TcpDiscoverySpiState(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState) Collection(java.util.Collection) DiscoveryNotification(org.apache.ignite.spi.discovery.DiscoveryNotification) DiscoverySpiListener(org.apache.ignite.spi.discovery.DiscoverySpiListener)

Aggregations

Collection (java.util.Collection)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 DiscoverySpiListener (org.apache.ignite.spi.discovery.DiscoverySpiListener)2 TcpDiscoverySpiState (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState)2 DiscoveryNotification (org.apache.ignite.spi.discovery.DiscoveryNotification)1