Skip to content

Commit

Permalink
Configure DHT URL template, rather than hard-wire
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Jan 6, 2024
1 parent 9726ca1 commit 20b97b9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -229,14 +231,12 @@ public void smokin() throws Exception {
public void viewChange(Context<Participant> context, Digest viewId, List<EventCoordinates> joins,
List<Digest> 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());
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 20b97b9

Please sign in to comment.