Skip to content

Commit 552ee44

Browse files
authored
HDFS-16834: Removes request stateID consistency constraint between clients in different connection pools. (#5121)
Reviewed-by: Tao Li <tomscut@apache.org> Signed-off-by: Zander Xu <zanderxu@apache.org>
1 parent b398a7b commit 552ee44

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/PoolAlignmentContext.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public void receiveResponseState(RpcHeaderProtos.RpcResponseHeaderProto header)
7171
*/
7272
@Override
7373
public void updateRequestState(RpcHeaderProtos.RpcRequestHeaderProto.Builder header) {
74-
long maxStateId = Long.max(poolLocalStateId.get(), sharedGlobalStateId.get());
75-
header.setStateId(maxStateId);
74+
header.setStateId(poolLocalStateId.get());
7675
}
7776

7877
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.server.federation.router;
19+
20+
import org.apache.hadoop.conf.Configuration;
21+
import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto;
22+
import org.junit.jupiter.api.Assertions;
23+
import org.junit.jupiter.api.Test;
24+
25+
26+
public class TestPoolAlignmentContext {
27+
@Test
28+
public void testNamenodeRequestsOnlyUsePoolLocalStateID() {
29+
RouterStateIdContext routerStateIdContext = new RouterStateIdContext(new Configuration());
30+
String namespaceId = "namespace1";
31+
routerStateIdContext.getNamespaceStateId(namespaceId).accumulate(20L);
32+
PoolAlignmentContext poolContext1 = new PoolAlignmentContext(routerStateIdContext, namespaceId);
33+
PoolAlignmentContext poolContext2 = new PoolAlignmentContext(routerStateIdContext, namespaceId);
34+
35+
assertRequestHeaderStateId(poolContext1, Long.MIN_VALUE);
36+
assertRequestHeaderStateId(poolContext2, Long.MIN_VALUE);
37+
Assertions.assertEquals(20L, poolContext1.getLastSeenStateId());
38+
Assertions.assertEquals(20L, poolContext2.getLastSeenStateId());
39+
40+
poolContext1.advanceClientStateId(30L);
41+
assertRequestHeaderStateId(poolContext1, 30L);
42+
assertRequestHeaderStateId(poolContext2, Long.MIN_VALUE);
43+
Assertions.assertEquals(20L, poolContext1.getLastSeenStateId());
44+
Assertions.assertEquals(20L, poolContext2.getLastSeenStateId());
45+
}
46+
47+
private void assertRequestHeaderStateId(PoolAlignmentContext poolAlignmentContext,
48+
Long expectedValue) {
49+
RpcRequestHeaderProto.Builder builder = RpcRequestHeaderProto.newBuilder();
50+
poolAlignmentContext.updateRequestState(builder);
51+
Assertions.assertEquals(expectedValue, builder.getStateId());
52+
}
53+
}

0 commit comments

Comments
 (0)