當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。