Examples of HectorException


Examples of me.prettyprint.hector.api.exceptions.HectorException

        try {
          logger.debug("sleeping {}ms to throttle.", sleepInterval);
          Thread.sleep(sleepInterval);
        } catch (InterruptedException e) {
          // rethrow as hector exception
          throw new HectorException(e.getMessage());
        }
      }
    }

    return result;
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

  }


  public HThriftClient borrowClient() throws HectorException {
    if ( !active.get() ) {
      throw new HectorException("Attempt to borrow on in-active pool: " + getName());
    }
    HThriftClient cassandraClient;
    int currentActive = numActive.incrementAndGet();
    int tillExhausted = cassandraHost.getMaxActive() - currentActive;

    numBlocked.incrementAndGet();
    cassandraClient = availableClientQueue.poll();
    if ( cassandraClient == null ) {
      if ( tillExhausted > 0 ) {
        // if we start with #of threads == getMaxActive, we could trigger this condition
        addClientToPoolGently(new HThriftClient(cassandraHost).open());
        log.debug("created new client. NumActive:{} untilExhausted: {}", currentActive, tillExhausted);
      }
      // blocked take on the queue if we are configured to wait forever
      if ( log.isDebugEnabled() ) {
        log.debug("blocking on queue - current block count {}", numBlocked.get());
      }
      // wait and catch, creating a new one if the counts have changed. Infinite wait should just recurse.
      if ( maxWaitTimeWhenExhausted == 0 ) {
        while (cassandraClient == null && active.get() ) {
          try {
            cassandraClient = availableClientQueue.poll(100, TimeUnit.MILLISECONDS);
          } catch (InterruptedException ie) {
            log.error("InterruptedException poll operation on retry forever", ie);
            break;
          }
        }
      } else {

        try {
          cassandraClient = availableClientQueue.poll(maxWaitTimeWhenExhausted, TimeUnit.MILLISECONDS);
          if ( cassandraClient == null ) {
            numBlocked.decrementAndGet();
            throw new PoolExhaustedException(String.format("maxWaitTimeWhenExhausted exceeded for thread %s on host %s",
                new Object[]{
                Thread.currentThread().getName(),
                cassandraHost.getName()}
            ));
          }
        } catch (InterruptedException ie) {
          //monitor.incCounter(Counter.POOL_EXHAUSTED);
          numActive.decrementAndGet();
        }
      }

    }
    if ( cassandraClient == null ) {
      throw new HectorException("HConnectionManager returned a null client after aquisition - are we shutting down?");
    }
    activeClients.add(cassandraClient);
    numBlocked.decrementAndGet();

View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

    } else if (original instanceof NoSuchElementException) {
      return new PoolExhaustedException(original);
    } else if (original instanceof IllegalStateException) {
      return new PoolIllegalStateException(original);
    } else {
      return new HectorException(original);
    }
  }
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

        success = true;
        stopWatch.stop(op.stopWatchTagName + ".success_");
        break;

      } catch (Exception ex) {
        HectorException he = exceptionsTranslator.translate(ex);
        if ( he instanceof HInvalidRequestException || he instanceof HCassandraInternalException ) {
          throw he;
        } else if ( he instanceof HectorTransportException) {
          --retries;
          client.close();
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

    }

  private HThriftClient getClientFromLBPolicy(Set<CassandraHost> excludeHosts) {
    HThriftClient client;
    if ( hostPools.isEmpty() ) {
      throw new HectorException("All host pools marked down. Retry burden pushed out to client.");
    }
    try {
      client = loadBalancingPolicy.getPool(hostPools.values(), excludeHosts).borrowClient();
    } catch (Exception e) {
      throw new HectorException("General exception in getClientFromLBPolicy",e);
    }
    return client;
  }
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

      SliceRange range = new SliceRange(findBytes(start), findBytes(finish), reversed, count);
      pred.setSlice_range(range);
      break;
    case Unknown:
    default:
      throw new HectorException(
          "Neither column names nor range were set, this is an invalid slice predicate");
    }
    return pred;
  }
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

                    keySlices.size());
              for (KeySlice keySlice : keySlices) {
                ret.put(ByteBuffer.wrap(keySlice.getKey()), ThriftConverter.getColumnList(keySlice.getColumns()));
              }
            } catch (Exception e) {
              HectorException he = keyspace.getExceptionsTranslator().translate(e);
              setException(he);
              throw he;
            }
            Map<K, List<Column>> thriftRet = keySerializer.fromBytesMap(ret);
            return new OrderedRowsImpl<K,N,V>((LinkedHashMap<K, List<Column>>) thriftRet, columnNameSerializer, valueSerializer);
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

        }

      }

      if ( cassandraClient == null ) {
        throw new HectorException("HConnectionManager returned a null client after aquisition - are we shutting down?");
      }
    } catch (RuntimeException e) {
      activeClientsCount.decrementAndGet();
      throw e;
    }
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

        success = true;
        timer.stop(timerToken, op.stopWatchTagName, true);
        break;

      } catch (Exception ex) {
        HectorException he = exceptionsTranslator.translate(ex);
        if ( he instanceof HUnavailableException) {
          // break out on HUnavailableException as well since we can no longer satisfy the CL
          throw he;
        } else if (he instanceof HInvalidRequestException || he instanceof HCassandraInternalException) {
          closeClient(client);
View Full Code Here

Examples of me.prettyprint.hector.api.exceptions.HectorException

      }
    }

  private HClientPool getClientFromLBPolicy(Set<CassandraHost> excludeHosts) {
    if ( hostPools.isEmpty() ) {
      throw new HectorException("All host pools marked down. Retry burden pushed out to client.");
    }       
    return loadBalancingPolicy.getPool(hostPoolValues, excludeHosts);   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.