public static TxInfo getTransactionInfo()

in modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java [52:114]


  public static TxInfo getTransactionInfo(Environment env, Bytes prow, Column pcol, long startTs) {
    // TODO ensure primary is visible

    IteratorSetting is = new IteratorSetting(10, RollbackCheckIterator.class);
    RollbackCheckIterator.setLocktime(is, startTs);

    Entry<Key, Value> entry = ColumnUtil.checkColumn(env, is, prow, pcol);

    TxInfo txInfo = new TxInfo();

    if (entry == null) {
      txInfo.status = TxStatus.UNKNOWN;
      return txInfo;
    }

    ColumnType colType = ColumnType.from(entry.getKey());
    long ts = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK;

    switch (colType) {
      case LOCK: {
        if (ts == startTs) {
          txInfo.status = TxStatus.LOCKED;
          txInfo.lockValue = entry.getValue().get();
        } else {
          txInfo.status = TxStatus.UNKNOWN; // locked by another tx
        }
        break;
      }
      case DEL_LOCK: {
        DelLockValue dlv = new DelLockValue(entry.getValue().get());

        if (ts != startTs) {
          // expect this to always be false, must be a bug in the iterator
          throw new IllegalStateException(prow + " " + pcol + " (" + ts + " != " + startTs + ") ");
        }

        if (dlv.isRollback()) {
          txInfo.status = TxStatus.ROLLED_BACK;
        } else {
          txInfo.status = TxStatus.COMMITTED;
          txInfo.commitTs = dlv.getCommitTimestamp();
        }
        break;
      }
      case WRITE: {
        long timePtr = WriteValue.getTimestamp(entry.getValue().get());

        if (timePtr != startTs) {
          // expect this to always be false, must be a bug in the iterator
          throw new IllegalStateException(
              prow + " " + pcol + " (" + timePtr + " != " + startTs + ") ");
        }

        txInfo.status = TxStatus.COMMITTED;
        txInfo.commitTs = ts;
        break;
      }
      default:
        throw new IllegalStateException("unexpected col type returned " + colType);
    }

    return txInfo;
  }