Skip to content

Commit 3e4a002

Browse files
committed
Add support for customizing the server heap size
1 parent e34a3f6 commit 3e4a002

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

galvan-support/src/main/java/org/terracotta/testing/rules/BasicExternalCluster.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class BasicExternalCluster extends Cluster {
7171
private final Properties tcProperties = new Properties();
7272
private final Properties systemProperties = new Properties();
7373
private final String logConfigExt;
74+
private final int serverHeapSize;
7475
private final Supplier<StartupCommandBuilder> startupBuilder;
7576

7677
private String displayName;
@@ -87,7 +88,7 @@ class BasicExternalCluster extends Cluster {
8788

8889
BasicExternalCluster(Path clusterDirectory, int stripeSize, Set<Path> serverJars, String namespaceFragment,
8990
String serviceFragment, int clientReconnectWindow, int voterCount, boolean consistentStart, Properties tcProperties,
90-
Properties systemProperties, String logConfigExt, Supplier<StartupCommandBuilder> startupBuilder) {
91+
Properties systemProperties, String logConfigExt, int serverHeapSize, Supplier<StartupCommandBuilder> startupBuilder) {
9192
if (Files.exists(clusterDirectory)) {
9293
if (Files.isRegularFile(clusterDirectory)) {
9394
throw new IllegalArgumentException("Cluster directory is a file: " + clusterDirectory);
@@ -110,6 +111,7 @@ class BasicExternalCluster extends Cluster {
110111
this.tcProperties.putAll(tcProperties);
111112
this.systemProperties.putAll(systemProperties);
112113
this.logConfigExt = logConfigExt;
114+
this.serverHeapSize = serverHeapSize;
113115
this.startupBuilder = startupBuilder;
114116
this.clientThread = Thread.currentThread();
115117
}
@@ -184,7 +186,7 @@ private void internalStart() throws Throwable {
184186
Path kitLocation = installKit(stripeVerboseManager, kitDir, serverJars, stripeInstallationDir);
185187

186188
StripeConfiguration stripeConfig = new StripeConfiguration(serverDebugPorts, serverPorts, serverGroupPorts, serverNames,
187-
stripeName, DEFAULT_SERVER_HEAP_MB, logConfigExt, systemProperties);
189+
stripeName, serverHeapSize, logConfigExt, systemProperties);
188190
StripeInstaller stripeInstaller = new StripeInstaller(interlock, stateManager, stripeVerboseManager, stripeConfig);
189191
// Configure and install each server in the stripe.
190192
for (int i = 0; i < stripeSize; ++i) {

galvan-support/src/main/java/org/terracotta/testing/rules/BasicExternalClusterBuilder.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.function.Supplier;
3030

3131
import static org.terracotta.testing.config.ConfigConstants.DEFAULT_CLIENT_RECONNECT_WINDOW;
32+
import static org.terracotta.testing.config.ConfigConstants.DEFAULT_SERVER_HEAP_MB;
3233
import static org.terracotta.testing.config.ConfigConstants.DEFAULT_VOTER_COUNT;
3334

3435
public class BasicExternalClusterBuilder {
@@ -44,6 +45,7 @@ public class BasicExternalClusterBuilder {
4445
private Properties tcProperties = new Properties();
4546
private Properties systemProperties = new Properties();
4647
private String logConfigExt = "logback-ext.xml";
48+
private int serverHeapSize = DEFAULT_SERVER_HEAP_MB;
4749
private Supplier<StartupCommandBuilder> startupBuilder = DefaultStartupCommandBuilder::new;
4850

4951
private BasicExternalClusterBuilder(final int stripeSize) {
@@ -127,6 +129,11 @@ public BasicExternalClusterBuilder withSystemProperty(String key, String value)
127129
return this;
128130
}
129131

132+
public BasicExternalClusterBuilder withServerHeap(int heapSize) {
133+
this.serverHeapSize = heapSize;
134+
return this;
135+
}
136+
130137
public BasicExternalClusterBuilder logConfigExtensionResourceName(String logConfigExt) {
131138
this.logConfigExt = logConfigExt;
132139
return this;
@@ -144,6 +151,7 @@ public BasicExternalClusterBuilder withConsistentStartup(boolean consistent) {
144151

145152
public Cluster build() {
146153
return new BasicExternalCluster(clusterDirectory, stripeSize, serverJars, namespaceFragment, serviceFragment,
147-
clientReconnectWindowTime, failoverPriorityVoterCount, consistentStart, tcProperties, systemProperties, logConfigExt, startupBuilder);
154+
clientReconnectWindowTime, failoverPriorityVoterCount, consistentStart, tcProperties, systemProperties,
155+
logConfigExt, serverHeapSize, startupBuilder);
148156
}
149157
}

0 commit comments

Comments
 (0)