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

com.datastax.driver.core.exceptions.BusyPoolException 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 (C) 2012-2015 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.HostDistance;
import com.datastax.driver.core.Statement;

import java.net.InetAddress;
import java.net.InetSocketAddress;

/**
 * Indicates that a connection pool has run out of available connections.
 * 

* This happens if the pool has no connections (for example if it's currently reconnecting to its host), or if all * connections have reached their maximum number of in flight queries. The query will be retried on the next host in the * {@link com.datastax.driver.core.policies.LoadBalancingPolicy#newQueryPlan(String, Statement) query plan}. *

* This exception is a symptom that the driver is experiencing a high workload. If it happens regularly on all hosts, * you should consider tuning one (or a combination of) the following pooling options: *

    *
  • {@link com.datastax.driver.core.PoolingOptions#setMaxRequestsPerConnection(HostDistance, int)}: maximum number of * requests per connection;
  • *
  • {@link com.datastax.driver.core.PoolingOptions#setMaxConnectionsPerHost(HostDistance, int)}: maximum number of * connections in the pool;
  • *
  • {@link com.datastax.driver.core.PoolingOptions#setMaxQueueSize(int)}: maximum number of enqueued requests before * this exception is thrown.
  • *
*/ public class BusyPoolException extends DriverException implements CoordinatorException { private static final long serialVersionUID = 0; private final InetSocketAddress address; private final int queueSize; public BusyPoolException(InetSocketAddress address, int queueSize) { this(address, queueSize, null); } private BusyPoolException(InetSocketAddress address, int queueSize, Throwable cause) { super(buildMessage(address, queueSize), cause); this.address = address; this.queueSize = queueSize; } private static String buildMessage(InetSocketAddress address, int queueSize) { return String.format("[%s] Pool is busy (no available connection and the queue has reached its max size %d)", address.getAddress(), queueSize); } @Override public InetAddress getHost() { return address.getAddress(); } @Override public InetSocketAddress getAddress() { return address; } @Override public BusyPoolException copy() { return new BusyPoolException(address, queueSize, this); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy