Skip to content

Commit 19f75e0

Browse files
HDDS-13852. Remove dependency on HDDSLayout for OM to SCM request
1 parent 929f7bb commit 19f75e0

File tree

13 files changed

+28
-84
lines changed

13 files changed

+28
-84
lines changed

hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ScmInfo.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public final class ScmInfo {
2929
private final String clusterId;
3030
private final String scmId;
3131
private final List<String> peerRoles;
32-
private final int metadataLayoutVersion;
3332

3433
/**
3534
* Builder for ScmInfo.
@@ -38,7 +37,6 @@ public static class Builder {
3837
private String clusterId;
3938
private String scmId;
4039
private final List<String> peerRoles;
41-
private int metadataLayoutVersion;
4240

4341
public Builder() {
4442
peerRoles = new ArrayList<>();
@@ -74,21 +72,15 @@ public Builder setPeerRoles(List<String> roles) {
7472
return this;
7573
}
7674

77-
public Builder setMetaDataLayoutVersion(int version) {
78-
this.metadataLayoutVersion = version;
79-
return this;
80-
}
81-
8275
public ScmInfo build() {
83-
return new ScmInfo(clusterId, scmId, peerRoles, metadataLayoutVersion);
76+
return new ScmInfo(clusterId, scmId, peerRoles);
8477
}
8578
}
8679

87-
private ScmInfo(String clusterId, String scmId, List<String> peerRoles, int metadataLayoutVersion) {
80+
private ScmInfo(String clusterId, String scmId, List<String> peerRoles) {
8881
this.clusterId = clusterId;
8982
this.scmId = scmId;
9083
this.peerRoles = Collections.unmodifiableList(peerRoles);
91-
this.metadataLayoutVersion = metadataLayoutVersion;
9284
}
9385

9486
/**
@@ -115,8 +107,4 @@ public List<String> getPeerRoles() {
115107
return peerRoles;
116108
}
117109

118-
public int getMetaDataLayoutVersion() {
119-
return metadataLayoutVersion;
120-
}
121-
122110
}

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import org.apache.hadoop.hdds.scm.protocol.ScmBlockLocationProtocol;
6666
import org.apache.hadoop.hdds.scm.proxy.SCMBlockLocationFailoverProxyProvider;
6767
import org.apache.hadoop.hdds.tracing.TracingUtil;
68-
import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature;
6968
import org.apache.hadoop.io.retry.RetryProxy;
7069
import org.apache.hadoop.ipc.ProtobufHelper;
7170
import org.apache.hadoop.ipc.ProtocolTranslator;
@@ -249,10 +248,8 @@ public List<AllocatedBlock> allocateBlock(
249248
@Override
250249
public List<DeleteBlockGroupResult> deleteKeyBlocks(
251250
List<BlockGroup> keyBlocksInfoList) throws IOException {
252-
boolean useDataDistribution = getScmInfoSafe().getMetaDataLayoutVersion() >=
253-
HDDSLayoutFeature.DATA_DISTRIBUTION.layoutVersion();
254251
List<KeyBlocks> keyBlocksProto = keyBlocksInfoList.stream()
255-
.map(blockGroup -> blockGroup.getProto(useDataDistribution))
252+
.map(BlockGroup::getProto)
256253
.collect(Collectors.toList());
257254
List<DeleteBlockGroupResult> allResults = new ArrayList<>();
258255
List<KeyBlocks> batch = new ArrayList<>();
@@ -304,14 +301,6 @@ private List<DeleteBlockGroupResult> submitDeleteKeyBlocks(List<KeyBlocks> batch
304301
return results;
305302
}
306303

307-
private synchronized ScmInfo getScmInfoSafe() throws IOException {
308-
if (scmInfo == null || scmInfo.getMetaDataLayoutVersion() <
309-
HDDSLayoutFeature.DATA_DISTRIBUTION.layoutVersion()) {
310-
getScmInfo(); // refresh cached scmInfo
311-
}
312-
return scmInfo;
313-
}
314-
315304
/**
316305
* Gets the cluster Id and Scm Id from SCM.
317306
* @return ScmInfo
@@ -333,11 +322,8 @@ public ScmInfo getScmInfo() throws IOException {
333322
resp = wrappedResponse.getGetScmInfoResponse();
334323
ScmInfo.Builder builder = new ScmInfo.Builder()
335324
.setClusterId(resp.getClusterId())
336-
.setScmId(resp.getScmId())
337-
.setMetaDataLayoutVersion(resp.hasMetaDataLayoutVersion() ?
338-
resp.getMetaDataLayoutVersion() : HDDSLayoutFeature.INITIAL_VERSION.layoutVersion());
339-
scmInfo = builder.build();
340-
return scmInfo;
325+
.setScmId(resp.getScmId());
326+
return builder.build();
341327
}
342328

343329
/**

hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@
137137
import org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocol;
138138
import org.apache.hadoop.hdds.scm.proxy.SCMContainerLocationFailoverProxyProvider;
139139
import org.apache.hadoop.hdds.tracing.TracingUtil;
140-
import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature;
141140
import org.apache.hadoop.io.retry.RetryProxy;
142141
import org.apache.hadoop.ipc.ProtobufHelper;
143142
import org.apache.hadoop.ipc.ProtocolTranslator;
@@ -780,9 +779,7 @@ public ScmInfo getScmInfo() throws IOException {
780779
ScmInfo.Builder builder = new ScmInfo.Builder()
781780
.setClusterId(resp.getClusterId())
782781
.setScmId(resp.getScmId())
783-
.setPeerRoles(resp.getPeerRolesList())
784-
.setMetaDataLayoutVersion(resp.hasMetaDataLayoutVersion() ?
785-
resp.getMetaDataLayoutVersion() : HDDSLayoutFeature.INITIAL_VERSION.layoutVersion());
782+
.setPeerRoles(resp.getPeerRolesList());
786783
return builder.build();
787784
}
788785

hadoop-hdds/framework/src/main/java/org/apache/hadoop/ozone/common/BlockGroup.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ public String getGroupID() {
4747
}
4848

4949
public KeyBlocks getProto() {
50-
return getProtoForDeletedBlock();
51-
}
52-
53-
public KeyBlocks getProto(boolean isIncludeBlockSize) {
54-
return isIncludeBlockSize ? getProtoForDeletedBlock() : getProtoForBlockID();
55-
}
56-
57-
private KeyBlocks getProtoForDeletedBlock() {
5850
KeyBlocks.Builder kbb = KeyBlocks.newBuilder();
5951
for (DeletedBlock block : deletedBlocks) {
6052
ScmBlockLocationProtocolProtos.DeletedBlock deletedBlock = ScmBlockLocationProtocolProtos.DeletedBlock
@@ -68,14 +60,6 @@ private KeyBlocks getProtoForDeletedBlock() {
6860
return kbb.setKey(groupID).build();
6961
}
7062

71-
private KeyBlocks getProtoForBlockID() {
72-
KeyBlocks.Builder kbb = KeyBlocks.newBuilder();
73-
for (DeletedBlock block : deletedBlocks) {
74-
kbb.addBlocks(block.getBlockID().getProtobuf());
75-
}
76-
return kbb.setKey(groupID).build();
77-
}
78-
7963
/**
8064
* Parses a KeyBlocks proto to a group of blocks.
8165
* @param proto KeyBlocks proto.

hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/scm/protocolPB/TestScmBlockLocationProtocolClientSideTranslatorPB.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public void testGetScmInfo() throws IOException, ServiceException {
8181
// Verify
8282
assertEquals("test-cluster-id", result.getClusterId());
8383
assertEquals("test-scm-id", result.getScmId());
84-
assertEquals(1, result.getMetaDataLayoutVersion());
8584
verify(mockRpcProxy).send(any(), any(SCMBlockLocationRequest.class));
8685
}
8786

@@ -108,7 +107,6 @@ public void testGetScmInfoWithoutMetaDataLayoutVersion() throws IOException, Ser
108107
// Verify
109108
assertEquals("test-cluster-id", result.getClusterId());
110109
assertEquals("test-scm-id", result.getScmId());
111-
assertEquals(0, result.getMetaDataLayoutVersion());
112110
verify(mockRpcProxy).send(any(), any(SCMBlockLocationRequest.class));
113111
}
114112

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/ScmBlockLocationProtocolServerSideTranslatorPB.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,11 @@ private SCMBlockLocationResponse processMessage(
145145
request.getAllocateScmBlockRequest(), request.getVersion()));
146146
break;
147147
case DeleteScmKeyBlocks:
148-
if (scm.getLayoutVersionManager().needsFinalization() &&
149-
!scm.getLayoutVersionManager()
150-
.isAllowed(HDDSLayoutFeature.DATA_DISTRIBUTION)
151-
) {
152-
boolean isRequestHasNewData = request.getDeleteScmKeyBlocksRequest().getKeyBlocksList().stream()
153-
.anyMatch(keyBlocks -> keyBlocks.getDeletedBlocksCount() > 0);
154-
155-
if (isRequestHasNewData) {
156-
throw new SCMException("Cluster is not finalized yet, it is"
157-
+ " not enabled to to handle data distribution feature",
158-
SCMException.ResultCodes.INTERNAL_ERROR);
159-
}
148+
boolean isRequestHasNewData = request.getDeleteScmKeyBlocksRequest().getKeyBlocksList().stream()
149+
.anyMatch(keyBlocks -> keyBlocks.getDeletedBlocksCount() > 0);
150+
if (!isRequestHasNewData) {
151+
throw new SCMException("Received request without DeletedBlocks",
152+
SCMException.ResultCodes.INTERNAL_ERROR);
160153
}
161154
response.setDeleteScmKeyBlocksResponse(
162155
deleteScmKeyBlocks(request.getDeleteScmKeyBlocksRequest()));
@@ -264,7 +257,6 @@ public HddsProtos.GetScmInfoResponseProto getScmInfo(
264257
return HddsProtos.GetScmInfoResponseProto.newBuilder()
265258
.setClusterId(scmInfo.getClusterId())
266259
.setScmId(scmInfo.getScmId())
267-
.setMetaDataLayoutVersion(scmInfo.getMetaDataLayoutVersion())
268260
.build();
269261
}
270262

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ public HddsProtos.GetScmInfoResponseProto getScmInfo(
10221022
.setClusterId(scmInfo.getClusterId())
10231023
.setScmId(scmInfo.getScmId())
10241024
.addAllPeerRoles(scmInfo.getPeerRoles())
1025-
.setMetaDataLayoutVersion(scmInfo.getMetaDataLayoutVersion())
10261025
.build();
10271026
}
10281027

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMBlockProtocolServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ public ScmInfo getScmInfo() throws IOException {
336336
ScmInfo.Builder builder =
337337
new ScmInfo.Builder()
338338
.setClusterId(scm.getScmStorageConfig().getClusterID())
339-
.setScmId(scm.getScmStorageConfig().getScmId())
340-
.setMetaDataLayoutVersion(scm.getLayoutVersionManager().getMetadataLayoutVersion());
339+
.setScmId(scm.getScmStorageConfig().getScmId());
341340
return builder.build();
342341
} catch (Exception ex) {
343342
auditSuccess = false;

hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ public ScmInfo getScmInfo() {
909909
new ScmInfo.Builder()
910910
.setClusterId(scm.getScmStorageConfig().getClusterID())
911911
.setScmId(scm.getScmStorageConfig().getScmId())
912-
.setPeerRoles(scm.getScmHAManager().getRatisServer().getRatisRoles())
913-
.setMetaDataLayoutVersion(scm.getLayoutVersionManager().getMetadataLayoutVersion());
912+
.setPeerRoles(scm.getScmHAManager().getRatisServer().getRatisRoles());
914913
ScmInfo info = builder.build();
915914
AUDIT.logReadSuccess(buildAuditMessageForSuccess(
916915
SCMAction.GET_SCM_INFO, null));

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,6 @@ public void testScmInfo(@TempDir Path tempDir) throws Exception {
623623
ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
624624
assertEquals(clusterId, scmInfo.getClusterId());
625625
assertEquals(scmId, scmInfo.getScmId());
626-
assertTrue(scmInfo.getMetaDataLayoutVersion() >= 0);
627626

628627
String expectedVersion = HddsVersionInfo.HDDS_VERSION_INFO.getVersion();
629628
String actualVersion = scm.getSoftwareVersion();

0 commit comments

Comments
 (0)