use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor in project ignite by apache.
the class CacheObjectImpl method value.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Nullable
@Override
public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
cpy = cpy && needCopy(ctx);
try {
GridKernalContext kernalCtx = ctx.kernalContext();
IgniteCacheObjectProcessor proc = ctx.kernalContext().cacheObjects();
if (cpy) {
if (valBytes == null) {
assert val != null;
valBytes = proc.marshal(ctx, val);
}
ClassLoader clsLdr;
if (val != null)
clsLdr = val.getClass().getClassLoader();
else if (kernalCtx.config().isPeerClassLoadingEnabled())
clsLdr = kernalCtx.cache().context().deploy().globalLoader();
else
clsLdr = null;
return (T) proc.unmarshal(ctx, valBytes, clsLdr);
}
if (val != null)
return (T) val;
assert valBytes != null;
Object val = proc.unmarshal(ctx, valBytes, kernalCtx.config().isPeerClassLoadingEnabled() ? kernalCtx.cache().context().deploy().globalLoader() : null);
if (ctx.storeValue())
this.val = val;
return (T) val;
} catch (IgniteCheckedException e) {
throw new IgniteException("Failed to unmarshall object.", e);
}
}
use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor in project ignite by apache.
the class StandaloneWalRecordsIterator method postProcessRecord.
/**
* {@inheritDoc}
*/
@Override
@NotNull
protected WALRecord postProcessRecord(@NotNull final WALRecord rec) {
GridKernalContext kernalCtx = sharedCtx.kernalContext();
IgniteCacheObjectProcessor processor = kernalCtx.cacheObjects();
if (processor != null && (rec.type() == RecordType.DATA_RECORD || rec.type() == RecordType.DATA_RECORD_V2 || rec.type() == RecordType.MVCC_DATA_RECORD)) {
try {
return postProcessDataRecord((DataRecord) rec, kernalCtx, processor);
} catch (Exception e) {
log.error("Failed to perform post processing for data record ", e);
}
}
return super.postProcessRecord(rec);
}
use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor in project ignite by apache.
the class GridQueryProcessor method registerTypeLocally.
/**
* Register class metadata locally if it didn't do it earlier.
*
* @param clsName Class name for which the metadata should be registered.
* @param platformOnly Whether to only register non-Java platform types only.
* @throws BinaryObjectException if register was failed.
*/
private void registerTypeLocally(String clsName, boolean platformOnly) throws BinaryObjectException {
if (clsName == null)
return;
IgniteCacheObjectProcessor cacheObjProc = ctx.cacheObjects();
if (cacheObjProc instanceof CacheObjectBinaryProcessorImpl) {
CacheObjectBinaryProcessorImpl binProc = (CacheObjectBinaryProcessorImpl) cacheObjProc;
Class<?> cls = U.box(U.classForName(clsName, null, true));
if (cls != null) {
if (!platformOnly)
binProc.binaryContext().registerClass(cls, true, false, true);
} else
registerPlatformTypeLocally(clsName, binProc);
}
}
use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor in project ignite by apache.
the class IgniteKernal method binary.
/**
* {@inheritDoc}
*/
@Override
public IgniteBinary binary() {
checkClusterState();
IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
return objProc.binary();
}
use of org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor 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());
}
}
Aggregations