use of com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology in project esop by instaclustr.
the class CassandraClusterTopologyTest method testDcFiltering.
@Test
public void testDcFiltering() throws Exception {
final ClusterTopology topology = getClusterTopology();
ClusterTopology filtered = ClusterTopology.filter(topology, "dc1");
Assert.assertEquals(topology.schemaVersion, filtered.schemaVersion);
Assert.assertEquals(3, topology.endpointDcs.size());
Assert.assertEquals(3, topology.endpoints.size());
Assert.assertEquals(3, topology.hostnames.size());
Assert.assertEquals(3, topology.endpointRacks.size());
}
use of com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology in project esop by instaclustr.
the class CassandraClusterTopologyTest method testMultipleDcFiltering.
@Test
public void testMultipleDcFiltering() throws Exception {
final ClusterTopology topology = getClusterTopology();
ClusterTopology filtered = ClusterTopology.filter(topology, " dc1, dc2 ,");
Assert.assertEquals(topology.schemaVersion, filtered.schemaVersion);
Assert.assertEquals(6, topology.endpointDcs.size());
Assert.assertEquals(6, topology.endpoints.size());
Assert.assertEquals(6, topology.hostnames.size());
Assert.assertEquals(6, topology.endpointRacks.size());
}
use of com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology in project esop by instaclustr.
the class CassandraClusterTopology method act.
@Override
public ClusterTopology act() throws Exception {
final String clusterName = new CassandraClusterName(cassandraJMXService).act();
// map of endpoints and host ids
final Map<InetAddress, UUID> endpoints = new CassandraEndpoints(cassandraJMXService).act();
// map of endpoints and dc they belong to
final Map<InetAddress, String> endpointDcs = new CassandraEndpointDC(cassandraJMXService, endpoints.keySet()).act();
// map of endpoints and hostnames
final Map<InetAddress, String> hostnames = new CassandraHostname(endpoints.keySet()).act();
// map of endpoints and rack they belong to
final Map<InetAddress, String> endpointRacks = new CassandraEndpointRack(cassandraJMXService, endpoints.keySet()).act();
final String schemaVersion = new CassandraSchemaVersion(cassandraJMXService).act();
final ClusterTopology resolvedTopology = constructTopology(clusterName, endpoints, endpointDcs, hostnames, endpointRacks, schemaVersion);
final Set<String> invalidDcs = ClusterTopology.sanitizeDcs(dcs).stream().filter(dc -> !resolvedTopology.getDcs().contains(dc)).collect(toSet());
if (!invalidDcs.isEmpty()) {
throw new IllegalStateException(format("Some DCs to filter on do not exist: %s, existing: %s", invalidDcs, String.join(",", resolvedTopology.getDcs())));
}
logger.info(resolvedTopology.toString());
return resolvedTopology;
}
use of com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology in project esop by instaclustr.
the class CassandraClusterTopology method constructTopology.
private ClusterTopology constructTopology(final String clusterName, final Map<InetAddress, UUID> endpoints, final Map<InetAddress, String> endpointDcs, final Map<InetAddress, String> hostnames, final Map<InetAddress, String> endpointRacks, final String schemaVersion) {
final ClusterTopology topology = new ClusterTopology();
topology.setTimestamp(System.currentTimeMillis());
for (InetAddress inetAddress : endpoints.keySet()) {
final ClusterTopology.NodeTopology nodeTopology = new ClusterTopology.NodeTopology();
nodeTopology.setCluster(clusterName);
nodeTopology.setDc(endpointDcs.get(inetAddress));
nodeTopology.setNodeId(endpoints.get(inetAddress));
nodeTopology.setHostname(hostnames.get(inetAddress));
nodeTopology.setRack(endpointRacks.get(inetAddress));
nodeTopology.setIpAddress(inetAddress.getHostAddress());
topology.topology.add(nodeTopology);
}
topology.clusterName = clusterName;
topology.schemaVersion = schemaVersion;
topology.endpoints = endpoints;
topology.endpointDcs = endpointDcs;
topology.hostnames = hostnames;
topology.endpointRacks = endpointRacks;
return ClusterTopology.filter(topology, dcs);
}
Aggregations