use of org.apache.ignite.internal.util.GridJavaProcess in project ignite by apache.
the class IpcSharedMemoryCrashDetectionSelfTest method startSharedMemoryTestServer.
/**
* Starts {@code IgfsSharedMemoryTestServer}. The method waits while server being started.
*
* @return Start result of the {@code IgfsSharedMemoryTestServer}.
* @throws Exception In case of any exception happen.
*/
private ProcessStartResult startSharedMemoryTestServer() throws Exception {
final CountDownLatch srvReady = new CountDownLatch(1);
final CountDownLatch isKilledLatch = new CountDownLatch(1);
GridJavaProcess proc = GridJavaProcess.exec(IgfsSharedMemoryTestServer.class, null, log, new CI1<String>() {
@Override
public void apply(String str) {
info("Server process prints: " + str);
if (str.contains("IPC shared memory server endpoint started"))
srvReady.countDown();
}
}, new CA() {
@Override
public void apply() {
info("Server is killed");
isKilledLatch.countDown();
}
}, null, System.getProperty("surefire.test.class.path"));
srvReady.await();
ProcessStartResult res = new ProcessStartResult();
res.proc(proc);
res.isKilledLatch(isKilledLatch);
return res;
}
use of org.apache.ignite.internal.util.GridJavaProcess in project ignite by apache.
the class IpcSharedMemoryCrashDetectionSelfTest method startSharedMemoryTestClient.
/**
* Starts {@code IgfsSharedMemoryTestClient}. The method doesn't wait while client being started.
*
* @return Start result of the {@code IgfsSharedMemoryTestClient}.
* @throws Exception In case of any exception happen.
*/
private ProcessStartResult startSharedMemoryTestClient() throws Exception {
/**
*/
final CountDownLatch killedLatch = new CountDownLatch(1);
/**
*/
final CountDownLatch readyLatch = new CountDownLatch(1);
/**
*/
final ProcessStartResult res = new ProcessStartResult();
/**
* Process.
*/
GridJavaProcess proc = GridJavaProcess.exec(IgfsSharedMemoryTestClient.class, null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Client process prints: " + s);
if (s.startsWith(IgfsSharedMemoryTestClient.SHMEM_IDS_MSG_PREFIX)) {
res.shmemIds(s.substring(IgfsSharedMemoryTestClient.SHMEM_IDS_MSG_PREFIX.length()));
readyLatch.countDown();
}
}
}, new CA() {
@Override
public void apply() {
info("Client is killed");
killedLatch.countDown();
}
}, null, System.getProperty("surefire.test.class.path"));
res.proc(proc);
res.isKilledLatch(killedLatch);
res.isReadyLatch(readyLatch);
return res;
}
use of org.apache.ignite.internal.util.GridJavaProcess in project ignite by apache.
the class IgniteNoClassOnServerAbstractTest method testNoClassOnServerNode.
/**
* @throws Exception If failed.
*/
public final void testNoClassOnServerNode() throws Exception {
info("Run test with client: " + clientClassName());
// Check class is really not available.
try {
Class.forName("org.apache.ignite.tests.p2p.cache.Person");
fail();
} catch (ClassNotFoundException ignore) {
// Expected exception.
}
try (Ignite ignite = Ignition.start(createConfiguration())) {
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
// To store only value bytes.
cfg.setCopyOnRead(true);
ignite.createCache(cfg);
final CountDownLatch clientReadyLatch = new CountDownLatch(1);
Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
GridJavaProcess clientNode = null;
try {
String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
clientNode = GridJavaProcess.exec(clientClassName(), null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Client node: " + s);
if (s.contains(NODE_START_MSG))
clientReadyLatch.countDown();
}
}, null, null, jvmArgs, cp);
assertTrue(clientReadyLatch.await(60, SECONDS));
int exitCode = clientNode.getProcess().waitFor();
assertEquals("Unexpected exit code", 0, exitCode);
} finally {
if (clientNode != null)
clientNode.killProcess();
}
}
}
use of org.apache.ignite.internal.util.GridJavaProcess in project ignite by apache.
the class CacheConfigurationP2PTest method testCacheConfigurationP2P.
/**
* @throws Exception If failed.
*/
public void testCacheConfigurationP2P() throws Exception {
fail("Enable when IGNITE-537 is fixed.");
try (Ignite ignite = Ignition.start(createConfiguration())) {
final CountDownLatch srvsReadyLatch = new CountDownLatch(2);
final CountDownLatch clientReadyLatch = new CountDownLatch(1);
GridJavaProcess node1 = null;
GridJavaProcess node2 = null;
GridJavaProcess clientNode = null;
Collection<String> jvmArgs = Arrays.asList("-ea", "-DIGNITE_QUIET=false");
try {
node1 = GridJavaProcess.exec(CacheConfigurationP2PTestServer.class.getName(), null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Server node1: " + s);
if (s.contains(NODE_START_MSG))
srvsReadyLatch.countDown();
}
}, null, null, jvmArgs, null);
node2 = GridJavaProcess.exec(CacheConfigurationP2PTestServer.class.getName(), null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Server node2: " + s);
if (s.contains(NODE_START_MSG))
srvsReadyLatch.countDown();
}
}, null, null, jvmArgs, null);
assertTrue(srvsReadyLatch.await(60, SECONDS));
String cp = U.getIgniteHome() + "/modules/extdata/p2p/target/classes/";
clientNode = GridJavaProcess.exec(CLIENT_CLS_NAME, null, log, new CI1<String>() {
@Override
public void apply(String s) {
info("Client node: " + s);
if (s.contains(NODE_START_MSG))
clientReadyLatch.countDown();
}
}, null, null, jvmArgs, cp);
assertTrue(clientReadyLatch.await(60, SECONDS));
int exitCode = clientNode.getProcess().waitFor();
assertEquals("Unexpected exit code", 0, exitCode);
node1.killProcess();
node2.killProcess();
final DiscoverySpi spi = ignite.configuration().getDiscoverySpi();
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
Map p2pLdrs = GridTestUtils.getFieldValue(spi, "p2pLdrs");
log.info("p2pLdrs: " + p2pLdrs.size());
return p2pLdrs.isEmpty();
}
}, 10_000);
assertTrue(wait);
} finally {
if (node1 != null)
node1.killProcess();
if (node2 != null)
node2.killProcess();
if (clientNode != null)
clientNode.killProcess();
}
}
}
Aggregations