@Test public void shouldIgnoreHiddenFiles() throws Exception { assertFalse(repository.list().findFirst().isPresent()); File hidden = new File("target/test/store/metadata/.hidden_file"); FileOutputStream fos = new FileOutputStream(hidden); fos.write("hello".getBytes()); fos.close(); final DataSetMetadata dataSetMetadata = repository.get(".hidden"); hidden.delete(); assertNull(dataSetMetadata); }
@Override public DataSetMetadata get(String id) { final File file = getFile(id); if (file.getName().startsWith(".")) { LOG.info("Ignore hidden file {}", file.getName()); return null; } if (!file.exists()) { LOG.info("dataset #{} not found in file system", id); return null; } ReentrantReadWriteLock lock = locks.getLock(id); lock.readLock().lock(); try (FileInputStream fileInputStream = new FileInputStream(file); GZIPInputStream input = new GZIPInputStream(fileInputStream)) { return mapper.readerFor(DataSetMetadata.class).readValue(input); } catch (IOException e) { LOG.error("unable to load dataset {}", id, e); return null; } finally { lock.readLock().unlock(); } }
FileSystemDataSetMetadataRepository extends ObjectDataSetMetadataRepository { @Override public DataSetMetadata get(String id) { final File file = getFile(id); if (file.getName().startsWith(".")) { LOG.info("Ignore hidden file {}", file.getName()); return null; } if (!file.exists()) { LOG.info("dataset #{} not found in file system", id); return null; } ReentrantReadWriteLock lock = locks.getLock(id); lock.readLock().lock(); try (FileInputStream fileInputStream = new FileInputStream(file); GZIPInputStream input = new GZIPInputStream(fileInputStream)) { return mapper.readerFor(DataSetMetadata.class).readValue(input); } catch (IOException e) { LOG.error("unable to load dataset {}", id, e); return null; } finally { lock.readLock().unlock(); } } }
FileSystemDataSetMetadataRepository extends ObjectDataSetMetadataRepository { @Override public DataSetMetadata get(String id) { final File file = getFile(id); if (file.getName().startsWith(".")) { LOG.info("Ignore hidden file {}", file.getName()); return null; } if (!file.exists()) { LOG.info("dataset #{} not found in file system", id); return null; } ReentrantReadWriteLock lock = locks.getLock(id); lock.readLock().lock(); try (FileInputStream fileInputStream = new FileInputStream(file); GZIPInputStream input = new GZIPInputStream(fileInputStream)) { return mapper.readerFor(DataSetMetadata.class).readValue(input); } catch (IOException e) { LOG.error("unable to load dataset {}", id, e); return null; } finally { lock.readLock().unlock(); } }  }
FileSystemDataSetMetadataRepository extends ObjectDataSetMetadataRepository { @Override public DataSetMetadata get(String id) { final File file = getFile(id); if (file.getName().startsWith(".")) { LOG.info("Ignore hidden file {}", file.getName()); return null; } if (!file.exists()) { LOG.info("dataset #{} not found in file system", id); return null; } ReentrantReadWriteLock lock = locks.getLock(id); lock.readLock().lock(); try (FileInputStream fileInputStream = new FileInputStream(file); GZIPInputStream input = new GZIPInputStream(fileInputStream)) { return mapper.readerFor(DataSetMetadata.class).readValue(input); } catch (IOException e) { LOG.error("unable to load dataset {}", id, e); return null; } finally { lock.readLock().unlock(); } }  @Override void save(DataSetMetadata metadata); @Override DataSetMetadata get(String id); @Override void remove(String id); @Override Stream<DataSetMetadata> source(); }
FileSystemDataSetMetadataRepository extends ObjectDataSetMetadataRepository { @Override public DataSetMetadata get(String id) { final File file = getFile(id); if (file.getName().startsWith(".")) { LOG.info("Ignore hidden file {}", file.getName()); return null; } if (!file.exists()) { LOG.info("dataset #{} not found in file system", id); return null; } ReentrantReadWriteLock lock = locks.getLock(id); lock.readLock().lock(); try (FileInputStream fileInputStream = new FileInputStream(file); GZIPInputStream input = new GZIPInputStream(fileInputStream)) { return mapper.readerFor(DataSetMetadata.class).readValue(input); } catch (IOException e) { LOG.error("unable to load dataset {}", id, e); return null; } finally { lock.readLock().unlock(); } }  @Override void save(DataSetMetadata metadata); @Override DataSetMetadata get(String id); @Override void remove(String id); @Override Stream<DataSetMetadata> source();  }