/** * @return Binary processor. */ public IgniteCacheObjectProcessor cacheObjects() { return kernalContext().cacheObjects(); }
/** {@inheritDoc} */ @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException { if (valBytes == null) valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); return valBytes; }
/** {@inheritDoc} */ @Override public void ignite(Ignite ignite) { super.ignite(ignite); if (ignite != null) { IgniteKernal kernal = (IgniteKernal)ignite; proc = (CacheObjectBinaryProcessorImpl)kernal.context().cacheObjects(); } } }
/** {@inheritDoc} */ @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException { if (valBytes == null) valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); return valBytes; }
/** {@inheritDoc} */ @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { assert val != null || valBytes != null; if (valBytes == null) valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); }
/** {@inheritDoc} */ @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException { if (valBytes == null) valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); }
/** {@inheritDoc} */ @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { if (val == null) { assert valBytes != null; val = ctx.kernalContext().cacheObjects().unmarshal(ctx, valBytes, ldr); } }
/** {@inheritDoc} */ @Nullable @Override public GridCacheMapEntry getEntry(GridCacheContext ctx, KeyCacheObject key) { CacheMapHolder hld = entriesMapIfExists(ctx.cacheIdBoxed()); key = (KeyCacheObject)ctx.kernalContext().cacheObjects().prepareForCache(key, ctx); return hld != null ? hld.map.get(key) : null; }
/** * @param ctx Context. * @return {@code True} need to copy value returned to user. */ private boolean needCopy(CacheObjectValueContext ctx) { return ctx.copyOnGet() && obj != null && !ctx.kernalContext().cacheObjects().immutable(obj); }
/** * @param bytes Bytes. * @param ldr Class loader. * @return Object. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unchecked") private <Z> Z unmarshall(byte[] bytes, ClassLoader ldr) throws IgniteCheckedException { if (coctx == null) // For tests. return (Z)JdbcUtils.deserialize(bytes, null); return (Z)coctx.kernalContext().cacheObjects().unmarshal(coctx, bytes, ldr); }
/** * Returns cache object context if created or creates new and caches it until cache started. * * @param cacheId Cache id. */ @Nullable public CacheObjectContext cacheObjectContext(int cacheId) throws IgniteCheckedException { GridCacheContext<K, V> ctx = ctxMap.get(cacheId); if (ctx != null) return ctx.cacheObjectContext(); DynamicCacheDescriptor desc = cache().cacheDescriptor(cacheId); return desc != null ? desc.cacheObjectContext(kernalContext().cacheObjects()) : null; }
/** {@inheritDoc} */ @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException { assert val != null || valBytes != null; if (val == null && ctx.storeValue()) val = ctx.kernalContext().cacheObjects().unmarshal(ctx, valBytes, ldr); }
/** * @param ctx Context. * @return {@code True} need to copy value returned to user. */ protected boolean needCopy(CacheObjectValueContext ctx) { return ctx.copyOnGet() && val != null && !ctx.kernalContext().cacheObjects().immutable(val); }
/** * @param bytes Bytes. * @return Cache key object. * @throws IgniteCheckedException If failed. */ public KeyCacheObject toCacheKeyObject(byte[] bytes) throws IgniteCheckedException { Object obj = ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, deploy().localLoader()); return cacheObjects().toCacheKeyObject(cacheObjCtx, this, obj, false); }
/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { BinaryContext binCtx = ((CacheObjectBinaryProcessorImpl) ctx.kernalContext().cacheObjects()).binaryContext(); binCtx.updateMetadata(meta.typeId(), meta, false); return super.process(ctx); } }
/** {@inheritDoc} */ @Override public CacheObject value() { if (val == null && valBytes != null) { GridCacheContext cacheCtx = cctx.cacheContext(cacheId); if (cacheCtx == null) throw new IgniteException("Failed to find cache context for the given cache ID: " + cacheId); IgniteCacheObjectProcessor co = cctx.kernalContext().cacheObjects(); val = co.toCacheObject(cacheCtx.cacheObjectContext(), valType, valBytes); } return val; }
/** {@inheritDoc} */ @Override public CacheObject value() { if (val == null && valBytes != null) { GridCacheContext cacheCtx = cctx.cacheContext(cacheId); if (cacheCtx == null) throw new IgniteException("Failed to find cache context for the given cache ID: " + cacheId); IgniteCacheObjectProcessor co = cctx.kernalContext().cacheObjects(); val = co.toCacheObject(cacheCtx.cacheObjectContext(), valType, valBytes); } return val; }
/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { BinaryTypeImpl type = (BinaryTypeImpl)ctx.kernalContext().cacheObjects().binary().type(typeId); return new ClientBinaryTypeGetResponse(requestId(), type != null ? type.metadata() : null); } }
/** * Initialize query infrastructure for not started cache. * * @param cacheDesc Cache descriptor. * @throws IgniteCheckedException If failed. */ public void initQueryStructuresForNotStartedCache(DynamicCacheDescriptor cacheDesc) throws IgniteCheckedException { QuerySchema schema = cacheDesc.schema() != null ? cacheDesc.schema() : new QuerySchema(); CacheObjectContext coCtx = cacheDesc.cacheObjectContext(ctx.cacheObjects()); GridCacheContextInfo cacheInfo = new GridCacheContextInfo(cacheDesc); ctx.query().onCacheStart(cacheInfo, schema, cacheDesc.sql()); }
@Override public AffinityInfo applyx(IgniteInternalFuture<GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment>> fut) throws IgniteCheckedException { GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> t = fut.get(); AffinityFunction f = (AffinityFunction)unmarshall(ctx, n.id(), t.get1()); AffinityKeyMapper m = (AffinityKeyMapper)unmarshall(ctx, n.id(), t.get2()); assert m != null; // Bring to initial state. f.reset(); m.reset(); CacheConfiguration ccfg = ctx.cache().cacheConfiguration(cacheName); return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(ccfg)); } });