Esempio n. 1
0
 private void doInsert(int consistency_level, RowMutation rm) throws UnavailableException {
   if (consistency_level != ConsistencyLevel.ZERO) {
     StorageProxy.insertBlocking(rm, consistency_level);
   } else {
     StorageProxy.insert(rm);
   }
 }
Esempio n. 2
0
  protected ColumnFamily readColumnFamily(ReadCommand command, int consistency_level)
      throws InvalidRequestException {
    String cfName = command.getColumnFamilyName();
    ThriftValidation.validateKey(command.key);

    if (consistency_level == ConsistencyLevel.ZERO) {
      throw new InvalidRequestException(
          "Consistency level zero may not be applied to read operations");
    }
    if (consistency_level == ConsistencyLevel.ALL) {
      throw new InvalidRequestException(
          "Consistency level all is not yet supported on read operations");
    }

    Row row;
    try {
      row = StorageProxy.readProtocol(command, consistency_level);
    } catch (IOException e) {
      throw new RuntimeException(e);
    } catch (TimeoutException e) {
      throw new RuntimeException(e);
    }

    if (row == null) {
      return null;
    }
    return row.getColumnFamily(cfName);
  }
  protected List<Row> queryNextPage(
      int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery)
      throws RequestExecutionException {
    AbstractRangeCommand pageCmd = command.withUpdatedLimit(pageSize);
    if (lastReturnedKey != null)
      pageCmd = pageCmd.forSubRange(makeExcludingKeyBounds(lastReturnedKey));

    return localQuery
        ? pageCmd.executeLocally()
        : StorageProxy.getRangeSlice(pageCmd, consistencyLevel);
  }
Esempio n. 4
0
  public List<String> get_key_range(
      String tablename, String columnFamily, String startWith, String stopAt, int maxResults)
      throws InvalidRequestException, TException {
    if (logger.isDebugEnabled()) logger.debug("get_key_range");
    ThriftValidation.validateCommand(tablename, columnFamily);
    if (!(StorageService.getPartitioner() instanceof OrderPreservingPartitioner)) {
      throw new InvalidRequestException(
          "range queries may only be performed against an order-preserving partitioner");
    }
    if (maxResults <= 0) {
      throw new InvalidRequestException("maxResults must be positive");
    }

    try {
      return StorageProxy.getKeyRange(
          new RangeCommand(tablename, columnFamily, startWith, stopAt, maxResults));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }