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 5, 2024
1 parent 172fa08 commit 9726ca1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
22 changes: 13 additions & 9 deletions model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
*/
public class ProcessDomain extends Domain {

private final static Logger log = LoggerFactory.getLogger(ProcessDomain.class);
protected final KerlDHT dht;
protected final View foundation;
private final UUID listener;
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);

protected final KerlDHT dht;
protected final View foundation;
private final UUID listener;

public ProcessDomain(Digest group, ControlledIdentifierMember member, ProcessDomainParameters parameters,
Builder builder, Parameters.RuntimeParameters.Builder runtime, InetSocketAddress endpoint,
Expand All @@ -57,9 +59,10 @@ public ProcessDomain(Digest group, ControlledIdentifierMember member, ProcessDom
.setpByz(parameters.dhtPbyz)
.setId(group)
.build();
final var dhtUrl = String.format("jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID());
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, "", "");
connectionPool.setMaxConnections(10);
connectionPool.setMaxConnections(parameters.jdbcMaxConnections());
dht = new KerlDHT(parameters.dhtOpsFrequency, params.context(), member, connectionPool,
params.digestAlgorithm(), params.communications(), parameters.dhtOperationsTimeout,
parameters.dhtFpr, stereotomyMetrics);
Expand Down Expand Up @@ -124,8 +127,9 @@ protected void stopServices() {
dht.stop();
}

public record ProcessDomainParameters(String dbURL, Duration dhtOperationsTimeout, Path checkpointBaseDir,
Duration dhtOpsFrequency, double dhtFpr, Duration dhtEventValidTO,
int dhtBias, int jdbcMaxConnections, double dhtPbyz) {
public record ProcessDomainParameters(String dbURL, Duration dhtOperationsTimeout, String dhtDbUrlTemplate,
Path checkpointBaseDir, Duration dhtOpsFrequency, double dhtFpr,
Duration dhtEventValidTO, int dhtBias, int jdbcMaxConnections,
double dhtPbyz) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public void before() throws Exception {
final var member = new ControlledIdentifierMember(id);
var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30));
routers.add(localRouter);
var dbUrl = String.format("jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID());
var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), checkpointDirBase,
Duration.ofMillis(10), 0.00125,
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,
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 3, 10, 0.1);
var domain = new ProcessContainerDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public void before() throws Exception {
final var member = new ControlledIdentifierMember(id);
var localRouter = new LocalServer(prefix, member).router(ServerConnectionCache.newBuilder().setTarget(30));
routers.add(localRouter);
var dbUrl = String.format("jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID());
var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofMinutes(1), checkpointDirBase,
Duration.ofMillis(10), 0.00125,
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,
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 3, 10, 0.1);
var domain = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(sealed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,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 dbUrl = String.format("jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1", member.getId(), UUID.randomUUID());
var pdParams = new ProcessDomain.ProcessDomainParameters(dbUrl, Duration.ofSeconds(5), checkpointDirBase,
Duration.ofMillis(10), 0.00125,
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,
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofSeconds(5), 3, 10, 0.1);
var node = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(sealed)
Expand Down Expand Up @@ -116,14 +116,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

0 comments on commit 9726ca1

Please sign in to comment.