Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -724,6 +724,11 @@ public static boolean shouldNotFailoverOnRpcException(Throwable exception) {
return exception instanceof InvalidProtocolBufferException;
}

public static long requiredReplicationSpace(long defaultContainerSize) {
// During container import it requires double the container size to hold container in tmp and dest directory
return 2 * defaultContainerSize;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code in hdds-common is shared between client and server. requiredReplicationSpace is only for servers. Please move it to HddsServerUtil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to HddsServerUtil.

/**
* Remove binary data from request {@code msg}. (May be incomplete, feel
* free to add any missing cleanups.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.StorageUnit;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
Expand Down Expand Up @@ -149,7 +150,7 @@ HddsVolume chooseNextVolume() throws IOException {
// Choose volume that can hold both container in tmp and dest directory
return volumeChoosingPolicy.chooseVolume(
StorageVolumeUtil.getHddsVolumesList(volumeSet.getVolumesList()),
containerSize * 2);
HddsUtils.requiredReplicationSpace(containerSize));
}

public static Path getUntarDirectory(HddsVolume hddsVolume)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto;
Expand Down Expand Up @@ -78,7 +79,7 @@ public static List<DatanodeDetails> getTargetDatanodes(PlacementPolicy policy,
// Ensure that target datanodes have enough space to hold a complete
// container.
final long dataSizeRequired =
Math.max(container.getUsedBytes(), defaultContainerSize);
Math.max(container.getUsedBytes(), HddsUtils.requiredReplicationSpace(defaultContainerSize));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't 2x apply to the result of (the original) max?

Example: if the container is 5GB and default size is 1GB, then we need 10GB on the datanode, not 5GB.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense, updated with (the original) max.


int mutableRequiredNodes = requiredNodes;
while (mutableRequiredNodes > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState.IN_SERVICE;
import static org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto.State.CLOSED;
import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
Expand All @@ -34,15 +35,18 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.HddsUtils;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.StorageUnit;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto;
import org.apache.hadoop.hdds.scm.ContainerPlacementStatus;
import org.apache.hadoop.hdds.scm.PlacementPolicy;
import org.apache.hadoop.hdds.scm.SCMCommonPlacementPolicy;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
import org.apache.hadoop.hdds.scm.container.ContainerReplica;
Expand Down Expand Up @@ -328,6 +332,9 @@ protected List<DatanodeDetails> chooseDatanodesInternal(
List<DatanodeDetails> favoredNodes, int nodesRequiredToChoose,
long metadataSizeRequired, long dataSizeRequired)
throws SCMException {
long containerSize = (long) conf.getStorageSize(ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE,
ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES);
assertEquals(HddsUtils.requiredReplicationSpace(containerSize), dataSizeRequired);
if (nodesRequiredToChoose > 1) {
throw new IllegalArgumentException("Only one node is allowed");
}
Expand Down Expand Up @@ -356,6 +363,9 @@ protected List<DatanodeDetails> chooseDatanodesInternal(
List<DatanodeDetails> favoredNodes, int nodesRequiredToChoose,
long metadataSizeRequired, long dataSizeRequired)
throws SCMException {
long containerSize = (long) conf.getStorageSize(ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE,
ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES);
assertEquals(HddsUtils.requiredReplicationSpace(containerSize), dataSizeRequired);
throw new SCMException("No nodes available",
FAILED_TO_FIND_SUITABLE_NODE);
}
Expand Down Expand Up @@ -383,6 +393,9 @@ protected List<DatanodeDetails> chooseDatanodesInternal(
List<DatanodeDetails> favoredNodes, int nodesRequiredToChoose,
long metadataSizeRequired, long dataSizeRequired)
throws SCMException {
long containerSize = (long) conf.getStorageSize(ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE,
ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES);
assertEquals(HddsUtils.requiredReplicationSpace(containerSize), dataSizeRequired);
if (nodesRequiredToChoose >= throwWhenThisOrMoreNodesRequested) {
throw new SCMException("No nodes available",
FAILED_TO_FIND_SUITABLE_NODE);
Expand Down