@Override public RootVertex<TagFamily> getRootVertex() { return boot.meshRoot().getTagFamilyRoot(); }
@Override public RootVertex<Node> getRootVertex() { return boot.meshRoot().getNodeRoot(); }
@Override public RootVertex<Role> getRootVertex() { return boot.meshRoot().getRoleRoot(); }
@Override public RootVertex<MicroschemaContainer> getRootVertex() { return boot.meshRoot().getMicroschemaContainerRoot(); }
@Override public RootVertex<User> getRootVertex() { return boot.meshRoot().getUserRoot(); }
@Override public RootVertex<Group> getRootVertex() { return boot.meshRoot().getGroupRoot(); }
@Override public RootVertex<Tag> getRootVertex() { return boot.meshRoot().getTagRoot(); }
@Override public RootVertex<Project> getRootVertex() { return boot.meshRoot().getProjectRoot(); }
@Override public RootVertex<SchemaContainer> getRootVertex() { return boot.meshRoot().getSchemaContainerRoot(); }
@Override public Set<String> filterUnknownIndices(Set<String> indices) { return db.tx(() -> { Set<String> activeIndices = new HashSet<>(); for (Project project : boot.meshRoot().getProjectRoot().findAll()) { activeIndices.add(TagFamily.composeIndexName(project.getUuid())); } return indices.stream() .filter(i -> i.startsWith(getType())) .filter(i -> !activeIndices.contains(i)) .collect(Collectors.toSet()); }); }
@Override public Set<String> filterUnknownIndices(Set<String> indices) { return db.tx(() -> { Set<String> activeIndices = new HashSet<>(); for (Project project : boot.meshRoot().getProjectRoot().findAll()) { activeIndices.add(Tag.composeIndexName(project.getUuid())); } return indices.stream() .filter(i -> i.startsWith(getType() + "-")) .filter(i -> !activeIndices.contains(i)) .collect(Collectors.toSet()); }); }
@Override public Set<String> filterUnknownIndices(Set<String> indices) { Set<String> activeIndices = new HashSet<>(); db.tx(() -> { for (Project currentProject : boot.meshRoot().getProjectRoot().findAll()) { for (Branch branch : currentProject.getBranchRoot().findAll()) { for (SchemaContainerVersion version : branch.findActiveSchemaVersions()) { Arrays.asList(ContainerType.DRAFT, ContainerType.PUBLISHED).forEach(type -> { activeIndices .add(NodeGraphFieldContainer.composeIndexName(currentProject.getUuid(), branch.getUuid(), version.getUuid(), type)); }); } } } }); if (log.isDebugEnabled()) { for (String name : activeIndices) { log.debug("Active index: {" + name + "}"); } } return indices.stream() // Only handle indices of the handler's type .filter(i -> i.startsWith(getType())) // Filter out indices which are active .filter(i -> !activeIndices.contains(i)) .collect(Collectors.toSet()); }
@Override public Map<String, IndexInfo> getIndices() { return db.tx(() -> { Map<String, IndexInfo> indexInfo = new HashMap<>(); ProjectRoot projectRoot = boot.meshRoot().getProjectRoot(); for (Project project : projectRoot.findAll()) { String indexName = Tag.composeIndexName(project.getUuid()); IndexInfo info = new IndexInfo(indexName, null, getMappingProvider().getMapping(), "tag"); indexInfo.put(indexName, info); } return indexInfo; }); }
@Override public Map<String, IndexInfo> getIndices() { return db.tx(() -> { ProjectRoot root = boot.meshRoot().getProjectRoot(); Map<String, IndexInfo> indexInfo = new HashMap<>(); for (Project project : root.findAll()) { String indexName = TagFamily.composeIndexName(project.getUuid()); IndexInfo info = new IndexInfo(indexName, null, getMappingProvider().getMapping(), "tagFamily"); indexInfo.put(indexName, info); } return indexInfo; }); }
@Override public Completable syncIndices() { return Completable.defer(() -> { return db.tx(() -> { ProjectRoot root = boot.meshRoot().getProjectRoot(); Set<Completable> actions = new HashSet<>(); SyncMetric metric = new SyncMetric(getType()); for (Project project : root.findAll()) { String uuid = project.getUuid(); actions.add(diffAndSync(Tag.composeIndexName(uuid), uuid, metric)); } return Completable.merge(actions); }); }); }
@Override public Completable syncIndices() { return Completable.defer(() -> { return db.tx(() -> { SyncMetric metric = new SyncMetric(getType()); Set<Completable> actions = new HashSet<>(); for (Project project : boot.meshRoot().getProjectRoot().findAll()) { for (Branch branch : project.getBranchRoot().findAll()) { for (SchemaContainerVersion version : branch.findActiveSchemaVersions()) { for (ContainerType type : Arrays.asList(DRAFT, PUBLISHED)) { actions.add(diffAndSync(project, branch, version, type, metric)); } } } } // Nothing will be synced if there is no managed index return Completable.merge(actions); }); }); }
@Override public Completable syncIndices() { return Completable.defer(() -> { return db.tx(() -> { ProjectRoot root = boot.meshRoot().getProjectRoot(); SyncMetric metric = new SyncMetric(getType()); Set<Completable> actions = new HashSet<>(); for (Project project : root.findAll()) { String uuid = project.getUuid(); String indexName = TagFamily.composeIndexName(uuid); actions.add(diffAndSync(indexName, uuid, metric)); } return Completable.merge(actions); }); }); }
private void synchronizeProjectRoutes() throws InvalidNameException { BootstrapInitializer cboot = boot.get(); Database cdb = db.get(); try (Tx tx = cdb.tx()) { for (RouterStorage rs : RouterStorage.getInstances()) { Map<String, Router> registeredProjectRouters = rs.root().apiRouter().projectsRouter().getProjectRouters(); // Load all projects and check whether they are already registered for (Project project : cboot.meshRoot().getProjectRoot().findAll()) { if (registeredProjectRouters.containsKey(project.getName())) { continue; } else { rs.root().apiRouter().projectsRouter().addProjectRouter(project.getName()); } } } } } }
@Override public Set<String> getSelectedIndices(InternalActionContext ac) { return db.tx(() -> { Set<String> indices = new HashSet<>(); Project project = ac.getProject(); if (project != null) { Branch branch = ac.getBranch(); // Locate all schema versions which need to be taken into consideration when choosing the indices for (SchemaContainerVersion version : branch.findActiveSchemaVersions()) { indices.add(NodeGraphFieldContainer.composeIndexName(project.getUuid(), branch.getUuid(), version.getUuid(), ContainerType .forVersion(ac.getVersioningParameters().getVersion()))); } } else { // The project was not specified. Maybe a global search wants to know which indices must be searched. // In that case we just iterate over all projects and collect index names per branch. for (Project currentProject : boot.meshRoot().getProjectRoot().findAll()) { for (Branch branch : currentProject.getBranchRoot().findAll()) { for (SchemaContainerVersion version : branch.findActiveSchemaVersions()) { indices.add(NodeGraphFieldContainer.composeIndexName(currentProject.getUuid(), branch.getUuid(), version.getUuid(), ContainerType.forVersion(ac.getVersioningParameters().getVersion()))); } } } } return indices; }); }
for (Project project : boot.meshRoot().getProjectRoot().findAll()) {