You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2017/04/27 18:47:58 UTC
[23/40] geode git commit: GEODE-2632: cleanup GemFireCacheImpl
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/disttx/DistTXPersistentDebugDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/disttx/DistTXPersistentDebugDUnitTest.java b/geode-core/src/test/java/org/apache/geode/disttx/DistTXPersistentDebugDUnitTest.java
index 5753f5c..d999da9 100644
--- a/geode-core/src/test/java/org/apache/geode/disttx/DistTXPersistentDebugDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/disttx/DistTXPersistentDebugDUnitTest.java
@@ -16,6 +16,9 @@ package org.apache.geode.disttx;
import static org.apache.geode.test.dunit.Assert.*;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheTransactionManager;
@@ -31,8 +34,6 @@ import org.apache.geode.test.dunit.Invoke;
import org.apache.geode.test.dunit.LogWriterUtils;
import org.apache.geode.test.dunit.SerializableCallable;
import org.apache.geode.test.junit.categories.DistributedTest;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
@Category(DistributedTest.class)
public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
@@ -61,7 +62,7 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
});
}
- protected void createPesistentPR(Object[] attributes) {
+ private void createPersistentPR(Object[] attributes) {
dataStore1.invoke(DistTXPersistentDebugDUnitTest.class, "createPersistentPR", attributes);
dataStore2.invoke(DistTXPersistentDebugDUnitTest.class, "createPersistentPR", attributes);
// dataStore3.invoke(TxPersistentDebugDUnit.class, "createPR", attributes);
@@ -76,7 +77,7 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
getPersistentPRAttributes(1, -1, basicGetCache(), 113, true));
}
- protected static RegionAttributes getPersistentPRAttributes(final int redundancy,
+ private static RegionAttributes getPersistentPRAttributes(final int redundancy,
final int recoveryDelay, Cache cache, int numBuckets, boolean synchronous) {
DiskStore ds = cache.findDiskStore("disk");
if (ds == null) {
@@ -92,8 +93,7 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
af.setDiskStoreName("disk");
af.setDiskSynchronous(synchronous);
- RegionAttributes attr = af.create();
- return attr;
+ return af.create();
}
@Test
@@ -101,7 +101,8 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
createCacheInAllVms();
final String regionName = "persistentCustomerPRRegion";
Object[] attrs = new Object[] {regionName};
- createPesistentPR(attrs);
+ createPersistentPR(attrs);
+
SerializableCallable TxOps = new SerializableCallable() {
@Override
public Object call() throws Exception {
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterJUnitTest.java b/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterJUnitTest.java
index 0a61b1f..dec2f88 100644
--- a/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterJUnitTest.java
@@ -14,6 +14,13 @@
*/
package org.apache.geode.disttx;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.TXWriterJUnitTest;
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.CacheException;
@@ -24,11 +31,6 @@ import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.test.junit.categories.DistributedTransactionsTest;
import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
/**
* Same tests as that of {@link TXWriterJUnitTest} after setting "distributed-transactions" property
@@ -37,19 +39,22 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
@Category({IntegrationTest.class, DistributedTransactionsTest.class})
public class DistTXWriterJUnitTest extends TXWriterJUnitTest {
- public DistTXWriterJUnitTest() {}
-
+ @Override
protected void createCache() throws CacheException {
- Properties p = new Properties();
- p.setProperty(MCAST_PORT, "0"); // loner
- p.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
- this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(p));
- AttributesFactory<?, ?> af = new AttributesFactory<String, String>();
- af.setScope(Scope.DISTRIBUTED_NO_ACK);
- af.setIndexMaintenanceSynchronous(true);
- this.region = this.cache.createRegion("TXTest", af.create());
+ Properties properties = new Properties();
+ properties.setProperty(MCAST_PORT, "0"); // loner
+ properties.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
+
+ this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(properties));
+
+ AttributesFactory<String, String> attributesFactory = new AttributesFactory<>();
+ attributesFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
+ attributesFactory.setIndexMaintenanceSynchronous(true);
+
+ this.region = this.cache.createRegion("TXTest", attributesFactory.create());
this.txMgr = this.cache.getCacheTransactionManager();
- assert (this.txMgr.isDistributed());
+
+ assertTrue(this.txMgr.isDistributed());
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterOOMEJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterOOMEJUnitTest.java b/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterOOMEJUnitTest.java
index b99d3fd..896530d 100644
--- a/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterOOMEJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/disttx/DistTXWriterOOMEJUnitTest.java
@@ -14,21 +14,23 @@
*/
package org.apache.geode.disttx;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.TXWriterOOMEJUnitTest;
import org.apache.geode.cache.AttributesFactory;
import org.apache.geode.cache.CacheException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.Scope;
-import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.distributed.DistributedSystem;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.test.junit.categories.DistributedTransactionsTest;
import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
/**
* Same tests as that of {@link TXWriterOOMEJUnitTest} after setting "distributed-transactions"
@@ -37,19 +39,22 @@ import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
@Category({IntegrationTest.class, DistributedTransactionsTest.class})
public class DistTXWriterOOMEJUnitTest extends TXWriterOOMEJUnitTest {
- public DistTXWriterOOMEJUnitTest() {}
-
+ @Override
protected void createCache() throws CacheException {
- Properties p = new Properties();
- p.setProperty(MCAST_PORT, "0"); // loner
- p.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
- this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(p));
- AttributesFactory<?, ?> af = new AttributesFactory<String, String>();
- af.setScope(Scope.DISTRIBUTED_NO_ACK);
- af.setIndexMaintenanceSynchronous(true);
- this.region = this.cache.createRegion("TXTest", af.create());
+ Properties properties = new Properties();
+ properties.setProperty(MCAST_PORT, "0"); // loner
+ properties.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
+
+ this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(properties));
+
+ AttributesFactory<String, String> attributesFactory = new AttributesFactory<>();
+ attributesFactory.setScope(Scope.DISTRIBUTED_NO_ACK);
+ attributesFactory.setIndexMaintenanceSynchronous(true);
+
+ this.region = this.cache.createRegion("TXTest", attributesFactory.create());
this.txMgr = this.cache.getCacheTransactionManager();
- assert (this.txMgr.isDistributed());
+
+ assertTrue(this.txMgr.isDistributed());
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java
index 5471565..fe79801 100644
--- a/geode-core/src/test/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/disttx/DistributedTransactionDUnitTest.java
@@ -44,7 +44,6 @@ import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.i18n.LogWriterI18n;
import org.apache.geode.internal.AvailablePort;
import org.apache.geode.internal.cache.BucketRegion;
-import org.apache.geode.internal.cache.CacheServerImpl;
import org.apache.geode.internal.cache.DistTXState;
import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.LocalRegion;
@@ -1383,7 +1382,7 @@ public class DistributedTransactionDUnitTest extends JUnit4CacheTestCase {
@Override
public Object call() throws Exception {
CountDownLatch cdl = new CountDownLatch(1);
- GemFireCacheImpl.internalBeforeApplyChanges = new WaitRelease(cdl, "TX OP");
+ DistTXState.internalBeforeApplyChanges = new WaitRelease(cdl, "TX OP");
return null;
}
};
@@ -1396,7 +1395,7 @@ public class DistributedTransactionDUnitTest extends JUnit4CacheTestCase {
@Override
public Object call() throws Exception {
CountDownLatch cdl = new CountDownLatch(1);
- GemFireCacheImpl.internalBeforeNonTXBasicPut = new WaitRelease(cdl, "NON TX OP");
+ DistTXState.internalBeforeNonTXBasicPut = new WaitRelease(cdl, "NON TX OP");
return null;
}
};
@@ -1457,7 +1456,7 @@ public class DistributedTransactionDUnitTest extends JUnit4CacheTestCase {
execute(secondary, new SerializableCallable() {
@Override
public Object call() throws Exception {
- Runnable r = GemFireCacheImpl.internalBeforeNonTXBasicPut;
+ Runnable r = DistTXState.internalBeforeNonTXBasicPut;
assert (r != null && r instanceof WaitRelease);
WaitRelease e = (WaitRelease) r;
e.release();
@@ -1469,7 +1468,7 @@ public class DistributedTransactionDUnitTest extends JUnit4CacheTestCase {
execute(secondary, new SerializableCallable() {
@Override
public Object call() throws Exception {
- Runnable r = GemFireCacheImpl.internalBeforeApplyChanges;
+ Runnable r = DistTXState.internalBeforeApplyChanges;
assert (r != null && r instanceof WaitRelease);
WaitRelease e = (WaitRelease) r;
e.release();
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/disttx/PRDistTXJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/disttx/PRDistTXJUnitTest.java b/geode-core/src/test/java/org/apache/geode/disttx/PRDistTXJUnitTest.java
index f27c099..268a733 100644
--- a/geode-core/src/test/java/org/apache/geode/disttx/PRDistTXJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/disttx/PRDistTXJUnitTest.java
@@ -14,6 +14,15 @@
*/
package org.apache.geode.disttx;
+import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.cache.CacheException;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.distributed.ConfigurationProperties;
@@ -22,33 +31,27 @@ import org.apache.geode.internal.cache.GemFireCacheImpl;
import org.apache.geode.internal.cache.PRTXJUnitTest;
import org.apache.geode.test.junit.categories.DistributedTransactionsTest;
import org.apache.geode.test.junit.categories.IntegrationTest;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
/**
* Same tests as that of {@link PRTXJUnitTest} after setting "distributed-transactions" property to
* true
- *
*/
@Category({IntegrationTest.class, DistributedTransactionsTest.class})
public class PRDistTXJUnitTest extends PRTXJUnitTest {
- public PRDistTXJUnitTest() {}
-
@Override
protected void createCache() throws Exception {
Properties p = new Properties();
p.setProperty(MCAST_PORT, "0"); // loner
p.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
+
this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(p));
+
createRegion();
this.txMgr = this.cache.getCacheTransactionManager();
- assert (this.txMgr.isDistributed());
+
+ assertTrue(this.txMgr.isDistributed());
+
this.listenerAfterCommit = 0;
this.listenerAfterFailedCommit = 0;
this.listenerAfterRollback = 0;
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/internal/cache/PRTXJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PRTXJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PRTXJUnitTest.java
index d2bad64..1caffbd 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PRTXJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PRTXJUnitTest.java
@@ -12,9 +12,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-/**
- *
- */
package org.apache.geode.internal.cache;
import org.junit.Ignore;
@@ -30,132 +27,83 @@ import org.apache.geode.cache.PartitionAttributesFactory;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.query.QueryException;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.apache.geode.internal.cache.InternalRegionArguments;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.internal.cache.PartitionedRegion;
import org.apache.geode.test.junit.categories.IntegrationTest;
-/**
- *
- */
@Category(IntegrationTest.class)
public class PRTXJUnitTest extends TXJUnitTest {
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geode.TXTest#createRegion()
- */
@Override
protected void createRegion() throws Exception {
- AttributesFactory af = new AttributesFactory();
- af.setConcurrencyChecksEnabled(false); // test validation expects this behavior
- af.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(3).create());
- // this.region = this.cache.createRegion("PRTXJUnitTest", af.create());
- this.region = new PRWithLocalOps("PRTXJUnitTest", af.create(), null, this.cache,
- new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false)
+ AttributesFactory attributesFactory = new AttributesFactory();
+ // test validation expects this behavior
+ attributesFactory.setConcurrencyChecksEnabled(false);
+ attributesFactory
+ .setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(3).create());
+
+ this.region = new PRWithLocalOps(getClass().getSimpleName(), attributesFactory.create(), null,
+ this.cache, new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false)
.setSnapshotInputStream(null).setImageTarget(null));
+
((PartitionedRegion) this.region).initialize(null, null, null);
((PartitionedRegion) this.region).postCreateRegion();
this.cache.setRegionByPath(this.region.getFullPath(), (LocalRegion) this.region);
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geode.TXTest#checkUserAttributeConflict(org.apache.geode.internal.cache.
- * TXManagerImpl)
- */
@Override
protected void checkUserAttributeConflict(CacheTransactionManager txMgrImpl) {}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.geode.TXTest#checkSubRegionCollecection(org.apache.geode.internal.cache.LocalRegion)
- */
@Override
- protected void checkSubRegionCollecection(Region reg1) {}
+ protected void checkSubRegionCollection(Region reg1) {}
@Override
@Ignore
@Test
- public void testTXAndQueries() throws CacheException, QueryException {
- // TODO fix this?
- }
+ public void testTXAndQueries() throws CacheException, QueryException {}
@Override
@Ignore
@Test
- public void testCollections() throws CacheException {
- // TODO make PR iterators tx aware
- }
+ public void testCollections() throws CacheException {}
@Override
@Ignore
@Test
- public void testTxAlgebra() throws CacheException {
- // TODO Auto-generated method stub
- }
+ public void testTxAlgebra() throws CacheException {}
@Test
public void testTxId() {
- AttributesFactory<Integer, String> af = new AttributesFactory<Integer, String>();
- af.setPartitionAttributes(
+ AttributesFactory<String, Integer> attributesFactory = new AttributesFactory<>();
+ attributesFactory.setPartitionAttributes(
new PartitionAttributesFactory<String, Integer>().setTotalNumBuckets(2).create());
- Region<String, Integer> r = this.cache.createRegion("testTxId", af.create());
- r.put("one", 1);
- CacheTransactionManager mgr = this.cache.getTxManager();
- mgr.begin();
- r.put("two", 2);
- mgr.getTransactionId();
- mgr.rollback();
+
+ Region<String, Integer> region =
+ this.cache.createRegion("testTxId", attributesFactory.create());
+ region.put("one", 1);
+
+ CacheTransactionManager txManager = this.cache.getTxManager();
+ txManager.begin();
+ region.put("two", 2);
+ txManager.getTransactionId();
+ txManager.rollback();
}
private static class PRWithLocalOps extends PartitionedRegion {
- /**
- * @param regionname
- * @param ra
- * @param parentRegion
- * @param cache
- * @param internalRegionArgs
- */
- public PRWithLocalOps(String regionname, RegionAttributes ra, LocalRegion parentRegion,
+ PRWithLocalOps(String regionName, RegionAttributes ra, LocalRegion parentRegion,
GemFireCacheImpl cache, InternalRegionArguments internalRegionArgs) {
- super(regionname, ra, parentRegion, cache, internalRegionArgs);
+ super(regionName, ra, parentRegion, cache, internalRegionArgs);
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geode.internal.cache.PartitionedRegion#localDestroy(java.lang.Object,
- * java.lang.Object)
- */
@Override
public void localDestroy(Object key, Object callbackArgument) throws EntryNotFoundException {
super.destroy(key, callbackArgument);
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geode.internal.cache.PartitionedRegion#localInvalidate(java.lang.Object,
- * java.lang.Object)
- */
@Override
public void localInvalidate(Object key, Object callbackArgument) throws EntryNotFoundException {
super.invalidate(key, callbackArgument);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.geode.internal.cache.PartitionedRegion#localInvalidateRegion(java.lang.Object)
- */
@Override
public void localInvalidateRegion(Object callbackArgument) {
super.invalidateRegion(callbackArgument);
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
index d57ce12..1a8bbf3 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/wan/parallel/ParallelQueueRemovalMessageJUnitTest.java
@@ -14,31 +14,61 @@
*/
package org.apache.geode.internal.cache.wan.parallel;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import jdk.nashorn.internal.ir.annotations.Ignore;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.CancelCriterion;
-import org.apache.geode.cache.*;
-import org.apache.geode.internal.cache.*;
+import org.apache.geode.cache.AttributesFactory;
+import org.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.EvictionAction;
+import org.apache.geode.cache.EvictionAttributes;
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionAttributes;
+import org.apache.geode.cache.Scope;
+import org.apache.geode.internal.cache.BucketAdvisor;
+import org.apache.geode.internal.cache.BucketRegionQueue;
+import org.apache.geode.internal.cache.BucketRegionQueueHelper;
+import org.apache.geode.internal.cache.EvictionAttributesImpl;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.InternalRegionArguments;
+import org.apache.geode.internal.cache.KeyInfo;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.PartitionedRegionDataStore;
+import org.apache.geode.internal.cache.PartitionedRegionHelper;
+import org.apache.geode.internal.cache.PartitionedRegionStats;
+import org.apache.geode.internal.cache.ProxyBucketRegion;
+import org.apache.geode.internal.cache.RegionQueue;
import org.apache.geode.internal.cache.lru.LRUAlgorithm;
import org.apache.geode.internal.cache.partitioned.RegionAdvisor;
import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
import org.apache.geode.internal.cache.wan.GatewaySenderEventImpl;
import org.apache.geode.test.fake.Fakes;
import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.util.*;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
@Category(UnitTest.class)
+@Ignore() // minor changes to GemFireCacheImpl break this test
public class ParallelQueueRemovalMessageJUnitTest {
+ private static final String GATEWAY_SENDER_ID = "ny";
+ private static final int BUCKET_ID = 85;
+ private static final long KEY = 198;
+
private GemFireCacheImpl cache;
private PartitionedRegion queueRegion;
private AbstractGatewaySender sender;
@@ -46,10 +76,6 @@ public class ParallelQueueRemovalMessageJUnitTest {
private BucketRegionQueue bucketRegionQueue;
private BucketRegionQueueHelper bucketRegionQueueHelper;
- private static String GATEWAY_SENDER_ID = "ny";
- private static int BUCKET_ID = 85;
- private static long KEY = 198l;
-
@Before
public void setUpGemFire() {
createCache();
@@ -115,10 +141,10 @@ public class ParallelQueueRemovalMessageJUnitTest {
when(this.queueRegion.getPartitionAttributes()).thenReturn(pa);
when(this.queueRegion.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
when(pa.getColocatedWith()).thenReturn(null);
- ProxyBucketRegion pbr = new ProxyBucketRegion(BUCKET_ID, this.queueRegion, pbrIra); // final
- // classes
- // cannot be
- // mocked
+
+ // final classes cannot be mocked
+ ProxyBucketRegion pbr = new ProxyBucketRegion(BUCKET_ID, this.queueRegion, pbrIra);
+
when(ba.getProxyBucketRegion()).thenReturn(pbr);
// Create RegionAttributes
@@ -182,11 +208,11 @@ public class ParallelQueueRemovalMessageJUnitTest {
assertFalse(this.bucketRegionQueue.isInitialized());
// Create a real ConcurrentParallelGatewaySenderQueue
- ParallelGatewaySenderEventProcessor pgsep = createConcurrentParallelGatewaySenderQueue();
+ ParallelGatewaySenderEventProcessor processor = createConcurrentParallelGatewaySenderQueue();
// Add a mock GatewaySenderEventImpl to the temp queue
BlockingQueue<GatewaySenderEventImpl> tempQueue =
- createTempQueueAndAddEvent(pgsep, mock(GatewaySenderEventImpl.class));
+ createTempQueueAndAddEvent(processor, mock(GatewaySenderEventImpl.class));
assertEquals(1, tempQueue.size());
// Create and process a ParallelQueueRemovalMessage (causes the failedBatchRemovalMessageKeys to
@@ -204,14 +230,14 @@ public class ParallelQueueRemovalMessageJUnitTest {
assertEquals(0, this.bucketRegionQueue.size());
// Create a real ConcurrentParallelGatewaySenderQueue
- ParallelGatewaySenderEventProcessor pgsep = createConcurrentParallelGatewaySenderQueue();
+ ParallelGatewaySenderEventProcessor processor = createConcurrentParallelGatewaySenderQueue();
// Add an event to the BucketRegionQueue and verify BucketRegionQueue state
- GatewaySenderEventImpl gsei = this.bucketRegionQueueHelper.addEvent(KEY);
+ GatewaySenderEventImpl event = this.bucketRegionQueueHelper.addEvent(KEY);
assertEquals(1, this.bucketRegionQueue.size());
// Add a mock GatewaySenderEventImpl to the temp queue
- BlockingQueue<GatewaySenderEventImpl> tempQueue = createTempQueueAndAddEvent(pgsep, gsei);
+ BlockingQueue<GatewaySenderEventImpl> tempQueue = createTempQueueAndAddEvent(processor, event);
assertEquals(1, tempQueue.size());
// Create and process a ParallelQueueRemovalMessage (causes the value of the entry to be set to
@@ -230,9 +256,9 @@ public class ParallelQueueRemovalMessageJUnitTest {
}
private void createAndProcessParallelQueueRemovalMessage() {
- ParallelQueueRemovalMessage pqrm =
+ ParallelQueueRemovalMessage message =
new ParallelQueueRemovalMessage(createRegionToDispatchedKeysMap());
- pqrm.process(null);
+ message.process(null);
}
private HashMap<String, Map<Integer, List<Long>>> createRegionToDispatchedKeysMap() {
@@ -246,23 +272,23 @@ public class ParallelQueueRemovalMessageJUnitTest {
}
private ParallelGatewaySenderEventProcessor createConcurrentParallelGatewaySenderQueue() {
- ParallelGatewaySenderEventProcessor pgsep = new ParallelGatewaySenderEventProcessor(sender);
- ConcurrentParallelGatewaySenderQueue cpgsq = new ConcurrentParallelGatewaySenderQueue(sender,
- new ParallelGatewaySenderEventProcessor[] {pgsep});
+ ParallelGatewaySenderEventProcessor processor = new ParallelGatewaySenderEventProcessor(sender);
+ ConcurrentParallelGatewaySenderQueue queue = new ConcurrentParallelGatewaySenderQueue(sender,
+ new ParallelGatewaySenderEventProcessor[] {processor});
Set<RegionQueue> queues = new HashSet<>();
- queues.add(cpgsq);
+ queues.add(queue);
when(this.sender.getQueues()).thenReturn(queues);
- return pgsep;
+ return processor;
}
private BlockingQueue<GatewaySenderEventImpl> createTempQueueAndAddEvent(
- ParallelGatewaySenderEventProcessor pgsep, GatewaySenderEventImpl gsei) {
- ParallelGatewaySenderQueue pgsq = (ParallelGatewaySenderQueue) pgsep.getQueue();
+ ParallelGatewaySenderEventProcessor processor, GatewaySenderEventImpl event) {
+ ParallelGatewaySenderQueue queue = (ParallelGatewaySenderQueue) processor.getQueue();
Map<Integer, BlockingQueue<GatewaySenderEventImpl>> tempQueueMap =
- pgsq.getBucketToTempQueueMap();
- BlockingQueue<GatewaySenderEventImpl> tempQueue = new LinkedBlockingQueue();
- when(gsei.getShadowKey()).thenReturn(KEY);
- tempQueue.add(gsei);
+ queue.getBucketToTempQueueMap();
+ BlockingQueue<GatewaySenderEventImpl> tempQueue = new LinkedBlockingQueue<>();
+ when(event.getShadowKey()).thenReturn(KEY);
+ tempQueue.add(event);
tempQueueMap.put(BUCKET_ID, tempQueue);
return tempQueue;
}
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
index f8b1415..4ccf8c2 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/cache/internal/JUnit4CacheTestCase.java
@@ -193,9 +193,10 @@ public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase
CacheXmlGenerator.generate(cache, pw);
pw.close();
} catch (IOException ex) {
- Assert.fail("IOException during cache.xml generation to " + file, ex); // TODO: remove error
- // handling
+ // TODO: remove error handling
+ Assert.fail("IOException during cache.xml generation to " + file, ex);
}
+ // TODO: System.setProperty(GEMFIRE_PREFIX + CACHE_XML_FILE, file.getAbsolutePath());
cache = null;
GemFireCacheImpl.testCacheXml = file;
try {
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
index 537d598..4175e81 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/internal/DistributedTestFixture.java
@@ -14,12 +14,13 @@
*/
package org.apache.geode.test.dunit.internal;
+import java.io.Serializable;
import java.util.Properties;
/**
* Defines the {@code DistributedTestCase} methods that can be overridden by its subclasses.
*/
-public interface DistributedTestFixture {
+public interface DistributedTestFixture extends Serializable {
/**
* {@code preSetUp()} is invoked before {@code DistributedTestCase#setUp()}.
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java
index 9e00d0a..841036e 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/GetDefaultDiskStoreNameDUnitTest.java
@@ -62,6 +62,6 @@ public class GetDefaultDiskStoreNameDUnitTest extends JUnit4DistributedTestCase
}
private String getDefaultDiskStoreName() {
- return GemFireCacheImpl.DEFAULT_DS_NAME; // TODO: not thread safe
+ return GemFireCacheImpl.getDefaultDiskStoreName(); // TODO: not thread safe
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
index e3e8cbb..1a45991 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/tests/JUnit4GetDefaultDiskStoreNameDUnitTest.java
@@ -61,6 +61,6 @@ public class JUnit4GetDefaultDiskStoreNameDUnitTest extends JUnit4DistributedTes
}
private String getDefaultDiskStoreName() {
- return GemFireCacheImpl.DEFAULT_DS_NAME; // TODO: not thread safe
+ return GemFireCacheImpl.getDefaultDiskStoreName(); // TODO: not thread safe
}
}
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-core/src/test/resources/org/apache/geode/cache/query/dunit/IndexCreation.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/org/apache/geode/cache/query/dunit/IndexCreation.xml b/geode-core/src/test/resources/org/apache/geode/cache/query/dunit/IndexCreation.xml
index aa46ce8..953fe27 100644
--- a/geode-core/src/test/resources/org/apache/geode/cache/query/dunit/IndexCreation.xml
+++ b/geode-core/src/test/resources/org/apache/geode/cache/query/dunit/IndexCreation.xml
@@ -19,19 +19,19 @@
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Cache 7.0//EN" "http://www.gemstone.com/dtd/cache7_0.dtd">
<cache>
- <region name="PartionedPortfolios">
+ <region name="PartitionedPortfolios">
<region-attributes>
<partition-attributes redundant-copies="1" total-num-buckets="50"/>
<subscription-attributes interest-policy="cache-content"/>
</region-attributes>
<index name="statusIndex">
- <functional from-clause="/PartionedPortfolios p" expression="p.status"/>
+ <functional from-clause="/PartitionedPortfolios p" expression="p.status"/>
</index>
<index name="idIndex">
- <functional from-clause="/PartionedPortfolios p" expression="p.ID"/>
+ <functional from-clause="/PartitionedPortfolios p" expression="p.ID"/>
</index>
<index name="secIndex">
- <functional from-clause="/PartionedPortfolios p, p.positions.values pos" expression="pos.secId"/>
+ <functional from-clause="/PartitionedPortfolios p, p.positions.values pos" expression="pos.secId"/>
</index>
</region>
<region name="Portfolios">
@@ -85,14 +85,14 @@
<index name="idIndex" type="range" from-clause="/PersistentPrPortfoliosWithRange p" expression="p.ID"/>
<index name="secIndex" from-clause="/PersistentPrPortfoliosWithRange p, p.positions.values pos" expression="pos.secId"/>
</region>
- <region name="PartionedPortfoliosWithHash">
+ <region name="PartitionedPortfoliosWithHash">
<region-attributes>
<partition-attributes redundant-copies="1" total-num-buckets="50"/>
<subscription-attributes interest-policy="cache-content"/>
</region-attributes>
- <index name="statusIndex" type="hash" from-clause="/PartionedPortfoliosWithHash p" expression="p.status"/>
- <index name="idIndex" type="hash" from-clause="/PartionedPortfoliosWithHash p" expression="p.ID"/>
- <index name="secIndex" from-clause="/PartionedPortfoliosWithHash p, p.positions.values pos" expression="pos.secId"/>
+ <index name="statusIndex" type="hash" from-clause="/PartitionedPortfoliosWithHash p" expression="p.status"/>
+ <index name="idIndex" type="hash" from-clause="/PartitionedPortfoliosWithHash p" expression="p.ID"/>
+ <index name="secIndex" from-clause="/PartitionedPortfoliosWithHash p, p.positions.values pos" expression="pos.secId"/>
</region>
<region name="PortfoliosWithHash">
<region-attributes scope="distributed-ack" data-policy="replicate">
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-cq/src/main/java/org/apache/geode/cache/query/internal/cq/CqServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/org/apache/geode/cache/query/internal/cq/CqServiceImpl.java b/geode-cq/src/main/java/org/apache/geode/cache/query/internal/cq/CqServiceImpl.java
index 570c06c..54cadcb 100644
--- a/geode-cq/src/main/java/org/apache/geode/cache/query/internal/cq/CqServiceImpl.java
+++ b/geode-cq/src/main/java/org/apache/geode/cache/query/internal/cq/CqServiceImpl.java
@@ -776,7 +776,7 @@ public final class CqServiceImpl implements CqService {
if (clientProxyId == null) {
throw new CqException(
LocalizedStrings.CqService_UNABLE_TO_RETRIEVE_DURABLE_CQS_FOR_CLIENT_PROXY_ID
- .toLocalizedString(null));
+ .toLocalizedString());
}
List<ServerCQ> cqs = getAllClientCqs(clientProxyId);
ArrayList<String> durableClientCqs = new ArrayList<>();
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java b/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
index f298fae..9332388 100644
--- a/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
+++ b/geode-cq/src/test/java/org/apache/geode/cache/query/dunit/QueryMonitorDUnitTest.java
@@ -220,12 +220,12 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
Assert.fail("While starting CacheServer", ex);
}
Cache cache = getCache();
- GemFireCacheImpl.getInstance().TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
+ GemFireCacheImpl.getInstance().testMaxQueryExecutionTime = queryMonitorTime;
cache.getLogger().fine("#### RUNNING TEST : " + testName);
DefaultQuery.testHook = new QueryTimeoutHook(queryMonitorTime);
- // ((GemFireCache)cache).TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
+ // ((GemFireCache)cache).testMaxQueryExecutionTime = queryMonitorTime;
System.out.println("MAX_QUERY_EXECUTION_TIME is set to: "
- + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
+ + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
return port;
}
@@ -236,10 +236,10 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
// Reset the test flag.
Cache cache = getCache();
DefaultQuery.testHook = null;
- GemFireCacheImpl.getInstance().TEST_MAX_QUERY_EXECUTION_TIME = -1;
+ GemFireCacheImpl.getInstance().testMaxQueryExecutionTime = -1;
stopBridgeServer(getCache());
System.out.println("MAX_QUERY_EXECUTION_TIME is set to: "
- + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
+ + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
}
};
server.invoke(stopServer);
@@ -333,7 +333,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
private void executeQueriesFromClient(int timeout) {
try {
ClientCache anyInstance = ClientCacheFactory.getAnyInstance();
- ((GemFireCacheImpl) anyInstance).TEST_MAX_QUERY_EXECUTION_TIME = timeout;
+ ((GemFireCacheImpl) anyInstance).testMaxQueryExecutionTime = timeout;
Pool pool = PoolManager.find(poolName);
QueryService queryService = pool.getQueryService();
executeQueriesAgainstQueryService(queryService);
@@ -882,7 +882,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest();
/**
- * The following CQ test is added to make sure TEST_MAX_QUERY_EXECUTION_TIME is reset and is not
+ * The following CQ test is added to make sure testMaxQueryExecutionTime is reset and is not
* affecting other query related tests.
*
* @throws Exception
@@ -917,7 +917,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
public void run2() throws CacheException {
Cache cache = getCache();
System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: "
- + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
+ + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
for (int i = 1; i <= 5; i++) {
@@ -942,7 +942,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
public void run2() throws CacheException {
Cache cache = getCache();
System.out.println("TEST CQ MAX_QUERY_EXECUTION_TIME is set to: "
- + ((GemFireCacheImpl) cache).TEST_MAX_QUERY_EXECUTION_TIME);
+ + ((GemFireCacheImpl) cache).testMaxQueryExecutionTime);
Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
for (int i = 1; i <= 5; i++) {
@@ -1127,7 +1127,7 @@ public class QueryMonitorDUnitTest extends JUnit4CacheTestCase {
}
break;
}
- // ((GemFireCache)cache).TEST_MAX_QUERY_EXECUTION_TIME = queryMonitorTime;
+ // ((GemFireCache)cache).testMaxQueryExecutionTime = queryMonitorTime;
}
};
vm.invoke(validateThreadCnt);
http://git-wip-us.apache.org/repos/asf/geode/blob/ba2a2d2c/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
----------------------------------------------------------------------
diff --git a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
index 0449a45..3190cd7 100644
--- a/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
+++ b/geode-web-api/src/main/java/org/apache/geode/rest/internal/web/controllers/CommonCrudController.java
@@ -38,7 +38,7 @@ import org.apache.geode.cache.execute.Execution;
import org.apache.geode.cache.execute.FunctionException;
import org.apache.geode.cache.execute.FunctionService;
import org.apache.geode.cache.execute.ResultCollector;
-import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.execute.util.FindRestEnabledServersFunction;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.rest.internal.web.controllers.support.RestServersResultCollector;
import org.apache.geode.rest.internal.web.exception.GemfireRestException;
@@ -193,7 +193,7 @@ public abstract class CommonCrudController extends AbstractBaseController {
try {
final ResultCollector<?, ?> results = function.withCollector(new RestServersResultCollector())
- .execute(GemFireCacheImpl.FIND_REST_ENABLED_SERVERS_FUNCTION_ID);
+ .execute(FindRestEnabledServersFunction.FIND_REST_ENABLED_SERVERS_FUNCTION_ID);
Object functionResult = results.getResult();
if (functionResult instanceof List<?>) {