Skip to content

Commit d9a43c8

Browse files
committed
respect -DGWC_DISKQUOTA_DISABLED=true at BDBQuotaStore startup
1 parent ac2c74c commit d9a43c8

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

geowebcache/diskquota/src/main/java/org/geowebcache/diskquota/storage/BDBQuotaStore.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.geowebcache.diskquota.storage;
22

3+
import static org.geowebcache.diskquota.DiskQuotaMonitor.GWC_DISKQUOTA_DISABLED;
4+
35
import java.io.File;
46
import java.math.BigInteger;
57
import java.util.ArrayList;
@@ -70,6 +72,8 @@ public class BDBQuotaStore implements QuotaStore, InitializingBean, DisposableBe
7072

7173
private volatile boolean open;
7274

75+
private boolean diskQuotaEnabled;
76+
7377
public BDBQuotaStore(final DefaultStorageFinder cacheDirFinder,
7478
TilePageCalculator tilePageCalculator) throws StorageException {
7579

@@ -78,6 +82,14 @@ public BDBQuotaStore(final DefaultStorageFinder cacheDirFinder,
7882

7983
this.tilePageCalculator = tilePageCalculator;
8084
this.cacheRootDir = cacheDirFinder.getDefaultPath();
85+
86+
boolean disabled = Boolean.valueOf(cacheDirFinder.findEnvVar(GWC_DISKQUOTA_DISABLED))
87+
.booleanValue();
88+
if (disabled) {
89+
log.warn(" -- Found environment variable " + GWC_DISKQUOTA_DISABLED
90+
+ " set to true. DiskQuotaMonitor is disabled.");
91+
}
92+
this.diskQuotaEnabled = !disabled;
8193
}
8294

8395
/**
@@ -91,6 +103,11 @@ public void afterPropertiesSet() throws Exception {
91103
}
92104

93105
public void startUp() throws InterruptedException {
106+
if (!diskQuotaEnabled) {
107+
log.info(getClass().getName() + " won't start, got env variable "
108+
+ GWC_DISKQUOTA_DISABLED + "=true");
109+
return;
110+
}
94111
open = true;
95112
File storeDirectory = new File(cacheRootDir, "diskquota_page_store");
96113
storeDirectory.mkdirs();
@@ -115,6 +132,9 @@ public void startUp() throws InterruptedException {
115132
* @see org.springframework.beans.factory.DisposableBean#destroy()
116133
*/
117134
public void destroy() throws Exception {
135+
if (!diskQuotaEnabled) {
136+
return;
137+
}
118138
open = false;
119139
log.info("Requesting to close quota store...");
120140
transactionRunner.shutdown();

geowebcache/diskquota/src/test/java/org/geowebcache/diskquota/storage/BDBQuotaStoreTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.geowebcache.config.Configuration;
2222
import org.geowebcache.config.XMLConfiguration;
2323
import org.geowebcache.config.XMLConfigurationTest;
24+
import org.geowebcache.diskquota.DiskQuotaMonitor;
2425
import org.geowebcache.grid.GridSetBroker;
2526
import org.geowebcache.layer.TileLayerDispatcher;
2627
import org.geowebcache.storage.DefaultStorageFinder;
@@ -48,6 +49,9 @@ public void setUp() throws Exception {
4849
cacheDirFinder = EasyMock.createMock(DefaultStorageFinder.class);
4950
EasyMock.expect(cacheDirFinder.getDefaultPath()).andReturn(targetDir.getAbsolutePath())
5051
.anyTimes();
52+
EasyMock.expect(
53+
cacheDirFinder.findEnvVar(EasyMock.eq(DiskQuotaMonitor.GWC_DISKQUOTA_DISABLED)))
54+
.andReturn(null).anyTimes();
5155
EasyMock.replay(cacheDirFinder);
5256

5357
XMLConfiguration xmlConfig = loadXMLConfig();

0 commit comments

Comments
 (0)