Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.HLogEdit


  /**
   * @param transactionId
   * @throws IOException
   */
  public void writeStartToLog(final long transactionId) throws IOException {
    HLogEdit logEdit;
    logEdit = new HLogEdit(transactionId, HLogEdit.TransactionalOperation.START);

    hlog.append(regionInfo, logEdit);
  }
View Full Code Here


    long commitTime = update.getTimestamp() == HConstants.LATEST_TIMESTAMP ? System
        .currentTimeMillis()
        : update.getTimestamp();

    for (BatchOperation op : update) {
      HLogEdit logEdit = new HLogEdit(transactionId, op, commitTime);
      hlog.append(regionInfo, update.getRow(), logEdit);
    }
  }
View Full Code Here

  /**
   * @param transactionId
   * @throws IOException
   */
  public void writeCommitToLog(final long transactionId) throws IOException {
    HLogEdit logEdit;
    logEdit = new HLogEdit(transactionId,
        HLogEdit.TransactionalOperation.COMMIT);

    hlog.append(regionInfo, logEdit);
  }
View Full Code Here

  /**
   * @param transactionId
   * @throws IOException
   */
  public void writeAbortToLog(final long transactionId) throws IOException {
    HLogEdit logEdit;
    logEdit = new HLogEdit(transactionId, HLogEdit.TransactionalOperation.ABORT);

    hlog.append(regionInfo, logEdit);
  }
View Full Code Here

    SequenceFile.Reader logReader = new SequenceFile.Reader(fileSystem,
        reconstructionLog, conf);

    try {
      HLogKey key = new HLogKey();
      HLogEdit val = new HLogEdit();
      long skippedEdits = 0;
      long totalEdits = 0;
      long startCount = 0;
      long writeCount = 0;
      long abortCount = 0;
      long commitCount = 0;
      // How many edits to apply before we send a progress report.
      int reportInterval = conf.getInt("hbase.hstore.report.interval.edits",
          2000);
      while (logReader.next(key, val)) {
        LOG.debug("Processing edit: key: " + key.toString() + " val: "
            + val.toString());
        if (key.getLogSeqNum() < maxSeqID) {
          skippedEdits++;
          continue;
        }

        // Check this edit is for me.
        byte[] column = val.getColumn();
        Long transactionId = val.getTransactionId();
        if (!val.isTransactionEntry() || HLog.isMetaColumn(column)
            || !Bytes.equals(key.getRegionName(), regionInfo.getRegionName())) {
          continue;
        }

        List<BatchUpdate> updates = pendingTransactionsById.get(transactionId);
        switch (val.getOperation()) {
        case START:
          if (updates != null || abortedTransactions.contains(transactionId)
              || commitedTransactionsById.containsKey(transactionId)) {
            LOG.error("Processing start for transaction: " + transactionId
                + ", but have already seen start message");
            throw new IOException("Corrupted transaction log");
          }
          updates = new LinkedList<BatchUpdate>();
          pendingTransactionsById.put(transactionId, updates);
          startCount++;
          break;

        case WRITE:
          if (updates == null) {
            LOG.error("Processing edit for transaction: " + transactionId
                + ", but have not seen start message");
            throw new IOException("Corrupted transaction log");
          }

          BatchUpdate tranUpdate = new BatchUpdate(key.getRow());
          if (val.getVal() != null) {
            tranUpdate.put(val.getColumn(), val.getVal());
          } else {
            tranUpdate.delete(val.getColumn());
          }
          updates.add(tranUpdate);
          writeCount++;
          break;
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.HLogEdit

Copyright © 2018 www.massapicom. 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.