Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -25,6 +25,7 @@
import org.apache.hadoop.metrics2.annotation.Metric;
import org.apache.hadoop.metrics2.annotation.Metrics;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.metrics2.lib.MutableCounterInt;
import org.apache.hadoop.metrics2.lib.MutableCounterLong;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ public class OMMetrics implements OmMetadataReaderMetrics {
private @Metric MutableCounterLong numSnapshotLists;
private @Metric MutableCounterLong numSnapshotDiffJobs;
private @Metric MutableCounterLong numSnapshotInfos;

private @Metric MutableCounterInt numSnapshotCacheSize;
private @Metric MutableCounterLong numGetFileStatus;
private @Metric MutableCounterLong numCreateDirectory;
private @Metric MutableCounterLong numCreateFile;
Expand Down Expand Up @@ -520,6 +521,19 @@ public void decNumSnapshotDeleted() {
numSnapshotDeleted.incr(-1);
}

public void setNumSnapshotCacheSize(int num) {
int curVal = numSnapshotCacheSize.value();
numSnapshotCacheSize.incr(num - curVal);
Comment thread
ceekay47 marked this conversation as resolved.
Outdated
}

public void incNumSnapshotCacheSize() {
numSnapshotCacheSize.incr();
Comment thread
ceekay47 marked this conversation as resolved.
}

public void decNumSnapshotCacheSize() {
numSnapshotCacheSize.incr(-1);
Comment thread
ceekay47 marked this conversation as resolved.
Outdated
}

public void incNumCompleteMultipartUploadFails() {
numCompleteMultipartUploadFails.incr();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public int getSnapshotCacheSize() {
public void invalidateCache() {
if (snapshotCache != null) {
snapshotCache.invalidateAll();
updateSnapshotCacheSizeMetric();
}
}

Expand All @@ -429,6 +430,7 @@ public void invalidateCache() {
public void invalidateCacheEntry(UUID key) throws IOException {
if (snapshotCache != null) {
snapshotCache.invalidate(key);
updateSnapshotCacheSizeMetric();
}
}

Expand Down Expand Up @@ -679,7 +681,9 @@ private ReferenceCounted<OmSnapshot> getSnapshot(String snapshotTableKey, boolea
}

// retrieve the snapshot from the cache
return snapshotCache.get(snapshotInfo.getSnapshotId());
ReferenceCounted<OmSnapshot> snapshot = snapshotCache.get(snapshotInfo.getSnapshotId());
updateSnapshotCacheSizeMetric();
return snapshot;
}

/**
Expand Down Expand Up @@ -977,4 +981,11 @@ public void close() {
public long getDiffCleanupServiceInterval() {
return diffCleanupServiceInterval;
}

/**
* Updates the SnapshotCache size jmx metric.
*/
public void updateSnapshotCacheSizeMetric() {
this.ozoneManager.getMetrics().setNumSnapshotCacheSize(getSnapshotCacheSize());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ private void instantiateServices(boolean withNewSnapshot) throws IOException {
omSnapshotManager = new OmSnapshotManager(this);

// Snapshot metrics
metrics.setNumSnapshotCacheSize(omSnapshotManager.getSnapshotCacheSize());
Comment thread
ceekay47 marked this conversation as resolved.
Outdated
updateActiveSnapshotMetrics();

if (withNewSnapshot) {
Expand Down Expand Up @@ -1801,7 +1802,6 @@ private void updateActiveSnapshotMetrics()
}
}
}

Comment thread
ceekay47 marked this conversation as resolved.
metrics.setNumSnapshotActive(activeGauge);
metrics.setNumSnapshotDeleted(deletedGauge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public ReferenceCounted<OmSnapshot> get(UUID key) throws IOException {
}
return v;
});

if (rcOmSnapshot == null) {
// The only exception that would fall through the loader logic above
// is OMException with FILE_NOT_FOUND.
Expand Down