smengcl commented on code in PR #11617:
URL: https://github.com/apache/ozone/pull/11617#discussion_r4693318175
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java:
##########
@@ -153,14 +163,35 @@ public ContainerInfo getContainer(final long size,
@Nullable
private ContainerInfo getContainer(ReplicationConfig repConfig, String owner,
- ExcludeList excludeList, PipelineRequestInformation req) {
+ ExcludeList excludeList, PipelineRequestInformation req, DatanodeDetails
client) {
// Acquire pipeline manager lock, to avoid any updates to pipeline
// while allocate container happens. This is to avoid scenario like
// mentioned in HDDS-5655.
pipelineManager.acquireReadLock();
try {
List<Pipeline> availablePipelines = findPipelinesByState(repConfig,
excludeList, Pipeline.PipelineState.OPEN);
+ if (client != null) {
Review Comment:
Done in ab603aee39, an excluded client datanode no longer gets the
preference, including on the drop-exclusions fallback.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java:
##########
@@ -153,14 +163,35 @@ public ContainerInfo getContainer(final long size,
@Nullable
private ContainerInfo getContainer(ReplicationConfig repConfig, String owner,
- ExcludeList excludeList, PipelineRequestInformation req) {
+ ExcludeList excludeList, PipelineRequestInformation req, DatanodeDetails
client) {
// Acquire pipeline manager lock, to avoid any updates to pipeline
// while allocate container happens. This is to avoid scenario like
// mentioned in HDDS-5655.
pipelineManager.acquireReadLock();
try {
List<Pipeline> availablePipelines = findPipelinesByState(repConfig,
excludeList, Pipeline.PipelineState.OPEN);
+ if (client != null) {
+ // Try pipelines with a replica on the writer's datanode first, like
the HDFS first replica.
+ // Among those, prefer pipelines led by that datanode, since Ratis
writes go through the leader.
+ List<Pipeline> leaderPipelines = new ArrayList<>();
+ List<Pipeline> localPipelines = new ArrayList<>();
+ for (Pipeline pipeline : availablePipelines) {
+ if (client.getID().equals(pipeline.getLeaderId())) {
+ leaderPipelines.add(pipeline);
+ } else if (pipeline.getNodes().contains(client)) {
Review Comment:
Done in ab603aee39, it's a single pass using `getNodeSet()` with no list
copies.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRequest.java:
##########
@@ -230,12 +230,14 @@ protected List<OmKeyLocationInfo> allocateBlock(
// DNS-to-switch mapping is consulted at most once.
final Node omClient = clusterMap != null && !remoteAddress.isEmpty()
? keyManager.resolveClientForWrite(remoteAddress, clusterMap) : null;
+ // SCM needs the client address to prefer a pipeline on the client's
datanode; it then also sorts by it.
+ final String localityClientMachine =
keyManager.isPreferClientLocalPipeline() ? remoteAddress : "";
Review Comment:
Done with the new `sortDatanodes` request field. OM sets it to true only
when SCM should sort: the client asked for sorted datanodes and OM can't sort
them itself. When it's false, SCM finds the local datanode by address only and
doesn't sort or call the topology mapping. When the field is absent (an older
OM), SCM sorts whenever `client` is set, as before.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -233,6 +235,7 @@ public KeyManagerImpl(OzoneManager om, ScmClient scmClient,
this.grpcBlockTokenEnabled = conf.getBoolean(
HDDS_BLOCK_TOKEN_ENABLED,
HDDS_BLOCK_TOKEN_ENABLED_DEFAULT);
+ this.preferClientLocalPipeline =
conf.getObject(ScmConfig.class).isPreferClientLocalPipeline();
Review Comment:
Resolved by the change above: OM no longer reads the key, so only SCM has it.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMBlockProtocolServer.java:
##########
@@ -235,12 +238,14 @@ public List<AllocatedBlock> allocateBlock(
num, size, excludeList);
}
try {
+ final Node client = getClientNode(clientMachine);
+ final DatanodeDetails localDatanode = preferClientLocalPipeline &&
client instanceof DatanodeDetails
Review Comment:
Good point. I'd rather add the per-outcome counters in a follow-up so this
PR stays small, unless you think they need to land together.
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableRatisContainerProvider.java:
##########
Review Comment:
Added:
- Excluded client datanode with the drop-exclusions fallback:
`skipsPreferenceWhenClientDatanodeIsExcluded`.
- Null `leaderId`: `MockPipeline.createPipeline(...)` builds pipelines with
no leader, so `prefersPipelineOnClientDatanode` and the follower pipeline in
`prefersPipelineLedByClientDatanode` cover it.
- `SCMBlockProtocolServer` flag off, no space, several datanodes at one
address, and a non-datanode client, all without sorting:
`allocateBlockPassesClientDatanodeOnlyWhenPreferredAndHasSpace`.
- Absent `sortDatanodes` means sort: `sortDatanodesDefaultsToTrueWhenAbsent`.
- OM with `shouldSortDatanodes=false`:
`testAllocateBlockSendsClientMachineWithoutSortToScm`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]