All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.datastax.driver.core.exceptions.QueryConsistencyException Maven / Gradle / Ivy

Go to download

A driver for Apache Cassandra 1.2+ that works exclusively with the Cassandra Query Language version 3 (CQL3) and Cassandra's binary protocol.

There is a newer version: 4.0.0
Show newest version
/*
 * Copyright DataStax, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.datastax.driver.core.exceptions;

import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.EndPoint;
import java.net.InetAddress;
import java.net.InetSocketAddress;

/**
 * A failure to reach the required consistency level during the execution of a query.
 *
 * 

Such an exception is returned when the query has been tried by Cassandra but cannot be * achieved with the requested consistency level because either: * *

    *
  • the coordinator did not receive enough replica responses within the rpc timeout set for * Cassandra; *
  • some replicas replied with an error. *
* * . */ @SuppressWarnings("serial") public abstract class QueryConsistencyException extends QueryExecutionException implements CoordinatorException { private final EndPoint endPoint; private final ConsistencyLevel consistency; private final int received; private final int required; protected QueryConsistencyException( EndPoint endPoint, String msg, ConsistencyLevel consistency, int received, int required) { super(msg); this.endPoint = endPoint; this.consistency = consistency; this.received = received; this.required = required; } protected QueryConsistencyException( EndPoint endPoint, String msg, Throwable cause, ConsistencyLevel consistency, int received, int required) { super(msg, cause); this.endPoint = endPoint; this.consistency = consistency; this.received = received; this.required = required; } /** * The consistency level of the operation that failed. * * @return the consistency level of the operation that failed. */ public ConsistencyLevel getConsistencyLevel() { return consistency; } /** * The number of replicas that had acknowledged/responded to the operation before it failed. * * @return the number of replica that had acknowledged/responded the operation before it failed. */ public int getReceivedAcknowledgements() { return received; } /** * The minimum number of replica acknowledgements/responses that were required to fulfill the * operation. * * @return The minimum number of replica acknowledgements/response that were required to fulfill * the operation. */ public int getRequiredAcknowledgements() { return required; } /** * {@inheritDoc} * *

Note that this is the information of the host that coordinated the query, not the * one that timed out. */ @Override public EndPoint getEndPoint() { return endPoint; } @Override @Deprecated public InetSocketAddress getAddress() { return (endPoint == null) ? null : endPoint.resolve(); } @Override @Deprecated public InetAddress getHost() { return (endPoint == null) ? null : endPoint.resolve().getAddress(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy