Search in sources :

Example 1 with IgniteCacheObjectProcessor

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);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) IgniteException(org.apache.ignite.IgniteException) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IgniteCacheObjectProcessor

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);
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException) WalSegmentTailReachedException(org.apache.ignite.internal.processors.cache.persistence.wal.WalSegmentTailReachedException) FileNotFoundException(java.io.FileNotFoundException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with IgniteCacheObjectProcessor

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);
    }
}
Also used : CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor)

Example 4 with IgniteCacheObjectProcessor

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();
}
Also used : IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) CacheConfigurationOverride(org.apache.ignite.internal.processors.cache.CacheConfigurationOverride)

Example 5 with IgniteCacheObjectProcessor

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());
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) GridNearCacheAdapter(org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) Ignite(org.apache.ignite.Ignite) BinaryObject(org.apache.ignite.binary.BinaryObject) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

IgniteCacheObjectProcessor (org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor)17 IgniteException (org.apache.ignite.IgniteException)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)4 CacheObjectBinaryProcessorImpl (org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl)4 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 ByteBuffer (java.nio.ByteBuffer)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 CacheObjectContext (org.apache.ignite.internal.processors.cache.CacheObjectContext)2 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)2 Nullable (org.jetbrains.annotations.Nullable)2 Test (org.junit.Test)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)1 Duration (javax.cache.expiry.Duration)1 Ignite (org.apache.ignite.Ignite)1 IgniteCacheRestartingException (org.apache.ignite.IgniteCacheRestartingException)1