Class GridDhtCacheAdapter<K,​V>

    • Constructor Detail

      • GridDhtCacheAdapter

        protected GridDhtCacheAdapter()
        Empty constructor required for Externalizable.
      • GridDhtCacheAdapter

        protected GridDhtCacheAdapter​(GridCacheContext<K,​V> ctx)
        Parameters:
        ctx - Context.
      • GridDhtCacheAdapter

        protected GridDhtCacheAdapter​(GridCacheContext<K,​V> ctx,
                                      GridCacheConcurrentMap map)
        Constructor used for near-only cache.
        Parameters:
        ctx - Cache context.
        map - Cache map.
    • Method Detail

      • addFuture

        public boolean addFuture​(GridDhtForceKeysFuture<?,​?> fut)
        Adds future to future map.
        Parameters:
        fut - Future to add.
        Returns:
        False if node cache is stopping and future was completed with error.
      • removeFuture

        public void removeFuture​(GridDhtForceKeysFuture<?,​?> fut)
        Removes future from future map.
        Parameters:
        fut - Future to remove.
      • processForceKeysRequest

        protected final void processForceKeysRequest​(ClusterNode node,
                                                     GridDhtForceKeysRequest msg)
        Parameters:
        node - Node originated request.
        msg - Force keys message.
      • dumpDebugInfo

        public void dumpDebugInfo()
      • processNearGetResponse

        protected final void processNearGetResponse​(UUID nodeId,
                                                    GridNearGetResponse res)
        Parameters:
        nodeId - Sender node ID.
        res - Near get response.
      • processNearSingleGetResponse

        protected void processNearSingleGetResponse​(UUID nodeId,
                                                    GridNearSingleGetResponse res)
        Parameters:
        nodeId - Sender node ID.
        res - Near get response.
      • localLoadCache

        public void localLoadCache​(IgniteBiPredicate<K,​V> p,
                                   Object[] args)
                            throws IgniteCheckedException
        Delegates to CacheStore.loadCache(IgniteBiInClosure, Object...) method to load state from the underlying persistent storage. The loaded values will then be given to the optionally passed in predicate, and, if the predicate returns true, will be stored in cache. If predicate is null, then all loaded values will be stored in cache.

        Note that this method does not receive keys as a parameter, so it is up to CacheStore implementation to provide all the data to be loaded.

        This method is not transactional and may end up loading a stale value into cache if another thread has updated the value immediately after it has been loaded. It is mostly useful when pre-loading the cache from underlying data store before start, or for read-only caches.

        Specified by:
        localLoadCache in interface IgniteInternalCache<K,​V>
        Overrides:
        localLoadCache in class GridCacheAdapter<K,​V>
        Parameters:
        p - Optional predicate (may be null). If provided, will be used to filter values to be put into cache.
        args - Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method.
        Throws:
        IgniteCheckedException - If loading failed.
      • size

        public int size()
        Gets the number of all entries cached on this node. This method will return the count of all cache entries and has O(1) complexity on base IgniteInternalCache. It is essentially the size of cache key set and is semantically identical to {Cache.keySet().size().

        NOTE: this operation is not distributed and returns only the number of entries cached on this node.

        Specified by:
        size in interface IgniteInternalCache<K,​V>
        Overrides:
        size in class GridCacheAdapter<K,​V>
        Returns:
        Size of cache on this node.
      • sizeLong

        public long sizeLong()
        Gets the number of all entries cached on this node as a long value. This method will return the count of all cache entries and has O(1) complexity on base IgniteInternalCache. It is essentially the size of cache key set and is semantically identical to {Cache.keySet().size().

        NOTE: this operation is not distributed and returns only the number of entries cached on this node.

        Specified by:
        sizeLong in interface IgniteInternalCache<K,​V>
        Overrides:
        sizeLong in class GridCacheAdapter<K,​V>
        Returns:
        Size of cache on this node.
      • primarySize

        public int primarySize()
        Gets the number of all primary entries cached on this node.

        For CacheMode.PARTITIONED and CacheMode.REPLICATED modes, this method will return number of primary entries cached on this node (excluding any backups). The complexity of this method is O(P), where P is the total number of partitions.

        NOTE: this operation is not distributed and returns only the number of primary entries cached on this node.

        Specified by:
        primarySize in interface IgniteInternalCache<K,​V>
        Overrides:
        primarySize in class GridCacheAdapter<K,​V>
        Returns:
        Number of primary entries in cache.
      • primarySizeLong

        public long primarySizeLong()
        Gets the number of all primary entries cached on this node as a long value.

        For CacheMode.PARTITIONED and CacheMode.REPLICATED modes, this method will return number of primary entries cached on this node (excluding any backups). The complexity of this method is O(P), where P is the total number of partitions.

        NOTE: this operation is not distributed and returns only the number of primary entries cached on this node.

        Specified by:
        primarySizeLong in interface IgniteInternalCache<K,​V>
        Overrides:
        primarySizeLong in class GridCacheAdapter<K,​V>
        Returns:
        Number of primary entries in cache.
      • getAllAsync

        public IgniteInternalFuture<Map<K,​V>> getAllAsync​(@Nullable
                                                                @Nullable Collection<? extends K> keys,
                                                                boolean forcePrimary,
                                                                boolean skipTx,
                                                                String taskName,
                                                                boolean deserializeBinary,
                                                                boolean recovery,
                                                                ReadRepairStrategy readRepairStrategy,
                                                                boolean skipVals,
                                                                boolean needVer)
        Specified by:
        getAllAsync in class GridCacheAdapter<K,​V>
        Parameters:
        keys - Keys.
        forcePrimary - Force primary.
        skipTx - Skip tx.
        taskName - Task name.
        deserializeBinary - Deserialize binary.
        recovery - Recovery mode flag.
        skipVals - Skip values.
        needVer - Need version.
        Returns:
        Future for the get operation.
        See Also:
        GridCacheAdapter.getAllAsync(Collection)
      • getDhtAsync

        public GridDhtFuture<Collection<GridCacheEntryInfo>> getDhtAsync​(UUID reader,
                                                                         long msgId,
                                                                         Map<KeyCacheObject,​Boolean> keys,
                                                                         boolean addReaders,
                                                                         boolean readThrough,
                                                                         AffinityTopologyVersion topVer,
                                                                         int taskNameHash,
                                                                         @Nullable
                                                                         @Nullable IgniteCacheExpiryPolicy expiry,
                                                                         boolean skipVals,
                                                                         boolean recovery,
                                                                         @Nullable
                                                                         @Nullable String txLbl)
        Parameters:
        reader - Reader node ID.
        msgId - Message ID.
        keys - Keys to get.
        addReaders - Add readers flag.
        readThrough - Read through flag.
        topVer - Topology version.
        taskNameHash - Task name hash code.
        expiry - Expiry policy.
        skipVals - Skip values flag.
        txLbl - Transaction label.
        Returns:
        DHT future.
      • processNearSingleGetRequest

        protected void processNearSingleGetRequest​(UUID nodeId,
                                                   GridNearSingleGetRequest req)
        Parameters:
        nodeId - Node ID.
        req - Get request.
      • processNearGetRequest

        protected void processNearGetRequest​(UUID nodeId,
                                             GridNearGetRequest req)
        Parameters:
        nodeId - Node ID.
        req - Get request.
      • sendTtlUpdateRequest

        public void sendTtlUpdateRequest​(@Nullable
                                         @Nullable IgniteCacheExpiryPolicy expiryPlc)
        Initiates process of notifying all interested nodes that TTL was changed. Directly sends requests to primary nodes and IgniteCacheExpiryPolicy.readers().
        Parameters:
        expiryPlc - Expiry policy.
      • unlockAll

        public void unlockAll​(Collection<? extends K> keys)
        Unlocks given keys only if current thread owns the locks. Only the keys that have been locked by calling thread and pass through the filter (if any) will be unlocked. If none of the key locks is owned by current thread, then this method will do nothing.

        Transactions

        Locks are not transactional and should not be used from within transactions. If you do need explicit locking within transaction, then you should use TransactionConcurrency.PESSIMISTIC concurrency control for transaction which will acquire explicit locks for relevant cache operations.
        Parameters:
        keys - Keys to unlock.
      • splitClearLocally

        public List<GridCacheClearAllRunnable<K,​V>> splitClearLocally​(boolean srv,
                                                                            boolean near,
                                                                            boolean readers)
        Split clearLocally all task into multiple runnables.
        Overrides:
        splitClearLocally in class GridCacheAdapter<K,​V>
        Parameters:
        srv - Whether to clear server cache.
        near - Whether to clear near cache.
        readers - Whether to clear readers.
        Returns:
        Split runnables.
      • needRemap

        protected final boolean needRemap​(AffinityTopologyVersion rmtVer)
        Parameters:
        rmtVer - Topology version that the cache request was mapped to by the remote node.
        Returns:
        True if cache affinity changed and operation should be remapped.
      • localEntriesIterator

        public Iterator<javax.cache.Cache.Entry<K,​V>> localEntriesIterator​(boolean primary,
                                                                                 boolean backup,
                                                                                 boolean keepBinary)
        Parameters:
        primary - If true includes primary entries.
        backup - If true includes backup entries.
        keepBinary - Keep binary flag.
        Returns:
        Local entries iterator.