diff --git a/pom.xml b/pom.xml index 2e1f132..052b7ed 100644 --- a/pom.xml +++ b/pom.xml @@ -146,7 +146,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.10.1 + 3.11.2 *.connect,*.controller,*.generator,*.jfr,*.metric,*.run,*.util public @@ -167,7 +167,7 @@ 'core.autocrlf' to true --> com.diffplug.spotless spotless-maven-plugin - 2.43.0 + 2.44.2 @@ -193,7 +193,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.1 + 3.5.2 /io/deephaven/benchmark/tests/**/*Test @@ -203,14 +203,14 @@ org.junit.jupiter junit-jupiter-engine - 5.9.2 + 5.9.3 org.apache.maven.plugins maven-failsafe-plugin - 3.5.1 + 3.5.2 0 @@ -221,7 +221,7 @@ org.junit.jupiter junit-jupiter-engine - 5.9.2 + 5.9.3 @@ -247,39 +247,39 @@ io.netty netty-all - 4.1.100.Final + 4.1.114.Final io.grpc grpc-all - 1.58.0 + 1.65.1 com.google.protobuf protobuf-java - 3.25.3 + 3.25.4 io.confluent kafka-avro-serializer - 7.7.1 + 7.9.0 io.confluent kafka-protobuf-serializer - 7.7.1 + 7.9.0 io.deephaven deephaven-java-client-barrage-dagger - 0.36.1 + 0.37.6 io.deephaven deephaven-log-to-slf4j - 0.36.1 + 0.37.6 org.junit.platform diff --git a/src/main/java/io/deephaven/benchmark/api/BenchQuery.java b/src/main/java/io/deephaven/benchmark/api/BenchQuery.java index b5388af..7c4779f 100644 --- a/src/main/java/io/deephaven/benchmark/api/BenchQuery.java +++ b/src/main/java/io/deephaven/benchmark/api/BenchQuery.java @@ -1,9 +1,10 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ +/* Copyright (c) 2022-2025 Deephaven Data Labs and Patent Pending */ package io.deephaven.benchmark.api; import java.io.Closeable; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Properties; import java.util.concurrent.Future; import java.util.function.Consumer; import java.util.function.Function; @@ -24,6 +25,7 @@ final public class BenchQuery implements Closeable { final QueryLog queryLog; final Map> snapshotFetchers = new LinkedHashMap<>(); final Map> tickingFetchers = new LinkedHashMap<>(); + final Properties props = new Properties(); private Connector session = null; BenchQuery(Bench bench, String logic, QueryLog queryLog) { @@ -58,6 +60,16 @@ public BenchQuery fetchDuring(String table, Function table return this; } + /** + * Add properties to be passed to the Connector used in the query + */ + public BenchQuery withProperty(String name, String value) { + if (value != null && !value.isBlank()) { + props.setProperty(name, value); + } + return this; + } + /** * Execute the query logic through a session */ @@ -97,10 +109,10 @@ public void close() { // Add function defs in separate query so if there are errors in the "logic" part, the line numbers match up private void executeBarrageQuery(String logic) { if (session == null) { - var deephavenServer = bench.property("deephaven.addr", "localhost:10000"); var connectorClass = bench.property("connector.class", "io.deephaven.benchmark.connect.BarrageConnector"); - var connectorAuth = bench.property("deephaven.auth", ""); - session = ConnectorFactory.create(connectorClass, deephavenServer, connectorAuth); + var localProps = Bench.profile.getProperties(); + localProps.putAll(props); + session = ConnectorFactory.create(connectorClass, localProps); } String snippetsLogic = Bench.profile.replaceProperties(Snippets.getFunctions(logic)); if (!snippetsLogic.isBlank()) { diff --git a/src/main/java/io/deephaven/benchmark/api/Profile.java b/src/main/java/io/deephaven/benchmark/api/Profile.java index c0a71f7..91d1e46 100644 --- a/src/main/java/io/deephaven/benchmark/api/Profile.java +++ b/src/main/java/io/deephaven/benchmark/api/Profile.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2022-2024 Deephaven Data Labs and Patent Pending */ +/* Copyright (c) 2022-2025 Deephaven Data Labs and Patent Pending */ package io.deephaven.benchmark.api; import java.io.InputStream; @@ -13,19 +13,20 @@ import io.deephaven.benchmark.util.Log; /** - * Represents properties for a the Benchmark API .profile file in addition to allowing retrieval of System and - * environment properties. + * Represents properties for the Benchmark API profile file in addition to allowing retrieval of System and environment + * properties. The default property file (e.g. default.properties) for the profile can be overridden with + * System.setProperty("benchmark.profile.default", "my-properties-path"). */ class Profile { final private URL url; final private Properties props; /** - * Initialize the profile from the supplied benchmark.profile property. That that property is absent, use the - * default properties file. + * Initialize the profile from the supplied "benchmark.profile" property. If that property is absent, use the + * "benchmark.profile.default" property. If that property is absent, use the "default.properties" resource file. */ Profile() { - this(System.getProperty("benchmark.profile", "default.properties")); + this(System.getProperty("benchmark.profile", getProfileDefaultFile())); } /** @@ -218,4 +219,8 @@ private URL findProfileAsResource(Class parentClass, String uri) { } } + static String getProfileDefaultFile() { + return System.getProperty("benchmark.profile.default", "default.properties"); + } + } diff --git a/src/main/java/io/deephaven/benchmark/connect/BarrageConnector.java b/src/main/java/io/deephaven/benchmark/connect/BarrageConnector.java index c6f7369..dbfaec7 100644 --- a/src/main/java/io/deephaven/benchmark/connect/BarrageConnector.java +++ b/src/main/java/io/deephaven/benchmark/connect/BarrageConnector.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2022-2023 Deephaven Data Labs and Patent Pending */ +/* Copyright (c) 2022-2025 Deephaven Data Labs and Patent Pending */ package io.deephaven.benchmark.connect; import java.util.*; @@ -51,7 +51,9 @@ class BarrageConnector implements Connector { * * @param hostPort a host and port string for connecting to a Deephaven worker (ex. localhost:10000) */ - BarrageConnector(String hostPort, String userPass) { + BarrageConnector(Properties props) { + var hostPort = props.getProperty("deephaven.addr", "localhost:10000"); + var userPass = props.getProperty("deephaven.auth", ""); var host = hostPort.replaceAll(":.*", ""); var port = hostPort.replaceAll(".*:", ""); if (host.isEmpty() || port.isEmpty()) diff --git a/src/main/java/io/deephaven/benchmark/connect/ConnectorFactory.java b/src/main/java/io/deephaven/benchmark/connect/ConnectorFactory.java index 7290df6..ab56b63 100644 --- a/src/main/java/io/deephaven/benchmark/connect/ConnectorFactory.java +++ b/src/main/java/io/deephaven/benchmark/connect/ConnectorFactory.java @@ -1,14 +1,19 @@ /* Copyright (c) 2022-2025 Deephaven Data Labs and Patent Pending */ package io.deephaven.benchmark.connect; +import java.util.Properties; + +/** + * Instantiate the Connector for the given full-qualified class name with the given properties. + */ public class ConnectorFactory { - static public Connector create(String connectorClassName, String hostPort, String userPass) { + static public Connector create(String connectorClassName, Properties props) { try { var myClass = Class.forName(connectorClassName); - var constructor = myClass.getDeclaredConstructor(String.class, String.class); - return (Connector) constructor.newInstance(hostPort, userPass); + var constructor = myClass.getDeclaredConstructor(Properties.class); + return (Connector) constructor.newInstance(props); } catch (Exception ex) { - throw new RuntimeException("Failed to instantiate Connector: " + hostPort, ex); + throw new RuntimeException("Failed to instantiate Connector: " + connectorClassName, ex); } }