"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "galvan-support/src/main/java/org/terracotta/testing/rules/BasicExternalCluster.java" between
terracotta-core-5.7.0.tar.gz and terracotta-core-5.7.1.tar.gz

About: Terracotta - Clustering technology for Java ("Network Attached Memory", "Distributed Cache"). Source code of the server (5.x) core components.

BasicExternalCluster.java  (terracotta-core-5.7.0):BasicExternalCluster.java  (terracotta-core-5.7.1)
skipping to change at line 22 skipping to change at line 22
* *
* The Covered Software is Terracotta Core. * The Covered Software is Terracotta Core.
* *
* The Initial Developer of the Covered Software is * The Initial Developer of the Covered Software is
* Terracotta, Inc., a Software AG company * Terracotta, Inc., a Software AG company
* *
*/ */
package org.terracotta.testing.rules; package org.terracotta.testing.rules;
import com.tc.util.Assert; import com.tc.util.Assert;
import com.tc.util.PortChooser;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.terracotta.connection.Connection; import org.terracotta.connection.Connection;
import org.terracotta.connection.ConnectionException; import org.terracotta.connection.ConnectionException;
import org.terracotta.connection.ConnectionFactory; import org.terracotta.connection.ConnectionFactory;
import org.terracotta.passthrough.IClusterControl; import org.terracotta.passthrough.IClusterControl;
import org.terracotta.testing.config.StartupCommandBuilder; import org.terracotta.testing.config.StartupCommandBuilder;
import org.terracotta.testing.config.StripeConfiguration; import org.terracotta.testing.config.StripeConfiguration;
import org.terracotta.testing.config.TcConfigBuilder; import org.terracotta.testing.config.TcConfigBuilder;
import org.terracotta.testing.logging.VerboseLogger; import org.terracotta.testing.logging.VerboseLogger;
skipping to change at line 49 skipping to change at line 48
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
import java.net.URI; import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.IntStream;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.terracotta.testing.config.ConfigConstants.DEFAULT_SERVER_HEAP_ import static java.util.stream.Collectors.toList;
MB;
import org.terracotta.testing.logging.ContextualLogger; import org.terracotta.testing.logging.ContextualLogger;
import org.terracotta.testing.master.FileHelpers; import org.terracotta.testing.master.FileHelpers;
import org.terracotta.testing.support.PortTool;
import org.terracotta.utilities.test.net.PortManager;
/** /**
* @author cdennis * @author cdennis
*/ */
class BasicExternalCluster extends Cluster { class BasicExternalCluster extends Cluster {
private final Path clusterDirectory; private final Path clusterDirectory;
private final int stripeSize; private final int stripeSize;
private final Set<Path> serverJars; private final Set<Path> serverJars;
private final String namespaceFragment; private final String namespaceFragment;
skipping to change at line 167 skipping to change at line 171
Path kitDir = Paths.get(kitInstallationPath); Path kitDir = Paths.get(kitInstallationPath);
File testParentDir = File.createTempFile(displayName, "", clusterDirectory.t oFile()); File testParentDir = File.createTempFile(displayName, "", clusterDirectory.t oFile());
testParentDir.delete(); testParentDir.delete();
testParentDir.mkdir(); testParentDir.mkdir();
String debugPortString = System.getProperty("serverDebugPortStart"); String debugPortString = System.getProperty("serverDebugPortStart");
int serverDebugStartPort = debugPortString != null ? Integer.parseInt(debugP ortString) : 0; int serverDebugStartPort = debugPortString != null ? Integer.parseInt(debugP ortString) : 0;
stateManager = new TestStateManager(); stateManager = new TestStateManager();
interlock = new GalvanStateInterlock(verboseManager.createComponentManager(" [Interlock]").createHarnessLogger(), stateManager); interlock = new GalvanStateInterlock(verboseManager.createComponentManager(" [Interlock]").createHarnessLogger(), stateManager);
List<String> serverNames = new ArrayList<>(); /*
List<Integer> serverPorts = new ArrayList<>(); * Debug ports, if requested, are reserved from a specified base port, first
List<Integer> serverGroupPorts = new ArrayList<>(); . This
* provides the best chance of allocating a consecutive list of ports withou
t interference
* from the server and group port reservations.
*/
PortManager portManager = PortManager.getInstance();
List<PortManager.PortRef> debugPortRefs = new ArrayList<>();
List<Integer> serverDebugPorts = new ArrayList<>(); List<Integer> serverDebugPorts = new ArrayList<>();
int basePort = new PortChooser().chooseRandomPorts(stripeSize * 2); PortTool.assignDebugPorts(portManager, serverDebugStartPort, stripeSize, deb
for (int i = 0; i < stripeSize; i++) { ugPortRefs, serverDebugPorts);
serverNames.add("testServer" + i);
serverPorts.add(basePort++); List<PortManager.PortRef> serverPortRefs = portManager.reservePorts(stripeSi
serverGroupPorts.add(basePort++); ze);
serverDebugPorts.add(serverDebugStartPort == 0 ? 0 : serverDebugStartPort+ List<PortManager.PortRef> groupPortRefs = portManager.reservePorts(stripeSiz
+); e);
}
List<Integer> serverPorts = serverPortRefs.stream().map(PortManager.PortRef:
:port).collect(toList());
List<Integer> serverGroupPorts = groupPortRefs.stream().map(PortManager.Port
Ref::port).collect(toList());
List<String> serverNames = IntStream.range(0, stripeSize).mapToObj(i -> "tes
tserver" + i).collect(toList());
String stripeName = "stripe1"; String stripeName = "stripe1";
Path stripeInstallationDir = testParentDir.toPath().resolve(stripeName); Path stripeInstallationDir = testParentDir.toPath().resolve(stripeName);
Files.createDirectory(stripeInstallationDir); Files.createDirectory(stripeInstallationDir);
VerboseManager stripeVerboseManager = displayVerboseManager.createComponentM anager("[" + stripeName + "]"); VerboseManager stripeVerboseManager = displayVerboseManager.createComponentM anager("[" + stripeName + "]");
Path tcConfig = createTcConfig(serverNames, serverPorts, serverGroupPorts, s tripeInstallationDir); Path tcConfig = createTcConfig(serverNames, serverPorts, serverGroupPorts, s tripeInstallationDir);
Path kitLocation = installKit(stripeVerboseManager, kitDir, serverJars, stri peInstallationDir); Path kitLocation = installKit(stripeVerboseManager, kitDir, serverJars, stri peInstallationDir);
skipping to change at line 230 skipping to change at line 239
this.shepherdingThread = new Thread(){ this.shepherdingThread = new Thread(){
@Override @Override
public void run() { public void run() {
setSafeForRun(true); setSafeForRun(true);
boolean didPass = false; boolean didPass = false;
try { try {
stateManager.waitForFinish(); stateManager.waitForFinish();
didPass = true; didPass = true;
} catch (GalvanFailureException e) { } catch (GalvanFailureException e) {
didPass = false; didPass = false;
} } finally {
// Whether we passed or failed, bring everything down. // Whether we passed or failed, bring everything down.
try { try {
interlock.forceShutdown(); interlock.forceShutdown();
} catch (GalvanFailureException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
didPass = false; didPass = false;
} } finally {
setSafeForRun(false); setSafeForRun(false);
if (!didPass) {
// Typically, we want to interrupt the thread running as the "client" serverPortRefs.forEach(PortManager.PortRef::close);
as it might be stuck in a connection groupPortRefs.forEach(PortManager.PortRef::close);
// attempt, etc. When Galvan is run in the purely multi-process mode, debugPortRefs.stream().filter(Objects::nonNull).forEach(PortManager.
this is typically where all PortRef::close);
// sub-processes would be terminated. Since we are running the client
as another thread, in-process, the if (!didPass) {
// best we can do is interrupt it from a lower-level blocking call. // Typically, we want to interrupt the thread running as the "clie
// NOTE: the "client" is also the thread which created us and will jo nt" as it might be stuck in a connection
in on our termination, before // attempt, etc. When Galvan is run in the purely multi-process m
// returning back to the user code so it is possible that this interru ode, this is typically where all
ption could be experienced in its // sub-processes would be terminated. Since we are running the cl
// join() call (in which case, we can safely ignore it). ient as another thread, in-process, the
isInterruptingClient = true; // best we can do is interrupt it from a lower-level blocking call
clientThread.interrupt(); .
// NOTE: the "client" is also the thread which created us and wil
l join on our termination, before
// returning back to the user code so it is possible that this int
erruption could be experienced in its
// join() call (in which case, we can safely ignore it).
isInterruptingClient = true;
clientThread.interrupt();
}
}
} }
} }
}; };
this.shepherdingThread.setName("Shepherding Thread"); this.shepherdingThread.setName("Shepherding Thread");
this.shepherdingThread.start(); this.shepherdingThread.start();
waitForSafe(); waitForSafe();
} }
private Path relativize(Path root, Path other) { private Path relativize(Path root, Path other) {
return root.toAbsolutePath().relativize(other.toAbsolutePath()); return root.toAbsolutePath().relativize(other.toAbsolutePath());
 End of changes. 8 change blocks. 
38 lines changed or deleted 62 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)