Java Code Examples for org.apache.hadoop.hbase.client.Durability#USE_DEFAULT

The following examples show how to use org.apache.hadoop.hbase.client.Durability#USE_DEFAULT . 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: ProtobufUtil.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Convert a protobuf Durability into a client Durability
 */
public static Durability toDurability(
    final ClientProtos.MutationProto.Durability proto) {
  switch(proto) {
  case USE_DEFAULT:
    return Durability.USE_DEFAULT;
  case SKIP_WAL:
    return Durability.SKIP_WAL;
  case ASYNC_WAL:
    return Durability.ASYNC_WAL;
  case SYNC_WAL:
    return Durability.SYNC_WAL;
  case FSYNC_WAL:
    return Durability.FSYNC_WAL;
  default:
    return Durability.USE_DEFAULT;
  }
}
 
Example 2
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 3
Source File: LoadTestTool.java    From hbase with Apache License 2.0 5 votes vote down vote up
public void initTestTable() throws IOException {
  Durability durability = Durability.USE_DEFAULT;
  if (deferredLogFlush) {
    durability = Durability.ASYNC_WAL;
  }

  HBaseTestingUtility.createPreSplitLoadTestTable(conf, tableName,
    getColumnFamilies(), compressAlgo, dataBlockEncodingAlgo, numRegionsPerServer,
      regionReplication, durability);
  applyColumnFamilyOptions(tableName, getColumnFamilies());
}
 
Example 4
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static TPut putFromHBase(Put in) {
  TPut out = new TPut();
  out.setRow(in.getRow());
  if (in.getTimestamp() != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(in.getTimestamp());
  }
  if (in.getDurability() != Durability.USE_DEFAULT) {
    out.setDurability(durabilityFromHBase(in.getDurability()));
  }
  for (Map.Entry<byte [], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
    byte[] family = entry.getKey();
    for (Cell cell : entry.getValue()) {
      TColumnValue columnValue = new TColumnValue();
      columnValue.setFamily(family)
          .setQualifier(CellUtil.cloneQualifier(cell))
          .setType(cell.getType().getCode())
          .setTimestamp(cell.getTimestamp())
          .setValue(CellUtil.cloneValue(cell));
      if (cell.getTagsLength() != 0) {
        columnValue.setTags(PrivateCellUtil.cloneTags(cell));
      }
      out.addToColumnValues(columnValue);
    }
  }
  for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
    out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())),
        ByteBuffer.wrap(attribute.getValue()));
  }
  try {
    CellVisibility cellVisibility = in.getCellVisibility();
    if (cellVisibility != null) {
      TCellVisibility tCellVisibility = new TCellVisibility();
      tCellVisibility.setExpression(cellVisibility.getExpression());
      out.setCellVisibility(tCellVisibility);
    }
  } catch (DeserializationException e) {
    throw new RuntimeException(e);
  }
  return out;
}
 
Example 5
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static Durability durabilityFromThrift(TDurability tDurability) {
  switch (tDurability.getValue()) {
    case 0: return Durability.USE_DEFAULT;
    case 1: return Durability.SKIP_WAL;
    case 2: return Durability.ASYNC_WAL;
    case 3: return Durability.SYNC_WAL;
    case 4: return Durability.FSYNC_WAL;
    default: return Durability.USE_DEFAULT;
  }
}
 
Example 6
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                   final Put put, final WALEdit edit,
                   final Durability durability) throws IOException {
  if (put.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Put should preserve attributes");
  }
  if (put.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 7
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 8
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                   final Put put, final WALEdit edit,
                   final Durability durability) throws IOException {
  if (put.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Put should preserve attributes");
  }
  if (put.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 9
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 10
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 11
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                   final Put put, final WALEdit edit,
                   final Durability durability) throws IOException {
  if (put.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Put should preserve attributes");
  }
  if (put.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 12
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
    final Delete delete, final WALEdit edit, final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 13
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override

    public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c, final Put put,
        final WALEdit edit, final Durability durability) throws IOException {
      if (put.getAttribute(TEST_ATTRIBUTE) == null) {
        throw new DoNotRetryIOException("Put should preserve attributes");
      }
      if (put.getDurability() != Durability.USE_DEFAULT) {
        throw new DoNotRetryIOException("Durability is not propagated correctly");
      }
    }
 
Example 14
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 15
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                   final Put put, final WALEdit edit,
                   final Durability durability) throws IOException {
  if (put.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Put should preserve attributes");
  }
  if (put.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 16
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void preDelete(final ObserverContext<RegionCoprocessorEnvironment> c,
                      final Delete delete, final WALEdit edit,
                      final Durability durability) throws IOException {
  if (delete.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Delete should preserve attributes");
  }
  if (delete.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 17
Source File: TransactionAwareHTableTest.java    From phoenix-tephra with Apache License 2.0 5 votes vote down vote up
@Override
public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                   final Put put, final WALEdit edit,
                   final Durability durability) throws IOException {
  if (put.getAttribute(TEST_ATTRIBUTE) == null) {
    throw new DoNotRetryIOException("Put should preserve attributes");
  }
  if (put.getDurability() != Durability.USE_DEFAULT) {
    throw new DoNotRetryIOException("Durability is not propagated correctly");
  }
}
 
Example 18
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static TIncrement incrementFromHBase(Increment in) throws IOException {
  TIncrement out = new TIncrement();
  out.setRow(in.getRow());

  if (in.getDurability() != Durability.USE_DEFAULT) {
    out.setDurability(durabilityFromHBase(in.getDurability()));
  }
  for (Map.Entry<byte [], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
    byte[] family = entry.getKey();
    for (Cell cell : entry.getValue()) {
      TColumnIncrement columnValue = new TColumnIncrement();
      columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell));
      columnValue.setAmount(
          Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
      out.addToColumns(columnValue);
    }
  }
  for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
    out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())),
        ByteBuffer.wrap(attribute.getValue()));
  }
  try {
    CellVisibility cellVisibility = in.getCellVisibility();
    if (cellVisibility != null) {
      TCellVisibility tCellVisibility = new TCellVisibility();
      tCellVisibility.setExpression(cellVisibility.getExpression());
      out.setCellVisibility(tCellVisibility);
    }
  } catch (DeserializationException e) {
    throw new RuntimeException(e);
  }
  out.setReturnResults(in.isReturnResults());
  return out;
}
 
Example 19
Source File: BaseRowProcessor.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
public Durability useDurability() {
  return Durability.USE_DEFAULT;
}
 
Example 20
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<>(in.getFamilyCellMap().entrySet().size());
  long rowTimestamp = in.getTimestamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
    out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())),
        ByteBuffer.wrap(attribute.getValue()));
  }
  if (in.getDurability() != Durability.USE_DEFAULT)  {
    out.setDurability(durabilityFromHBase(in.getDurability()));
  }
  // Delete the whole row
  if (in.getFamilyCellMap().size() == 0) {
    return out;
  }
  TDeleteType type = null;
  for (Map.Entry<byte[], List<Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    byte[] family = familyEntry.getKey();
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (Cell cell: familyEntry.getValue()) {
      TDeleteType cellDeleteType = deleteTypeFromHBase(cell.getType());
      if (type == null) {
        type = cellDeleteType;
      } else if (type != cellDeleteType){
        throw new RuntimeException("Only the same delete type is supported, but two delete type "
            + "is founded, one is " + type + " the other one is " + cellDeleteType);
      }
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      column.setFamily(family);
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);
  out.setDeleteType(type);

  return out;
}