SGF-323 - Add support for GemFire 8's DiskStore 'diskUsageCriticalPercentage' and 'diskUsageWarningPercentage' properties in the SDG XML namespace (XSD) and DiskStoreFactoryBean API.
This commit is contained in:
@@ -55,6 +55,9 @@ public class DiskStoreFactoryBean implements BeanNameAware , FactoryBean<DiskSto
|
||||
private Integer timeInterval;
|
||||
private Integer writeBufferSize;
|
||||
|
||||
private Float diskUsageCriticalPercentage;
|
||||
private Float diskUsageWarningPercentage;
|
||||
|
||||
private List<DiskDir> diskDirs;
|
||||
|
||||
private String name;
|
||||
@@ -90,6 +93,12 @@ public class DiskStoreFactoryBean implements BeanNameAware , FactoryBean<DiskSto
|
||||
if (compactionThreshold != null) {
|
||||
diskStoreFactory.setCompactionThreshold(compactionThreshold);
|
||||
}
|
||||
if (diskUsageCriticalPercentage != null) {
|
||||
diskStoreFactory.setDiskUsageCriticalPercentage(diskUsageCriticalPercentage);
|
||||
}
|
||||
if (diskUsageWarningPercentage != null) {
|
||||
diskStoreFactory.setDiskUsageWarningPercentage(diskUsageWarningPercentage);
|
||||
}
|
||||
if (maxOplogSize != null) {
|
||||
diskStoreFactory.setMaxOplogSize(maxOplogSize);
|
||||
}
|
||||
@@ -155,6 +164,14 @@ public class DiskStoreFactoryBean implements BeanNameAware , FactoryBean<DiskSto
|
||||
this.diskDirs = diskDirs;
|
||||
}
|
||||
|
||||
public void setDiskUsageCriticalPercentage(Float diskUsageCriticalPercentage) {
|
||||
this.diskUsageCriticalPercentage = diskUsageCriticalPercentage;
|
||||
}
|
||||
|
||||
public void setDiskUsageWarningPercentage(Float diskUsageWarningPercentage) {
|
||||
this.diskUsageWarningPercentage = diskUsageWarningPercentage;
|
||||
}
|
||||
|
||||
public void setMaxOplogSize(Integer maxOplogSize) {
|
||||
this.maxOplogSize = maxOplogSize;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,8 @@ public class DiskStoreParser extends AbstractSingleBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, builder, "allow-force-compaction");
|
||||
ParsingUtils.setPropertyValue(element, builder, "auto-compact");
|
||||
ParsingUtils.setPropertyValue(element, builder, "compaction-threshold");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-usage-critical-percentage");
|
||||
ParsingUtils.setPropertyValue(element, builder, "disk-usage-warning-percentage");
|
||||
ParsingUtils.setPropertyValue(element, builder, "max-oplog-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "queue-size");
|
||||
ParsingUtils.setPropertyValue(element, builder, "time-interval");
|
||||
|
||||
@@ -1789,7 +1789,28 @@ Sets the threshold at which an oplog will become compactable. Until it reaches t
|
||||
The threshold is a percentage in the range 0..100. When the amount of garbage in an oplog exceeds this percentage then when a
|
||||
compaction is done and this garbage will be cleaned up freeing up disk space. Garbage is created by entry destroys,
|
||||
entry updates, and region destroys.
|
||||
]]></xsd:documentation>
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="disk-usage-critical-percentage" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Disk usage above this threshold generates an error message and shuts down the member's cache. For example,
|
||||
if the threshold is set to 99%, then falling under 10 GB of free disk space on a 1 TB drive generates the error
|
||||
and shuts down the cache.
|
||||
|
||||
Set to "0" (zero) to disable. GemFire default is 99%.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="disk-usage-warning-percentage" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Disk usage above this threshold generates a warning message. For example, if the threshold is set to 90%,
|
||||
then on a 1 TB drive falling under 100 GB of free disk space generates the warning.
|
||||
|
||||
Set to "0" (zero) to disable. GemFire default is 90%.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="max-oplog-size" type="xsd:string" default="1024">
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.junit.Test;
|
||||
* The DiskStoreFactoryBeanTest class is a test suite of test cases testing the contract and functionality of the
|
||||
* DiskStoreFactoryBean class.
|
||||
*
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.DiskStoreFactoryBean
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.DiskStore;
|
||||
|
||||
/**
|
||||
* The DiskStoreNamespaceTest class is a test suite of test cases testing the contract and functionality of using
|
||||
* Spring Data GemFire's XML namespace to configure GemFire Disk Stores.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "diskstore-ns.xml", initializers = GemfireTestApplicationContextInitializer.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class DiskStoreNamespaceTest {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("fullyConfiguredDiskStore")
|
||||
private DiskStore diskStore;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("props")
|
||||
private Properties props;
|
||||
|
||||
@Test
|
||||
public void testDiskStoreConfiguration() {
|
||||
assertNotNull("The 'fullyConfiguredDiskStore' was not properly configured and initialized", diskStore);
|
||||
assertEquals("fullyConfiguredDiskStore", diskStore.getName());
|
||||
assertEquals(Boolean.valueOf(props.getProperty("allowForceCompaction")), diskStore.getAllowForceCompaction());
|
||||
assertEquals(Boolean.valueOf(props.getProperty("autoCompact")), diskStore.getAutoCompact());
|
||||
assertEquals(Long.valueOf(props.getProperty("compactionThreshold")),
|
||||
Long.valueOf(diskStore.getCompactionThreshold()));
|
||||
assertEquals(Double.valueOf(props.getProperty("diskUsageCriticalPercentage")),
|
||||
Double.valueOf(diskStore.getDiskUsageCriticalPercentage()));
|
||||
assertEquals(Double.valueOf(props.getProperty("diskUsageWarningPercentage")),
|
||||
Double.valueOf(diskStore.getDiskUsageWarningPercentage()));
|
||||
assertEquals(Long.valueOf(props.getProperty("maxOplogSize")), Long.valueOf(diskStore.getMaxOplogSize()));
|
||||
assertEquals(Long.valueOf(props.getProperty("queueSize")), Long.valueOf(diskStore.getQueueSize()));
|
||||
assertEquals(Long.valueOf(props.getProperty("timeInterval")), Long.valueOf(diskStore.getTimeInterval()));
|
||||
assertEquals(Long.valueOf(props.getProperty("writeBufferSize")), Long.valueOf(diskStore.getWriteBufferSize()));
|
||||
assertNotNull(diskStore.getDiskDirs());
|
||||
assertEquals(1, diskStore.getDiskDirs().length);
|
||||
assertEquals(new File(props.getProperty("location")), diskStore.getDiskDirs()[0]);
|
||||
assertEquals(Long.valueOf(props.getProperty("maxSize")), Long.valueOf(diskStore.getDiskDirSizes()[0]));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,21 +11,45 @@
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
|
||||
">
|
||||
|
||||
<gfe:cache/>
|
||||
<util:properties id="gemfireProperties">
|
||||
<prop key="name">DiskStoreNamespaceTest</prop>
|
||||
<prop key="mcast-port">0</prop>
|
||||
<prop key="log-level">warning</prop>
|
||||
</util:properties>
|
||||
|
||||
<gfe:cache properties-ref="gemfireProperties"/>
|
||||
|
||||
<util:properties id="props">
|
||||
<prop key="allowForceCompaction">true</prop>
|
||||
<prop key="autoCompact">true</prop>
|
||||
<prop key="compactionThreshold">70</prop>
|
||||
<prop key="diskUsageCriticalPercentage">90</prop>
|
||||
<prop key="diskUsageWarningPercentage">75</prop>
|
||||
<prop key="location">./build/tmp</prop>
|
||||
<prop key="maxOpLogSize">1</prop>
|
||||
<prop key="maxOplogSize">1</prop>
|
||||
<prop key="maxSize">10</prop>
|
||||
<prop key="queueSize">50</prop>
|
||||
<prop key="timeInterval">9999</prop>
|
||||
<prop key="writeBufferSize">4096</prop>
|
||||
<prop key="ttl">300</prop>
|
||||
</util:properties>
|
||||
|
||||
<context:property-placeholder properties-ref="props"/>
|
||||
|
||||
<gfe:disk-store id="diskStore1" auto-compact="${autoCompact}" max-oplog-size="${maxOpLogSize}"
|
||||
<gfe:disk-store id="fullyConfiguredDiskStore"
|
||||
allow-force-compaction="${allowForceCompaction}"
|
||||
auto-compact="${autoCompact}"
|
||||
compaction-threshold="${compactionThreshold}"
|
||||
disk-usage-critical-percentage="${diskUsageCriticalPercentage}"
|
||||
disk-usage-warning-percentage="${diskUsageWarningPercentage}"
|
||||
max-oplog-size="${maxOplogSize}"
|
||||
queue-size="${queueSize}"
|
||||
time-interval="${timeInterval}"
|
||||
write-buffer-size="${writeBufferSize}">
|
||||
<gfe:disk-dir location="${location}" max-size="${maxSize}"/>
|
||||
</gfe:disk-store>
|
||||
|
||||
<gfe:disk-store id="diskStore1" auto-compact="${autoCompact}" max-oplog-size="${maxOplogSize}"
|
||||
queue-size="${queueSize}" time-interval="${timeInterval}">
|
||||
<gfe:disk-dir location="${location}" max-size="${maxSize}"/>
|
||||
</gfe:disk-store>
|
||||
|
||||
Reference in New Issue
Block a user