Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class TopNOrderedContainerDeletionChoosingPolicy
private static final Comparator<KeyValueContainerData>
KEY_VALUE_CONTAINER_DATA_COMPARATOR = (KeyValueContainerData c1,
KeyValueContainerData c2) ->
Integer.compare(c2.getNumPendingDeletionBlocks(),
Long.compare(c2.getNumPendingDeletionBlocks(),
c1.getNumPendingDeletionBlocks());

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import static java.lang.Math.max;
import static org.apache.hadoop.ozone.OzoneConsts.DB_BLOCK_COUNT_KEY;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class KeyValueContainerData extends ContainerData {
/**
* Number of pending deletion blocks in KeyValueContainer.
*/
private final AtomicInteger numPendingDeletionBlocks;
private final AtomicLong numPendingDeletionBlocks;

private long deleteTransactionId;

Expand All @@ -97,15 +97,15 @@ public KeyValueContainerData(long id, ChunkLayOutVersion layOutVersion,
long size, String originPipelineId, String originNodeId) {
super(ContainerProtos.ContainerType.KeyValueContainer, id, layOutVersion,
size, originPipelineId, originNodeId);
this.numPendingDeletionBlocks = new AtomicInteger(0);
this.numPendingDeletionBlocks = new AtomicLong(0);
this.deleteTransactionId = 0;
}

public KeyValueContainerData(ContainerData source) {
super(source);
Preconditions.checkArgument(source.getContainerType()
== ContainerProtos.ContainerType.KeyValueContainer);
this.numPendingDeletionBlocks = new AtomicInteger(0);
this.numPendingDeletionBlocks = new AtomicLong(0);
this.deleteTransactionId = 0;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ public void setContainerDBType(String containerDBType) {
*
* @param numBlocks increment number
*/
public void incrPendingDeletionBlocks(int numBlocks) {
public void incrPendingDeletionBlocks(long numBlocks) {
this.numPendingDeletionBlocks.addAndGet(numBlocks);
}

Expand All @@ -196,14 +196,14 @@ public void incrPendingDeletionBlocks(int numBlocks) {
*
* @param numBlocks decrement number
*/
public void decrPendingDeletionBlocks(int numBlocks) {
public void decrPendingDeletionBlocks(long numBlocks) {
this.numPendingDeletionBlocks.addAndGet(-1 * numBlocks);
}

/**
* Get the number of pending deletion blocks.
*/
public int getNumPendingDeletionBlocks() {
public long getNumPendingDeletionBlocks() {
return this.numPendingDeletionBlocks.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.nio.file.Paths;
import java.util.List;

import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
Expand Down Expand Up @@ -171,7 +170,7 @@ public static void parseKVContainerData(KeyValueContainerData kvContainerData,
containerDB.getStore().get(DB_PENDING_DELETE_BLOCK_COUNT_KEY);
if (pendingDeleteBlockCount != null) {
kvContainerData.incrPendingDeletionBlocks(
Ints.fromByteArray(pendingDeleteBlockCount));
Longs.fromByteArray(pendingDeleteBlockCount));
} else {
// Set pending deleted block count.
MetadataKeyFilters.KeyPrefixFilter filter =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.concurrent.TimeoutException;

import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.hdds.client.BlockID;
Expand Down Expand Up @@ -179,7 +178,7 @@ private void createToDeleteBlocks(ContainerSet containerSet,
metadata.getStore().put(OzoneConsts.DB_CONTAINER_BYTES_USED_KEY,
Longs.toByteArray(blockLength * numOfBlocksPerContainer));
metadata.getStore().put(DB_PENDING_DELETE_BLOCK_COUNT_KEY,
Ints.toByteArray(numOfBlocksPerContainer));
Longs.toByteArray(numOfBlocksPerContainer));
}
}
}
Expand Down Expand Up @@ -250,6 +249,8 @@ public void testBlockDeletion() throws Exception {

// Ensure there are 3 blocks under deletion and 0 deleted blocks
Assert.assertEquals(3, getUnderDeletionBlocksCount(meta));
Assert.assertEquals(3, Longs.fromByteArray(
meta.getStore().get(DB_PENDING_DELETE_BLOCK_COUNT_KEY)));
Assert.assertEquals(0, getDeletedBlocksCount(meta));

// An interval will delete 1 * 2 blocks
Expand All @@ -268,7 +269,7 @@ public void testBlockDeletion() throws Exception {

// Check finally DB counters.
// Not checking bytes used, as handler is a mock call.
Assert.assertEquals(0, Ints.fromByteArray(
Assert.assertEquals(0, Longs.fromByteArray(
meta.getStore().get(DB_PENDING_DELETE_BLOCK_COUNT_KEY)));
Assert.assertEquals(0, Longs.fromByteArray(
meta.getStore().get(DB_BLOCK_COUNT_KEY)));
Expand Down