You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by es...@apache.org on 2018/01/11 21:38:45 UTC
[geode] branch feature/GEODE-3583-storage updated: Revert
"GEODE-4200: get cache from DM instead of using singleton."
This is an automated email from the ASF dual-hosted git repository.
eshu11 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 97474de Revert "GEODE-4200: get cache from DM instead of using singleton."
97474de is described below
commit 97474deb5c72bf3db35bfb44cac038707ba51a95
Author: eshu <es...@pivotal.io>
AuthorDate: Thu Jan 11 13:37:42 2018 -0800
Revert "GEODE-4200: get cache from DM instead of using singleton."
This reverts commit eac2dde4a2abe454a1e3a233eab4b11d5acce68f.
---
.../internal/cache/CacheDistributionAdvisor.java | 2 +-
.../internal/cache/InitialImageOperation.java | 62 +++++-----------------
.../apache/geode/internal/cache/LocalRegion.java | 16 ++++++
.../geode/internal/cache/TXCommitMessage.java | 10 ++--
.../geode/internal/cache/CacheProfileTest.java | 57 --------------------
.../internal/cache/InitialImageOperationTest.java | 56 -------------------
.../geode/internal/cache/RegionCommitTest.java | 58 --------------------
.../cache/RequestFilterInfoMessageTest.java | 30 -----------
8 files changed, 33 insertions(+), 258 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheDistributionAdvisor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheDistributionAdvisor.java
index f4872dc..5dcf6d9 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheDistributionAdvisor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheDistributionAdvisor.java
@@ -752,7 +752,7 @@ public class CacheDistributionAdvisor extends DistributionAdvisor {
LocalRegion lclRgn;
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT);
try {
- lclRgn = dm.getCache().getRegionByPath(adviseePath);
+ lclRgn = LocalRegion.getRegionFromPath(dm.getSystem(), adviseePath);
} finally {
LocalRegion.setThreadInitLevelRequirement(oldLevel);
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java
index 9c1646d..a9ef94c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java
@@ -15,34 +15,14 @@
package org.apache.geode.internal.cache;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.io.*;
+import java.util.*;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.Logger;
-import org.apache.geode.CancelException;
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.InternalGemFireException;
-import org.apache.geode.SystemFailure;
+import org.apache.geode.*;
import org.apache.geode.cache.DiskAccessException;
import org.apache.geode.cache.RegionDestroyedException;
import org.apache.geode.cache.query.internal.CqStateImpl;
@@ -50,23 +30,10 @@ import org.apache.geode.cache.query.internal.DefaultQueryService;
import org.apache.geode.cache.query.internal.cq.CqService;
import org.apache.geode.cache.query.internal.cq.ServerCQ;
import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.internal.ClusterDistributionManager;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.distributed.internal.DistributionManager;
-import org.apache.geode.distributed.internal.DistributionMessage;
-import org.apache.geode.distributed.internal.HighPriorityDistributionMessage;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.distributed.internal.MessageWithReply;
-import org.apache.geode.distributed.internal.ReplyException;
-import org.apache.geode.distributed.internal.ReplyMessage;
-import org.apache.geode.distributed.internal.ReplyProcessor21;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.distributed.internal.*;
import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
-import org.apache.geode.internal.Assert;
-import org.apache.geode.internal.ByteArrayDataInput;
-import org.apache.geode.internal.DataSerializableFixedID;
-import org.apache.geode.internal.InternalDataSerializer;
-import org.apache.geode.internal.NullDataOutputStream;
-import org.apache.geode.internal.Version;
+import org.apache.geode.internal.*;
import org.apache.geode.internal.cache.InitialImageFlowControl.FlowControlPermitMessage;
import org.apache.geode.internal.cache.entries.DiskEntry;
import org.apache.geode.internal.cache.ha.HAContainerWrapper;
@@ -76,13 +43,7 @@ import org.apache.geode.internal.cache.tier.InterestType;
import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier;
import org.apache.geode.internal.cache.tier.sockets.CacheClientProxy;
import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID;
-import org.apache.geode.internal.cache.versions.DiskRegionVersionVector;
-import org.apache.geode.internal.cache.versions.DiskVersionTag;
-import org.apache.geode.internal.cache.versions.RegionVersionHolder;
-import org.apache.geode.internal.cache.versions.RegionVersionVector;
-import org.apache.geode.internal.cache.versions.VersionSource;
-import org.apache.geode.internal.cache.versions.VersionStamp;
-import org.apache.geode.internal.cache.versions.VersionTag;
+import org.apache.geode.internal.cache.versions.*;
import org.apache.geode.internal.cache.vmotion.VMotionObserverHolder;
import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -1473,11 +1434,13 @@ public class InitialImageOperation {
int initLevel = targetReinitialized ? LocalRegion.AFTER_INITIAL_IMAGE : LocalRegion.ANY_INIT;
int oldLevel = LocalRegion.setThreadInitLevelRequirement(initLevel);
try {
+ DistributedSystem system = dm.getSystem();
+ // GemFireCache cache = (GemFireCache)CacheFactory.getInstance(system);
if (isDebugEnabled) {
logger.debug("RequestImageMessage: attempting to get region reference for {}, initLevel={}",
regionPath, initLevel);
}
- lclRgn = dm.getCache().getRegionByPath(regionPath);
+ lclRgn = LocalRegion.getRegionFromPath(system, regionPath);
// if this is a targeted getInitialImage after a region was initialized,
// make sure this is the region that was reinitialized.
if (lclRgn != null && !lclRgn.isUsedForPartitionedRegionBucket() && targetReinitialized
@@ -1500,7 +1463,7 @@ public class InitialImageOperation {
return null;
}
- if (lclRgn.getScope().isLocal()) {
+ if (lclRgn.scope.isLocal()) {
if (isDebugEnabled) {
logger.debug("local scope region, nothing to do");
}
@@ -2233,7 +2196,8 @@ public class InitialImageOperation {
ReplyException rex = null;
try {
Assert.assertTrue(this.regionPath != null, "Region path is null.");
- lclRgn = dm.getCache().getRegionByPath(regionPath);
+ DistributedSystem system = dm.getSystem();
+ lclRgn = LocalRegion.getRegionFromPath(system, this.regionPath);
if (lclRgn == null) {
if (logger.isDebugEnabled()) {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index d8b51b1..8640751 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -144,6 +144,7 @@ import org.apache.geode.cache.query.internal.index.IndexUtils;
import org.apache.geode.cache.util.ObjectSizer;
import org.apache.geode.cache.wan.GatewaySender;
import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.distributed.internal.DistributionAdvisor;
import org.apache.geode.distributed.internal.DistributionAdvisor.Profile;
import org.apache.geode.distributed.internal.DistributionConfig;
@@ -2263,6 +2264,21 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/**
+ * Look up the LocalRegion with the specified full path.
+ *
+ * @param system the distributed system whose cache contains the root of interest
+ * @return the LocalRegion or null if not found
+ */
+ static LocalRegion getRegionFromPath(DistributedSystem system, String path) {
+ Cache cache = GemFireCacheImpl.getInstance();
+ if (cache == null) {
+ return null;
+ } else {
+ return (LocalRegion) cache.getRegion(path);
+ }
+ }
+
+ /**
* Do any extra initialization required. Region is already visible in parent's subregion map. This
* method releases the initialization Latches, so subclasses should call this super method last
* after performing additional initialization.
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
index bdee3f6..3cb9209 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/TXCommitMessage.java
@@ -1172,9 +1172,9 @@ public class TXCommitMessage extends PooledDistributionMessage
}
private boolean hookupRegion(DistributionManager dm) {
- this.r = getRegionByPath(dm, regionPath);
+ this.r = LocalRegion.getRegionFromPath(dm.getSystem(), this.regionPath);
if (this.r == null && this.parentRegionPath != null) {
- this.r = getRegionByPath(dm, this.parentRegionPath);
+ this.r = LocalRegion.getRegionFromPath(dm.getSystem(), this.parentRegionPath);
this.regionPath = this.parentRegionPath;
}
if (this.r == null && dm.getSystem().isLoner()) {
@@ -1186,10 +1186,6 @@ public class TXCommitMessage extends PooledDistributionMessage
return true;
}
- LocalRegion getRegionByPath(DistributionManager dm, String regionPath) {
- return dm.getCache().getRegionByPath(regionPath);
- }
-
/**
* Called when processing is complete; only needs to be called if beginProcess returned true.
*/
@@ -1359,7 +1355,7 @@ public class TXCommitMessage extends PooledDistributionMessage
public boolean isForceFireEvent(DistributionManager dm) {
- LocalRegion r = dm.getCache().getRegionByPath(regionPath);
+ LocalRegion r = LocalRegion.getRegionFromPath(dm.getSystem(), this.regionPath);
if (r instanceof PartitionedRegion || (r != null && r.isUsedForPartitionedRegionBucket())) {
return false;
}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/CacheProfileTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/CacheProfileTest.java
deleted file mode 100644
index d9b400f..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/CacheProfileTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.cache;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.distributed.internal.ClusterDistributionManager;
-import org.apache.geode.internal.cache.CacheDistributionAdvisor.CacheProfile;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class CacheProfileTest {
-
- private ClusterDistributionManager dm;
- private InternalCache cache;
- private String adviseePath;
- private LocalRegion region;
-
- @Before
- public void setUp() {
- adviseePath = "adviseePath";
-
- dm = mock(ClusterDistributionManager.class);
- cache = mock(InternalCache.class);
- region = mock(LocalRegion.class);
-
- when(dm.getCache()).thenReturn(cache);
- when(cache.getRegionByPath(adviseePath)).thenReturn(region);
- }
-
- @Test
- public void getsRegionFromCacheFromDM() {
- CacheProfile profile = new CacheProfile();
- profile.processIncoming(dm, adviseePath, false, false, null);
- verify(dm, times(1)).getCache();
- verify(cache, times(1)).getRegionByPath(adviseePath);
- }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/InitialImageOperationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/InitialImageOperationTest.java
deleted file mode 100644
index af98d9c..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/InitialImageOperationTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.cache;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.Scope;
-import org.apache.geode.distributed.internal.ClusterDistributionManager;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class InitialImageOperationTest {
-
- private ClusterDistributionManager dm;
- private String path;
- private LocalRegion region;
- private InternalCache cache;
-
- @Before
- public void setUp() {
- path = "path";
-
- cache = mock(InternalCache.class);
- dm = mock(ClusterDistributionManager.class);
- region = mock(LocalRegion.class);
-
- when(dm.getCache()).thenReturn(cache);
- when(cache.getRegionByPath(path)).thenReturn(region);
- when(region.isInitialized()).thenReturn(true);
- when(region.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
- }
-
- @Test
- public void getsRegionFromCacheFromDM() {
- LocalRegion value = InitialImageOperation.getGIIRegion(dm, path, false);
- assertThat(value).isSameAs(region);
- }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RegionCommitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RegionCommitTest.java
deleted file mode 100644
index 7f4fae8..0000000
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/RegionCommitTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.internal.cache;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.distributed.internal.ClusterDistributionManager;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
-import org.apache.geode.internal.cache.TXCommitMessage.RegionCommit;
-import org.apache.geode.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class RegionCommitTest {
-
- private ClusterDistributionManager dm;
- private String path;
- private LocalRegion region;
- private TXCommitMessage txCommitMessage;
-
- @Before
- public void setUp() {
- path = "path";
-
- InternalCache cache = mock(InternalCache.class);
-
- dm = mock(ClusterDistributionManager.class);
- region = mock(LocalRegion.class);
- txCommitMessage = mock(TXCommitMessage.class);
-
- when(dm.getCache()).thenReturn(cache);
- when(cache.getRegionByPath(path)).thenReturn(region);
- when(dm.getSystem()).thenReturn(mock(InternalDistributedSystem.class));
- }
-
- @Test
- public void getsRegionFromCacheFromDM() {
- RegionCommit regionCommit = new RegionCommit(txCommitMessage);
- assertThat(regionCommit.getRegionByPath(dm, path)).isEqualTo(region);
- }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java
index 31238af..062b0f0 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/RequestFilterInfoMessageTest.java
@@ -16,51 +16,21 @@ package org.apache.geode.internal.cache;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.apache.geode.distributed.internal.ClusterDistributionManager;
import org.apache.geode.internal.cache.InitialImageOperation.RequestFilterInfoMessage;
import org.apache.geode.test.junit.categories.UnitTest;
@Category(UnitTest.class)
public class RequestFilterInfoMessageTest {
- private ClusterDistributionManager dm;
- private InternalCache cache;
- private String path;
- private LocalRegion region;
-
- @Before
- public void setUp() {
- path = "path";
-
- dm = mock(ClusterDistributionManager.class);
- cache = mock(InternalCache.class);
- region = mock(LocalRegion.class);
-
- when(dm.getCache()).thenReturn(cache);
- when(cache.getRegionByPath(path)).thenReturn(region);
- }
-
@Test
public void shouldBeMockable() throws Exception {
RequestFilterInfoMessage mockRequestFilterInfoMessage = mock(RequestFilterInfoMessage.class);
when(mockRequestFilterInfoMessage.getProcessorType()).thenReturn(1);
assertThat(mockRequestFilterInfoMessage.getProcessorType()).isEqualTo(1);
}
-
- @Test
- public void getsRegionFromCacheFromDM() {
- RequestFilterInfoMessage message = new RequestFilterInfoMessage();
- message.regionPath = path;
- message.process(dm);
- verify(dm, times(1)).getCache();
- verify(cache, times(1)).getRegionByPath(path);
- }
}
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].