Mmuzaf commented on a change in pull request #9317:
URL: https://github.com/apache/ignite/pull/9317#discussion_r692418572



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
##########
@@ -271,6 +273,12 @@ public IndexStorage getIndexStorage() {
 
     /** {@inheritDoc} */
     @Override public void beforeCheckpointBegin(Context ctx) throws 
IgniteCheckedException {
+        List<CacheDataStore> destroyedStores = 
StreamSupport.stream(cacheDataStores().spliterator(), false)

Review comment:
       I've added there additional guarantees - destroyed cache data stores 
must not be visible to listeners. I've fixed the assertion as you suggested.

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
##########
@@ -398,33 +373,46 @@ public CacheDataStore dataStore(int part) {
 
     /** {@inheritDoc} */
     @Override public long cacheEntriesCount(int cacheId, int part) {
-        CacheDataStore store = partitionData(part);
+        CacheDataStore store = dataStore(part, true);
 
         return store == null ? 0 : store.cacheSize(cacheId);
     }
 
+    /** {@inheritDoc} */
+    @Override public Iterable<CacheDataStore> cacheDataStores() {
+        return cacheDataStores(grp -> new AlwaysTruePredicate<>());

Review comment:
       Fixed.

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
##########
@@ -398,33 +373,46 @@ public CacheDataStore dataStore(int part) {
 
     /** {@inheritDoc} */
     @Override public long cacheEntriesCount(int cacheId, int part) {
-        CacheDataStore store = partitionData(part);
+        CacheDataStore store = dataStore(part, true);
 
         return store == null ? 0 : store.cacheSize(cacheId);
     }
 
+    /** {@inheritDoc} */
+    @Override public Iterable<CacheDataStore> cacheDataStores() {
+        return cacheDataStores(grp -> new AlwaysTruePredicate<>());
+    }
+
+    /**
+     * @param factory Factory which will produce filtering predicate.

Review comment:
       Fixed.

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
##########
@@ -398,33 +373,46 @@ public CacheDataStore dataStore(int part) {
 
     /** {@inheritDoc} */
     @Override public long cacheEntriesCount(int cacheId, int part) {
-        CacheDataStore store = partitionData(part);
+        CacheDataStore store = dataStore(part, true);
 
         return store == null ? 0 : store.cacheSize(cacheId);
     }
 
+    /** {@inheritDoc} */
+    @Override public Iterable<CacheDataStore> cacheDataStores() {
+        return cacheDataStores(grp -> new AlwaysTruePredicate<>());
+    }
+
+    /**
+     * @param factory Factory which will produce filtering predicate.
+     * @return Iterable over all existing cache data stores except which one 
is marked as <tt>destroyed</tt>.
+     */
+    private Iterable<CacheDataStore> cacheDataStores(
+        Function<CacheGroupContext, IgnitePredicate<GridDhtLocalPartition>> 
factory
+    ) {
+        return grp.isLocal() ? Collections.singletonList(locCacheDataStore) :
+            F.iterator(grp.topology().currentLocalPartitions(), 
GridDhtLocalPartition::dataStore, true,
+                factory.apply(grp), p -> !p.dataStore().destroyed());
+    }
+
     /**
      * @param primary Primary data flag.
-     * @param backup Primary data flag.
+     * @param backup Backup data flag.
      * @param topVer Topology version.
      * @return Data stores iterator.
      */
     private Iterator<CacheDataStore> cacheData(boolean primary, boolean 
backup, AffinityTopologyVersion topVer) {
         assert primary || backup;
 
-        if (grp.isLocal())
-            return singletonIterator(locCacheDataStore);
-        else {
-            Iterator<GridDhtLocalPartition> it = 
grp.topology().currentLocalPartitions().iterator();
-
+        return cacheDataStores(grp -> {
             if (primary && backup)
-                return F.iterator(it, GridDhtLocalPartition::dataStore, true);
+                return new AlwaysTruePredicate<>();

Review comment:
       Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to