Class GridCacheContext<K,​V>

    • Method Detail

      • finishRecovery

        public void finishRecovery​(AffinityTopologyVersion topVer,
                                   DynamicCacheDescriptor clusterWideDesc)
        Called when cache was restored during recovery and node has joined to topology.
        Parameters:
        topVer - Cache topology join version.
        clusterWideDesc - Cluster-wide cache descriptor received during exchange.
      • isRecoveryMode

        public boolean isRecoveryMode()
        Returns:
        True if cache is in recovery mode.
      • groupId

        public int groupId()
        Returns:
        Cache group ID.
      • dynamicDeploymentId

        public IgniteUuid dynamicDeploymentId()
        Returns:
        Dynamic deployment ID.
      • affinityNode

        public boolean affinityNode()
        Returns:
        True if local node is affinity node.
      • isReplicatedAffinityNode

        public boolean isReplicatedAffinityNode()
        Returns:
        true If this is a replicated cache and we are on a data node.
      • started

        public boolean started()
        Returns:
        Started flag.
      • onStarted

        public void onStarted()
      • startTopologyVersion

        public AffinityTopologyVersion startTopologyVersion()
        Returns:
        Topology version when cache was started on local node.
      • expiry

        @Nullable
        public @Nullable javax.cache.expiry.ExpiryPolicy expiry()
        Returns:
        Cache default ExpiryPolicy.
      • expiryForTxEntry

        @Nullable
        public @Nullable javax.cache.expiry.ExpiryPolicy expiryForTxEntry​(IgniteTxEntry txEntry)
        Parameters:
        txEntry - TX entry.
        Returns:
        Expiry policy for the given TX entry.
      • cacheId

        public int cacheId()
        Returns:
        Cache ID.
      • cacheIdBoxed

        public Integer cacheIdBoxed()
        Returns:
        Cache ID.
      • systemTx

        public boolean systemTx()
        Returns:
        True if should use system transactions which are isolated from user transactions.
      • userCache

        public boolean userCache()
        Returns:
        True if cache created by user.
      • dataStructuresCache

        public boolean dataStructuresCache()
        Returns:
        True if cache created to store data structures.
      • ioPolicy

        public byte ioPolicy()
        Returns:
        IO policy for the given cache.
      • cache

        public void cache​(GridCacheAdapter<K,​V> cache)
        Parameters:
        cache - Cache.
      • isDht

        public boolean isDht()
        Returns:
        True if cache is DHT.
      • isDhtAtomic

        public boolean isDhtAtomic()
        Returns:
        True if cache is DHT atomic.
      • isColocated

        public boolean isColocated()
        Returns:
        True if cache is colocated (dht with near disabled).
      • isNear

        public boolean isNear()
        Returns:
        True if cache is near cache.
      • isReplicated

        public boolean isReplicated()
        Returns:
        True if cache is replicated cache.
      • isPartitioned

        public boolean isPartitioned()
        Returns:
        True if cache is partitioned cache.
      • isDrEnabled

        public boolean isDrEnabled()
        Returns:
        True in case replication is enabled.
      • isQueryEnabled

        public boolean isQueryEnabled()
        Returns:
        True in case cache supports query.
      • deferredDelete

        public boolean deferredDelete()
        Returns:
        True if entries should not be deleted from cache immediately.
      • incrementPublicSize

        public void incrementPublicSize​(GridCacheMapEntry e)
        Parameters:
        e - Entry.
      • decrementPublicSize

        public void decrementPublicSize​(GridCacheMapEntry e)
        Parameters:
        e - Entry.
      • grid

        public IgniteEx grid()
        Returns:
        Grid instance.
      • igniteInstanceName

        public String igniteInstanceName()
        Returns:
        Ignite instance name.
      • name

        public String name()
        Returns:
        Cache name.
      • dataRegion

        public DataRegion dataRegion()
        Returns:
        Data region.
      • txKey

        public IgniteTxKey txKey​(KeyCacheObject key)
        Parameters:
        key - Key to construct tx key for.
        Returns:
        Transaction key.
      • nodeId

        public UUID nodeId()
        Returns:
        Local node ID.
      • rebalanceEnabled

        public boolean rebalanceEnabled()
        Returns:
        True if rebalance is enabled.
      • atomic

        public boolean atomic()
        Returns:
        True if atomic.
      • transactional

        public boolean transactional()
        Returns:
        True if transactional.
      • disableTriggeringCacheInterceptorOnConflict

        public boolean disableTriggeringCacheInterceptorOnConflict()
        Returns:
        True if cache interceptor should be skipped in case of conflicts.
      • localNode

        public ClusterNode localNode()
        Returns:
        Local node.
      • localNodeId

        public UUID localNodeId()
        Returns:
        Local node ID.
      • isLocalNode

        public boolean isLocalNode​(ClusterNode n)
        Parameters:
        n - Node to check.
        Returns:
        True if node is local.
      • isLocalNode

        public boolean isLocalNode​(UUID id)
        Parameters:
        id - Node ID to check.
        Returns:
        True if node ID is local.
      • node

        @Nullable
        public @Nullable ClusterNode node​(UUID nodeId)
        Parameters:
        nodeId - Node id.
        Returns:
        Node.
      • topologyVersionFuture

        public GridDhtTopologyFuture topologyVersionFuture()
        Returns:
        Topology version future.
      • marshaller

        public Marshaller marshaller()
        Returns:
        Marshaller.
      • logger

        public IgniteLogger logger​(String ctgr)
        Parameters:
        ctgr - Category to log.
        Returns:
        Logger.
      • logger

        public IgniteLogger logger​(Class<?> cls)
        Parameters:
        cls - Class to log.
        Returns:
        Logger.
      • gridIO

        public GridIoManager gridIO()
        Returns:
        Grid communication manager.
      • writeToStoreFromDht

        public boolean writeToStoreFromDht()
        Returns:
        True If store writes should be performed from dht transactions. This happens if both writeBehindEnabled and writeBehindPreferPrimary cache configuration properties are set to true or the store is local.
      • putIfAbsentFilter

        public boolean putIfAbsentFilter​(@Nullable
                                         @Nullable CacheEntryPredicate[] p)
        Parameters:
        p - Predicate.
        Returns:
        True if given predicate is filter for putIfAbsent operation.
      • equalsVal

        public CacheEntryPredicate equalsVal​(V val)
        Parameters:
        val - Value to check.
        Returns:
        Predicate that checks for value.
      • emptyVersion

        public GridCacheVersion[] emptyVersion()
        Returns:
        Empty cache version array.
      • cacheObjectContext

        public void cacheObjectContext​(CacheObjectContext cacheObjCtx)
        Sets cache object context.
        Parameters:
        cacheObjCtx - Cache object context.
      • vararg

        public IgnitePredicate<javax.cache.Cache.Entry<K,​V>>[] vararg​(IgnitePredicate<javax.cache.Cache.Entry<K,​V>> p)
        Parameters:
        p - Single predicate.
        Returns:
        Array containing single predicate.
      • operationContextPerCall

        public void operationContextPerCall​(@Nullable
                                            @Nullable CacheOperationContext opCtx)
        Sets thread local cache operation context.
        Parameters:
        opCtx - Operation context.
      • operationContextPerCall

        public CacheOperationContext operationContextPerCall()
        Gets thread local cache operation context.
        Returns:
        Operation context per call.
      • skipStore

        public boolean skipStore()
        Returns:
        true if the skip store flag is set.
      • projectSafe

        public Runnable projectSafe​(Runnable r)
        Creates Runnable that can be executed safely in a different thread inheriting the same thread local projection as for the current thread. If no projection is set for current thread then there's no need to create new object and method simply returns given Runnable.
        Parameters:
        r - Runnable.
        Returns:
        Runnable that can be executed in a different thread with the same projection as for current thread.
      • projectSafe

        public <T> Callable<T> projectSafe​(Callable<T> r)
        Creates callable that can be executed safely in a different thread inheriting the same thread local projection as for the current thread. If no projection is set for current thread then there's no need to create new object and method simply returns given callable.
        Parameters:
        r - Callable.
        Returns:
        Callable that can be executed in a different thread with the same projection as for current thread.
      • deploymentEnabled

        public boolean deploymentEnabled()
        Returns:
        True if deployment is enabled.
      • readThrough

        public boolean readThrough()
        Returns:
        True if store read-through mode is enabled.
      • readThroughConfigured

        public boolean readThroughConfigured()
        Returns:
        True if store and read-through mode are enabled in configuration.
      • writeThrough

        public boolean writeThrough()
        Returns:
        True if store write-through is enabled.
      • isInvalidate

        public boolean isInvalidate()
        Returns:
        True if invalidation is enabled.
      • syncCommit

        public boolean syncCommit()
        Returns:
        True if synchronous commit is enabled.
      • syncRollback

        public boolean syncRollback()
        Returns:
        True if synchronous rollback is enabled.
      • syncPrimary

        public boolean syncPrimary()
        Returns:
        True if only primary node should be updated synchronously.
      • conflictNeedResolve

        public boolean conflictNeedResolve()
        Check whether conflict resolution is required.
        Returns:
        True in case DR is required.
      • dataCenterId

        public byte dataCenterId()
        Returns:
        Data center ID.
      • binaryMarshaller

        public boolean binaryMarshaller()
        Returns:
        True if is configured.
      • keepBinary

        public boolean keepBinary()
        Returns:
        Keep binary flag.
      • unwrapTemporary

        @Nullable
        public <T> T unwrapTemporary​(@Nullable
                                     @Nullable Object obj)
        Converts temporary offheap object to heap-based.
        Parameters:
        obj - Object.
        Returns:
        Heap-based object.
      • unwrapBinariesIfNeeded

        public Collection<Object> unwrapBinariesIfNeeded​(Collection<?> col,
                                                         boolean keepBinary)
        Unwraps collection.
        Parameters:
        col - Collection to unwrap.
        keepBinary - Keep binary flag.
        Returns:
        Unwrapped collection.
      • unwrapBinaryIfNeeded

        public Object unwrapBinaryIfNeeded​(Object o,
                                           boolean keepBinary,
                                           @Nullable
                                           @Nullable ClassLoader ldr)
        Unwraps object for binary.
        Parameters:
        o - Object to unwrap.
        keepBinary - Keep binary flag.
        ldr - Class loader, used for deserialization from binary representation.
        Returns:
        Unwrapped object.
      • unwrapBinaryIfNeeded

        public Object unwrapBinaryIfNeeded​(Object o,
                                           boolean keepBinary,
                                           boolean cpy,
                                           @Nullable
                                           @Nullable ClassLoader ldr)
        Unwraps object for binary.
        Parameters:
        o - Object to unwrap.
        keepBinary - Keep binary flag.
        cpy - Copy value flag.
        ldr - Class loader, used for deserialization from binary representation.
        Returns:
        Unwrapped object.
      • unwrapInvokeResult

        public Map unwrapInvokeResult​(@Nullable
                                      @Nullable Map<Object,​javax.cache.processor.EntryProcessorResult> resMap,
                                      boolean keepBinary)
        Parameters:
        resMap - Invoke results map.
        keepBinary - Keep binary flag.
        Returns:
        Unwrapped results.
      • cacheObjectContext

        public CacheObjectContext cacheObjectContext()
        Returns:
        Cache object context.
      • toCacheObject

        @Nullable
        public @Nullable CacheObject toCacheObject​(@Nullable
                                                   @Nullable Object obj)
        Parameters:
        obj - Object.
        Returns:
        Cache object.
      • toCacheKeyObject

        public KeyCacheObject toCacheKeyObject​(Object obj)
        Parameters:
        obj - Object.
        Returns:
        Cache key object.
      • addResult

        public <K1,​V1> void addResult​(Map<K1,​V1> map,
                                            KeyCacheObject key,
                                            CacheObject val,
                                            boolean skipVals,
                                            boolean keepCacheObjects,
                                            boolean deserializeBinary,
                                            boolean cpy,
                                            GridCacheVersion ver,
                                            long expireTime,
                                            long ttl,
                                            @Nullable
                                            @Nullable ClassLoader ldr)
        Parameters:
        map - Map.
        key - Key.
        val - Value.
        skipVals - Skip values flag.
        keepCacheObjects - Keep cache objects flag.
        deserializeBinary - Deserialize binary flag.
        cpy - Copy flag.
        ver - GridCacheVersion.
        ldr - Class loader, used for deserialization from binary representation.
      • addResult

        public <K1,​V1> void addResult​(Map<K1,​V1> map,
                                            KeyCacheObject key,
                                            EntryGetResult getRes,
                                            boolean skipVals,
                                            boolean keepCacheObjects,
                                            boolean deserializeBinary,
                                            boolean cpy,
                                            boolean needVer)
        Parameters:
        map - Map.
        key - Key.
        getRes - EntryGetResult.
        skipVals - Skip values.
        keepCacheObjects - Keep CacheObject.
        deserializeBinary - Deserialize binary flag.
        cpy - Copy flag.
        needVer - Need version flag.
      • addResult

        public <K1,​V1> void addResult​(Map<K1,​V1> map,
                                            KeyCacheObject key,
                                            CacheObject val,
                                            boolean skipVals,
                                            boolean keepCacheObjects,
                                            boolean deserializeBinary,
                                            boolean cpy,
                                            @Nullable
                                            @Nullable EntryGetResult getRes,
                                            GridCacheVersion ver,
                                            long expireTime,
                                            long ttl,
                                            boolean needVer,
                                            @Nullable
                                            @Nullable ClassLoader ldr)
        Parameters:
        map - Map.
        key - Key.
        val - Value.
        skipVals - Skip values.
        keepCacheObjects - Keep CacheObject.
        deserializeBinary - Deserialize binary.
        cpy - Copy flag.
        getRes - EntryGetResult.
        ver - Version.
        expireTime - Entry expire time.
        ttl - Entry TTL.
        needVer - Need version flag.
        ldr - Class loader, used for deserialization from binary representation.
      • updatesAllowed

        public boolean updatesAllowed()
        Returns:
        Updates allowed.
      • cleanup

        public void cleanup()
        Nulling references to potentially leak-prone objects.
      • printMemoryStats

        public void printMemoryStats()
        Print memory statistics of all cache managers. NOTE: this method is for testing and profiling purposes only.
      • cacheKeysView

        public Collection<KeyCacheObject> cacheKeysView​(Collection<?> keys)
        Parameters:
        keys - Keys.
        Returns:
        Read-only collection of KeyCacheObject instances.
      • reserveForFastLocalGet

        public boolean reserveForFastLocalGet​(int part,
                                              AffinityTopologyVersion topVer)
        Checks if local reads are allowed for the given partition and reserves the partition when needed. If this method returns true, then releaseForFastLocalGet(int, AffinityTopologyVersion) method must be called after the read is completed.
        Parameters:
        part - Partition.
        topVer - Topology version.
        Returns:
        True if cache 'get' operation is allowed to get entry locally.
      • recordEvent

        public boolean recordEvent​(int type)
        Parameters:
        type - Event type.
        Returns:
        True if event should be recorded.
      • selectAffinityNodeBalanced

        @Nullable
        public @Nullable ClusterNode selectAffinityNodeBalanced​(List<ClusterNode> affNodes,
                                                                Set<ClusterNode> invalidNodes,
                                                                int partId,
                                                                boolean canRemap,
                                                                boolean forcePrimary)
        Determines an affinity node to send get request to.
        Parameters:
        affNodes - All affinity nodes.
        canRemap - Flag indicating that 'get' should be done on a locked topology version.
        partId - Partition ID.
        forcePrimary - Force primary flag.
        Returns:
        Affinity node to get key from or null if there is no suitable alive node.
      • prepareAffinityField

        public void prepareAffinityField​(BinaryObjectBuilder builder)
        Prepare affinity field for builder (if possible).
        Parameters:
        builder - Builder.
      • statisticsEnabled

        public boolean statisticsEnabled()
        Returns:
        Statistics enabled flag.
      • statisticsEnabled

        public void statisticsEnabled​(boolean statisticsEnabled)
        Parameters:
        statisticsEnabled - Statistics enabled flag.
      • onSchemaAddQueryEntity

        public void onSchemaAddQueryEntity​(Collection<QueryEntity> entities,
                                           String sqlSchema,
                                           boolean isSqlEscape,
                                           int qryParallelism)
        Apply changes on enable indexing.
        Parameters:
        entities - New query entities.
        sqlSchema - Sql schema name.
        isSqlEscape - Sql escape flag.
        qryParallelism - Query parallelism parameter.
      • transactionChanges

        public TransactionChanges<Object> transactionChanges​(Integer part)
        Parameters:
        part - Partition.
        Returns:
        First, set of object changed in transaction, second, list of transaction data in required format.
        See Also:
        ExecutionContext#transactionChanges(int, int[], Function)