use of org.infinispan.filter.KeyFilter in project indy by Commonjava.
the class StorageFileIO method process.
@Override
public void process(KeyFilter<? super String> filter, CacheLoaderTask<String, byte[]> task, Executor executor, boolean fetchValue, boolean fetchMetadata) {
Path root = Paths.get(storageRoot);
walkFiles((path -> {
if (filter.accept(path.relativize(root).toString())) {
executor.execute(() -> {
if (Thread.currentThread().isInterrupted()) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("The cache-loader process thread is interrupted at the start. Bailing out.");
return;
}
try (ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(path.toFile())))) {
StorageFileEntry entry = new StorageFileEntry();
entry.load(in, fetchMetadata, fetchValue);
StorageFileTaskContext ctx = new StorageFileTaskContext();
task.processEntry(entry, ctx);
} catch (ClassNotFoundException | IOException e) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.error("Cannot read file: " + path, e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("cache-loader process method interrupted on: " + path, e);
}
});
}
}));
}
Aggregations