-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-6184: EC: put command should create EC key if bucket is EC #2990
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
+280
−3
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
511ed6d
HDDS-6184: EC: put command should create EC key if bucket is EC
umagangumalla 7953435
Corrected comments.
umagangumalla 3a7ea0b
Fixed the review comments.
umagangumalla 40a956e
removed an unused import
umagangumalla c5acd23
Added some tests for util APIs
umagangumalla 7ead029
Nit:Updated a javadoc in test
umagangumalla 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
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
105 changes: 105 additions & 0 deletions
105
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneConfigUtil.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,105 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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.ozone.om; | ||
|
|
||
| import org.apache.hadoop.hdds.client.DefaultReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.ECReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.RatisReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.ReplicationConfig; | ||
| import org.apache.hadoop.hdds.client.ReplicationFactor; | ||
| import org.apache.hadoop.hdds.client.ReplicationType; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * Tests the server side replication config preference logic. | ||
| */ | ||
| public class TestOzoneConfigUtil { | ||
| private ReplicationConfig ratis3ReplicationConfig = | ||
| new RatisReplicationConfig(HddsProtos.ReplicationFactor.THREE); | ||
| private HddsProtos.ReplicationType noneType = HddsProtos.ReplicationType.NONE; | ||
| private HddsProtos.ReplicationFactor zeroFactor = | ||
| HddsProtos.ReplicationFactor.ZERO; | ||
| private HddsProtos.ECReplicationConfig clientECReplicationConfig = | ||
| new ECReplicationConfig("rs-3-2-1024K").toProto(); | ||
| private DefaultReplicationConfig bucketECConfig = | ||
| new DefaultReplicationConfig( | ||
| new ECReplicationConfig(clientECReplicationConfig)); | ||
|
|
||
| /** | ||
| * Tests EC bucket defaults. | ||
| */ | ||
| @Test | ||
| public void testResolveClientSideRepConfigWhenBucketHasEC() { | ||
| ReplicationConfig replicationConfig = OzoneConfigUtil | ||
| .resolveReplicationConfigPreference(noneType, zeroFactor, | ||
| clientECReplicationConfig, bucketECConfig, ratis3ReplicationConfig); | ||
| // Client has no preference, so we should bucket defaults as we passed. | ||
| Assert.assertEquals(bucketECConfig.getEcReplicationConfig(), | ||
| replicationConfig); | ||
| } | ||
|
|
||
| /** | ||
| * Tests server defaults. | ||
| */ | ||
| @Test | ||
| public void testResolveClientSideRepConfigWithNoClientAndBucketDefaults() { | ||
| ReplicationConfig replicationConfig = OzoneConfigUtil | ||
| .resolveReplicationConfigPreference(noneType, zeroFactor, | ||
| clientECReplicationConfig, null, ratis3ReplicationConfig); | ||
| // Client has no preference, no bucket defaults, so it should return server | ||
| // defaults. | ||
| Assert.assertEquals(ratis3ReplicationConfig, replicationConfig); | ||
| } | ||
|
|
||
| /** | ||
| * Tests client preference of EC. | ||
| */ | ||
| @Test | ||
| public void testResolveClientSideRepConfigWhenClientPassEC() { | ||
| ReplicationConfig replicationConfig = OzoneConfigUtil | ||
| .resolveReplicationConfigPreference(HddsProtos.ReplicationType.EC, | ||
| zeroFactor, clientECReplicationConfig, null, | ||
| ratis3ReplicationConfig); | ||
| // Client has preference of type EC, no bucket defaults, so it should return | ||
| // client preference. | ||
| Assert.assertEquals(new ECReplicationConfig("rs-3-2-1024K"), | ||
| replicationConfig); | ||
| } | ||
|
|
||
| /** | ||
| * Tests bucket ratis defaults. | ||
| */ | ||
| @Test | ||
| public void testResolveClientSideRepConfigWhenBucketHasEC3() { | ||
| DefaultReplicationConfig ratisBucketDefaults = | ||
| new DefaultReplicationConfig(ReplicationType.RATIS, | ||
| ReplicationFactor.THREE); | ||
| ReplicationConfig replicationConfig = OzoneConfigUtil | ||
| .resolveReplicationConfigPreference(noneType, zeroFactor, | ||
| clientECReplicationConfig, ratisBucketDefaults, | ||
| ratis3ReplicationConfig); | ||
| // Client has no preference of type and bucket has ratis defaults, so it | ||
| // should return ratis. | ||
| Assert.assertEquals(ratisBucketDefaults.getType().name(), | ||
| replicationConfig.getReplicationType().name()); | ||
| Assert.assertEquals(ratisBucketDefaults.getFactor(), | ||
| ReplicationFactor.valueOf(replicationConfig.getRequiredNodes())); | ||
| } | ||
|
|
||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.