org.apache.hadoop.hbase.client.OperationWithAttributes Java Examples

The following examples show how to use org.apache.hadoop.hbase.client.OperationWithAttributes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is
 *          associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a
 *           transaction IOException throw if the value of max lifetime of transaction is
 *           unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
    @SuppressWarnings("unused") OperationWithAttributes op, @Nullable Transaction tx)
    throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
      (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System
          .currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(
        String.format("Transaction %s has exceeded max lifetime %s ms", tx.getTransactionId(),
          txMaxLifetimeMillis));
  }
}
 
Example #2
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #3
Source File: ThriftHBaseServiceHandler.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Adds all the attributes into the Operation object
 */
private static void addAttributes(OperationWithAttributes op,
    Map<ByteBuffer, ByteBuffer> attributes) {
  if (attributes == null || attributes.isEmpty()) {
    return;
  }
  for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
    String name = Bytes.toStringBinary(getBytes(entry.getKey()));
    byte[] value =  getBytes(entry.getValue());
    op.setAttribute(name, value);
  }
}
 
Example #4
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Adds all the attributes into the Operation object
 */
private static void addAttributes(OperationWithAttributes op,
                                  Map<ByteBuffer, ByteBuffer> attributes) {
  if (attributes == null || attributes.isEmpty()) {
    return;
  }
  for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
    String name = Bytes.toStringBinary(getBytes(entry.getKey()));
    byte[] value =  getBytes(entry.getValue());
    op.setAttribute(name, value);
  }
}
 
Example #5
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #6
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #7
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #8
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #9
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #10
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #11
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #12
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #13
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #14
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #15
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #16
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
private Transaction getFromOperation(OperationWithAttributes op) throws IOException {
  byte[] encoded = op.getAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY);
  if (encoded == null) {
    // to support old clients
    encoded = op.getAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY);
  }
  if (encoded != null) {
    return txCodec.decode(encoded);
  }
  return null;
}
 
Example #17
Source File: TTable.java    From phoenix-omid with Apache License 2.0 5 votes vote down vote up
static private void propagateAttributes(OperationWithAttributes from, OperationWithAttributes to) {
    Map<String,byte[]> attributeMap = from.getAttributesMap();

    for (Map.Entry<String,byte[]> entry : attributeMap.entrySet()) {
        to.setAttribute(entry.getKey(), entry.getValue());
    }
}
 
Example #18
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #19
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
/**
 * Make sure that the transaction is within the max valid transaction lifetime.
 *
 * @param env {@link RegionCoprocessorEnvironment} of the Region to which the coprocessor is associated
 * @param op {@link OperationWithAttributes} HBase operation to access its attributes if required
 * @param tx {@link Transaction} supplied by the
 * @throws DoNotRetryIOException thrown if the transaction is older than the max lifetime of a transaction
 *         IOException throw if the value of max lifetime of transaction is unavailable
 */
protected void ensureValidTxLifetime(RegionCoprocessorEnvironment env,
                                     @SuppressWarnings("unused") OperationWithAttributes op,
                                     @Nullable Transaction tx) throws IOException {
  if (tx == null) {
    return;
  }

  boolean validLifetime =
    (TxUtils.getTimestamp(tx.getTransactionId()) + txMaxLifetimeMillis) > System.currentTimeMillis();
  if (!validLifetime) {
    throw new DoNotRetryIOException(String.format("Transaction %s has exceeded max lifetime %s ms",
                                                  tx.getTransactionId(), txMaxLifetimeMillis));
  }
}
 
Example #20
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
private boolean isRollbackOperation(OperationWithAttributes op) throws IOException {
  return op.getAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY) != null ||
    // to support old clients
    op.getAttribute(TxConstants.OLD_TX_ROLLBACK_ATTRIBUTE_KEY) != null;
}
 
Example #21
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #22
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
private boolean isRollbackOperation(OperationWithAttributes op) throws IOException {
  return op.getAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY) != null ||
    // to support old clients
    op.getAttribute(TxConstants.OLD_TX_ROLLBACK_ATTRIBUTE_KEY) != null;
}
 
Example #23
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #24
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #25
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #26
Source File: TransactionProcessor.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
private boolean isRollbackOperation(OperationWithAttributes op) throws IOException {
  return op.getAttribute(TxConstants.TX_ROLLBACK_ATTRIBUTE_KEY) != null ||
    // to support old clients
    op.getAttribute(TxConstants.OLD_TX_ROLLBACK_ATTRIBUTE_KEY) != null;
}
 
Example #27
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #28
Source File: TransactionAwareHTable.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #29
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 4 votes vote down vote up
@Override
public void addToOperation(OperationWithAttributes op, Transaction tx) throws IOException {
  op.setAttribute(TxConstants.OLD_TX_OPERATION_ATTRIBUTE_KEY, txCodec.encode(tx));
}
 
Example #30
Source File: SIObserver.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
protected boolean shouldUseSI(OperationWithAttributes op){
    if(op.getAttribute(SIConstants.SI_NEEDED)==null) return false;
    else return op.getAttribute(SIConstants.SUPPRESS_INDEXING_ATTRIBUTE_NAME)==null;
}