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

agingade pushed a commit to branch feature/GEODE-3583-storage
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-3583-storage by 
this push:
     new c474e0d  GEODE-4199: Remove GemFireCacheImpl.getInstance call from 
GridAdvisor
c474e0d is described below

commit c474e0d3d23b5abecdf69a4287ffc61cd0220687
Author: Anil <aging...@pivotal.io>
AuthorDate: Wed Jan 10 12:29:30 2018 -0800

    GEODE-4199: Remove GemFireCacheImpl.getInstance call from GridAdvisor
---
 .../org/apache/geode/internal/cache/CacheServerAdvisor.java   |  2 +-
 .../org/apache/geode/internal/cache/ControllerAdvisor.java    |  2 +-
 .../java/org/apache/geode/internal/cache/GridAdvisor.java     | 11 ++++++-----
 .../java/org/apache/geode/internal/cache/GridProfileTest.java |  6 ++++--
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerAdvisor.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerAdvisor.java
index 47b7cb3..d48375b 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerAdvisor.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerAdvisor.java
@@ -123,7 +123,7 @@ public class CacheServerAdvisor extends GridAdvisor {
       // tell local controllers about this cache server
       tellLocalControllers(removeProfile, exchangeProfiles, replyProfiles);
       // for QRM messaging we need cache servers to know about each other
-      tellLocalBridgeServers(removeProfile, exchangeProfiles, replyProfiles);
+      tellLocalBridgeServers(dm.getCache(), removeProfile, exchangeProfiles, 
replyProfiles);
     }
 
     @Override
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/ControllerAdvisor.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/ControllerAdvisor.java
index 624edbd..4bf5ba1 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/ControllerAdvisor.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/ControllerAdvisor.java
@@ -114,7 +114,7 @@ public class ControllerAdvisor extends GridAdvisor {
       // tell local controllers about this remote controller
       tellLocalControllers(removeProfile, exchangeProfiles, replyProfiles);
       // tell local bridge servers about this remote controller
-      tellLocalBridgeServers(removeProfile, exchangeProfiles, replyProfiles);
+      tellLocalBridgeServers(dm.getCache(), removeProfile, exchangeProfiles, 
replyProfiles);
     }
 
     @Override
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/GridAdvisor.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/GridAdvisor.java
index 12acc2e..3c15fe9 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GridAdvisor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GridAdvisor.java
@@ -204,7 +204,8 @@ public abstract class GridAdvisor extends 
DistributionAdvisor {
       // Exchange with any local servers or controllers.
       List<Profile> otherProfiles = new ArrayList<Profile>();
       GridProfile profile = (GridProfile) createProfile();
-      profile.tellLocalBridgeServers(false, true, otherProfiles);
+      profile.tellLocalBridgeServers(getDistributionManager().getCache(), 
false, true,
+          otherProfiles);
       profile.tellLocalControllers(false, true, otherProfiles);
       for (Profile otherProfile : otherProfiles) {
         if (!otherProfile.equals(profile)) {
@@ -223,7 +224,7 @@ public abstract class GridAdvisor extends 
DistributionAdvisor {
       // Notify any local bridge servers or controllers
       // that we are closing.
       GridProfile profile = (GridProfile) createProfile();
-      profile.tellLocalBridgeServers(true, false, null);
+      profile.tellLocalBridgeServers(getDistributionManager().getCache(), 
true, false, null);
       profile.tellLocalControllers(true, false, null);
       super.close();
     } catch (DistributedSystemDisconnectedException ignore) {
@@ -325,9 +326,9 @@ public abstract class GridAdvisor extends 
DistributionAdvisor {
      *
      * @since GemFire 5.7
      */
-    protected void tellLocalBridgeServers(boolean removeProfile, boolean 
exchangeProfiles,
-        final List<Profile> replyProfiles) {
-      final InternalCache cache = GemFireCacheImpl.getInstance();
+    protected void tellLocalBridgeServers(InternalCache cache, boolean 
removeProfile,
+        boolean exchangeProfiles, final List<Profile> replyProfiles) {
+
       if (cache != null && !cache.isClosed()) {
         List<?> bridgeServers = cache.getCacheServersAndGatewayReceiver();
         for (int i = 0; i < bridgeServers.size(); i++) {
diff --git 
a/geode-core/src/test/java/org/apache/geode/internal/cache/GridProfileTest.java 
b/geode-core/src/test/java/org/apache/geode/internal/cache/GridProfileTest.java
index c2e65ac..d2d7af5 100644
--- 
a/geode-core/src/test/java/org/apache/geode/internal/cache/GridProfileTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/internal/cache/GridProfileTest.java
@@ -29,6 +29,7 @@ import org.junit.experimental.categories.Category;
 import org.apache.geode.distributed.internal.DistributionAdvisor.Profile;
 import org.apache.geode.distributed.internal.DistributionAdvisor.ProfileId;
 import org.apache.geode.internal.cache.GridAdvisor.GridProfile;
+import org.apache.geode.test.fake.Fakes;
 import org.apache.geode.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
@@ -37,6 +38,7 @@ public class GridProfileTest {
   @Test
   public void shouldBeMockable() throws Exception {
     GridProfile mockGridProfile = mock(GridProfile.class);
+    InternalCache cache = Fakes.cache();
     ProfileId mockProfileId = mock(ProfileId.class);
     List<Profile> listOfProfiles = new ArrayList<>();
     listOfProfiles.add(mock(Profile.class));
@@ -48,12 +50,12 @@ public class GridProfileTest {
     mockGridProfile.setHost("host");
     mockGridProfile.setPort(2);
     mockGridProfile.tellLocalControllers(true, true, listOfProfiles);
-    mockGridProfile.tellLocalBridgeServers(true, true, listOfProfiles);
+    mockGridProfile.tellLocalBridgeServers(cache, true, true, listOfProfiles);
 
     verify(mockGridProfile, times(1)).setHost("host");
     verify(mockGridProfile, times(1)).setPort(2);
     verify(mockGridProfile, times(1)).tellLocalControllers(true, true, 
listOfProfiles);
-    verify(mockGridProfile, times(1)).tellLocalBridgeServers(true, true, 
listOfProfiles);
+    verify(mockGridProfile, times(1)).tellLocalBridgeServers(cache, true, 
true, listOfProfiles);
 
     assertThat(mockGridProfile.getHost()).isEqualTo("HOST");
     assertThat(mockGridProfile.getPort()).isEqualTo(1);

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Reply via email to