DATAGEODE-88 - Add configuration support for critical and eviction off-heap percentages in client, peer and cache server application annotations.
This commit is contained in:
@@ -48,7 +48,7 @@ import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.test.support.ThreadUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -64,7 +64,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings({ "rawtypes", "unused"})
|
||||
public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTest {
|
||||
@@ -88,7 +88,8 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() throws IOException {
|
||||
System.setProperty("gemfire.log-level", "warning");
|
||||
|
||||
System.setProperty("gemfire.log-level", "error");
|
||||
|
||||
String serverName = "GemFireDataSourceGemFireBasedServer";
|
||||
|
||||
@@ -123,6 +124,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
}
|
||||
|
||||
private static String customClasspath() {
|
||||
|
||||
String[] classpathElements = ProcessExecutor.JAVA_CLASSPATH.split(File.pathSeparator);
|
||||
|
||||
List<String> customClasspath = new ArrayList<String>(classpathElements.length);
|
||||
@@ -137,6 +139,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
}
|
||||
|
||||
private static void waitForProcessStart(final long milliseconds, final ProcessWrapper process, final String processControlFilename) {
|
||||
|
||||
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() {
|
||||
private File processControlFile = new File(process.getWorkingDirectory(), processControlFilename);
|
||||
|
||||
@@ -148,6 +151,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
|
||||
serverProcess.shutdown();
|
||||
|
||||
if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
|
||||
@@ -156,6 +160,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
}
|
||||
|
||||
protected void assertRegion(Region actualRegion, String expectedRegionName) {
|
||||
|
||||
assertThat(actualRegion, is(not(nullValue())));
|
||||
assertThat(actualRegion.getName(), is(equalTo(expectedRegionName)));
|
||||
assertThat(actualRegion.getFullPath(), is(equalTo(String.format("%1$s%2$s",
|
||||
@@ -168,9 +173,9 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void clientProxyRegionBeansExist() {
|
||||
|
||||
assertRegion(localRegion, "LocalRegion");
|
||||
assertRegion(serverRegion, "ServerRegion");
|
||||
assertRegion(anotherServerRegion, "AnotherServerRegion");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -235,7 +236,7 @@ public class AbstractCacheConfigurationUnitTests {
|
||||
protected static class TestCacheConfiguration extends AbstractCacheConfiguration {
|
||||
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
protected Class<? extends Annotation> getAnnotationType() {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,9 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
|
||||
MockPropertySource testPropertySource = new MockPropertySource()
|
||||
.withProperty("spring.data.gemfire.cache.critical-heap-percentage", 90.0f)
|
||||
.withProperty("spring.data.gemfire.cache.critical-off-heap-percentage", 95.0f)
|
||||
.withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f)
|
||||
.withProperty("spring.data.gemfire.cache.eviction-off-heap-percentage", 80.0f)
|
||||
.withProperty("spring.data.gemfire.pdx.ignore-unread-fields", false)
|
||||
.withProperty("spring.data.gemfire.pdx.persistent", true)
|
||||
.withProperty("spring.data.gemfire.pool.free-connection-timeout", 20000L)
|
||||
@@ -134,7 +136,9 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
|
||||
assertThat(resourceManager).isNotNull();
|
||||
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(95.0f);
|
||||
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,16 +244,17 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
// TODO add more tests!
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
|
||||
@ClientCacheApplication(name = "TestClientCache", copyOnRead = true,
|
||||
criticalHeapPercentage = 95.0f, evictionHeapPercentage = 80.0f, idleTimeout = 15000L,
|
||||
maxConnections = 100, minConnections = 10, pingInterval = 15000L, readTimeout = 15000, retryAttempts = 1,
|
||||
subscriptionEnabled = true, subscriptionRedundancy = 1)
|
||||
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestClientCacheConfiguration {
|
||||
|
||||
@Bean
|
||||
ClientCacheConfigurer testClientCacheConfigurer() {
|
||||
|
||||
return (beanName, factoryBean) -> {
|
||||
factoryBean.setEvictionHeapPercentage(90.0f);
|
||||
factoryBean.setPdxReadSerialized(false);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -68,6 +69,30 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
assertThat(region.getAttributes().getOffHeap()).isEqualTo(offHeapEnabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void offHeapCriticalAndEvictionMemoryPercentagesConfiguredProperly() {
|
||||
|
||||
this.applicationContext = newApplicationContext(OffHeapCriticalAndEvictionMemoryPercentagesConfiguration.class);
|
||||
|
||||
assertThat(this.applicationContext).isNotNull();
|
||||
|
||||
GemFireCache gemfireCache = this.applicationContext.getBean("gemfireCache", GemFireCache.class);
|
||||
|
||||
assertThat(gemfireCache).isNotNull();
|
||||
assertThat(gemfireCache.getDistributedSystem()).isNotNull();
|
||||
assertThat(gemfireCache.getDistributedSystem().getProperties()).containsKey("off-heap-memory-size");
|
||||
assertThat(gemfireCache.getDistributedSystem().getProperties().getProperty("off-heap-memory-size"))
|
||||
.isEqualTo("1024g");
|
||||
|
||||
ResourceManager resourceManager = gemfireCache.getResourceManager();
|
||||
|
||||
assertThat(resourceManager).isNotNull();
|
||||
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.55f);
|
||||
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(90.5f);
|
||||
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.75f);
|
||||
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(75.25f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void offHeapConfiguredForAllRegions() {
|
||||
|
||||
@@ -160,7 +185,6 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "8192m")
|
||||
@Import(TestRegionConfiguration.class)
|
||||
@SuppressWarnings("unused")
|
||||
static class EnableOffHeapForAllRegionsConfiguration {
|
||||
}
|
||||
|
||||
@@ -169,7 +193,17 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "1024m", regionNames = { "People", "ExamplePartitionRegion" })
|
||||
@Import(TestRegionConfiguration.class)
|
||||
@SuppressWarnings("unused")
|
||||
static class EnableOffHeapForSelectRegionsConfiguration {
|
||||
}
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@PeerCacheApplication(
|
||||
criticalHeapPercentage = 95.55f,
|
||||
criticalOffHeapPercentage = 90.5f,
|
||||
evictionHeapPercentage = 85.75f,
|
||||
evictionOffHeapPercentage = 75.25f
|
||||
)
|
||||
@EnableOffHeap(memorySize = "1024g")
|
||||
static class OffHeapCriticalAndEvictionMemoryPercentagesConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +58,12 @@ public class PeerCacheApplicationIntegrationTests {
|
||||
assertThat(echo.get("Test")).isEqualTo("Test");
|
||||
}
|
||||
|
||||
//@EnableLocator
|
||||
//@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests",
|
||||
// logLevel = "warn", locators="localhost[10334]")
|
||||
@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests", logLevel="warn")
|
||||
static class PeerCacheApplicationConfiguration {
|
||||
|
||||
@Bean("Echo")
|
||||
PartitionedRegionFactoryBean<String, String> echoRegion(Cache gemfireCache) {
|
||||
|
||||
PartitionedRegionFactoryBean<String, String> echoRegion =
|
||||
new PartitionedRegionFactoryBean<String, String>();
|
||||
|
||||
@@ -78,7 +76,9 @@ public class PeerCacheApplicationIntegrationTests {
|
||||
}
|
||||
|
||||
CacheLoader<String, String> echoCacheLoader() {
|
||||
|
||||
return new CacheLoader<String, String>() {
|
||||
|
||||
@Override
|
||||
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {
|
||||
return helper.getKey();
|
||||
|
||||
@@ -75,7 +75,9 @@ public class PeerCachePropertiesIntegrationTests {
|
||||
MockPropertySource testPropertySource = new MockPropertySource()
|
||||
.withProperty("spring.data.gemfire.cache.copy-on-read", true)
|
||||
.withProperty("spring.data.gemfire.cache.critical-heap-percentage", 95.0f)
|
||||
.withProperty("spring.data.gemfire.cache.critical-off-heap-percentage", 90.0f)
|
||||
.withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f)
|
||||
.withProperty("spring.data.gemfire.cache.eviction-off-heap-percentage", 80.0f)
|
||||
.withProperty("spring.data.gemfire.cache.peer.lock-lease", 180)
|
||||
.withProperty("spring.data.gemfire.cache.peer.lock-timeout", 30)
|
||||
.withProperty("spring.data.gemfire.cache.peer.search-timeout", 120)
|
||||
@@ -107,7 +109,9 @@ public class PeerCachePropertiesIntegrationTests {
|
||||
|
||||
assertThat(resourceManager).isNotNull();
|
||||
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.0f);
|
||||
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.0f);
|
||||
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1656,14 +1656,12 @@ public abstract class MockGemFireObjectsSupport extends MockObjectsSupport {
|
||||
AtomicReference<Float> criticalHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
|
||||
|
||||
AtomicReference<Float> criticalOffHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
|
||||
AtomicReference<Float> criticalOffHeapPercentage = new AtomicReference<>(0.0f);
|
||||
|
||||
AtomicReference<Float> evictionHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
|
||||
|
||||
AtomicReference<Float> evictionOffHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
|
||||
AtomicReference<Float> evictionOffHeapPercentage = new AtomicReference<>(0.0f);
|
||||
|
||||
doAnswer(newSetter(criticalHeapPercentage, null))
|
||||
.when(mockResourceManager).setCriticalHeapPercentage(anyFloat());
|
||||
|
||||
Reference in New Issue
Block a user