Class GridDhtColocatedCache<K,​V>

    • Constructor Detail

      • GridDhtColocatedCache

        public GridDhtColocatedCache()
        Empty constructor required for Externalizable
      • GridDhtColocatedCache

        public GridDhtColocatedCache​(GridCacheContext<K,​V> ctx)
        Parameters:
        ctx - Cache context.
      • GridDhtColocatedCache

        public GridDhtColocatedCache​(GridCacheContext<K,​V> ctx,
                                     GridCacheConcurrentMap map)
        Creates colocated cache with specified map.
        Parameters:
        ctx - Cache context.
        map - Cache map.
    • Method Detail

      • entryExx

        public GridDistributedCacheEntry entryExx​(KeyCacheObject key,
                                                  AffinityTopologyVersion topVer,
                                                  boolean allowDetached)
        Gets or creates entry for given key and given topology version.
        Parameters:
        key - Key for entry.
        topVer - Topology version.
        allowDetached - Whether to allow detached entries. If true and node is not primary for given key, a new detached entry will be created. Otherwise, entry will be obtained from dht cache map.
        Returns:
        Cache entry.
        Throws:
        GridDhtInvalidPartitionException - If allowDetached is false and node is not primary for given key.
      • isLocked

        public boolean isLocked​(K key)
        Checks if any node owns a lock for this key.

        This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.

        Specified by:
        isLocked in interface IgniteInternalCache<K,​V>
        Overrides:
        isLocked in class GridCacheAdapter<K,​V>
        Parameters:
        key - Key to check.
        Returns:
        True if lock is owned by some node.
      • isLockedByThread

        public boolean isLockedByThread​(K key)
        Checks if current thread owns a lock on this key.

        This is a local in-VM operation and does not involve any network trips or access to persistent storage in any way.

        Specified by:
        isLockedByThread in interface IgniteInternalCache<K,​V>
        Overrides:
        isLockedByThread in class GridCacheAdapter<K,​V>
        Parameters:
        key - Key to check.
        Returns:
        True if key is locked by current thread.
      • getAsync

        protected IgniteInternalFuture<V> getAsync​(K key,
                                                   boolean forcePrimary,
                                                   boolean skipTx,
                                                   String taskName,
                                                   boolean deserializeBinary,
                                                   boolean skipVals,
                                                   boolean needVer)
        Overrides:
        getAsync in class GridCacheAdapter<K,​V>
        Parameters:
        key - Key.
        forcePrimary - Force primary.
        skipTx - Skip tx.
        taskName - Task name.
        deserializeBinary - Deserialize binary.
        skipVals - Skip values.
        needVer - Need version.
        Returns:
        Future for the get operation.
      • 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)
        Overrides:
        getAllAsync in class GridDhtCacheAdapter<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)
      • loadAsync

        public final IgniteInternalFuture<Object> loadAsync​(KeyCacheObject key,
                                                            boolean readThrough,
                                                            boolean forcePrimary,
                                                            AffinityTopologyVersion topVer,
                                                            String taskName,
                                                            boolean deserializeBinary,
                                                            @Nullable
                                                            @Nullable IgniteCacheExpiryPolicy expiryPlc,
                                                            boolean skipVals,
                                                            boolean needVer,
                                                            boolean keepCacheObj,
                                                            boolean recovery,
                                                            @Nullable
                                                            @Nullable String txLbl)
        Parameters:
        key - Key to load.
        readThrough - Read through flag.
        forcePrimary - Force get from primary node flag.
        topVer - Topology version.
        taskName - Task name.
        deserializeBinary - Deserialize binary flag.
        expiryPlc - Expiry policy.
        skipVals - Skip values flag.
        needVer - If true returns values as tuples containing value and version.
        keepCacheObj - Keep cache objects flag.
        txLbl - Transaction label.
        Returns:
        Load future.
      • loadAsync

        public final IgniteInternalFuture<Map<K,​V>> loadAsync​(@Nullable
                                                                    @Nullable Collection<KeyCacheObject> keys,
                                                                    boolean readThrough,
                                                                    boolean forcePrimary,
                                                                    AffinityTopologyVersion topVer,
                                                                    String taskName,
                                                                    boolean deserializeBinary,
                                                                    boolean recovery,
                                                                    @Nullable
                                                                    @Nullable IgniteCacheExpiryPolicy expiryPlc,
                                                                    boolean skipVals,
                                                                    boolean needVer,
                                                                    boolean keepCacheObj,
                                                                    @Nullable
                                                                    @Nullable String txLbl)
        Parameters:
        keys - Keys to load.
        readThrough - Read through flag.
        forcePrimary - Force get from primary node flag.
        topVer - Topology version.
        taskName - Task name.
        deserializeBinary - Deserialize binary flag.
        expiryPlc - Expiry policy.
        skipVals - Skip values flag.
        needVer - If true returns values as tuples containing value and version.
        keepCacheObj - Keep cache objects flag.
        txLbl - Transaction label.
        Returns:
        Load future.
      • lockAllAsync

        public IgniteInternalFuture<Boolean> lockAllAsync​(Collection<KeyCacheObject> keys,
                                                          long timeout,
                                                          @Nullable
                                                          @Nullable IgniteTxLocalEx tx,
                                                          boolean isInvalidate,
                                                          boolean isRead,
                                                          boolean retval,
                                                          @Nullable
                                                          @Nullable TransactionIsolation isolation,
                                                          long createTtl,
                                                          long accessTtl)
        This is an entry point to pessimistic locking within transaction.
        Overrides:
        lockAllAsync in class GridDhtTransactionalCacheAdapter<K,​V>
        Parameters:
        keys - Keys to lock.
        timeout - Timeout.
        tx - Transaction
        isInvalidate - Invalidation flag.
        isRead - Indicates whether value is read or written.
        retval - Flag to return value.
        isolation - Transaction isolation.
        createTtl - TTL for create operation.
        accessTtl - TTL for read operation.
        Returns:
        Future for locks.
      • 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.
        Specified by:
        unlockAll in interface IgniteInternalCache<K,​V>
        Overrides:
        unlockAll in class GridDhtCacheAdapter<K,​V>
        Parameters:
        keys - Keys to unlock.
      • removeLocks

        public void removeLocks​(long threadId,
                                GridCacheVersion ver,
                                Collection<KeyCacheObject> keys)
        Removes locks regardless of whether they are owned or not for given version and keys.
        Parameters:
        threadId - Thread ID.
        ver - Lock version.
        keys - Keys.