Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.hdds.client.ReplicationConfigValidator;
Expand Down Expand Up @@ -1554,23 +1555,26 @@ public OzoneInputStream getKey(
OmKeyInfo keyInfo = getKeyInfo(volumeName, bucketName, keyName, true);
List<OmKeyLocationInfo> keyLocationInfos
= keyInfo.getLatestVersionLocations().getBlocksLatestVersionOnly();

ReplicationConfig replicationConfig = keyInfo.getReplicationConfig();
for (OmKeyLocationInfo locationInfo : keyLocationInfos) {
Map<DatanodeDetails, OzoneInputStream> blocks = new HashMap<>();


Pipeline pipelineBefore = locationInfo.getPipeline();
List<DatanodeDetails> datanodes = pipelineBefore.getNodes();

for (DatanodeDetails dn : datanodes) {
List<DatanodeDetails> nodes = new ArrayList<>();
nodes.add(dn);
Pipeline pipeline
= new Pipeline.Builder(pipelineBefore).setNodes(nodes)
.setId(PipelineID.randomId()).build();
long length = replicationConfig instanceof ECReplicationConfig
? internalBlockLength(pipelineBefore.getReplicaIndex(dn),
(ECReplicationConfig) replicationConfig, locationInfo.getLength())
: locationInfo.getLength();
OmKeyLocationInfo dnKeyLocation = new OmKeyLocationInfo.Builder()
.setBlockID(locationInfo.getBlockID())
.setLength(locationInfo.getLength())
.setLength(length)
.setOffset(locationInfo.getOffset())
.setToken(locationInfo.getToken())
.setPartNumber(locationInfo.getPartNumber())
Expand All @@ -1594,7 +1598,9 @@ public OzoneInputStream getKey(
.setDataSize(keyInfo.getDataSize())
.setCreationTime(keyInfo.getCreationTime())
.setModificationTime(keyInfo.getModificationTime())
.setReplicationConfig(keyInfo.getReplicationConfig())
.setReplicationConfig(replicationConfig instanceof ECReplicationConfig
? RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.ONE)
: keyInfo.getReplicationConfig())
.setFileEncryptionInfo(keyInfo.getFileEncryptionInfo())
.setAcls(keyInfo.getAcls())
.setObjectID(keyInfo.getObjectID())
Expand All @@ -1603,9 +1609,9 @@ public OzoneInputStream getKey(
.setFileChecksum(keyInfo.getFileChecksum())
.setOwnerName(keyInfo.getOwnerName())
.build();

dnKeyInfo.setMetadata(keyInfo.getMetadata());
dnKeyInfo.setKeyLocationVersions(keyLocationInfoGroups);

blocks.put(dn, createInputStream(dnKeyInfo, Function.identity()));
}

Expand All @@ -1615,6 +1621,30 @@ public OzoneInputStream getKey(
return result;
}

// Helper method to calculate the internal block length of an EC-replicated key.
private long internalBlockLength(int index, ECReplicationConfig ecRepConfig, long blockLength) {
long ecChunkSize = (long) ecRepConfig.getEcChunkSize();
long stripeSize = ecChunkSize * ecRepConfig.getData();
long lastStripe = blockLength % stripeSize;
long blockSize = (blockLength - lastStripe) / ecRepConfig.getData();
long lastCell = lastStripe / ecChunkSize + 1;
long lastCellLength = lastStripe % ecChunkSize;
if (index > ecRepConfig.getData()) {
// Parity blocks and their size are driven by the size of the
// first block of the block group. All parity blocks have the same size
// as block_1.
index = 1;
}

if (index < lastCell) {
return blockSize + ecChunkSize;
} else if (index == lastCell) {
return blockSize + lastCellLength;
} else {
return blockSize;
}
}

@Override
public void deleteKey(
String volumeName, String bucketName, String keyName, boolean recursive)
Expand Down
3 changes: 3 additions & 0 deletions hadoop-ozone/dist/src/main/compose/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ execute_debug_tests() {
docker start "${container}"

wait_for_datanode "${container}" HEALTHY 60
start_docker_env 9
execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-tests-ec3-2.robot
execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-tests-ec6-3.robot
}

## @description Wait for datanode state
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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.

*** Settings ***
Documentation Test ozone Debug CLI for EC(3,2) replicated keys
Library OperatingSystem
Library Process
Resource ../lib/os.robot
Resource ozone-debug.robot
Test Timeout 5 minute
Suite Setup Create Volume Bucket

*** Variables ***
${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${TESTFILE} testfile
${EC_DATA} 3
${EC_PARITY} 2

*** Keywords ***
Create Volume Bucket
Execute ozone sh volume create o3://om/${VOLUME}
Execute ozone sh bucket create o3://om/${VOLUME}/${BUCKET}

Create EC key
[arguments] ${bs} ${count}

Execute dd if=/dev/urandom of=${TEMP_DIR}/testfile bs=${bs} count=${count}
Execute ozone sh key put o3://om/${VOLUME}/${BUCKET}/testfile ${TEMP_DIR}/testfile -r rs-${EC_DATA}-${EC_PARITY}-1024k -t EC

*** Test Cases ***
0 data block
Create EC key 1000 0
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 1

1 data block
Create EC key 1048576 1
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 6
${sum_size} = Evaluate 1048576 * 3
Verify Healthy EC Replica ${directory} 1 ${sum_size}

2 data blocks
Create EC key 1048576 2
${directory} = Execute read-replicas CLI tool
${sum_size} = Evaluate 1048576 * 4
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 6
Verify Healthy EC Replica ${directory} 1 ${sum_size}

3 data blocks
Create EC key 1048576 3
${directory} = Execute read-replicas CLI tool
${sum_size} = Evaluate 1048576 * 5
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 6
Verify Healthy EC Replica ${directory} 1 ${sum_size}

3 data blocks and partial stripe
Create EC key 1000000 4
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 5
${sum_size_last_stripe} = Evaluate ((1000000 * 4) % 1048576) * 3
Should Be Equal As Integers ${count_files} 11
Verify Healthy EC Replica ${directory} 1 ${sum_size}
Verify Healthy EC Replica ${directory} 2 ${sum_size_last_stripe}

4 data blocks and partial stripe
Create EC key 1000000 5
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 5
${sum_size_last_stripe} = Evaluate 1048576 * 3 + ((1000000 * 5) % 1048576)
Should Be Equal As Integers ${count_files} 11
Verify Healthy EC Replica ${directory} 1 ${sum_size}
Verify Healthy EC Replica ${directory} 2 ${sum_size_last_stripe}

6 data blocks
Create EC key 1048576 6
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 5
Should Be Equal As Integers ${count_files} 11
FOR ${block} IN RANGE 1 3
Verify Healthy EC Replica ${directory} ${block} ${sum_size}
END
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# 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.

*** Settings ***
Documentation Test ozone Debug CLI for EC(6,3) replicated key
Library OperatingSystem
Library Process
Resource ../lib/os.robot
Resource ozone-debug.robot
Test Timeout 5 minute

*** Variables ***
${PREFIX} ${EMPTY}
${VOLUME} cli-debug-volume${PREFIX}
${BUCKET} cli-debug-bucket
${TESTFILE} testfile
${EC_DATA} 6
${EC_PARITY} 3

*** Keywords ***
Create EC key
[arguments] ${bs} ${count}

Execute dd if=/dev/urandom of=${TEMP_DIR}/testfile bs=${bs} count=${count}
Execute ozone sh key put o3://om/${VOLUME}/${BUCKET}/testfile ${TEMP_DIR}/testfile -r rs-${EC_DATA}-${EC_PARITY}-1024k -t EC

*** Test Cases ***
0 data block
Create EC key 1048576 0
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 1

1 data block
Create EC key 1048576 1
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 10
${sum_size} = Evaluate 1048576 * 4
Verify Healthy EC Replica ${directory} 1 ${sum_size}

2 data blocks
Create EC key 1048576 2
${directory} = Execute read-replicas CLI tool
${sum_size} = Evaluate 1048576 * 5
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 10
Verify Healthy EC Replica ${directory} 1 ${sum_size}

3 data blocks
Create EC key 1048576 3
${directory} = Execute read-replicas CLI tool
${sum_size} = Evaluate 1048576 * 6
${count_files} = Count Files In Directory ${directory}
Should Be Equal As Integers ${count_files} 10
Verify Healthy EC Replica ${directory} 1 ${sum_size}

4 data blocks
Create EC key 1048576 4
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 7
Should Be Equal As Integers ${count_files} 10
Verify Healthy EC Replica ${directory} 1 ${sum_size}

5 data blocks
Create EC key 1048576 5
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 8
Should Be Equal As Integers ${count_files} 10
Verify Healthy EC Replica ${directory} 1 ${sum_size}

6 data blocks
Create EC key 1048576 6
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 9
Should Be Equal As Integers ${count_files} 10
Verify Healthy EC Replica ${directory} 1 ${sum_size}

6 data blocks and partial stripe
Create EC key 1000000 7
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 9
${sum_size_last_stripe} = Evaluate ((1000000 * 7) % 1048576) * 4
Should Be Equal As Integers ${count_files} 19
Verify Healthy EC Replica ${directory} 1 ${sum_size}
Verify Healthy EC Replica ${directory} 2 ${sum_size_last_stripe}

7 data blocks and partial stripe
Create EC key 1000000 8
${directory} = Execute read-replicas CLI tool
${count_files} = Count Files In Directory ${directory}
${sum_size} = Evaluate 1048576 * 9
${sum_size_last_stripe} = Evaluate 1048576 * 4 + ((1000000 * 8) % 1048576)
Should Be Equal As Integers ${count_files} 19
Verify Healthy EC Replica ${directory} 1 ${sum_size}
Verify Healthy EC Replica ${directory} 2 ${sum_size_last_stripe}
8 changes: 7 additions & 1 deletion hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug.robot
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Get Replica Filenames
END

${filenames} = Catenate @{list}

[return] ${filenames}

Verify Healthy Replica
Expand All @@ -75,6 +75,12 @@ Verify Healthy Replica
${md5sum} = Execute cat ${block_filenames} | md5sum | awk '{print $1}'
Should Be Equal ${md5sum} ${expected_md5sum}

Verify Healthy EC Replica
[arguments] ${directory} ${block} ${expected_block_size}

${block_size} = Execute ls -l ${directory} | grep "testfile_block${block}_ozone-datanode-.*\.ozone_default" | awk '{sum += $5} END {print sum}'
Should Be Equal As Integers ${block_size} ${expected_block_size}

Verify Corrupt Replica
[arguments] ${json} ${replica} ${valid_md5sum}

Expand Down
Loading