Search in sources :

Example 1 with NetworkTopology

use of org.apache.cassandra.distributed.shared.NetworkTopology in project cassandra by apache.

the class AbstractCluster method buildNetworkTopology.

public static NetworkTopology buildNetworkTopology(INodeProvisionStrategy provisionStrategy, Map<Integer, NetworkTopology.DcAndRack> nodeIdTopology) {
    NetworkTopology topology = NetworkTopology.build("", 0, Collections.emptyMap());
    IntStream.rangeClosed(1, nodeIdTopology.size()).forEach(nodeId -> {
        InetSocketAddress addressAndPort = addressAndPort(provisionStrategy.ipAddress(nodeId), provisionStrategy.storagePort(nodeId));
        NetworkTopology.DcAndRack dcAndRack = nodeIdTopology.get(nodeId);
        topology.put(addressAndPort, dcAndRack);
    });
    return topology;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology)

Example 2 with NetworkTopology

use of org.apache.cassandra.distributed.shared.NetworkTopology in project cassandra by apache.

the class AbstractCluster method createInstanceConfig.

private InstanceConfig createInstanceConfig(int nodeNum) {
    INodeProvisionStrategy provisionStrategy = nodeProvisionStrategy.create(subnet);
    long token = tokenSupplier.token(nodeNum);
    NetworkTopology topology = buildNetworkTopology(provisionStrategy, nodeIdTopology);
    InstanceConfig config = InstanceConfig.generate(nodeNum, provisionStrategy, topology, root, Long.toString(token), datadirCount);
    config.set(Constants.KEY_DTEST_API_CLUSTER_ID, clusterId.toString());
    if (configUpdater != null)
        configUpdater.accept(config);
    return config;
}
Also used : IInstanceConfig(org.apache.cassandra.distributed.api.IInstanceConfig) NetworkTopology(org.apache.cassandra.distributed.shared.NetworkTopology)

Aggregations

NetworkTopology (org.apache.cassandra.distributed.shared.NetworkTopology)2 InetSocketAddress (java.net.InetSocketAddress)1 IInstanceConfig (org.apache.cassandra.distributed.api.IInstanceConfig)1