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); }
public static String getSuggestDirName(Mount mount) { if (mount.isDefault()){ return SUGGEST_DATA_CHILD_NAME; } String name = mount.getPathFragmentName(); return ":" + name + SUGGEST_DIR_SUFFIX; }
private boolean supportMounts(String path) { return mountInfoProvider .getNonDefaultMounts() .stream() .anyMatch(m -> m.isSupportFragmentUnder(path) || m.isUnder(path)); }
static Set<String> getSupportedPaths(@NotNull ConfigurationParameters params, @NotNull MountInfoProvider mountInfoProvider) { Set<String> supportedPaths = params.getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, ImmutableSet.of()); if (!supportedPaths.isEmpty() && mountInfoProvider.hasNonDefaultMounts()) { for (Mount mount : mountInfoProvider.getNonDefaultMounts()) { for (String path : supportedPaths) { if (mount.isUnder(path)) { log.error("Configured supported CUG path '{}' includes node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } else if (mount.isMounted(path)) { log.error("Configured supported CUG path '{}' is part of node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } } } } return supportedPaths; }
@Override public Mount getMountByName(String name) { return DEFAULT_MOUNT.getName().equals(name) ? DEFAULT_MOUNT : null; }
private StrategyWrapper(UniqueEntryStoreStrategy strategy, NodeState indexNode, String indexName, MountedNodeStore nodeStore) { this.strategy = strategy; this.mount = nodeStore.getMount(); this.indexNode = indexNode; this.nodeStore = nodeStore; this.indexName = indexName; this.priority = mount.isDefault() ? PRIORITY_MOUNT : PRIORITY_DEFAULT; }
@Override public boolean apply(String p) { return m.isMounted(p); } };
private <T> void visit(Tree tree, MountedNodeStore mountedStore, ErrorHolder errorHolder, T context, MountedNodeStoreChecker<T> c) { // a mounted NodeStore may contain more paths than what it owns, but since these are not accessible // through the CompositeNodeStore skip them Mount mount = mountedStore.getMount(); boolean under = mount.isUnder(tree.getPath()); boolean mounted = mount.isMounted(tree.getPath()); boolean keepGoing = true; if ( mounted ) { keepGoing = c.check(mountedStore, tree, errorHolder, context); } if ( ( mounted || under ) && keepGoing ) { tree.getChildren().forEach( child -> visit(child, mountedStore, errorHolder, context, c)); } }
boolean shouldBeComposite(final String path) { boolean supportMounts = false; if (mip.getNonDefaultMounts().stream().anyMatch(m -> m.isSupportFragmentUnder(path))) { supportMounts = true; } else if (!mip.getMountsPlacedUnder(path).isEmpty()) { supportMounts = true; } return supportMounts && mip.getMountByPath(path).isDefault(); }
private boolean hasChildrenContainingPathFragmentName(MountedNodeStore mns, String parentPath, Function<MountedNodeStore, Iterable<String>> childrenProvider) { final Mount mount = mns.getMount(); if (!mount.isSupportFragment(parentPath)) { return false; } return StreamSupport.stream(childrenProvider.apply(mns).spliterator(), false) .anyMatch(i -> i.contains(mount.getPathFragmentName())); }
@Override public Collection<Mount> getMountsPlacedUnder(String path) { Collection<Mount> mounts = Lists.newArrayList(); for ( Mount mount : this.mounts.values()) { if ( mount.isUnder(path) ) { mounts.add(mount); } } return mounts; }
public InitialContentMigrator(NodeStore targetNodeStore, NodeStore seedNodeStore, Mount seedMount) { this.targetNodeStore = targetNodeStore; this.seedNodeStore = seedNodeStore; this.seedMount = seedMount; this.includePaths = FilteringNodeState.ALL; this.excludeFragments = ImmutableSet.of(seedMount.getPathFragmentName()); if (seedMount instanceof MountInfo) { this.excludePaths = Sets.union(((MountInfo) seedMount).getIncludedPaths(), DEFAULT_IGNORED_PATHS); this.fragmentPaths = new HashSet<>(); for (String p : ((MountInfo) seedMount).getPathsSupportingFragments()) { fragmentPaths.add(stripPatternCharacters(p)); } } else { this.excludePaths = DEFAULT_IGNORED_PATHS; this.fragmentPaths = FilteringNodeState.ALL; } }
@Override public boolean isDirectlyUnder(String path) { for (Mount m : mounts) { if (m.isDirectlyUnder(path)) { return false; } } return true; } }
static Set<String> getSupportedPaths(@NotNull ConfigurationParameters params, @NotNull MountInfoProvider mountInfoProvider) { Set<String> supportedPaths = params.getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, ImmutableSet.of()); if (!supportedPaths.isEmpty() && mountInfoProvider.hasNonDefaultMounts()) { for (Mount mount : mountInfoProvider.getNonDefaultMounts()) { for (String path : supportedPaths) { if (mount.isUnder(path)) { log.error("Configured supported CUG path '{}' includes node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } else if (mount.isMounted(path)) { log.error("Configured supported CUG path '{}' is part of node store mount '{}'.", path, mount.getName()); throw new IllegalStateException(); } } } } return supportedPaths; }
@Override public void onSwitchNodeToNative(Mount mount) { if (mount.isDefault()) { nodeSwitchToDefaultMount.inc(); } else { nodeSwitchToNonDefaultMount.inc(); } }
@Override public boolean isMounted(String path) { for (Mount m : mounts) { if (m.isMounted(path)) { return false; } } return true; }
private boolean supportMounts(String path) { return mountInfoProvider .getNonDefaultMounts() .stream() .anyMatch(m -> m.isSupportFragmentUnder(path) || m.isUnder(path)); }
@Override public Collection<Mount> getMountsPlacedUnder(String path) { Collection<Mount> mounts = Lists.newArrayList(); for ( Mount mount : this.mounts.values()) { if ( mount.isUnder(path) ) { mounts.add(mount); } } return mounts; }