use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class GridCacheContext method readResolve.
/**
* Reconstructs object on unmarshalling.
*
* @return Reconstructed object.
* @throws ObjectStreamException Thrown in case of unmarshalling error.
*/
protected Object readResolve() throws ObjectStreamException {
try {
IgniteBiTuple<String, String> t = stash.get();
IgniteKernal grid = IgnitionEx.localIgnite();
GridCacheAdapter<K, V> cache = grid.internalCache(t.get2());
if (cache == null)
throw new IllegalStateException("Failed to find cache for name: " + t.get2());
return cache.context();
} catch (IllegalStateException e) {
throw U.withCause(new InvalidObjectException(e.getMessage()), e);
} finally {
stash.remove();
}
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class GridCacheQueryJdbcMetadataTask method map.
/**
* {@inheritDoc}
*/
@NotNull
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable String cacheName) {
Map<JdbcDriverMetadataJob, ClusterNode> map = new HashMap<>();
IgniteKernal kernal = (IgniteKernal) ignite;
GridDiscoveryManager discoMgr = kernal.context().discovery();
for (ClusterNode n : subgrid) if (discoMgr.cacheAffinityNode(n, cacheName)) {
map.put(new JdbcDriverMetadataJob(cacheName), n);
break;
}
return map;
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class CacheGetEntryAbstractTest method compareVersionWithPrimaryNode.
/**
* @param e Entry.
* @param cache Cache.
* @throws Exception If failed.
*/
private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue> cache) throws Exception {
CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
if (cfg.getCacheMode() != LOCAL) {
Ignite prim = primaryNode(e.getKey(), cache.getName());
GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal) prim).internalCache(cache.getName());
if (cfg.getNearConfiguration() != null)
cacheAdapter = ((GridNearCacheAdapter) cacheAdapter).dht();
IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
GridCacheEntryEx mapEntry = cacheAdapter.entryEx(cacheObjects.toCacheKeyObject(cacheObjCtx, cacheAdapter.context(), e.getKey(), true));
mapEntry.unswap();
assertNotNull("No entry for key: " + e.getKey(), mapEntry);
assertEquals(mapEntry.version(), e.version());
}
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class GridCacheBinaryObjectsAbstractSelfTest method afterTest.
/**
* {@inheritDoc}
*/
@Override
protected void afterTest() throws Exception {
for (int i = 0; i < gridCount(); i++) {
GridCacheAdapter<Object, Object> c = ((IgniteKernal) grid(i)).internalCache(DEFAULT_CACHE_NAME);
for (GridCacheEntryEx e : c.map().entries(c.context().cacheId())) {
Object key = e.key().value(c.context().cacheObjectContext(), false);
Object val = CU.value(e.rawGet(), c.context(), false);
if (key instanceof BinaryObject)
assert ((BinaryObjectImpl) key).detached() : val;
if (val instanceof BinaryObject)
assert ((BinaryObjectImpl) val).detached() : val;
}
}
IgniteCache<Object, Object> c = jcache(0);
for (int i = 0; i < ENTRY_CNT; i++) c.remove(i);
assertEquals(0, c.size());
}
use of org.apache.ignite.internal.IgniteKernal in project ignite by apache.
the class ViewCacheClosure method call.
/**
* {@inheritDoc}
*/
@Override
public List<CacheInfo> call() throws Exception {
Pattern compiled = Pattern.compile(regex);
List<CacheInfo> cacheInfo = new ArrayList<>();
IgniteKernal k = (IgniteKernal) ignite;
if (cmd == null)
cmd = VisorViewCacheCmd.CACHES;
switch(cmd) {
case SEQ:
collectSequences(k.context(), compiled, cacheInfo);
return cacheInfo;
case GROUPS:
Collection<CacheGroupContext> contexts = k.context().cache().cacheGroups();
for (CacheGroupContext context : contexts) {
if (!context.userCache() || !compiled.matcher(context.cacheOrGroupName()).find())
continue;
CacheInfo ci = new CacheInfo();
ci.setGrpName(context.cacheOrGroupName());
ci.setGrpId(context.groupId());
ci.setCachesCnt(context.caches().size());
ci.setPartitions(context.config().getAffinity().partitions());
ci.setBackupsCnt(context.config().getBackups());
ci.setAffinityClsName(context.config().getAffinity().getClass().getSimpleName());
ci.setMode(context.config().getCacheMode());
ci.setAtomicityMode(context.config().getAtomicityMode());
ci.setMapped(mapped(context.caches().iterator().next().name()));
cacheInfo.add(ci);
}
return cacheInfo;
default:
Map<String, DynamicCacheDescriptor> descMap = k.context().cache().cacheDescriptors();
for (Map.Entry<String, DynamicCacheDescriptor> entry : descMap.entrySet()) {
DynamicCacheDescriptor desc = entry.getValue();
if (!desc.cacheType().userCache() || !compiled.matcher(desc.cacheName()).find())
continue;
CacheInfo ci = new CacheInfo();
ci.setCacheName(desc.cacheName());
ci.setCacheId(desc.cacheId());
ci.setGrpName(desc.groupDescriptor().groupName());
ci.setGrpId(desc.groupDescriptor().groupId());
ci.setPartitions(desc.cacheConfiguration().getAffinity().partitions());
ci.setBackupsCnt(desc.cacheConfiguration().getBackups());
ci.setAffinityClsName(desc.cacheConfiguration().getAffinity().getClass().getSimpleName());
ci.setMode(desc.cacheConfiguration().getCacheMode());
ci.setAtomicityMode(desc.cacheConfiguration().getAtomicityMode());
ci.setMapped(mapped(desc.cacheName()));
cacheInfo.add(ci);
}
return cacheInfo;
}
}
Aggregations