Search in sources :

Example 6 with DatanodeStoreSchemaTwoImpl

use of org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaTwoImpl in project ozone by apache.

the class TestBlockDeletingService method createTxn.

private void createTxn(KeyValueContainerData data, List<Long> containerBlocks, int txnID, long containerID) {
    try (ReferenceCountedDB metadata = BlockUtils.getDB(data, conf)) {
        StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction dtx = StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction.newBuilder().setTxID(txnID).setContainerID(containerID).addAllLocalID(containerBlocks).setCount(0).build();
        try (BatchOperation batch = metadata.getStore().getBatchHandler().initBatchOperation()) {
            DatanodeStore ds = metadata.getStore();
            DatanodeStoreSchemaTwoImpl dnStoreTwoImpl = (DatanodeStoreSchemaTwoImpl) ds;
            dnStoreTwoImpl.getDeleteTransactionTable().putWithBatch(batch, (long) txnID, dtx);
            metadata.getStore().getBatchHandler().commitBatchOperation(batch);
        }
    } catch (IOException exception) {
        LOG.warn("Transaction creation was not successful for txnID: " + txnID + " consisting of " + containerBlocks.size() + " blocks.");
    }
}
Also used : DatanodeStore(org.apache.hadoop.ozone.container.metadata.DatanodeStore) BatchOperation(org.apache.hadoop.hdds.utils.db.BatchOperation) IOException(java.io.IOException) StorageContainerDatanodeProtocolProtos(org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos) DatanodeStoreSchemaTwoImpl(org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaTwoImpl) ReferenceCountedDB(org.apache.hadoop.ozone.container.common.utils.ReferenceCountedDB)

Aggregations

DatanodeStoreSchemaTwoImpl (org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaTwoImpl)6 DatanodeStore (org.apache.hadoop.ozone.container.metadata.DatanodeStore)5 ReferenceCountedDB (org.apache.hadoop.ozone.container.common.utils.ReferenceCountedDB)4 IOException (java.io.IOException)3 DeletedBlocksTransaction (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction)2 BatchOperation (org.apache.hadoop.hdds.utils.db.BatchOperation)2 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 StorageContainerDatanodeProtocolProtos (org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos)1 Table (org.apache.hadoop.hdds.utils.db.Table)1 BlockData (org.apache.hadoop.ozone.container.common.helpers.BlockData)1 DatanodeStoreSchemaOneImpl (org.apache.hadoop.ozone.container.metadata.DatanodeStoreSchemaOneImpl)1