Search in sources :

Example 26 with NodeToolResult

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

the class RepairCoordinatorFast method onlyCoordinator.

@Test
public void onlyCoordinator() {
    // this is very similar to ::desiredHostNotCoordinator but has the difference that the only host to do repair
    // is the coordinator
    String table = tableName("onlycoordinator");
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        CLUSTER.schemaChange(format("CREATE TABLE %s.%s (key text, value text, PRIMARY KEY (key))", KEYSPACE, table));
        long repairExceptions = getRepairExceptions(CLUSTER, 2);
        NodeToolResult result = repair(1, KEYSPACE, table, "--in-hosts", "localhost");
        result.asserts().failure().errorContains("Specified hosts [localhost] do not share range");
        if (withNotifications) {
            result.asserts().notificationContains(ProgressEventType.START, "Starting repair command").notificationContains(ProgressEventType.START, "repairing keyspace " + KEYSPACE + " with repair options").notificationContains(ProgressEventType.ERROR, "Specified hosts [localhost] do not share range").notificationContains(ProgressEventType.COMPLETE, "finished with error");
        }
        assertParentRepairNotExist(CLUSTER, KEYSPACE, table);
        // TODO should this be marked as fail to match others?  Should they not be marked?
        Assert.assertEquals(repairExceptions, getRepairExceptions(CLUSTER, 2));
    });
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 27 with NodeToolResult

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

the class RepairCoordinatorFast method desiredHostNotCoordinator.

@Test
public void desiredHostNotCoordinator() {
    // current limitation is that the coordinator must be apart of the repair, so as long as that exists this test
    // verifies that the validation logic will termniate the repair properly
    String table = tableName("desiredhostnotcoordinator");
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        CLUSTER.schemaChange(format("CREATE TABLE %s.%s (key text, value text, PRIMARY KEY (key))", KEYSPACE, table));
        long repairExceptions = getRepairExceptions(CLUSTER, 2);
        NodeToolResult result = repair(2, KEYSPACE, table, "--in-hosts", "localhost");
        result.asserts().failure().errorContains("The current host must be part of the repair");
        if (withNotifications) {
            result.asserts().notificationContains(ProgressEventType.START, "Starting repair command").notificationContains(ProgressEventType.START, "repairing keyspace " + KEYSPACE + " with repair options").notificationContains(ProgressEventType.ERROR, "The current host must be part of the repair").notificationContains(ProgressEventType.COMPLETE, "finished with error");
        }
        assertParentRepairNotExist(CLUSTER, KEYSPACE, table);
        Assert.assertEquals(repairExceptions + 1, getRepairExceptions(CLUSTER, 2));
    });
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 28 with NodeToolResult

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

the class RepairCoordinatorFast method prepareFailure.

@Test
public void prepareFailure() {
    String table = tableName("preparefailure");
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        CLUSTER.schemaChange(format("CREATE TABLE %s.%s (key text, value text, PRIMARY KEY (key))", KEYSPACE, table));
        IMessageFilters.Filter filter = CLUSTER.verbs(Verb.PREPARE_MSG).messagesMatching(of(m -> {
            throw new RuntimeException("prepare fail");
        })).drop();
        try {
            long repairExceptions = getRepairExceptions(CLUSTER, 1);
            NodeToolResult result = repair(1, KEYSPACE, table);
            result.asserts().failure().errorContains("Got negative replies from endpoints");
            if (withNotifications) {
                result.asserts().notificationContains(ProgressEventType.START, "Starting repair command").notificationContains(ProgressEventType.START, "repairing keyspace " + KEYSPACE + " with repair options").notificationContains(ProgressEventType.ERROR, "Got negative replies from endpoints").notificationContains(ProgressEventType.COMPLETE, "finished with error");
            }
            Assert.assertEquals(repairExceptions + 1, getRepairExceptions(CLUSTER, 1));
            if (repairType != RepairType.PREVIEW) {
                assertParentRepairFailedWithMessageContains(CLUSTER, KEYSPACE, table, "Got negative replies from endpoints");
            } else {
                assertParentRepairNotExist(CLUSTER, KEYSPACE, table);
            }
        } finally {
            filter.off();
        }
    });
}
Also used : IMessageFilters(org.apache.cassandra.distributed.api.IMessageFilters) NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 29 with NodeToolResult

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

the class ClusterUtils method gossipInfo.

/**
 * Get the gossip information from the node.  Currently only address, generation, and heartbeat are returned
 *
 * @param inst to check on
 * @return gossip info
 */
public static Map<String, Map<String, String>> gossipInfo(IInstance inst) {
    NodeToolResult results = inst.nodetoolResult("gossipinfo");
    results.asserts().success();
    return parseGossipInfo(results.getStdout());
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult)

Aggregations

NodeToolResult (org.apache.cassandra.distributed.api.NodeToolResult)29 Test (org.junit.Test)24 Cluster (org.apache.cassandra.distributed.Cluster)6 IMessageFilters (org.apache.cassandra.distributed.api.IMessageFilters)5 UnknownHostException (java.net.UnknownHostException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Token (org.apache.cassandra.dht.Token)2 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Random (java.util.Random)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Future (java.util.concurrent.Future)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CassandraRelevantProperties (org.apache.cassandra.config.CassandraRelevantProperties)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 Range (org.apache.cassandra.dht.Range)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1