Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Abstract classes for Result Loggers #421

Merged
merged 11 commits into from
Sep 23, 2023
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
76 changes: 45 additions & 31 deletions perl/src/main/java/io/perl/logger/impl/ResultsLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,34 @@
public class ResultsLogger implements PerformanceLogger {

/**
* <code>String prefix</code>.
* <code>String header</code>.
*/
protected String prefix;

/**
* <code>String timeUnitName</code>.
*/
protected String timeUnitName;
private String prefix;

/**
* <code>String[] percentileNames</code>.
*/
protected String[] percentileNames;
private String[] percentileNames;

/**
* <code>TimeUnit timeUnit</code>.
*/
protected TimeUnit timeUnit;
private TimeUnit timeUnit;

/**
* <code>double[] percentiles</code>.
*/
protected double[] percentiles;
private double[] percentiles;

/**
* <code>long minLatency</code>.
*/
protected long minLatency;
private long minLatency;

/**
* <code>long maxLatency</code>.
*/
protected long maxLatency;
private long maxLatency;

/**
* <code>DecimalFormat format</code>.
Expand All @@ -78,11 +73,9 @@ public ResultsLogger(String prefix, @Nonnull double[] percentiles,
this.format = new DecimalFormat(LatencyConfig.PERCENTILE_FORMAT);
this.prefix = prefix;
this.timeUnit = timeUnit;
this.percentiles = percentiles.clone();
this.timeUnitName = timeUnit.name();
this.minLatency = minLatency;
this.maxLatency = maxLatency;
setPercentileNames(percentiles);
setPercentiles(percentiles.clone());
}

/**
Expand All @@ -93,37 +86,57 @@ public ResultsLogger() {
LatencyConfig.DEFAULT_MIN_LATENCY, LatencyConfig.DEFAULT_MAX_LATENCY);
}

/**
* Method setPercentileNames collecting all names and setting it in {@link #percentileNames}.
*
* @param percentiles double[]
*/
protected void setPercentileNames(double[] percentiles) {
Arrays.sort(percentiles);
percentileNames = new String[percentiles.length];
for (int i = 0; i < percentiles.length; i++) {
percentileNames[i] = format.format(percentiles[i]);
}
protected void setPrefix(String prefix) {
this.prefix = prefix;
}


protected void setTimeUnit(TimeUnit timeUnit) {
this.timeUnit = timeUnit;
}

protected final String[] getPercentileNames() {
return this.percentileNames;
}

protected final void setMinLatency(long minLatency) {
this.minLatency = minLatency;
}

protected final void setMaxLatency(long maxLatency) {
this.maxLatency = maxLatency;
}

@Override
public TimeUnit getTimeUnit() {
public final TimeUnit getTimeUnit() {
return timeUnit;
}

@Override
public long getMinLatency() {
public final long getMinLatency() {
return minLatency;
}

@Override
public long getMaxLatency() {
public final long getMaxLatency() {
return maxLatency;
}

@Override
public double[] getPercentiles() {
protected final void setPercentiles(double[] percentiles) {
this.percentiles = percentiles;
Arrays.sort(percentiles);
percentileNames = new String[percentiles.length];
for (int i = 0; i < percentiles.length; i++) {
percentileNames[i] = format.format(percentiles[i]);
}
}

protected final String getPrefix() {
return this.prefix;
}

@Override
public final double[] getPercentiles() {
if (percentiles == null) {
return null;
}
Expand Down Expand Up @@ -154,6 +167,7 @@ protected final void appendResultString(StringBuilder out, double seconds, long
long maxLatency, long invalid, long lowerDiscard, long higherDiscard,
long slc1, long slc2, long[] percentileValues) {
final double mBytes = (bytes * 1.0) / Bytes.BYTES_PER_MB;
String timeUnitName = timeUnit.name();
out.append(String.format("%8d seconds, %11.1f MB, %16d records, %11.1f records/sec, %8.2f MB/sec"
+ ", %8.1f %s avg latency, %7d %s min latency, %7d %s max latency;"
+ " %8d invalid latencies; Discarded Latencies:%8d lower, %8d higher;"
Expand Down
2 changes: 1 addition & 1 deletion sbk-api/src/main/java/io/sbk/logger/CountRW.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
/**
* non-sealed interface CountRW which extends CountReaders and CountWriters.
*/
public non-sealed interface CountRW extends CountReaders, CountWriters {
public sealed interface CountRW extends CountReaders, CountWriters permits RWLogger {

}
2 changes: 1 addition & 1 deletion sbk-api/src/main/java/io/sbk/logger/RWLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Interface for recoding/printing results.
*/
public interface RWLogger extends Logger, CountRW, ReportLatency, WriteRequestsLogger, ReadRequestsLogger, RWPrint {
public non-sealed interface RWLogger extends Logger, CountRW, ReportLatency, WriteRequestsLogger, ReadRequestsLogger, RWPrint {

/**
* Default method to record latency of every/multiple event(s).
Expand Down
4 changes: 2 additions & 2 deletions sbk-api/src/main/java/io/sbk/logger/RWPrint.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface RWPrint {
* @param readRequestBytes Read requests Bytes
* @param readRequestMbPerSec Read requests MB/sec
* @param readRequestRecords Read requests
* @param readRequestsRecordsPerSec Read Requests/sec
* @param readRequestRecordsPerSec Read Requests/sec
* @param writeResponsePendingRecords Write response pending records
* @param writeResponsePendingBytes Write response pending bytes
* @param readResponsePendingRecords Read response pending records
Expand Down Expand Up @@ -54,7 +54,7 @@ public interface RWPrint {
void print(int writers, int maxWriters, int readers, int maxReaders,
long writeRequestBytes, double writeRequestMbPerSec, long writeRequestRecords,
double writeRequestRecordsPerSec, long readRequestBytes, double readRequestMbPerSec,
long readRequestRecords, double readRequestsRecordsPerSec, long writeResponsePendingRecords,
long readRequestRecords, double readRequestRecordsPerSec, long writeResponsePendingRecords,
long writeResponsePendingBytes, long readResponsePendingRecords, long readResponsePendingBytes,
long writeReadRequestPendingRecords, long writeReadRequestPendingBytes,
long writeTimeoutEvents, double writeTimeoutEventsPerSec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/

package io.sbm.logger;
package io.sbk.logger;

/**
* Interface SetRW.
Expand Down
Loading
Loading