public NIOLockProvider( DefaultStorageFinder storageFinder, int waitBeforeRetry, int maxLockAttempts) throws ConfigurationException { this.root = storageFinder.getDefaultPath(); this.waitBeforeRetry = waitBeforeRetry; this.maxLockAttempts = maxLockAttempts; }
public BDBQuotaStore( final DefaultStorageFinder cacheDirFinder, TilePageCalculator tilePageCalculator) throws ConfigurationException { Assert.notNull(cacheDirFinder, "cacheDirFinder can't be null"); Assert.notNull(tilePageCalculator, "tilePageCalculator can't be null"); this.tilePageCalculator = tilePageCalculator; this.cacheRootDir = cacheDirFinder.getDefaultPath(); boolean disabled = Boolean.valueOf(cacheDirFinder.findEnvVar(GWC_DISKQUOTA_DISABLED)).booleanValue(); if (disabled) { log.warn( " -- Found environment variable " + GWC_DISKQUOTA_DISABLED + " set to true. DiskQuotaMonitor is disabled."); } this.diskQuotaEnabled = !disabled; }
public synchronized String getDefaultPath() throws ConfigurationException { if (this.defaultPrefix == null) { determineDefaultPrefix(); if (this.defaultPrefix == null) { throw new ConfigurationException("Unable to find writable path for cache."); } } return this.defaultPrefix; }
private String getVariable(String variable, String defaultValue) { String value = storageFinder.findEnvVar(DefaultStorageFinder.GWC_METASTORE_USERNAME); if (value != null) { return value; } else { return defaultValue; } }
@Override @Before public void setUpTest() throws Exception { super.setUpTest(); compositeBlobStore = new CompositeBlobStore( tileLayerDispatcher, new DefaultStorageFinder(context.getContextProvider()), testSupport.getServerConfiguration(), blobStoreAggregator); }
/** * @param configLoader loads and saves the layers quota config and usage status * @param tld provides access to the layers configured for disk quota insurance quota usage * @throws IOException * @throws ConfigurationException */ public DiskQuotaMonitor( final DefaultStorageFinder storageFinder, final ConfigLoader configLoader, final TileLayerDispatcher tld, final StorageBroker sb, QuotaStoreProvider quotaStoreProvider, final CacheCleaner cacheCleaner) throws IOException, ConfigurationException { boolean disabled = Boolean.valueOf(storageFinder.findEnvVar(GWC_DISKQUOTA_DISABLED)).booleanValue(); if (disabled) { log.warn( " -- Found environment variable " + GWC_DISKQUOTA_DISABLED + " set to true. DiskQuotaMonitor is disabled."); } this.diskQuotaEnabled = !disabled; this.storageFinder = storageFinder; this.configLoader = configLoader; this.storageBroker = sb; this.tileLayerDispatcher = tld; this.quotaStoreProvider = quotaStoreProvider; this.cacheCleaner = cacheCleaner; }
public FileBlobStore(DefaultStorageFinder defStoreFinder) throws StorageException, ConfigurationException { this(defStoreFinder.getDefaultPath()); }
EasyMock.expect(cacheDirFinder.getDefaultPath()) .andReturn(targetDir.getRoot().getAbsolutePath()) .anyTimes(); EasyMock.expect( cacheDirFinder.findEnvVar( EasyMock.eq(DiskQuotaMonitor.GWC_DISKQUOTA_DISABLED))) .andReturn(null)
private static ByteArrayResource loadBlankTile(DefaultStorageFinder defaultStorageFinder) { ByteArrayResource blankTile = null; String blankTilePath = defaultStorageFinder.findEnvVar(DefaultStorageFinder.GWC_BLANK_TILE_PATH);
public NIOLockProvider(DefaultStorageFinder storageFinder) throws ConfigurationException { this(storageFinder.getDefaultPath()); }
EasyMock.expect(cacheDirFinder.getDefaultPath()) .andReturn(targetDir.getAbsolutePath()) .anyTimes(); EasyMock.expect( cacheDirFinder.findEnvVar( EasyMock.eq(DiskQuotaMonitor.GWC_DISKQUOTA_DISABLED))) .andReturn(null)
private void loadBlankTile() { String blankTilePath = defaultStorageFinder.findEnvVar(DefaultStorageFinder.GWC_BLANK_TILE_PATH);
public File getRootCacheDir() throws ConfigurationException { return new File(storageFinder.getDefaultPath()); }
this.configDirectory = new File(storageDirFinder.getDefaultPath());
localStorageLoc = defaultStorageFinder.getDefaultPath(); } catch (ConfigurationException ex) { localStorageLoc = "Error";
public MetastoreRemover(DefaultStorageFinder finder) throws Exception { this.storageFinder = finder; File root = new File(storageFinder.getDefaultPath()); Connection conn = null; try {
File cacheRoot; try { cacheRoot = new File(storageFinder.getDefaultPath()); } catch (ConfigurationException e) { throw new RuntimeException(e);
/** * Prepares a simple data source for the embedded H2 * * @param cacheDirFinder * @return * @throws ConfigurationException */ private DataSource getH2DataSource(DefaultStorageFinder cacheDirFinder) throws ConfigurationException { File storeDirectory = new File(cacheDirFinder.getDefaultPath(), "diskquota_page_store_h2"); storeDirectory.mkdirs(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); String database = new File(storeDirectory, "diskquota").getAbsolutePath(); dataSource.setUrl("jdbc:h2:" + database); dataSource.setUsername("sa"); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(-1); // boundless dataSource.setMaxWait(5000); return dataSource; }
@Before public void setup() throws Exception { layers = mock(TileLayerDispatcher.class); bsa = mock(BlobStoreAggregator.class); defaultStorageFinder = mock(DefaultStorageFinder.class); configuration = mock(XMLConfiguration.class); configs = new LinkedList<>(); when(bsa.getBlobStores()).thenReturn(configs); when(defaultStorageFinder.getDefaultPath()) .thenReturn(tmpFolder.getRoot().getAbsolutePath()); defaultLayer = mock(TileLayer.class); when(layers.getTileLayer(eq(DEFAULT_LAYER))).thenReturn(defaultLayer); when(layers.getTileLayer((String) argThat(new NotEq<>(DEFAULT_LAYER)))) .thenThrow(new GeoWebCacheException("layer not found")); }
config.setEnabled(true); config.setDefault(true); config.setBaseDirectory(defaultStorageFinder.getDefaultPath()); BlobStore store; store = new FileBlobStore(config.getBaseDirectory());