Skip to content

Commit

Permalink
Enable IO Usage Tracker For Linux OS
Browse files Browse the repository at this point in the history
Signed-off-by: Ajay Kumar Movva <[email protected]>
  • Loading branch information
Ajay Kumar Movva committed Mar 4, 2024
1 parent 22da423 commit b5fa081
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.Constants;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.monitor.fs.FsInfo.DeviceStats;
import org.opensearch.monitor.fs.FsService;
Expand All @@ -28,14 +29,14 @@ public class AverageIoUsageTracker extends AbstractAverageUsageTracker {
private final FsService fsService;
private final HashMap<String, Long> prevIoTimeDeviceMap;
private long prevTimeInMillis;
private final IoUsageStats ioUsageStats;
private IoUsageStats ioUsageStats;

public AverageIoUsageTracker(FsService fsService, ThreadPool threadPool, TimeValue pollingInterval, TimeValue windowDuration) {
super(threadPool, pollingInterval, windowDuration);
this.fsService = fsService;
this.prevIoTimeDeviceMap = new HashMap<>();
this.prevTimeInMillis = -1;
this.ioUsageStats = new IoUsageStats(-1);
this.ioUsageStats = null;
}

/**
Expand Down Expand Up @@ -67,11 +68,14 @@ public long getUsage() {

@Override
protected void doStart() {
scheduledFuture = threadPool.scheduleWithFixedDelay(() -> {
long usage = getUsage();
recordUsage(usage);
updateIoUsageStats();
}, pollingInterval, ThreadPool.Names.GENERIC);
if (Constants.LINUX) {
this.ioUsageStats = new IoUsageStats(-1);
scheduledFuture = threadPool.scheduleWithFixedDelay(() -> {
long usage = getUsage();
recordUsage(usage);
updateIoUsageStats();
}, pollingInterval, ThreadPool.Names.GENERIC);
}
}

private boolean preValidateFsStats() {
Expand Down

0 comments on commit b5fa081

Please sign in to comment.