Examples of IPooledConnection


Examples of org.scale7.cassandra.pelops.pool.IThriftPool.IPooledConnection

        {
            if (m.isCounterColumnType())
            {
                try
                {
                    IPooledConnection connection = getConnection();
                    org.apache.cassandra.thrift.Cassandra.Client thriftClient = connection.getAPI();
                    List<KeySlice> ks = thriftClient.get_range_slices(new ColumnParent(m.getTableName()),
                            slicePredicate, Selector.newKeyRange("", "", maxResult), getConsistencyLevel());
                    connection.release();
                    entities = onCounterColumn(m, isRelation, relations, ks);
                }
                catch (InvalidRequestException irex)
                {
                    log.error("Error during executing find, Caused by: .", irex);
View Full Code Here

Examples of org.scale7.cassandra.pelops.pool.IThriftPool.IPooledConnection

        Set<String> avoidNodes = null;
    Exception lastException = null;
    int retries = 0;
    do {
      // Get a connection to a Cassandra node
            IPooledConnection conn = null;
            try {
                conn = thrift.getConnectionExcept(avoidNodes);
            } catch (Exception e) {
                // the pool is responsible for blocking and waiting for a connection, so don't retry
                throw operandPolicy.getExceptionTranslator().translate(e);
            }

      try {
        // Execute operation
                // Return result!
        return operation.execute(conn);
      } catch (Exception e) {
                // Should we try again?
                if (e instanceof TimedOutException ||
                    e instanceof TTransportException ||
                    e instanceof UnavailableException) {

                    logger.warn("Operation failed as result of network exception. Connection to node {} is being marked as corrupt " +
                            "(and will probably be be destroyed). Cause of failure is {}", conn.getNode().getAddress(), e);

                    // This connection is "broken" by network timeout or other problem.
                    conn.corrupted();

                    // to avoid create the set for every request create the set here
                    if (avoidNodes == null) avoidNodes = new HashSet<String>(10);
                    avoidNodes.add(conn.getNode().getAddress());

          retries++;
          lastException = e;
        } else if (e instanceof NotFoundException) {
                    // Re-throw application-level exceptions immediately.
          throw operandPolicy.getExceptionTranslator().translate(e);
                } else {
                    // This connection is "broken" by network timeout or other problem.
                    conn.corrupted();

                    // Re-throw application-level exceptions immediately.
          throw operandPolicy.getExceptionTranslator().translate(e);
        }
      } finally {
                conn.release();
            }
    } while (retries < operandPolicy.getMaxOpRetries());

    throw operandPolicy.getExceptionTranslator().translate(lastException);
  }
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.