Search in sources :

Example 1 with Row

use of org.apache.cassandra.distributed.api.Row in project cassandra by apache.

the class DistributedRepairUtils method validateExistingParentRepair.

private static void validateExistingParentRepair(QueryResult rs, Consumer<Row> fn) {
    Assert.assertTrue("No rows found", rs.hasNext());
    Row row = rs.next();
    Assert.assertNotNull("parent_id (which is the primary key) was null", row.getUUID("parent_id"));
    fn.accept(row);
    // make sure no other records found
    Assert.assertFalse("Only one repair expected, but found more than one", rs.hasNext());
}
Also used : Row(org.apache.cassandra.distributed.api.Row)

Example 2 with Row

use of org.apache.cassandra.distributed.api.Row in project cassandra by apache.

the class DistributedRepairUtils method queryParentRepairHistory.

public static QueryResult queryParentRepairHistory(ICluster<IInvokableInstance> cluster, int coordinator, String ks, String table) {
    // This is kinda brittle since the caller never gets the ID and can't ask for the ID; it needs to infer the id
    // this logic makes the assumption the ks/table pairs are unique (should be or else create should fail) so any
    // repair for that pair will be the repair id
    Set<String> tableNames = table == null ? Collections.emptySet() : ImmutableSet.of(table);
    QueryResult rs = retryWithBackoffBlocking(10, () -> cluster.coordinator(coordinator).executeWithResult("SELECT * FROM system_distributed.parent_repair_history", ConsistencyLevel.QUORUM).filter(row -> ks.equals(row.getString("keyspace_name"))).filter(row -> tableNames.equals(row.getSet("columnfamily_names"))));
    return rs;
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult) StorageMetrics(org.apache.cassandra.metrics.StorageMetrics) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ICluster(org.apache.cassandra.distributed.api.ICluster) ArrayUtils(org.apache.commons.lang3.ArrayUtils) ConsistencyLevel(org.apache.cassandra.distributed.api.ConsistencyLevel) Consumer(java.util.function.Consumer) Row(org.apache.cassandra.distributed.api.Row) IInvokableInstance(org.apache.cassandra.distributed.api.IInvokableInstance) Assert(org.junit.Assert) Retry.retryWithBackoffBlocking(org.apache.cassandra.utils.Retry.retryWithBackoffBlocking) Collections(java.util.Collections) AbstractCluster(org.apache.cassandra.distributed.impl.AbstractCluster) NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) QueryResult(org.apache.cassandra.distributed.api.QueryResult)

Aggregations

Row (org.apache.cassandra.distributed.api.Row)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1 ICluster (org.apache.cassandra.distributed.api.ICluster)1 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)1 NodeToolResult (org.apache.cassandra.distributed.api.NodeToolResult)1 QueryResult (org.apache.cassandra.distributed.api.QueryResult)1 AbstractCluster (org.apache.cassandra.distributed.impl.AbstractCluster)1 StorageMetrics (org.apache.cassandra.metrics.StorageMetrics)1 Retry.retryWithBackoffBlocking (org.apache.cassandra.utils.Retry.retryWithBackoffBlocking)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 Assert (org.junit.Assert)1