Skip to content

Commit

Permalink
Merge branch 'ac-pr-final-1' of github.com:bharath-techie/OpenSearch …
Browse files Browse the repository at this point in the history
…into ac-pr-fs-stats-1
  • Loading branch information
bharath-techie committed Sep 21, 2023
2 parents bf75f28 + f867acf commit e52c988
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MovingAverage {
private final long[] observations;

private volatile long count = 0;
private volatile double sum = 0;
private volatile long sum = 0;
private volatile double average = 0;

public MovingAverage(int windowSize) {
Expand Down Expand Up @@ -67,7 +67,7 @@ public synchronized double record(long value) {

count++;
sum += delta;
average = sum / Math.min(count, observations.length);
average = (double) sum / Math.min(count, observations.length);
return average;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private void monitorFSHealth() {
}
Files.delete(tempDataPath);
final long elapsedTime = currentTimeMillisSupplier.getAsLong() - executionStartTime;
logger.info("health check took {}", elapsedTime);
if (elapsedTime > slowPathLoggingThreshold.millis()) {
logger.warn(
"health check of [{}] took [{}ms] which is above the warn threshold of [{}]",
Expand Down
48 changes: 2 additions & 46 deletions server/src/main/java/org/opensearch/monitor/fs/FsInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ public static class DeviceStats implements Writeable, ToXContentFragment {
final double previousReadTime;
final double currentWriteTime;
final double previousWriteTime;
final double currentReadLatency;
final double previousReadLatency;
final double currentWriteLatency;
final double previousWriteLatency;

public DeviceStats(
final int majorDeviceNumber,
Expand All @@ -261,8 +257,6 @@ public DeviceStats(
final long currentIOTime,
final double currentReadTime,
final double currentWriteTime,
final double currentReadLatency,
final double currentWriteLatency,
final DeviceStats previousDeviceStats
) {
this(
Expand All @@ -282,11 +276,7 @@ public DeviceStats(
currentReadTime,
previousDeviceStats != null ? previousDeviceStats.previousReadTime : -1.0,
currentWriteTime,
previousDeviceStats != null ? previousDeviceStats.previousWriteTime : -1.0,
currentReadLatency,
previousDeviceStats != null ? previousDeviceStats.currentReadLatency : -1.0,
currentWriteLatency,
previousDeviceStats != null ? previousDeviceStats.currentWriteLatency : -1.0
previousDeviceStats != null ? previousDeviceStats.previousWriteTime : -1.0
);
}

Expand All @@ -307,11 +297,7 @@ private DeviceStats(
final double currentReadTime,
final double previousReadTime,
final double currentWriteTime,
final double previousWriteTime,
final double currentReadLatency,
final double previousReadLatency,
final double currentWriteLatency,
final double previousWriteLatency
final double previousWriteTime
) {
this.majorDeviceNumber = majorDeviceNumber;
this.minorDeviceNumber = minorDeviceNumber;
Expand All @@ -330,10 +316,6 @@ private DeviceStats(
this.previousReadTime = previousReadTime;
this.currentWriteTime = currentWriteTime;
this.previousWriteTime = previousWriteTime;
this.currentReadLatency = currentReadLatency;
this.previousReadLatency = previousReadLatency;
this.currentWriteLatency = currentWriteLatency;
this.previousWriteLatency = previousWriteLatency;
}

public DeviceStats(StreamInput in) throws IOException {
Expand All @@ -354,10 +336,6 @@ public DeviceStats(StreamInput in) throws IOException {
previousReadTime = in.readDouble();
currentWriteTime = in.readDouble();
previousWriteTime = in.readDouble();
currentReadLatency = in.readDouble();
previousReadLatency = in.readDouble();
currentWriteLatency = in.readDouble();
previousWriteLatency = in.readDouble();
}

@Override
Expand All @@ -378,10 +356,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeDouble(currentReadTime);
out.writeDouble(currentWriteTime);
out.writeDouble(previousWriteTime);
out.writeDouble(currentReadLatency);
out.writeDouble(previousReadLatency);
out.writeDouble(currentWriteLatency);
out.writeDouble(previousWriteLatency);
}

public long operations() {
Expand Down Expand Up @@ -439,11 +413,6 @@ public long ioTimeInMillis() {
return (currentIOTime - previousIOTime);
}

public double getWriteLatency() {
if(previousWriteLatency == -1.0) return -1.0;
return currentWriteLatency - previousWriteLatency;
}

public double getNewWriteLatency() {
//double readLatency = getReadTime() / readOperations();
double writeLatency = getWriteTime() / writeOperations();
Expand All @@ -456,11 +425,6 @@ public double getNewReadLatency() {
return readLatency;
}

public double getReadLatency() {
if(previousReadLatency == -1.0) return -1.0;
return currentReadLatency - previousReadLatency;
}

public double getReadTime() {
if(previousReadTime == -1.0) return -1.0;
return currentReadTime - previousReadTime;
Expand All @@ -483,14 +447,6 @@ public double getCurrentWriteTime() {
return this.currentWriteTime;
}

public double getCurrentReadLatency() {
return this.currentReadLatency;
}

public double getCurrentWriteLatency() {
return this.currentWriteLatency;
}

public String getDeviceName() {
return this.deviceName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private void recordUsage(IoUsageFetcher.DiskStats usage) {
protected void doStart() {
scheduledFuture = threadPool.scheduleWithFixedDelay(() -> {
IoUsageFetcher.DiskStats usage = getUsage();
if(usage == null) return;
recordUsage(usage);
}, pollingInterval, ThreadPool.Names.GENERIC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ public DiskStats getDiskUtilizationStats() {
double writeLatency = 0.0;
double readOps = 0.0;
double writeOps = 0.0;
if(this.fsService.stats().getIoStats() == null) {
return null;
}
for (FsInfo.DeviceStats devicesStat : this.fsService.stats().getIoStats().getDevicesStats()) {
if (previousIOTimeMap != null && previousIOTimeMap.containsKey(devicesStat.getDeviceName())){
logger.info(this.fsService.stats().getTimestamp());
//logger.info(this.fsService.stats().getTimestamp());
long ioSpentTime = devicesStat.getCurrentIOTime() - previousIOTimeMap.get(devicesStat.getDeviceName()).ioTime;
ioUsePercent = (ioSpentTime * 100) / (1000);
readOps += devicesStat.currentReadOperations() - previousIOTimeMap.get(devicesStat.getDeviceName()).readOps;
Expand All @@ -104,11 +107,11 @@ public DiskStats getDiskUtilizationStats() {
devicesStat.getCurrentReadKilobytes(), devicesStat.getCurrentWriteKilobytes());
currentIOTimeMap.put(devicesStat.getDeviceName(), ps);
}
logger.info("Read in MB : {} , Write in MB : {}", readkb/1000, writekb/1000);
// logger.info("Read in MB : {} , Write in MB : {}", readkb/1000, writekb/1000);
// readLatency += (readOps / readTime) * 100;
// writeLatency += (writeOps / writeTime) * 100;
logger.info("read ops : {} , writeops : {} , readtime: {} , writetime: {}", readOps, writeOps, readTime, writeTime);
logger.info("Read latency : {} write latency : {}" , readLatency, writeLatency);
// logger.info("read ops : {} , writeops : {} , readtime: {} , writetime: {}", readOps, writeOps, readTime, writeTime);
// logger.info("Read latency : {} write latency : {}" , readLatency, writeLatency);
logger.info("IO use percent : {}", ioUsePercent);
previousIOTimeMap = currentIOTimeMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static class Defaults {
private static final long WINDOW_DURATION = 30;
private static final long REFRESH_INTERVAL = 1000;

private static final long IO_POLLING_INTERVAL = 60000;
private static final long IO_POLLING_INTERVAL = 1000;
private static final long IO_WINDOW_DURATION = 60;
}

Expand Down

0 comments on commit e52c988

Please sign in to comment.