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 @@ -270,7 +270,7 @@ public void getMetrics(MetricsCollector metricsCollector, boolean all) {
.addGauge(DatanodeCommandDetails.COMMANDS_TIMEOUT_BY_DN,
e.getValue().getCommandsTimeout())
.addGauge(DatanodeCommandDetails.BLOCKS_SENT_TO_DN_COMMAND,
e.getValue().getCommandsTimeout());
e.getValue().getBlocksSent());
}
recordBuilder.endRecord();
}
Expand Down Expand Up @@ -347,6 +347,10 @@ public long getCommandsTimeout() {
return commandsTimeout;
}

public long getBlocksSent() {
return blocksSent;
}

@Override
public String toString() {
return "Sent=" + commandsSent + ", Success=" + commandsSuccess + ", Failed=" + commandsFailure +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public final class SCMPerformanceMetrics implements MetricsSource {
private MetricsRegistry registry;
private static SCMPerformanceMetrics instance;

@Metric(about = "Number of failed deleteKey operations")
@Metric(about = "Number of failed deleteKeys")
private MutableCounterLong deleteKeyFailure;
@Metric(about = "Number of successful deleteKey operations")
@Metric(about = "Number of success deleteKeys")
private MutableCounterLong deleteKeySuccess;
@Metric(about = "Latency for deleteKey failure in nanoseconds")
private MutableRate deleteKeyFailureLatencyNs;
Expand All @@ -55,6 +55,10 @@ public final class SCMPerformanceMetrics implements MetricsSource {
private MutableRate allocateBlockSuccessLatencyNs;
@Metric(about = "Latency for a failed allocateBlock call in nanoseconds")
private MutableRate allocateBlockFailureLatencyNs;
@Metric(about = "Total blocks taken in each key delete cycle.")
private MutableCounterLong deleteKeyBlocksSuccess;
@Metric(about = "Total blocks taken in each key delete cycle failure.")
private MutableCounterLong deleteKeyBlocksFailure;

public SCMPerformanceMetrics() {
this.registry = new MetricsRegistry(SOURCE_NAME);
Expand Down Expand Up @@ -84,6 +88,8 @@ public void getMetrics(MetricsCollector collector, boolean all) {
deleteKeyFailureLatencyNs.snapshot(recordBuilder, true);
allocateBlockSuccessLatencyNs.snapshot(recordBuilder, true);
allocateBlockFailureLatencyNs.snapshot(recordBuilder, true);
deleteKeyBlocksSuccess.snapshot(recordBuilder, true);
deleteKeyBlocksFailure.snapshot(recordBuilder, true);
}

public void updateAllocateBlockSuccessLatencyNs(long startNanos) {
Expand All @@ -94,14 +100,22 @@ public void updateAllocateBlockFailureLatencyNs(long startNanos) {
allocateBlockFailureLatencyNs.add(Time.monotonicNowNanos() - startNanos);
}

public void updateDeleteKeySuccessStats(long startNanos) {
deleteKeySuccess.incr();
public void updateDeleteKeySuccessStats(long keys, long startNanos) {
deleteKeySuccess.incr(keys);
deleteKeySuccessLatencyNs.add(Time.monotonicNowNanos() - startNanos);
}

public void updateDeleteKeyFailureStats(long startNanos) {
deleteKeyFailure.incr();
public void updateDeleteKeyFailureStats(long keys, long startNanos) {
deleteKeyFailure.incr(keys);
deleteKeyFailureLatencyNs.add(Time.monotonicNowNanos() - startNanos);
}

public void updateDeleteKeySuccessBlocks(long keys) {
deleteKeyBlocksSuccess.incr(keys);
}

public void updateDeleteKeyFailedBlocks(long keys) {
deleteKeyBlocksFailure.incr(keys);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,32 @@ public List<AllocatedBlock> allocateBlock(
@Override
public List<DeleteBlockGroupResult> deleteKeyBlocks(
List<BlockGroup> keyBlocksInfoList) throws IOException {
long totalBlocks = 0;
for (BlockGroup bg : keyBlocksInfoList) {
totalBlocks += bg.getBlockIDList().size();
}
if (LOG.isDebugEnabled()) {
LOG.debug("SCM is informed by OM to delete {} blocks",
keyBlocksInfoList.size());
LOG.debug("SCM is informed by OM to delete {} keys. Total blocks to deleted {}.",
keyBlocksInfoList.size(), totalBlocks);
}

List<DeleteBlockGroupResult> results = new ArrayList<>();
Map<String, String> auditMap = Maps.newHashMap();
ScmBlockLocationProtocolProtos.DeleteScmBlockResult.Result resultCode;
Exception e = null;
long startNanos = Time.monotonicNowNanos();
try {
scm.getScmBlockManager().deleteBlocks(keyBlocksInfoList);
perfMetrics.updateDeleteKeySuccessStats(startNanos);
perfMetrics.updateDeleteKeySuccessBlocks(totalBlocks);
perfMetrics.updateDeleteKeySuccessStats(keyBlocksInfoList.size(), startNanos);
resultCode = ScmBlockLocationProtocolProtos.
DeleteScmBlockResult.Result.success;
if (LOG.isDebugEnabled()) {
LOG.debug("Total number of blocks ACK by SCM in this cycle: " + totalBlocks);
}
} catch (IOException ioe) {
e = ioe;
perfMetrics.updateDeleteKeyFailureStats(startNanos);
perfMetrics.updateDeleteKeyFailedBlocks(totalBlocks);
perfMetrics.updateDeleteKeyFailureStats(keyBlocksInfoList.size(), startNanos);
LOG.warn("Fail to delete {} keys", keyBlocksInfoList.size(), ioe);
switch (ioe instanceof SCMException ? ((SCMException) ioe).getResult() :
IO_EXCEPTION) {
Expand Down
Loading