use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class GridServiceProcessorStopSelfTest method testStopDuringHangedDeployment.
/**
* @throws Exception If failed.
*/
public void testStopDuringHangedDeployment() throws Exception {
final CountDownLatch depLatch = new CountDownLatch(1);
final CountDownLatch finishLatch = new CountDownLatch(1);
final IgniteEx node0 = startGrid(0);
final IgniteEx node1 = startGrid(1);
final IgniteEx node2 = startGrid(2);
final IgniteCache<Object, Object> cache = node2.getOrCreateCache(new CacheConfiguration<Object, Object>("def").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
node0.services().deployNodeSingleton("myService", new TestServiceImpl());
// Guarantee lock owner will never left topology unexpectedly.
final Integer lockKey = keyForNode(node2.affinity("def"), new AtomicInteger(1), node2.cluster().localNode());
// Lock to hold topology version undone.
final Lock lock = cache.lock(lockKey);
// Try to change topology once service has deployed.
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
depLatch.await();
node1.close();
return null;
}
}, "top-change-thread");
// Stop node on unstable topology.
GridTestUtils.runAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
depLatch.await();
Thread.sleep(1000);
node0.close();
finishLatch.countDown();
return null;
}
}, "stopping-node-thread");
assertNotNull(node0.services().service("myService"));
// Freeze topology changing
lock.lock();
depLatch.countDown();
boolean wait = finishLatch.await(15, TimeUnit.SECONDS);
if (!wait)
U.dumpThreads(log);
assertTrue("Deploy future isn't completed", wait);
fut.get();
Ignition.stopAll(true);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteServiceProxyTimeoutInitializedTest method testUnavailableService.
/**
* Checks that we limit retries to get not available service by timeout.
*
* @throws Exception If fail.
*/
@SuppressWarnings({ "Convert2Lambda", "ThrowableResultOfMethodCallIgnored" })
public void testUnavailableService() throws Exception {
srvc = new TestWaitServiceImpl();
latch1 = new CountDownLatch(1);
latch2 = new CountDownLatch(1);
try {
GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
startGrid(0);
return null;
}
});
assert latch1.await(1, TimeUnit.MINUTES);
final IgniteEx ignite1 = startGrid(1);
final TestService testSrvc = ignite1.services().serviceProxy("testService", TestService.class, false, 500);
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override
public Object call() throws Exception {
testSrvc.test();
return null;
}
}, IgniteException.class, null);
} finally {
latch2.countDown();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteServiceProxyTimeoutInitializedTest method testServiceException.
/**
* Checks that service not hangs if timeout set. Here we get hang with marshalling exception.
*
* @throws Exception If fail.
*/
@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored", "Convert2Lambda" })
public void testServiceException() throws Exception {
srvc = new HangServiceImpl();
// Start service grid.
startGrid(0);
final IgniteEx ignite1 = startGrid(1);
final HangService testSrvc = ignite1.services().serviceProxy("testService", HangService.class, false, 1_000);
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override
public Object call() throws Exception {
testSrvc.hang();
return null;
}
}, ComputeTaskTimeoutException.class, null);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testSingleCache.
/**
* @throws Exception If failed.
*/
public void testSingleCache() throws Exception {
final PersonsCountGetter personsCntGetter = new PersonsCountGetter() {
@Override
public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception {
return getPersonsCountSingleCache(ignite, log, orgId);
}
};
// Run restart threads: start re-balancing.
beginNodesRestart();
IgniteInternalFuture<Long> affFut = null;
try {
final AtomicInteger threadNum = new AtomicInteger(0);
affFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
@Override
public void run() {
if (threadNum.getAndIncrement() % 2 == 0) {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
grid(0).compute().affinityRun(Person.class.getSimpleName(), new Person(0, orgId).createKey(), new TestAffinityRun(personsCntGetter, orgId));
}
}
} else {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
int personsCnt = grid(0).compute().affinityCall(Person.class.getSimpleName(), new Person(0, orgId).createKey(), new TestAffinityCall(personsCntGetter, orgId));
assertEquals(PERS_AT_ORG_CNT, personsCnt);
}
}
}
}
}, AFFINITY_THREADS_CNT, "affinity-run");
} finally {
if (affFut != null)
affFut.get();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method testMultipleCaches.
/**
* @throws Exception If failed.
*/
public void testMultipleCaches() throws Exception {
final PersonsCountGetter personsCntGetter = new PersonsCountGetter() {
@Override
public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception {
return getPersonsCountMultipleCache(ignite, log, orgId);
}
};
// Run restart threads: start re-balancing.
beginNodesRestart();
IgniteInternalFuture<Long> affFut = null;
try {
final AtomicInteger threadNum = new AtomicInteger(0);
affFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
@Override
public void run() {
if (threadNum.getAndIncrement() % 2 == 0) {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
grid(0).compute().affinityRun(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new TestAffinityRun(personsCntGetter, orgId));
}
}
} else {
while (System.currentTimeMillis() < endTime) {
for (final int orgId : orgIds) {
if (System.currentTimeMillis() >= endTime)
break;
int personsCnt = grid(0).compute().affinityCall(Arrays.asList(Organization.class.getSimpleName(), Person.class.getSimpleName()), new Integer(orgId), new TestAffinityCall(personsCntGetter, orgId));
assertEquals(PERS_AT_ORG_CNT, personsCnt);
}
}
}
}
}, AFFINITY_THREADS_CNT, "affinity-run");
} finally {
if (affFut != null)
affFut.get();
}
}
Aggregations