use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.
the class TxDeadlockDetectionMessageMarshallingTest method testMessageUnmarshallWithoutCacheContext.
/**
* @throws Exception If failed.
*/
public void testMessageUnmarshallWithoutCacheContext() throws Exception {
try {
Ignite ignite = startGrid(0);
CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(ccfg);
clientMode = true;
Ignite client = startGrid(1);
final GridCacheSharedContext<Object, Object> clientCtx = ((IgniteKernal) client).context().cache().context();
final CountDownLatch latch = new CountDownLatch(1);
final AtomicBoolean res = new AtomicBoolean();
clientCtx.gridIO().addMessageListener(TOPIC, new GridMessageListener() {
@Override
public void onMessage(UUID nodeId, Object msg) {
if (msg instanceof TxLocksResponse) {
try {
((TxLocksResponse) msg).finishUnmarshal(clientCtx, clientCtx.deploy().globalLoader());
res.set(true);
} catch (Exception e) {
log.error("Message unmarshal failed", e);
} finally {
latch.countDown();
}
}
}
});
GridCacheContext cctx = ((IgniteCacheProxy) cache).context();
KeyCacheObject key = cctx.toCacheKeyObject(1);
TxLocksResponse msg = new TxLocksResponse();
msg.addKey(cctx.txKey(key));
msg.prepareMarshal(cctx.shared());
((IgniteKernal) ignite).context().cache().context().gridIO().sendToCustomTopic(((IgniteKernal) client).localNode(), TOPIC, msg, GridIoPolicy.PUBLIC_POOL);
boolean await = latch.await(1, TimeUnit.SECONDS);
assertTrue(await && res.get());
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxy in project ignite by apache.
the class IgfsCacheSelfTest method testCache.
/**
* Test cache.
*
* @throws Exception If failed.
*/
public void testCache() throws Exception {
final Ignite g = grid();
Collection<IgniteCacheProxy<?, ?>> caches = ((IgniteKernal) g).caches();
info("Caches: " + F.viewReadOnly(caches, new C1<IgniteCacheProxy<?, ?>, Object>() {
@Override
public Object apply(IgniteCacheProxy<?, ?> c) {
return c.getName();
}
}));
assertEquals(1, caches.size());
assert CACHE_NAME.equals(caches.iterator().next().getName());
GridTestUtils.assertThrows(log(), new Callable<Object>() {
@Override
public Object call() throws Exception {
g.cache(((IgniteKernal) g).igfsx("igfs").configuration().getMetaCacheConfiguration().getName());
return null;
}
}, IllegalStateException.class, null);
GridTestUtils.assertThrows(log(), new Callable<Object>() {
@Override
public Object call() throws Exception {
g.cache(((IgniteKernal) g).igfsx("igfs").configuration().getDataCacheConfiguration().getName());
return null;
}
}, IllegalStateException.class, null);
assert g.cache(CACHE_NAME) != null;
}
Aggregations