Hector API and Cassandra Database Problem: Undocumented Exception

Whenever I use any Hector API function to access my Cassandra database, I get an exception:

me.prettyprint.hector.api.exceptions.HectorException: all node pools are marked. The burden of resubmission is given to the customer.

My server has a Cassandra database running in the background.

I read about the exception and is actually not documented. It seems that the exception is due to connectivity issues.

How to fix it?

+5
source share
3 answers

You will get this error if the Hector client cannot connect to Cassandra. There may be several reasons and things:

  • Make sure the connection properties in your code (ip / host / port) are configured correctly.
  • , cassandra-cli - .
  • - , .
+3

- , . , API Hector:

/** An interface where inside the execute() method I call Hector */
public interface Retriable<T> {
    T execute();
}

/**
 * Executes operation and retries N times in case of an exception
 * @param retriable
 * @param maxRetries
 * @param <T>
 * @return
 */
public static <T> T executeWithRetry(Retriable<T> retriable, int maxRetries) {
    T result;
    int retries = 0;
    long sleepSec = 1;
    // retry in case of an exception:
    while (true) {
        try {
            result = retriable.execute();
            break;
        } catch (Exception e) {
            if (retries == maxRetries) {
                LOG.error("Exception occurred. Reached max retries.", e);
                throw e;
            }
            retries++;
            LOG.error(String.format("Exception occurred. Retrying in %d seconds - #%d", sleepSec, retries), e);
            try {
                Thread.sleep(sleepSec * 1000);
                // increase sleepSec exponentially:
                sleepSec *= 2;
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    }
    return result;
}

, :

    ColumnFamilyResult<String, String> columns = executeWithRetry(new Retriable<ColumnFamilyResult<String, String>>() {
        @Override
        public ColumnFamilyResult<String, String> execute() {
            return template.queryColumns(row.getKey());
        }
    });
0

I was getting the same error with cassandra-unit 2.0.2.1 , but Downgrading version prior to 2.0.2.0 solved the problem. This is strange, but now I used 2.0.2.0 with some additional sbt dependencies

         "com.datastax.cassandra" % "cassandra-driver-core" % "2.0.1",
         "org.cassandraunit" % "cassandra-unit" % "2.0.2.0" withSources() withJavadoc()
0
source

All Articles