Search in sources :

Example 1 with Peer

use of com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.Peer in project atlasdb by palantir.

the class CqlKeyValueService method performInitialSetup.

protected void performInitialSetup() {
    Metadata metadata = cluster.getMetadata();
    CassandraVerifier.validatePartitioner(metadata.getPartitioner(), config);
    Set<Peer> peers = CqlKeyValueServices.getPeers(session);
    boolean allNodesHaveSaneNumberOfVnodes = Iterables.all(peers, peer -> peer.tokens.size() > CassandraConstants.ABSOLUTE_MINIMUM_NUMBER_OF_TOKENS_PER_NODE);
    // node we're querying doesn't count itself as a peer
    if (peers.size() > 0 && !allNodesHaveSaneNumberOfVnodes) {
        throw new IllegalStateException("All nodes in cluster must have sane number of vnodes" + " (or cluster must consist of a single node).");
    }
    Set<String> dcsInCluster = Sets.newHashSet();
    for (Peer peer : peers) {
        dcsInCluster.add(peer.dataCenter);
        if (peer.dataCenter == null) {
            throw new IllegalStateException("Cluster should not mix datacenter-aware" + " and non-datacenter-aware nodes.");
        }
    }
    dcsInCluster.add(getLocalDataCenter());
    if (metadata.getKeyspace(config.getKeyspaceOrThrow()) == null) {
        // keyspace previously didn't exist; we need to set it up
        createKeyspace(config.getKeyspaceOrThrow(), dcsInCluster);
        return;
    }
    createTables(ImmutableMap.of(AtlasDbConstants.DEFAULT_METADATA_TABLE, AtlasDbConstants.EMPTY_TABLE_METADATA));
}
Also used : Peer(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.Peer) Metadata(com.datastax.driver.core.Metadata)

Aggregations

Metadata (com.datastax.driver.core.Metadata)1 Peer (com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.Peer)1