Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -65,6 +65,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.rules.Timeout;
import org.mockito.Mockito;

Expand Down Expand Up @@ -316,8 +317,20 @@ public void testKeyOps() throws Exception {
writeClient.commitKey(keyArgs, keySession.getId());
writeClient.deleteKey(keyArgs);

keyArgs = createKeyArgs(volumeName, bucketName,
new ECReplicationConfig("rs-6-4-1024K"));
try {
keySession = writeClient.openKey(keyArgs);
writeClient.commitKey(keyArgs, keySession.getId());
} catch (Exception e) {
//Expected Failure in preExecute due to not enough datanode
Assertions.assertTrue(e.getMessage()
.contains("No enough datanodes to choose"));
}

omMetrics = getMetrics("OMMetrics");
assertCounter("NumKeys", 2L, omMetrics);
assertCounter("NumBlockAllocationFails", 1L, omMetrics);

// inject exception to test for Failure Metrics on the read path
Mockito.doThrow(exception).when(mockKm).lookupKey(any(), any());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
new ExcludeList(), requestedSize, scmBlockSize,
ozoneManager.getPreallocateBlocksMax(),
ozoneManager.isGrpcBlockTokenEnabled(),
ozoneManager.getOMNodeId());
ozoneManager.getOMNodeId(),
ozoneManager.getMetrics());

KeyArgs.Builder newKeyArgs = keyArgs.toBuilder()
.setModificationTime(Time.now()).setType(type).setFactor(factor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
ozoneManager.getBlockTokenSecretManager(), repConfig, excludeList,
ozoneManager.getScmBlockSize(), ozoneManager.getScmBlockSize(),
ozoneManager.getPreallocateBlocksMax(),
ozoneManager.isGrpcBlockTokenEnabled(), ozoneManager.getOMNodeId());
ozoneManager.isGrpcBlockTokenEnabled(), ozoneManager.getOMNodeId(),
ozoneManager.getMetrics());

// Set modification time and normalize key if required.
KeyArgs.Builder newKeyArgs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
new ExcludeList(), requestedSize, scmBlockSize,
ozoneManager.getPreallocateBlocksMax(),
ozoneManager.isGrpcBlockTokenEnabled(),
ozoneManager.getOMNodeId());
ozoneManager.getOMNodeId(),
ozoneManager.getMetrics());

newKeyArgs = keyArgs.toBuilder().setModificationTime(Time.now())
.setType(type).setFactor(factor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.OzoneAcl;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.om.OMMetrics;
import org.apache.hadoop.ozone.om.PrefixManager;
import org.apache.hadoop.ozone.om.ResolvedBucket;
import org.apache.hadoop.ozone.om.helpers.BucketEncryptionKeyInfo;
Expand Down Expand Up @@ -134,7 +135,8 @@ protected List< OmKeyLocationInfo > allocateBlock(ScmClient scmClient,
OzoneBlockTokenSecretManager secretManager,
ReplicationConfig replicationConfig, ExcludeList excludeList,
long requestedSize, long scmBlockSize, int preallocateBlocksMax,
boolean grpcBlockTokenEnabled, String omID) throws IOException {
boolean grpcBlockTokenEnabled, String omID, OMMetrics omMetrics)
throws IOException {
int dataGroupSize = replicationConfig instanceof ECReplicationConfig
? ((ECReplicationConfig) replicationConfig).getData() : 1;
int numBlocks = (int) Math.min(preallocateBlocksMax,
Expand All @@ -148,6 +150,7 @@ protected List< OmKeyLocationInfo > allocateBlock(ScmClient scmClient,
.allocateBlock(scmBlockSize, numBlocks, replicationConfig, omID,
excludeList);
} catch (SCMException ex) {
omMetrics.incNumBlockAllocateCallFails();
if (ex.getResult()
.equals(SCMException.ResultCodes.SAFE_MODE_EXCEPTION)) {
throw new OMException(ex.getMessage(),
Expand Down