HDDS-237. Add updateDeleteTransactionId. Contributed by Bharat Viswanadham and Lokesh Jain
This commit is contained in:
parent
e899c4cc01
commit
cb9574a337
|
@ -32,6 +32,8 @@ import java.util.TreeMap;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static java.lang.Math.max;
|
||||
|
||||
/**
|
||||
* ContainerData is the in-memory representation of container metadata and is
|
||||
* represented on disk by the .container file.
|
||||
|
@ -70,6 +72,8 @@ public class ContainerData {
|
|||
|
||||
private HddsVolume volume;
|
||||
|
||||
private long deleteTransactionId;
|
||||
|
||||
/**
|
||||
* Number of pending deletion blocks in container.
|
||||
*/
|
||||
|
@ -110,6 +114,7 @@ public class ContainerData {
|
|||
this.keyCount = new AtomicLong(0L);
|
||||
this.maxSizeGB = size;
|
||||
this.numPendingDeletionBlocks = new AtomicInteger(0);
|
||||
this.deleteTransactionId = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -441,4 +446,20 @@ public class ContainerData {
|
|||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets deleteTransactionId to latest delete transactionId for the container.
|
||||
*
|
||||
* @param transactionId latest transactionId of the container.
|
||||
*/
|
||||
public void updateDeleteTransactionId(long transactionId) {
|
||||
deleteTransactionId = max(transactionId, deleteTransactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the latest deleteTransactionId of the container.
|
||||
*/
|
||||
public long getDeleteTransactionId() {
|
||||
return deleteTransactionId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,4 +91,10 @@ public interface Container extends RwLock {
|
|||
*/
|
||||
ContainerProtos.ContainerType getContainerType();
|
||||
|
||||
/**
|
||||
* updates the DeleteTransactionId.
|
||||
* @param deleteTransactionId
|
||||
*/
|
||||
void updateDeleteTransactionId(long deleteTransactionId);
|
||||
|
||||
}
|
||||
|
|
|
@ -415,6 +415,11 @@ public class KeyValueContainer implements Container {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeleteTransactionId(long deleteTransactionId) {
|
||||
containerData.updateDeleteTransactionId(deleteTransactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquire read lock.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue