Skip to content

Commit

Permalink
properly parameterize ProcessDomain
Browse files Browse the repository at this point in the history
Geebus :)
  • Loading branch information
Hellblazer committed Dec 25, 2023
1 parent ce58802 commit e13a72a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,15 @@ 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 node = new ProcessContainerDomain(group, member, params, "jdbc:h2:mem:", checkpointDirBase,
RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(localRouter),
var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:", Duration.ofMinutes(1),
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 10);
var node = new ProcessContainerDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(
sealed)
.setContext(context)
.setCommunications(
localRouter),
new InetSocketAddress(0), commsDirectory, ffParams,
IdentifierSpecification.newBuilder(), null);
domains.add(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public class ProcessContainerDomain extends ProcessDomain {
private final Map<String, DomainSocketAddress> routes = new HashMap<>();
private final IdentifierSpecification.Builder<SelfAddressingIdentifier> subDomainSpecification;

public ProcessContainerDomain(Digest group, ControlledIdentifierMember member, Parameters.Builder builder,
String dbURL, Path checkpointBaseDir, Parameters.RuntimeParameters.Builder runtime,
public ProcessContainerDomain(Digest group, ControlledIdentifierMember member, ProcessDomainParameters parameters,
Parameters.Builder builder, Parameters.RuntimeParameters.Builder runtime,
InetSocketAddress endpoint, Path commDirectory,
com.salesforce.apollo.fireflies.Parameters.Builder ff,
IdentifierSpecification.Builder<SelfAddressingIdentifier> subDomainSpecification,
StereotomyMetrics stereotomyMetrics) {
super(group, member, builder, dbURL, checkpointBaseDir, runtime, endpoint, ff, stereotomyMetrics);
super(group, member, parameters, builder, runtime, endpoint, ff, stereotomyMetrics);
communicationsDirectory = commDirectory;
bridge = new DomainSocketAddress(communicationsDirectory.resolve(UUID.randomUUID().toString()).toFile());
portalEndpoint = new DomainSocketAddress(
Expand Down
36 changes: 21 additions & 15 deletions model/src/main/java/com/salesforce/apollo/model/ProcessDomain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@
*/
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;

public ProcessDomain(Digest group, ControlledIdentifierMember member, Builder builder, String dbURL,
Path checkpointBaseDir, Parameters.RuntimeParameters.Builder runtime,
InetSocketAddress endpoint, com.salesforce.apollo.fireflies.Parameters.Builder ff,
StereotomyMetrics stereotomyMetrics) {
super(member, builder, dbURL, checkpointBaseDir, runtime);
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,
com.salesforce.apollo.fireflies.Parameters.Builder ff, StereotomyMetrics stereotomyMetrics) {
super(member, builder, parameters.dbURL, parameters.checkpointBaseDir, runtime);
var base = Context.<Participant>newBuilder().setId(group).build();
final var url = String.format("jdbc:h2:mem:%s-%s;DB_CLOSE_DELAY=-1", member.getId(), "");
JdbcConnectionPool connectionPool = JdbcConnectionPool.create(url, "", "");
dht = new KerlDHT(Duration.ofMillis(10), base, member, connectionPool, params.digestAlgorithm(),
params.communications(), Duration.ofSeconds(1), 0.00125, stereotomyMetrics);
this.foundation = new View(base, getMember(), endpoint, dht.getAni().eventValidation(Duration.ofSeconds(30)),
params.communications(), ff.build(), DigestAlgorithm.DEFAULT, null);
connectionPool.setMaxConnections(10);
dht = new KerlDHT(parameters.dhtOpsFrequency, base, member, connectionPool, params.digestAlgorithm(),
params.communications(), parameters.dhtOperationsTimeout, parameters.dhtFpr,
stereotomyMetrics);
this.foundation = new View(base, getMember(), endpoint,
dht.getAni().eventValidation(parameters.dhtEventValidTO), params.communications(),
ff.build(), DigestAlgorithm.DEFAULT, null);
listener = foundation.register(listener());
}

Expand Down Expand Up @@ -117,4 +117,10 @@ protected void startServices() {
protected void stopServices() {
dht.stop();
}

public record ProcessDomainParameters(String dbURL, Duration dhtOperationsTimeout, Path checkpointBaseDir,
Duration dhtOpsFrequency, double dhtFpr, Duration dhtEventValidTO,
int jdbcMaxConnections) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ 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 domain = new ProcessContainerDomain(group, member, params, "jdbc:h2:mem:", checkpointDirBase,
RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(localRouter),
var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:", Duration.ofMinutes(1),
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 10);
var domain = new ProcessContainerDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(
sealed)
.setContext(
context)
.setCommunications(
localRouter),
new InetSocketAddress(0), commsDirectory, ffParams,
IdentifierSpecification.newBuilder(), null);
domains.add(domain);
Expand Down
15 changes: 9 additions & 6 deletions model/src/test/java/com/salesforce/apollo/model/DomainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,15 @@ 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 domain = new ProcessDomain(group, member, params, "jdbc:h2:mem:", checkpointDirBase,
RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(localRouter), new InetSocketAddress(0),
ffParams, null);
var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:", Duration.ofMinutes(1),
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 10);
var domain = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(
localRouter),
new InetSocketAddress(0), ffParams, null);
domains.add(domain);
localRouter.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ 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 node = new ProcessDomain(group, member, params, "jdbc:h2:mem:", checkpointDirBase,
RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(localRouter), new InetSocketAddress(0),
ffParams, null);
var pdParams = new ProcessDomain.ProcessDomainParameters("jdbc:h2:mem:", Duration.ofMinutes(1),
checkpointDirBase, Duration.ofMillis(10), 0.00125,
Duration.ofMinutes(1), 10);
var node = new ProcessDomain(group, member, pdParams, params, RuntimeParameters.newBuilder()
.setFoundation(sealed)
.setContext(context)
.setCommunications(
localRouter),
new InetSocketAddress(0), ffParams, null);
domains.add(node);
routers.put(node, localRouter);
localRouter.start();
Expand Down

0 comments on commit e13a72a

Please sign in to comment.