Search in sources :

Example 1 with SyntaxException

use of org.apache.cassandra.exceptions.SyntaxException in project cassandra by apache.

the class ReadDigestConsistencyTest method checkTraceForDigestMismatch.

public static void checkTraceForDigestMismatch(ICoordinator coordinator, String query, Object... boundValues) {
    UUID sessionId = UUID.randomUUID();
    try {
        coordinator.executeWithTracing(sessionId, query, ConsistencyLevel.ALL, boundValues);
    } catch (RuntimeException ex) {
        if (Throwables.isCausedBy(ex, t -> t.getClass().getName().equals(SyntaxException.class.getName()))) {
            if (coordinator.instance().getReleaseVersionString().startsWith("3.") && query.contains("[")) {
                logger.warn("Query {} is not supported on node {} version {}", query, coordinator.instance().broadcastAddress().getAddress().getHostAddress(), coordinator.instance().getReleaseVersionString());
                // we can forgive SyntaxException for C* < 4.0 if the query contains collection element selection
                return;
            }
        }
        logger.error("Failing for coordinator {} and query {}", coordinator.instance().getReleaseVersionString(), query);
        throw ex;
    }
    Object[][] results = coordinator.execute(SELECT_TRACE, ConsistencyLevel.ALL, sessionId, coordinator.instance().broadcastAddress().getAddress());
    for (Object[] result : results) {
        String activity = (String) result[0];
        Assert.assertFalse(String.format("Found Digest Mismatch while executing query: %s with bound values %s on %s/%s", query, Arrays.toString(boundValues), coordinator.instance().broadcastAddress(), coordinator.instance().getReleaseVersionString()), activity.toLowerCase().contains("mismatch for key"));
    }
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) ICoordinator(org.apache.cassandra.distributed.api.ICoordinator) LoggerFactory(org.slf4j.LoggerFactory) Throwables(org.apache.cassandra.utils.Throwables) Test(org.junit.Test) Cluster(org.apache.cassandra.distributed.Cluster) UUID(java.util.UUID) ConsistencyLevel(org.apache.cassandra.distributed.api.ConsistencyLevel) Assert(org.junit.Assert) SyntaxException(org.apache.cassandra.exceptions.SyntaxException) SyntaxException(org.apache.cassandra.exceptions.SyntaxException) UUID(java.util.UUID)

Example 2 with SyntaxException

use of org.apache.cassandra.exceptions.SyntaxException in project cassandra by apache.

the class FrozenType method getInstance.

public static AbstractType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException {
    List<AbstractType<?>> innerTypes = parser.getTypeParameters();
    if (innerTypes.size() != 1)
        throw new SyntaxException("FrozenType() only accepts one parameter");
    AbstractType<?> innerType = innerTypes.get(0);
    return innerType.freeze();
}
Also used : SyntaxException(org.apache.cassandra.exceptions.SyntaxException)

Aggregations

SyntaxException (org.apache.cassandra.exceptions.SyntaxException)2 Arrays (java.util.Arrays)1 UUID (java.util.UUID)1 Cluster (org.apache.cassandra.distributed.Cluster)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1 ICoordinator (org.apache.cassandra.distributed.api.ICoordinator)1 Throwables (org.apache.cassandra.utils.Throwables)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1