-
Notifications
You must be signed in to change notification settings - Fork 615
HDDS-6177. Extend container info command to include replica details #2995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sodonnel
merged 6 commits into
apache:master
from
sodonnel:HDDS-6177-container-info-replicas
Jan 26, 2022
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9fdf00a
HDDS-6177. Extend container info command to include replica details
c99495f
Added CLI test to validate the new output is included
fc8cdf8
Fix findbugs and rat check
cfe2beb
Revert changes to OzoneAdmin.java
93d2198
Update hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/scm/co…
sodonnel 63b3e75
Address review comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerReplicaInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hdds.scm.container; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * Class which stores ContainerReplica details on the client. | ||
| */ | ||
| public final class ContainerReplicaInfo { | ||
|
|
||
| private long containerID; | ||
| private String state; | ||
| private DatanodeDetails datanodeDetails; | ||
| private UUID placeOfBirth; | ||
| private long sequenceId; | ||
| private long keyCount; | ||
| private long bytesUsed; | ||
|
|
||
| public static ContainerReplicaInfo fromProto( | ||
| HddsProtos.SCMContainerReplicaProto proto) { | ||
| ContainerReplicaInfo.Builder builder = new ContainerReplicaInfo.Builder(); | ||
| builder.setContainerID(proto.getContainerID()) | ||
| .setState(proto.getState()) | ||
| .setDatanodeDetails(DatanodeDetails | ||
| .getFromProtoBuf(proto.getDatanodeDetails())) | ||
| .setPlaceOfBirth(UUID.fromString(proto.getPlaceOfBirth())) | ||
| .setSequenceId(proto.getSequenceID()) | ||
| .setKeyCount(proto.getKeyCount()) | ||
| .setBytesUsed(proto.getBytesUsed()); | ||
| return builder.build(); | ||
| } | ||
|
|
||
| private ContainerReplicaInfo() { | ||
| } | ||
|
|
||
| public long getContainerID() { | ||
| return containerID; | ||
| } | ||
|
|
||
| public String getState() { | ||
| return state; | ||
| } | ||
|
|
||
| public DatanodeDetails getDatanodeDetails() { | ||
| return datanodeDetails; | ||
| } | ||
|
|
||
| public UUID getPlaceOfBirth() { | ||
| return placeOfBirth; | ||
| } | ||
|
|
||
| public long getSequenceId() { | ||
| return sequenceId; | ||
| } | ||
|
|
||
| public long getKeyCount() { | ||
| return keyCount; | ||
| } | ||
|
|
||
| public long getBytesUsed() { | ||
| return bytesUsed; | ||
| } | ||
|
|
||
| /** | ||
| * Builder for ContainerReplicaInfo class. | ||
| */ | ||
| public static class Builder { | ||
|
|
||
| private final ContainerReplicaInfo subject = new ContainerReplicaInfo(); | ||
|
|
||
| public Builder setContainerID(long containerID) { | ||
| subject.containerID = containerID; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setState(String state) { | ||
| subject.state = state; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setDatanodeDetails(DatanodeDetails datanodeDetails) { | ||
| subject.datanodeDetails = datanodeDetails; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setPlaceOfBirth(UUID placeOfBirth) { | ||
| subject.placeOfBirth = placeOfBirth; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setSequenceId(long sequenceId) { | ||
| subject.sequenceId = sequenceId; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setKeyCount(long keyCount) { | ||
| subject.keyCount = keyCount; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setBytesUsed(long bytesUsed) { | ||
| subject.bytesUsed = bytesUsed; | ||
| return this; | ||
| } | ||
|
|
||
| public ContainerReplicaInfo build() { | ||
| return subject; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...s/common/src/test/java/org/apache/hadoop/hdds/scm/container/ContainerReplicaInfoTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hdds.scm.container; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.MockDatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * Test for the ContainerReplicaInfo class. | ||
| */ | ||
| public class ContainerReplicaInfoTest { | ||
|
|
||
| @Test | ||
| public void testObjectCreatedFromProto() { | ||
| HddsProtos.SCMContainerReplicaProto proto = | ||
| HddsProtos.SCMContainerReplicaProto.newBuilder() | ||
| .setKeyCount(10) | ||
| .setBytesUsed(12345) | ||
| .setContainerID(567) | ||
| .setPlaceOfBirth(UUID.randomUUID().toString()) | ||
| .setSequenceID(5) | ||
| .setDatanodeDetails(MockDatanodeDetails.randomDatanodeDetails() | ||
| .getProtoBufMessage()) | ||
| .setState("OPEN") | ||
| .build(); | ||
|
|
||
| ContainerReplicaInfo info = ContainerReplicaInfo.fromProto(proto); | ||
|
|
||
| Assert.assertEquals(proto.getContainerID(), info.getContainerID()); | ||
| Assert.assertEquals(proto.getBytesUsed(), info.getBytesUsed()); | ||
| Assert.assertEquals(proto.getKeyCount(), info.getKeyCount()); | ||
| Assert.assertEquals(proto.getPlaceOfBirth(), | ||
| info.getPlaceOfBirth().toString()); | ||
| Assert.assertEquals(DatanodeDetails.getFromProtoBuf( | ||
| proto.getDatanodeDetails()), info.getDatanodeDetails()); | ||
| Assert.assertEquals(proto.getSequenceID(), info.getSequenceId()); | ||
| Assert.assertEquals(proto.getState(), info.getState()); | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/scm/container/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.hadoop.hdds.scm.container; | ||
| /** | ||
| Test cases for SCM container client classes. | ||
| */ | ||
|
sodonnel marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be renamed to
TestContainerReplicaInfoto be executed. (For some reason that's the naming convention for Ozone.)ozone/pom.xml
Line 1937 in 2af225d