From 20b97b9a33ba050beee4bec2e6c8ead3420378da Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Fri, 5 Jan 2024 18:04:28 -0800 Subject: [PATCH] Configure DHT URL template, rather than hard-wire --- .../salesforce/apollo/demesnes/FireFliesTrace.java | 14 +++++++------- .../com/salesforce/apollo/model/ProcessDomain.java | 10 +++------- .../apollo/model/ContainmentDomainTest.java | 3 ++- .../com/salesforce/apollo/model/DomainTest.java | 3 ++- .../com/salesforce/apollo/model/FireFliesTest.java | 3 ++- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/isolates/src/test/java/com/salesforce/apollo/demesnes/FireFliesTrace.java b/isolates/src/test/java/com/salesforce/apollo/demesnes/FireFliesTrace.java index 308d9deb5..9920411fd 100644 --- a/isolates/src/test/java/com/salesforce/apollo/demesnes/FireFliesTrace.java +++ b/isolates/src/test/java/com/salesforce/apollo/demesnes/FireFliesTrace.java @@ -199,7 +199,9 @@ public void before() throws Exception { var context = new ContextImpl<>(DigestAlgorithm.DEFAULT.getLast(), CARDINALITY, 0.2, 3); final var member = new ControlledIdentifierMember(id); var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30)); - var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:", Duration.ofMinutes(1), + var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:%s-state".formatted(digest), + Duration.ofMinutes(1), + "jdbc:h2:mem:%s-dht".formatted(digest), checkpointDirBase, Duration.ofMillis(10), 0.00125, Duration.ofMinutes(1), 3, 10, 0.1); var node = new ProcessContainerDomain(group, member, pdParams, params, RuntimeParameters.newBuilder() @@ -229,14 +231,12 @@ public void smokin() throws Exception { public void viewChange(Context context, Digest viewId, List joins, List leaves) { if (context.totalCount() == CARDINALITY) { - System.out.println( - String.format("Full view: %s members: %s on: %s", viewId, context.totalCount(), - d.getMember().getId())); + System.out.printf("Full view: %s members: %s on: %s%n", viewId, context.totalCount(), + d.getMember().getId()); countdown.countDown(); } else { - System.out.println( - String.format("Members joining: %s members: %s on: %s", viewId, context.totalCount(), - d.getMember().getId())); + System.out.printf("Members joining: %s members: %s on: %s%n", viewId, context.totalCount(), + d.getMember().getId()); } } }; diff --git a/model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java b/model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java index ff2d3199f..cd1c966b9 100644 --- a/model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java +++ b/model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java @@ -42,9 +42,7 @@ * @author hal.hildebrand */ public class ProcessDomain extends Domain { - - private final static String DEFAULT_DHT_DB_URL_TEMPLATE = "jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1"; - private final static Logger log = LoggerFactory.getLogger(ProcessDomain.class); + private final static Logger log = LoggerFactory.getLogger(ProcessDomain.class); protected final KerlDHT dht; protected final View foundation; @@ -59,9 +57,7 @@ public ProcessDomain(Digest group, ControlledIdentifierMember member, ProcessDom .setpByz(parameters.dhtPbyz) .setId(group) .build(); - var template = parameters.dhtDbUrlTemplate == null ? DEFAULT_DHT_DB_URL_TEMPLATE : parameters.dhtDbUrlTemplate; - final var dhtUrl = String.format(template, member.getId(), UUID.randomUUID()); - JdbcConnectionPool connectionPool = JdbcConnectionPool.create(dhtUrl, "", ""); + JdbcConnectionPool connectionPool = JdbcConnectionPool.create(parameters.dhtDbUrl, "", ""); connectionPool.setMaxConnections(parameters.jdbcMaxConnections()); dht = new KerlDHT(parameters.dhtOpsFrequency, params.context(), member, connectionPool, params.digestAlgorithm(), params.communications(), parameters.dhtOperationsTimeout, @@ -127,7 +123,7 @@ protected void stopServices() { dht.stop(); } - public record ProcessDomainParameters(String dbURL, Duration dhtOperationsTimeout, String dhtDbUrlTemplate, + public record ProcessDomainParameters(String dbURL, Duration dhtOperationsTimeout, String dhtDbUrl, Path checkpointBaseDir, Duration dhtOpsFrequency, double dhtFpr, Duration dhtEventValidTO, int dhtBias, int jdbcMaxConnections, double dhtPbyz) { diff --git a/model/src/test/java/com/salesforce/apollo/model/ContainmentDomainTest.java b/model/src/test/java/com/salesforce/apollo/model/ContainmentDomainTest.java index 30ed6d221..d63364eab 100644 --- a/model/src/test/java/com/salesforce/apollo/model/ContainmentDomainTest.java +++ b/model/src/test/java/com/salesforce/apollo/model/ContainmentDomainTest.java @@ -86,7 +86,8 @@ public void before() throws Exception { var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30)); routers.add(localRouter); var dbUrl = String.format("jdbc:h2:mem:sql-%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID()); - var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), null, + var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), + "jdbc:h2:mem:%s-state".formatted(d), checkpointDirBase, Duration.ofMillis(10), 0.00125, Duration.ofMinutes(1), 3, 10, 0.1); var domain = new ProcessContainerDomain(group, member, pdParams, params, RuntimeParameters.newBuilder() diff --git a/model/src/test/java/com/salesforce/apollo/model/DomainTest.java b/model/src/test/java/com/salesforce/apollo/model/DomainTest.java index acb806ff3..f42294fcd 100644 --- a/model/src/test/java/com/salesforce/apollo/model/DomainTest.java +++ b/model/src/test/java/com/salesforce/apollo/model/DomainTest.java @@ -216,7 +216,8 @@ public void before() throws Exception { var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30)); routers.add(localRouter); var dbUrl = String.format("jdbc:h2:mem:sql-%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID()); - var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), null, + var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), + "jdbc:h2:mem:%s-state".formatted(d), checkpointDirBase, Duration.ofMillis(10), 0.00125, Duration.ofMinutes(1), 3, 10, 0.1); var domain = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder() diff --git a/model/src/test/java/com/salesforce/apollo/model/FireFliesTest.java b/model/src/test/java/com/salesforce/apollo/model/FireFliesTest.java index 751966814..200a8e652 100644 --- a/model/src/test/java/com/salesforce/apollo/model/FireFliesTest.java +++ b/model/src/test/java/com/salesforce/apollo/model/FireFliesTest.java @@ -87,7 +87,8 @@ public void before() throws Exception { final var member = new ControlledIdentifierMember(id); var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30)); var dbUrl = String.format("jdbc:h2:mem:sql-%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID()); - var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofSeconds(5), null, + var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofSeconds(5), + "jdbc:h2:mem:%s-state".formatted(digest), checkpointDirBase, Duration.ofMillis(10), 0.00125, Duration.ofSeconds(5), 3, 10, 0.1); var node = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()