public void assertPartialMountsAreReadOnly() { List<String> readWriteMountNames = nonDefaultStores .stream() .map(MountedNodeStore::getMount) .filter(m -> !m.isReadOnly()) .map(Mount::getName) .collect(Collectors.toList()); checkArgument(readWriteMountNames.isEmpty(), "Following partial mounts are write-enabled: ", readWriteMountNames); }
private static void assertPartialMountsAreReadOnly(List<MountedNodeStore> nonDefaultStores) { List<String> readWriteMountNames = nonDefaultStores .stream() .map(MountedNodeStore::getMount) .filter(m -> !m.isReadOnly()) .map(Mount::getName) .collect(Collectors.toList()); checkArgument(readWriteMountNames.isEmpty(), "Following partial mounts are write-enabled: ", readWriteMountNames); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
@Override public boolean close(long timestamp) throws IOException { // explicitly get writers for mounts which haven't got writers even at close. // This essentially ensures we respect DefaultIndexWriters#close's intent to // create empty index even if nothing has been written during re-index. stream(concat(singleton(mountInfoProvider.getDefaultMount()), mountInfoProvider.getNonDefaultMounts()) .spliterator(), false) .filter(m -> reindex && !m.isReadOnly()) // only needed when re-indexing for read-write mounts. // reindex for ro-mount doesn't make sense in this case anyway. .forEach(m -> getWriter(m)); // open default writers for mounts that passed all our tests boolean indexUpdated = false; for (LuceneIndexWriter w : writers.values()) { indexUpdated |= w.close(timestamp); } return indexUpdated; }
private Validator checkPrivateStoreCommit(String commitPath) throws CommitFailedException { Mount mountInfo = mountInfoProvider.getMountByPath(commitPath); if (mountInfo.isReadOnly()) { Throwable throwable = new Throwable("Commit path: " + commitPath); logger.error("Detected commit to a read-only store! ", throwable); if (failOnDetection) { throw new CommitFailedException(CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store!", throwable); } } return new PrivateStoreValidator(commitPath); }
private boolean isMountedReadOnly(String path) { MountInfoProvider mip = sessionContext.getMountInfoProvider(); return mip != null && mip.getMountByPath(path).isReadOnly(); }
@Override public CompositeNodeBuilder builder() { return new CompositeNodeBuilder(nodeStates.lazyApply((mns, n) -> { if (mns.getMount().isReadOnly()) { return new ReadOnlyBuilder(n); } else { return n.builder(); } }), ctx, path); }
private Validator checkPrivateStoreCommit(String commitPath) throws CommitFailedException { Mount mountInfo = mountInfoProvider.getMountByPath(commitPath); if (mountInfo.isReadOnly()) { throw new CommitFailedException(CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store "+ commitPath); } return new PrivateStoreValidator(commitPath, mountInfoProvider); }
@Test public void readOnlyMounting() throws Exception{ MountInfoProvider mip = Mounts.newBuilder() .mount("foo", "/a", "/b") .readOnlyMount("bar", "/x", "/y") .build(); assertTrue(mip.getMountByName("bar").isReadOnly()); assertFalse(mip.getMountByName("foo").isReadOnly()); }
@Test public void mountWithConfig_Paths() throws Exception{ MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String, Object>of("mountedPaths", new String[] {"/a", "/b"})); MountInfoProvider provider = context.getService(MountInfoProvider.class); assertEquals(1, provider.getNonDefaultMounts().size()); Mount m = provider.getMountByName(MountInfoProviderService.PROP_MOUNT_NAME_DEFAULT); assertNotNull(m); Mount defMount = provider.getDefaultMount(); assertNotNull(defMount); assertFalse(m.isReadOnly()); assertEquals(m, provider.getMountByPath("/a")); assertEquals(defMount, provider.getMountByPath("/x")); }
@Test public void mountWithConfig_Name() throws Exception{ MockOsgi.activate(service, context.bundleContext(), ImmutableMap.<String, Object>of( "mountedPaths", new String[] {"/a", "/b"}, "mountName", "foo", "readOnlyMount", true )); MountInfoProvider provider = context.getService(MountInfoProvider.class); assertEquals(1, provider.getNonDefaultMounts().size()); Mount m = provider.getMountByName(MountInfoProviderService.PROP_MOUNT_NAME_DEFAULT); assertNull(m); Mount defMount = provider.getDefaultMount(); assertNotNull(defMount); m = provider.getMountByName("foo"); assertEquals(m, provider.getMountByPath("/a")); assertEquals(defMount, provider.getMountByPath("/x")); assertTrue(m.isReadOnly()); }