Skip to content

Commit 1a8ee8e

Browse files
committed
fix inline usage
1 parent 2006704 commit 1a8ee8e

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class BasicExternalCluster extends Cluster {
6868
private final int reconnectWindow;
6969
private final int voters;
7070
private final boolean consistent;
71+
private final boolean inline;
7172

7273
private final String logConfigExt;
7374
private final int serverHeapSize;
@@ -89,7 +90,7 @@ public class BasicExternalCluster extends Cluster {
8990
private boolean isSafe;
9091

9192
public BasicExternalCluster(Path clusterDirectory, int stripeSize, Path server, int serverHeapSize,
92-
Properties systemProperties, Properties tcProps, int reconnect, int voters, boolean consistent, int serverDebugPort,
93+
Properties systemProperties, Properties tcProps, int reconnect, int voters, boolean consistent, boolean inline, int serverDebugPort,
9394
String logConfigExt, OutputStream parentOutput, ConfigBuilder config, Supplier<StartupCommandBuilder> startupBuilder) {
9495
boolean didCreateDirectories = clusterDirectory.toFile().mkdirs();
9596
if (Files.exists(clusterDirectory)) {
@@ -108,6 +109,7 @@ public BasicExternalCluster(Path clusterDirectory, int stripeSize, Path server,
108109
this.reconnectWindow = reconnect;
109110
this.voters = voters;
110111
this.consistent = consistent;
112+
this.inline = inline;
111113
this.serverDebugPortStart = serverDebugPort;
112114
this.logConfigExt = logConfigExt;
113115
this.serverHeapSize = serverHeapSize;
@@ -222,6 +224,8 @@ private void internalStart(CompletableFuture<Void> checker) throws Throwable {
222224

223225
// Configure and install each server in the stripe.
224226
System.setProperty("tc.install-root", server.toString());
227+
systemProperties.setProperty("tc.install-root", server.toString());
228+
225229
configBuilder.withStripeConfiguration(stripeConfig);
226230
Path tcConfig = configBuilder.createConfig(stripeInstallationDir);
227231

@@ -240,11 +244,7 @@ private void internalStart(CompletableFuture<Void> checker) throws Throwable {
240244
.serverWorkingDir(serverWorkingDir)
241245
.logConfigExtension(logConfigExt);
242246

243-
if (serverHeapSize <= 0) {
244-
System.setProperty("com.tc.tc.messages.packup.enabled", "false");
245-
}
246-
247-
ServerInstance serverProcess = serverHeapSize > 0 ?
247+
ServerInstance serverProcess = !inline ?
248248
new ServerProcess(serverName, server, serverWorkingDir, serverHeapSize, debugPort, systemProperties, parentOutput, builder.build())
249249
:
250250
new InlineServer(serverName, server, serverWorkingDir, systemProperties, parentOutput, builder.build());

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public class BasicExternalClusterBuilder {
4545
private int reconnectWindow = ConfigConstants.DEFAULT_CLIENT_RECONNECT_WINDOW;
4646
private int voters = ConfigConstants.DEFAULT_VOTER_COUNT;
4747
private boolean consistent = false;
48+
private boolean inline = true;
4849

4950
private String logConfigExt = "logback-ext.xml";
5051
private int serverHeapSize = DEFAULT_SERVER_HEAP_MB;
51-
private int customHeapSize = DEFAULT_SERVER_HEAP_MB;
5252
private ConfigBuilder configBuilder;
5353
private ServerDeploymentBuilder serverBuilder = new ServerDeploymentBuilder();
5454
private Supplier<StartupCommandBuilder> startupBuilder;
@@ -138,7 +138,6 @@ public BasicExternalClusterBuilder withSystemProperty(String key, String value)
138138

139139
public BasicExternalClusterBuilder withServerHeap(int heapSize) {
140140
this.serverHeapSize = heapSize;
141-
this.customHeapSize = heapSize;
142141
return this;
143142
}
144143

@@ -163,11 +162,11 @@ public BasicExternalClusterBuilder startupBuilder(Supplier<StartupCommandBuilder
163162
}
164163

165164
public BasicExternalClusterBuilder inline(boolean yes) {
165+
inline = yes;
166166
if (yes) {
167167
this.serverHeapSize = -1;
168168
tcProperties.put("tc.messages.packup.enabled", false);
169169
} else {
170-
this.serverHeapSize = customHeapSize;
171170
tcProperties.put("tc.messages.packup.enabled", true);
172171
}
173172
return this;
@@ -201,7 +200,7 @@ public Cluster build() {
201200
int serverDebugStartPort = debugPortString != null ? Integer.parseInt(debugPortString) : 0;
202201

203202
return new BasicExternalCluster(clusterDirectory, stripeSize, this.serverBuilder.deploy(), serverHeapSize, systemProperties, tcProperties,
204-
this.reconnectWindow, this.voters, this.consistent, serverDebugStartPort,
203+
this.reconnectWindow, this.voters, this.consistent, this.inline, serverDebugStartPort,
205204
logConfigExt, parentStream,Optional.ofNullable(configBuilder).orElse(new DefaultLegacyConfigBuilder()),
206205
Optional.ofNullable(startupBuilder).orElse(DefaultStartupCommandBuilder::new));
207206

galvan-support/src/test/java/org/terracotta/functional/ExtendedServerIT.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@
3131
*
3232
*/
3333
public class ExtendedServerIT {
34-
static {
35-
System.setProperty("tc.server-jar", "extended-server");
36-
}
37-
3834
@Rule
3935
public final Cluster CLUSTER = BasicExternalClusterBuilder.newCluster(1).withClientReconnectWindowTime(30)
36+
.inline(false)
4037
.build();
4138

4239
@Test

server-bootstrap/src/main/java/com/tc/server/Directories.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,21 @@ public static Path getServerJar() throws FileNotFoundException {
9393
if (jar == null) {
9494
jar = "tc-server.*\\.jar";
9595
}
96-
Path jarFile = searchForServerJar(getInstallationRoot(), jar);
97-
98-
return jarFile;
96+
Path path = getInstallationRoot();
97+
try {
98+
return searchForServerJar(path, jar);
99+
} catch (NoSuchElementException no) {
100+
throw new FileNotFoundException("searching:" + path + " jar:" + jar);
101+
}
99102
}
100103

101-
private static Path searchForServerJar(Path directory, String name) {
104+
private static Path searchForServerJar(Path directory, String name) throws NoSuchElementException {
102105
try {
103106
Optional<Path> possible = Files.find(directory, 5, (path, o)->{
104107
return path.getFileName().toString().matches(name); }
105108
).findAny();
106-
return possible.orElse(null);
107-
} catch (IOException | NoSuchElementException io) {
109+
return possible.orElseThrow();
110+
} catch (IOException io) {
108111
return null;
109112
}
110113
}

terracotta/src/main/java/com/tc/server/TCServerMain.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,15 @@ public static Future<Boolean> createServer(List<String> args, OutputStream conso
6060
try {
6161
Path serverJar = Directories.getServerJar();
6262

63-
if (serverJar != null) {
64-
ClassLoader serverClassLoader = new URLClassLoader(new URL[] {serverJar.toUri().toURL()}, TCServerMain.class.getClassLoader());
63+
ClassLoader serverClassLoader = new URLClassLoader(new URL[] {serverJar.toUri().toURL()}, TCServerMain.class.getClassLoader());
6564

66-
return ServerFactory.createServer(args, console, serverClassLoader);
67-
}
65+
return ServerFactory.createServer(args, console, serverClassLoader);
6866
} catch (RuntimeException t) {
6967
throw t;
7068
} catch (IOException io) {
7169
throw new UncheckedIOException(io);
7270
} catch (Exception e) {
7371
throw new RuntimeException(e);
7472
}
75-
throw new RuntimeException("server libraries not found");
7673
}
7774
}

0 commit comments

Comments
 (0)