This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new d14627f  GEODE-4585: remove getAnyInstance call (#1428)
d14627f is described below

commit d14627fec8b6d66ec8afe862e2e4166a7c306c4f
Author: Darrel Schneider <dschnei...@pivotal.io>
AuthorDate: Wed Feb 14 10:59:13 2018 -0800

    GEODE-4585: remove getAnyInstance call (#1428)
    
    Cache is now passed in since the region might be
    a LocalDataSet. The cache is used to get the InternalDistributedSystem
---
 .../org/apache/geode/internal/cache/snapshot/ClientExporter.java | 4 +++-
 .../geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java | 9 +++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
index 1e4782f..92df20b 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/ClientExporter.java
@@ -30,6 +30,7 @@ import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.execute.ResultSender;
 import org.apache.geode.cache.snapshot.SnapshotOptions;
 import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.execute.InternalFunction;
 import 
org.apache.geode.internal.cache.snapshot.RegionSnapshotServiceImpl.ExportSink;
 import 
org.apache.geode.internal.cache.snapshot.RegionSnapshotServiceImpl.Exporter;
@@ -133,8 +134,9 @@ public class ClientExporter<K, V> implements Exporter<K, V> 
{
       ExportSink sink = new ResultSenderSink(rs);
 
       Region<K, V> region = context.getCache().getRegion(args.getRegion());
+      InternalCache cache = (InternalCache) context.getCache();
       Exporter<K, V> exp = args.isPRSingleHop() ? new LocalExporter<K, V>()
-          : RegionSnapshotServiceImpl.<K, V>createExporter(region, 
args.options);
+          : RegionSnapshotServiceImpl.<K, V>createExporter(cache, region, 
args.options);
 
       try {
         long count = exp.export(region, sink, args.getOptions());
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
index 057d081..4b65d8c 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/snapshot/RegionSnapshotServiceImpl.java
@@ -47,13 +47,13 @@ import org.apache.geode.cache.snapshot.SnapshotOptions;
 import org.apache.geode.cache.snapshot.SnapshotOptions.SnapshotFormat;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.DSCODE;
 import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.cache.CachePerfStats;
 import org.apache.geode.internal.cache.CachedDeserializable;
 import org.apache.geode.internal.cache.CachedDeserializableFactory;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.InternalRegion;
 import org.apache.geode.internal.cache.LocalDataSet;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.Token;
@@ -341,7 +341,7 @@ public class RegionSnapshotServiceImpl<K, V> implements 
RegionSnapshotService<K,
     }
     directory.mkdirs();
     LocalRegion local = getLocalRegion(region);
-    Exporter<K, V> exp = createExporter(region, options);
+    Exporter<K, V> exp = createExporter(local.getCache(), region, options);
 
     if (getLoggerI18n().fineEnabled()) {
       getLoggerI18n().fine("Writing to snapshot " + 
snapshot.getAbsolutePath());
@@ -396,12 +396,13 @@ public class RegionSnapshotServiceImpl<K, V> implements 
RegionSnapshotService<K,
     return true;
   }
 
-  static <K, V> Exporter<K, V> createExporter(Region<?, ?> region, 
SnapshotOptions<K, V> options) {
+  static <K, V> Exporter<K, V> createExporter(InternalCache cache, Region<?, 
?> region,
+      SnapshotOptions<K, V> options) {
     String pool = region.getAttributes().getPoolName();
     if (pool != null) {
       return new ClientExporter<>(PoolManager.find(pool));
 
-    } else if (InternalDistributedSystem.getAnyInstance().isLoner()
+    } else if (cache.getInternalDistributedSystem().isLoner()
         || region.getAttributes().getDataPolicy().equals(DataPolicy.NORMAL)
         || region.getAttributes().getDataPolicy().equals(DataPolicy.PRELOADED)
         || region instanceof LocalDataSet || (options.isParallelMode()

-- 
To stop receiving notification emails like this one, please contact
dschnei...@apache.org.

Reply via email to