Search in sources :

Example 1 with Gossiper

use of org.apache.cassandra.gms.Gossiper in project eiger by wlloyd.

the class HintedHandOffManager method waitForSchemaAgreement.

private int waitForSchemaAgreement(InetAddress endpoint) throws TimeoutException {
    Gossiper gossiper = Gossiper.instance;
    int waited = 0;
    // first, wait for schema to be gossiped.
    while (gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA) == null) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new AssertionError(e);
        }
        waited += 1000;
        if (waited > 2 * StorageService.RING_DELAY)
            throw new TimeoutException("Didin't receive gossiped schema from " + endpoint + " in " + 2 * StorageService.RING_DELAY + "ms");
    }
    waited = 0;
    // causes the two to diverge (see CASSANDRA-2946)
    while (!gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA).value.equals(gossiper.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress()).getApplicationState(ApplicationState.SCHEMA).value)) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new AssertionError(e);
        }
        waited += 1000;
        if (waited > 2 * StorageService.RING_DELAY)
            throw new TimeoutException("Could not reach schema agreement with " + endpoint + " in " + 2 * StorageService.RING_DELAY + "ms");
    }
    logger_.debug("schema for {} matches local schema", endpoint);
    return waited;
}
Also used : Gossiper(org.apache.cassandra.gms.Gossiper) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)1 Gossiper (org.apache.cassandra.gms.Gossiper)1