Skip to content

Commit 482b607

Browse files
authored
add option to disable mbtiles mutex (#438)
1 parent dac019c commit 482b607

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

xtraplatform-tiles/src/main/java/de/ii/xtraplatform/tiles/app/TileProviderFeatures.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ private TileStore getTileStore(
362362
tileMatrixSets,
363363
tileMatrixSetRepository,
364364
partitions,
365-
cache.getSeeded())
365+
cache.getSeeded() && cache.getSeededOnly())
366366
: new TileStorePlain(cacheStore);
367367
});
368368
}

xtraplatform-tiles/src/main/java/de/ii/xtraplatform/tiles/app/TileStoreMbTiles.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static TileStore readWrite(
6666
Map<String, Set<String>> tileMatrixSets,
6767
Optional<TileMatrixSetRepository> tileMatrixSetRepository,
6868
Optional<TileMatrixPartitions> partitions,
69-
boolean seeded) {
69+
boolean strictlySeeded) {
7070
Map<String, MbtilesTileset> tileSets = new ConcurrentHashMap<>();
7171
try {
7272
for (String tileset : tileSchemas.keySet()) {
@@ -81,7 +81,7 @@ static TileStore readWrite(
8181
getVectorLayers(tileSchemas, tileset),
8282
partitions,
8383
tileSchemas.get(tileset).isEmpty(),
84-
seeded));
84+
strictlySeeded));
8585
}
8686
}
8787
} catch (IOException e) {
@@ -436,7 +436,7 @@ private static MbtilesTileset createTileSet(
436436
List<VectorLayer> vectorLayers,
437437
Optional<TileMatrixPartitions> partitions,
438438
boolean isRaster,
439-
boolean seeded)
439+
boolean strictlySeeded)
440440
throws IOException {
441441
Path relPath =
442442
Path.of(tileset).resolve(tileMatrixSet + (partitions.isEmpty() ? MBTILES_SUFFIX : ""));
@@ -461,15 +461,15 @@ private static MbtilesTileset createTileSet(
461461
.build();
462462

463463
if (partitions.isPresent()) {
464-
return new MbtilesTileset(filePath.get(), md, partitions, isRaster, seeded);
464+
return new MbtilesTileset(filePath.get(), md, partitions, isRaster, strictlySeeded);
465465
}
466466

467467
if (rootStore.has(relPath)) {
468468
return new MbtilesTileset(filePath.get(), isRaster);
469469
}
470470

471471
try {
472-
return new MbtilesTileset(filePath.get(), md, Optional.empty(), isRaster, seeded);
472+
return new MbtilesTileset(filePath.get(), md, Optional.empty(), isRaster, strictlySeeded);
473473
} catch (FileAlreadyExistsException e) {
474474
throw new IllegalStateException(
475475
"A MBTiles file already exists. It must have been created by a parallel thread, which should not occur. MBTiles file creation must be synchronized.");

xtraplatform-tiles/src/main/java/de/ii/xtraplatform/tiles/domain/Cache.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ default boolean getSeeded() {
9898
return true;
9999
}
100100

101+
/**
102+
* @langEn Should this cache be exclusively used by the [Seeding](#seeding)?
103+
* @langDe Soll dieser Cache ausschließlich beim [Seeding](#seeding) verwendet werden?
104+
* @default false
105+
* @since v4.6
106+
*/
107+
@Value.Default
108+
default boolean getSeededOnly() {
109+
return false;
110+
}
111+
101112
/**
102113
* @langEn Tiling schemes and zoom levels that should be stored in the cache. Applies to all
103114
* tilesets that are not specified in `tilesetLevels`.

xtraplatform-tiles/src/main/java/de/ii/xtraplatform/tiles/domain/MbtilesTileset.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ public MbtilesTileset(
104104
MbtilesMetadata metadata,
105105
Optional<TileMatrixPartitions> partitions,
106106
boolean isRaster,
107-
boolean seeded)
107+
boolean strictlySeeded)
108108
throws IOException {
109109
this(
110110
tilesetPath,
111111
metadata,
112112
partitions,
113113
isRaster,
114114
false,
115-
partitions.isPresent() && seeded && isRaster ? Mutex.createNoOp() : Mutex.create());
115+
partitions.isPresent() && strictlySeeded ? Mutex.createNoOp() : Mutex.create());
116116
}
117117

118118
private MbtilesTileset(

0 commit comments

Comments
 (0)