clear cache after closing

This commit is contained in:
2023-02-13 19:35:56 +01:00
parent 7977882e93
commit 8c410fac4a
2 changed files with 4 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ import org.lucares.pdb.blockstorage.BSFile;
import org.lucares.pdb.blockstorage.LongStreamFile; import org.lucares.pdb.blockstorage.LongStreamFile;
import org.lucares.pdb.diskstorage.DiskStorage; import org.lucares.pdb.diskstorage.DiskStorage;
public class PartitionDiskStore { public class PartitionDiskStore implements AutoCloseable {
private final ConcurrentHashMap<ParititionId, DiskStorage> diskStorages = new ConcurrentHashMap<>(); private final ConcurrentHashMap<ParititionId, DiskStorage> diskStorages = new ConcurrentHashMap<>();
private final Function<ParititionId, DiskStorage> creator; private final Function<ParititionId, DiskStorage> creator;
@@ -61,6 +61,7 @@ public class PartitionDiskStore {
} }
} }
@Override
public void close() { public void close() {
final List<Throwable> throwables = new ArrayList<>(); final List<Throwable> throwables = new ArrayList<>();
@@ -71,6 +72,7 @@ public class PartitionDiskStore {
throwables.add(e); throwables.add(e);
} }
} }
diskStorages.clear();
if (!throwables.isEmpty()) { if (!throwables.isEmpty()) {
final RuntimeException ex = new RuntimeException(); final RuntimeException ex = new RuntimeException();
throwables.forEach(ex::addSuppressed); throwables.forEach(ex::addSuppressed);

View File

@@ -150,6 +150,7 @@ public class PartitionPersistentMap<K, V, P> implements AutoCloseable {
throwables.add(e); throwables.add(e);
} }
} }
maps.clear();
if (!throwables.isEmpty()) { if (!throwables.isEmpty()) {
final RuntimeException ex = new RuntimeException(); final RuntimeException ex = new RuntimeException();
throwables.forEach(ex::addSuppressed); throwables.forEach(ex::addSuppressed);