11package org .geowebcache .diskquota .storage ;
22
3+ import static org .geowebcache .diskquota .DiskQuotaMonitor .GWC_DISKQUOTA_DISABLED ;
4+
35import java .io .File ;
46import java .math .BigInteger ;
57import 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 ();
0 commit comments