Skip to content

Commit

Permalink
Merge pull request #318 from aerospike/stage
Browse files Browse the repository at this point in the history
Java client 8.1.1-jdk21
  • Loading branch information
BrianNichols authored May 7, 2024
2 parents 0c77b29 + 39e923c commit 2a1549a
Show file tree
Hide file tree
Showing 33 changed files with 564 additions and 251 deletions.
2 changes: 1 addition & 1 deletion benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-parent</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
</parent>
<artifactId>aerospike-benchmarks</artifactId>
<packaging>jar</packaging>
Expand Down
18 changes: 6 additions & 12 deletions benchmarks/src/com/aerospike/benchmarks/InsertTaskSync.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand All @@ -16,9 +16,6 @@
*/
package com.aerospike.benchmarks;

import java.util.HashMap;
import java.util.Map;

import com.aerospike.client.AerospikeException;
import com.aerospike.client.Bin;
import com.aerospike.client.IAerospikeClient;
Expand Down Expand Up @@ -87,11 +84,11 @@ private void runCommand(long keyCurrent, RandomShift random) {
private void put(Key key, Bin[] bins) {
if (counters.write.latency != null) {
long begin = System.nanoTime();

if (! skipKey(key)) {
client.put(args.writePolicy, key, bins);
}

long elapsed = System.nanoTime() - begin;
counters.write.count.getAndIncrement();
counters.write.latency.add(elapsed);
Expand All @@ -103,11 +100,8 @@ private void put(Key key, Bin[] bins) {
counters.write.count.getAndIncrement();
}
}

private boolean skipKey(Key key) {
if (args.partitionIds != null && !args.partitionIds.contains(Partition.getPartitionId(key.digest))) {
return true;
}
return false;
}
return args.partitionIds != null && !args.partitionIds.contains(Partition.getPartitionId(key.digest));
}
}
4 changes: 2 additions & 2 deletions benchmarks/src/com/aerospike/benchmarks/KeyType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand All @@ -17,5 +17,5 @@
package com.aerospike.benchmarks;

public enum KeyType {
STRING, INTEGER;
STRING, INTEGER
}
12 changes: 6 additions & 6 deletions benchmarks/src/com/aerospike/benchmarks/LatencyManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand All @@ -20,9 +20,9 @@

public interface LatencyManager {

public void add(long elapsed);
void add(long elapsed);

public void printHeader(PrintStream stream);
void printHeader(PrintStream stream);

/**
* Print latency percents for specified cumulative ranges.
Expand All @@ -32,9 +32,9 @@ public interface LatencyManager {
* affects performance. Fortunately, the values will even out over time
* (ie. no double counting).
*/
public void printResults(PrintStream stream, String prefix);
void printResults(PrintStream stream, String prefix);

public void printSummaryHeader(PrintStream stream);
void printSummaryHeader(PrintStream stream);

public void printSummary(PrintStream stream, String prefix);
void printSummary(PrintStream stream, String prefix);
}
26 changes: 13 additions & 13 deletions benchmarks/src/com/aerospike/benchmarks/LatencyManagerYcsb.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand All @@ -25,21 +25,21 @@ public class LatencyManagerYcsb implements LatencyManager {
public static final String BUCKETS = "histogram.buckets";
public static final String BUCKETS_DEFAULT = "1000";

private AtomicInteger _buckets;
private AtomicLongArray histogram;
private AtomicLong histogramoverflow;
private AtomicInteger operations;
private AtomicLong totallatency;
private AtomicInteger warmupCount;
private final AtomicInteger _buckets;
private final AtomicLongArray histogram;
private final AtomicLong histogramoverflow;
private final AtomicInteger operations;
private final AtomicLong totallatency;
private final AtomicInteger warmupCount;
private volatile boolean warmupComplete = false;

//keep a windowed version of these stats for printing status
private AtomicInteger windowoperations;
private AtomicLong windowtotallatency;
private final AtomicInteger windowoperations;
private final AtomicLong windowtotallatency;

private AtomicLong min;
private AtomicLong max;
private String name;
private final AtomicLong min;
private final AtomicLong max;
private final String name;

public LatencyManagerYcsb(String name, int warmupCount) {
this.name = name;
Expand Down Expand Up @@ -125,7 +125,7 @@ public void printResults(PrintStream exporter, String prefix) {
}
}
buffer.append(']');
exporter.println(buffer.toString());
exporter.println(buffer);
windowoperations.set(0);
windowtotallatency.set(0);
}
Expand Down
82 changes: 50 additions & 32 deletions benchmarks/src/com/aerospike/benchmarks/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public static void main(String[] args) {
}
}

private Arguments args = new Arguments();
private Host[] hosts;
private final Arguments args = new Arguments();
private final Host[] hosts;
private EventLoopType eventLoopType = EventLoopType.DIRECT_NIO;
private int port = 3000;
private long nKeys;
Expand All @@ -113,8 +113,8 @@ public static void main(String[] args) {
private String filepath;

private EventLoops eventLoops;
private ClientPolicy clientPolicy = new ClientPolicy();
private CounterStore counters = new CounterStore();
private final ClientPolicy clientPolicy = new ClientPolicy();
private final CounterStore counters = new CounterStore();

public Main(String[] commandLineArgs) throws Exception {
boolean hasTxns = false;
Expand Down Expand Up @@ -222,6 +222,11 @@ public Main(String[] commandLineArgs) throws Exception {
" 0: Default to namespace expiration time\n" +
" >0: Actual given expiration time"
);
options.addOption("rt", "readTouchTtlPercent", true,
"Read touch TTL percent is expressed as a percentage of the TTL (or expiration) sent on the most\n" +
"recent write such that a read within this interval of the record’s end of life will generate a touch.\n" +
"Range: 0 - 100"
);
options.addOption("g", "throughput", true,
"Set a target transactions per second for the client. The client should not exceed this " +
"average throughput."
Expand Down Expand Up @@ -392,6 +397,14 @@ public Main(String[] commandLineArgs) throws Exception {
}
}

if (line.hasOption("readTouchTtlPercent")) {
args.readPolicy.readTouchTtlPercent = Integer.parseInt(line.getOptionValue("readTouchTtlPercent"));
if (args.readPolicy.readTouchTtlPercent < 0 || args.readPolicy.readTouchTtlPercent > 100) {
throw new Exception("Invalid readTouchTtlPercent: " + args.readPolicy.readTouchTtlPercent +
" Range: 0 - 100");
}
}

if (line.hasOption("port")) {
this.port = Integer.parseInt(line.getOptionValue("port"));
}
Expand Down Expand Up @@ -1057,19 +1070,21 @@ else if (! level.equals("all")) {
if (args.workload != Workload.INITIALIZE) {
System.out.println("read policy:");
System.out.println(
" connectTimeout: " + args.readPolicy.connectTimeout
+ ", socketTimeout: " + args.readPolicy.socketTimeout
+ ", totalTimeout: " + args.readPolicy.totalTimeout
+ ", timeoutDelay: " + args.readPolicy.timeoutDelay
+ ", maxRetries: " + args.readPolicy.maxRetries
+ ", sleepBetweenRetries: " + args.readPolicy.sleepBetweenRetries
);
" connectTimeout: " + args.readPolicy.connectTimeout
+ ", socketTimeout: " + args.readPolicy.socketTimeout
+ ", totalTimeout: " + args.readPolicy.totalTimeout
+ ", timeoutDelay: " + args.readPolicy.timeoutDelay
+ ", maxRetries: " + args.readPolicy.maxRetries
+ ", sleepBetweenRetries: " + args.readPolicy.sleepBetweenRetries
);

System.out.println(
" readModeAP: " + args.readPolicy.readModeAP
+ ", readModeSC: " + args.readPolicy.readModeSC
+ ", replica: " + args.readPolicy.replica
+ ", reportNotFound: " + args.reportNotFound);
" readModeAP: " + args.readPolicy.readModeAP
+ ", readModeSC: " + args.readPolicy.readModeSC
+ ", replica: " + args.readPolicy.replica
+ ", readTouchTtlPercent: " + args.readPolicy.readTouchTtlPercent
+ ", reportNotFound: " + args.reportNotFound
);
}

System.out.println("write policy:");
Expand All @@ -1082,7 +1097,10 @@ else if (! level.equals("all")) {
+ ", sleepBetweenRetries: " + args.writePolicy.sleepBetweenRetries
);

System.out.println(" commitLevel: " + args.writePolicy.commitLevel);
System.out.println(
" commitLevel: " + args.writePolicy.commitLevel
+ ", expiration: " + args.writePolicy.expiration
);

if (args.batchSize > 1) {
System.out.println("batch size: " + args.batchSize);
Expand All @@ -1103,25 +1121,25 @@ else if (! level.equals("all")) {
System.out.print("bin[" + binCount + "]: ");

switch (spec.type) {
case INTEGER:
System.out.println("integer");
break;
case INTEGER:
System.out.println("integer");
break;

case STRING:
System.out.println("string[" + spec.size + "]");
break;
case STRING:
System.out.println("string[" + spec.size + "]");
break;

case BYTES:
System.out.println("byte[" + spec.size + "]");
break;
case BYTES:
System.out.println("byte[" + spec.size + "]");
break;

case RANDOM:
System.out.println("random[" + (spec.size * 8) + "]");
break;
case RANDOM:
System.out.println("random[" + (spec.size * 8) + "]");
break;

case TIMESTAMP:
System.out.println("timestamp");
break;
case TIMESTAMP:
System.out.println("timestamp");
break;
}
binCount++;
}
Expand All @@ -1146,7 +1164,7 @@ private static void logUsage(Options options) {
String syntax = Main.class.getName() + " [<options>]";
formatter.printHelp(pw, 100, syntax, "options:", options, 0, 2, null);

System.out.println(sw.toString());
System.out.println(sw);
}

private static String getLatencyUsage(String latencyString) {
Expand Down
46 changes: 23 additions & 23 deletions benchmarks/src/com/aerospike/benchmarks/RWTask.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand Down Expand Up @@ -59,41 +59,41 @@ public void stop() {
protected void runCommand(RandomShift random) {
try {
switch (args.workload) {
case READ_UPDATE:
case READ_REPLACE:
readUpdate(random);
break;
case READ_UPDATE:
case READ_REPLACE:
readUpdate(random);
break;

case READ_MODIFY_UPDATE:
readModifyUpdate(random);
break;
case READ_MODIFY_UPDATE:
readModifyUpdate(random);
break;

case READ_MODIFY_INCREMENT:
readModifyIncrement(random);
break;
case READ_MODIFY_INCREMENT:
readModifyIncrement(random);
break;

case READ_MODIFY_DECREMENT:
readModifyDecrement(random);
break;
case READ_MODIFY_DECREMENT:
readModifyDecrement(random);
break;

case READ_FROM_FILE:
readFromFile(random);
break;
case READ_FROM_FILE:
readFromFile(random);
break;

case TRANSACTION:
runTransaction(random);
break;
case TRANSACTION:
runTransaction(random);
break;

default:
break;
default:
break;
}
}
catch (Exception e) {
if (args.debug) {
e.printStackTrace();
}
else {
System.out.println("Exception - " + e.toString());
System.out.println("Exception - " + e);
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions benchmarks/src/com/aerospike/benchmarks/RWTaskSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,8 @@ protected void get(Key[] keys) {
}

private boolean skipKey(Key key) {
if (args.partitionIds != null && !args.partitionIds.contains(Partition.getPartitionId(key.digest))) {
return true;
}
return false;
}
return args.partitionIds != null && !args.partitionIds.contains(Partition.getPartitionId(key.digest));
}

private Key[] getFilteredKeys(Key[] keys) {
List<Key> filteredKeys = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 Aerospike, Inc.
* Copyright 2012-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
Expand All @@ -17,8 +17,9 @@
package com.aerospike.benchmarks;

public class TransactionalItem {
private TransactionalType type;
private int repetitions;
private final TransactionalType type;
private final int repetitions;

public TransactionalItem(TransactionalType type, int repetitions) {
super();
this.type = type;
Expand Down
Loading

0 comments on commit 2a1549a

Please sign in to comment.