use of org.apache.ignite.internal.util.lang.GridAbsPredicate in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method waitSegmented.
/**
* @param ignite Ignite.
* @throws Exception If failed.
*/
private void waitSegmented(final Ignite ignite) throws Exception {
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return IgniteState.STOPPED_ON_SEGMENTATION == Ignition.state(ignite.name());
}
}, 5000);
assertEquals(IgniteState.STOPPED_ON_SEGMENTATION, Ignition.state(ignite.name()));
}
use of org.apache.ignite.internal.util.lang.GridAbsPredicate in project ignite by apache.
the class TcpDiscoverySelfTest method waitNodeStop.
/**
* @param nodeName Node name.
* @throws Exception If failed.
*/
private void waitNodeStop(final String nodeName) throws Exception {
boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
try {
Ignition.ignite(nodeName);
return false;
} catch (IgniteIllegalStateException ignored) {
return true;
}
}
}, 30_000);
if (!wait)
U.dumpThreads(log);
assertTrue("Failed to wait for node stop.", wait);
}
use of org.apache.ignite.internal.util.lang.GridAbsPredicate in project ignite by apache.
the class TcpDiscoverySelfTest method testIpFinderCleaning.
/**
* @throws Exception If any error occurs.
*/
public void testIpFinderCleaning() throws Exception {
try {
ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("1.1.1.1", 1024), new InetSocketAddress("1.1.1.2", 1024)));
Ignite g1 = startGrid(1);
long failureDetectTimeout = g1.configuration().getFailureDetectionTimeout();
long timeout = (long) (discoMap.get(g1.name()).getIpFinderCleanFrequency() * 1.5) + failureDetectTimeout;
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return ipFinder.getRegisteredAddresses().size() == 1;
}
}, timeout);
if (ipFinder.getRegisteredAddresses().size() != 1) {
log.error("Failed to wait for IP cleanup, will dump threads.");
U.dumpThreads(log);
}
assert ipFinder.getRegisteredAddresses().size() == 1 : "ipFinder=" + ipFinder.getRegisteredAddresses();
// Check that missing addresses are returned back.
// Unregister valid address.
ipFinder.unregisterAddresses(ipFinder.getRegisteredAddresses());
ipFinder.registerAddresses(Arrays.asList(new InetSocketAddress("1.1.1.1", 1024), new InetSocketAddress("1.1.1.2", 1024)));
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return ipFinder.getRegisteredAddresses().size() == 1;
}
}, timeout);
assert ipFinder.getRegisteredAddresses().size() == 1 : "ipFinder=" + ipFinder.getRegisteredAddresses();
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.util.lang.GridAbsPredicate in project ignite by apache.
the class TcpDiscoveryVmIpFinderSelfTest method testUnregistration.
/**
*/
public void testUnregistration() throws Exception {
Ignition.start(config("server1", false, false));
int srvSize = IP_FINDER.getRegisteredAddresses().size();
Ignition.start(config("server2", false, false));
Ignition.start(config("client1", true, false));
assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size());
Ignition.start(config("client2", true, false));
Ignition.start(config("client3", true, false));
assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size());
Ignition.start(config("client4", true, true));
assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size());
Ignition.stop("client1", true);
Ignition.stop("client2", true);
Ignition.stop("client3", true);
assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size());
Ignition.stop("client4", true);
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return 2 == G.allGrids().size();
}
}, 10000);
Ignition.stop("server1", true);
Ignition.stop("server2", true);
boolean res = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return G.allGrids().isEmpty();
}
}, 10000);
assertTrue(res);
assertTrue(3 * srvSize >= IP_FINDER.getRegisteredAddresses().size());
}
use of org.apache.ignite.internal.util.lang.GridAbsPredicate in project ignite by apache.
the class DiscoveryUnmarshalVulnerabilityTest method testExploit.
/**
* @param positive Positive.
*/
private void testExploit(boolean positive) throws Exception {
try {
startGrid();
attack(marshal(new Exploit()));
boolean res = GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return SHARED.get();
}
}, 3000L);
if (positive)
assertTrue(res);
else
assertFalse(res);
} finally {
stopAllGrids();
}
}
Aggregations