当前位置: 首页>>代码示例>>Java>>正文


Java Status类代码示例

本文整理汇总了Java中org.apache.accumulo.core.client.ConditionalWriter.Status的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Status类属于org.apache.accumulo.core.client.ConditionalWriter包,在下文中一共展示了Status类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processResults

import org.apache.accumulo.core.client.ConditionalWriter.Status; //导入依赖的package包/类
@Override
public boolean processResults(CommitData cd, Iterator<Result> results) throws Exception {

  while (results.hasNext()) {
    Result result = results.next();
    // TODO handle unknown?
    Bytes row = Bytes.of(result.getMutation().getRow());
    if (result.getStatus() == Status.ACCEPTED) {
      cd.acceptedRows.add(row);
    } else {
      cd.addToRejected(row, updates.get(row).keySet());
    }
  }

  return cd.getRejected().size() == 0;
}
 
开发者ID:apache,项目名称:fluo,代码行数:17,代码来源:TransactionImpl.java

示例2: handleUnknown

import org.apache.accumulo.core.client.ConditionalWriter.Status; //导入依赖的package包/类
@Override
public Iterator<Result> handleUnknown(CommitData cd, Iterator<Result> results)
    throws Exception {
  // the code for handing this is synchronous and needs to be handled in another thread pool
  // TODO - how do we do the above without return a CF?
  long commitTs = getStats().getCommitTs();
  Result result = Iterators.getOnlyElement(results);
  Status ms = result.getStatus();

  while (ms == Status.UNKNOWN) {

    // TODO async
    TxInfo txInfo = TxInfo.getTransactionInfo(env, cd.prow, cd.pcol, startTs);

    switch (txInfo.status) {
      case COMMITTED:
        if (txInfo.commitTs != commitTs) {
          throw new IllegalStateException(
              cd.prow + " " + cd.pcol + " " + txInfo.commitTs + "!=" + commitTs);
        }
        ms = Status.ACCEPTED;
        break;
      case LOCKED:
        // TODO async
        ConditionalMutation delLockMutation = result.getMutation();
        ms = cd.cw.write(delLockMutation).getStatus();
        break;
      default:
        ms = Status.REJECTED;
    }
  }
  Result newResult = new Result(ms, result.getMutation(), result.getTabletServer());
  return Collections.singletonList(newResult).iterator();
}
 
开发者ID:apache,项目名称:fluo,代码行数:35,代码来源:TransactionImpl.java

示例3: cancel

import org.apache.accumulo.core.client.ConditionalWriter.Status; //导入依赖的package包/类
public void cancel(String what, String when, String who) throws Exception {

    String row = what + ":" + when;

    // Even though this method is only deleting a column, its important to use a conditional writer. By updating the seq # when deleting a reservation, it
    // will cause any concurrent reservations to retry. If this delete were done using a batch writer, then a concurrent reservation could report WAIT_LISTED
    // when it actually got the reservation.

    // its important to use an isolated scanner so that only whole mutations are seen
    try (ConditionalWriter cwriter = conn.createConditionalWriter(rTable, new ConditionalWriterConfig());
        Scanner scanner = new IsolatedScanner(conn.createScanner(rTable, Authorizations.EMPTY))) {
      while (true) {
        scanner.setRange(new Range(row));

        int seq = -1;
        String reservation = null;

        for (Entry<Key,Value> entry : scanner) {
          String cf = entry.getKey().getColumnFamilyData().toString();
          String cq = entry.getKey().getColumnQualifierData().toString();
          String val = entry.getValue().toString();

          // EXCERCISE avoid linear scan

          if (cf.equals("tx") && cq.equals("seq")) {
            seq = Integer.parseInt(val);
          } else if (cf.equals("res") && val.equals(who)) {
            reservation = cq;
          }
        }

        if (reservation != null) {
          ConditionalMutation update = new ConditionalMutation(row, new Condition("tx", "seq").setValue(seq + ""));
          update.putDelete("res", reservation);
          update.put("tx", "seq", (seq + 1) + "");

          Status status = cwriter.write(update).getStatus();
          switch (status) {
            case ACCEPTED:
              // successfully canceled reservation
              return;
            case REJECTED:
            case UNKNOWN:
              // retry
              // EXCERCISE exponential back-off could be used here
              break;
            default:
              throw new RuntimeException("Unexpected status " + status);
          }

        } else {
          // not reserved, nothing to do
          break;
        }

      }
    }
  }
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:59,代码来源:ARS.java


注:本文中的org.apache.accumulo.core.client.ConditionalWriter.Status类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。