@Override public void handleAddBlobStore(BlobStoreInfo newBlobStore) throws ConfigurationException, StorageException { if (newBlobStore.isDefault()) { loadBlobStoreOverwritingDefault(blobStores, newBlobStore); } else { loadBlobStore(blobStores, newBlobStore); } }
/** * @return the {@link BlobStoreInfo#isDefault() default} blobstore, or {@code null} if there's * no default */ public BlobStoreInfo getDefaultBlobStore() { BlobStoreAggregator agg = getBlobStoreAggregator(); // TODO We should be doing this on the aggregator upstream in GWC for (BlobStoreInfo config : agg.getBlobStores()) { if (config.isDefault()) { return config; } } return null; }
LiveStore removedStore = blobStores.remove(oldName); try { if (modifiedBlobStore.isDefault()) { BlobStoreInfo oldConfig = blobStores.get(DEFAULT_STORE_DEFAULT_ID).config;
@Override public void handleModifyBlobStore(BlobStoreInfo modifiedBlobStore) throws ConfigurationException, StorageException { LiveStore removedStore = blobStores.remove(modifiedBlobStore.getName()); try { if (modifiedBlobStore.isDefault() && !modifiedBlobStore .getName() .equals(blobStores.get(DEFAULT_STORE_DEFAULT_ID).config.getName())) { loadBlobStoreOverwritingDefault(blobStores, modifiedBlobStore); } else { loadBlobStore(blobStores, modifiedBlobStore); } } catch (StorageException | ConfigurationException e) { blobStores.put(modifiedBlobStore.getName(), removedStore); throw e; } }
private SqliteBlobStore getBlobStoreForLayer(String layerName) throws Exception { // let's find layer associated store String blobStoreId = tileLayerDispatcher.getTileLayer(layerName).getBlobStoreId(); BlobStoreInfo blobStoreConfig = null; for (BlobStoreInfo candidateBlobStoreConfig : blobConfiguration.getBlobStores()) { if (blobStoreId == null) { // we need to find the default configuration if (candidateBlobStoreConfig.isDefault()) { // this is the default configuration, we are done blobStoreConfig = candidateBlobStoreConfig; break; } } if (candidateBlobStoreConfig.getName().equals(blobStoreId)) { // we need to find a specific store by is id blobStoreConfig = candidateBlobStoreConfig; break; } } if (blobStoreConfig == null || !(blobStoreConfig instanceof SqliteInfo)) { // no store found or the store is not an sqlite store return null; } // returning an instance of found store return (SqliteBlobStore) blobStoreConfig.createInstance( tileLayerDispatcher, gwcConfiguration.getLockProvider()); } }
private SqliteBlobStore getBlobStoreForLayer(String layerName) throws Exception { // let's find layer associated store String blobStoreId = tileLayerDispatcher.getTileLayer(layerName).getBlobStoreId(); BlobStoreInfo blobStoreConfig = null; for (BlobStoreInfo candidateBlobStoreConfig : blobConfiguration.getBlobStores()) { if (blobStoreId == null) { // we need to find the default configuration if (candidateBlobStoreConfig.isDefault()) { // this is the default configuration, we are done blobStoreConfig = candidateBlobStoreConfig; break; } } if (candidateBlobStoreConfig.getName().equals(blobStoreId)) { // we need to find a specific store by is id blobStoreConfig = candidateBlobStoreConfig; break; } } if (blobStoreConfig == null || !(blobStoreConfig instanceof SqliteInfo)) { // no store found or the store is not an sqlite store return null; } // returning an instance of found store return (SqliteBlobStore) blobStoreConfig.createInstance( tileLayerDispatcher, gwcConfiguration.getLockProvider()); } }
stores.put(config.getName(), liveStore); if (config.isDefault()) { if (defaultStore == null || defaultStore.config.getName().equals(config.getName())) { if (!enabled) {
@Test public void testBlobStoreConfigIsLoaded() throws Exception { // get the blobstores from the config (from test resource geowebcache_190.xml) final List<BlobStoreInfo> blobStores = config.getBlobStores(); assertEquals( "Unexpected number of BlobStoreInfo elements configured", 1, blobStores.size()); // get the 1 configured BlobStoreInfo BlobStoreInfo info = blobStores.get(0); assertFalse("Unexpected BlobStoreInfo default setting", info.isDefault()); assertFalse("Unexpected BlobStoreInfo enabled setting", info.isEnabled()); assertTrue( "Unexpected BlobeStoreInfo class type", FileBlobStoreInfo.class.isAssignableFrom(info.getClass())); // cast the info to a FileBlobStoreInfo final FileBlobStoreInfo fileInfo = FileBlobStoreInfo.class.cast(info); assertEquals( "Unexpected FileBlobStoreInfo filesystem block size", 4096, fileInfo.getFileSystemBlockSize()); assertEquals( "Unexpected FileBlobStoreInfo location value", "/tmp/defaultCache", fileInfo.getBaseDirectory()); }