Search in sources :

Example 16 with Namespace

use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.

the class StandaloneSupport method preprocessTmp.

public void preprocessTmp(File tmpDir, List<File> descriptions) throws Exception {
    final Environment env = testConquery.getDropwizard().getEnvironment();
    final net.sourceforge.argparse4j.inf.Namespace namespace = new net.sourceforge.argparse4j.inf.Namespace(Map.of("in", tmpDir, "out", tmpDir, "desc", descriptions));
    // We use this to change the visibility of the run method, hence it cannot be instantiated.
    new PreprocessorCommand(MoreExecutors.newDirectExecutorService()) {

        @Override
        public void run(Environment environment, net.sourceforge.argparse4j.inf.Namespace namespace, ConqueryConfig config) throws Exception {
            super.run(environment, namespace, config);
        }
    }.run(env, namespace, config);
}
Also used : ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) Environment(io.dropwizard.setup.Environment) PreprocessorCommand(com.bakdata.conquery.commands.PreprocessorCommand) Namespace(com.bakdata.conquery.models.worker.Namespace) IOException(java.io.IOException)

Example 17 with Namespace

use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.

the class AdminDatasetProcessor method deleteTable.

/**
 * Deletes a table if it has no dependents or not forced to do so.
 */
public synchronized List<ConceptId> deleteTable(Table table, boolean force) {
    final Namespace namespace = datasetRegistry.get(table.getDataset().getId());
    final List<Concept<?>> dependentConcepts = namespace.getStorage().getAllConcepts().stream().flatMap(c -> c.getConnectors().stream()).filter(con -> con.getTable().equals(table)).map(Connector::getConcept).collect(Collectors.toList());
    if (force || dependentConcepts.isEmpty()) {
        for (Concept<?> concept : dependentConcepts) {
            deleteConcept(concept);
        }
        namespace.getStorage().getAllImports().stream().filter(imp -> imp.getTable().equals(table)).forEach(this::deleteImport);
        namespace.getStorage().removeTable(table.getId());
        namespace.sendToAll(new RemoveTable(table));
    }
    return dependentConcepts.stream().map(Concept::getId).collect(Collectors.toList());
}
Also used : Concept(com.bakdata.conquery.models.datasets.concepts.Concept) RemoveConcept(com.bakdata.conquery.models.messages.namespaces.specific.RemoveConcept) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) Arrays(java.util.Arrays) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) SneakyThrows(lombok.SneakyThrows) RequiredArgsConstructor(lombok.RequiredArgsConstructor) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap) Import(com.bakdata.conquery.models.datasets.Import) DictionaryId(com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) InternalOnly(com.bakdata.conquery.io.jackson.InternalOnly) RemoveImportJob(com.bakdata.conquery.models.messages.namespaces.specific.RemoveImportJob) NonNull(lombok.NonNull) Table(com.bakdata.conquery.models.datasets.Table) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) RemoveConcept(com.bakdata.conquery.models.messages.namespaces.specific.RemoveConcept) Set(java.util.Set) Validator(javax.validation.Validator) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) RemoveSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.RemoveSecondaryId) Dataset(com.bakdata.conquery.models.datasets.Dataset) Objects(java.util.Objects) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) JobManager(com.bakdata.conquery.models.jobs.JobManager) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) Jackson(com.bakdata.conquery.io.jackson.Jackson) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) Column(com.bakdata.conquery.models.datasets.Column) Namespace(com.bakdata.conquery.models.worker.Namespace) RemoveTable(com.bakdata.conquery.models.messages.namespaces.specific.RemoveTable) Getter(lombok.Getter) AddWorker(com.bakdata.conquery.models.messages.network.specific.AddWorker) UpdateTable(com.bakdata.conquery.models.messages.namespaces.specific.UpdateTable) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) UpdateSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.UpdateSecondaryId) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) IdMutex(com.bakdata.conquery.models.identifiable.IdMutex) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) CsvParser(com.univocity.parsers.csv.CsvParser) UpdateMatchingStatsMessage(com.bakdata.conquery.models.messages.namespaces.specific.UpdateMatchingStatsMessage) Identifiable(com.bakdata.conquery.models.identifiable.Identifiable) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) ForbiddenException(javax.ws.rs.ForbiddenException) ImportJob(com.bakdata.conquery.models.jobs.ImportJob) IOException(java.io.IOException) ValidatorHelper(com.bakdata.conquery.models.exceptions.ValidatorHelper) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) StructureNode(com.bakdata.conquery.models.datasets.concepts.StructureNode) FilterSearch(com.bakdata.conquery.apiv1.FilterSearch) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) Collections(java.util.Collections) InputStream(java.io.InputStream) RemoveTable(com.bakdata.conquery.models.messages.namespaces.specific.RemoveTable) Namespace(com.bakdata.conquery.models.worker.Namespace)

Example 18 with Namespace

use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.

the class AdminDatasetProcessor method deleteImport.

/**
 * Deletes an import.
 */
public synchronized void deleteImport(Import imp) {
    final Namespace namespace = datasetRegistry.get(imp.getTable().getDataset().getId());
    namespace.getStorage().removeImport(imp.getId());
    namespace.sendToAll(new RemoveImportJob(imp));
    // Remove bucket assignments for consistency report
    namespace.removeBucketAssignmentsForImportFormWorkers(imp);
}
Also used : RemoveImportJob(com.bakdata.conquery.models.messages.namespaces.specific.RemoveImportJob) Namespace(com.bakdata.conquery.models.worker.Namespace)

Example 19 with Namespace

use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.

the class AdminDatasetProcessor method addConcept.

/**
 * Add the concept to the dataset if it does not exist yet
 */
public synchronized void addConcept(@NonNull Dataset dataset, @NonNull Concept<?> concept) {
    concept.setDataset(dataset);
    ValidatorHelper.failOnError(log, validator.validate(concept));
    if (datasetRegistry.get(dataset.getId()).getStorage().hasConcept(concept.getId())) {
        throw new WebApplicationException("Can't replace already existing concept " + concept.getId(), Response.Status.CONFLICT);
    }
    final Namespace namespace = datasetRegistry.get(concept.getDataset().getId());
    // Register the Concept in the ManagerNode and Workers
    datasetRegistry.get(dataset.getId()).getStorage().updateConcept(concept);
    getJobManager().addSlowJob(new SimpleJob(String.format("sendToAll : Add %s ", concept.getId()), () -> namespace.sendToAll(new UpdateConcept(concept))));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) Namespace(com.bakdata.conquery.models.worker.Namespace)

Example 20 with Namespace

use of com.bakdata.conquery.models.worker.Namespace in project conquery by bakdata.

the class AdminDatasetProcessor method deleteSecondaryId.

/**
 * Delete SecondaryId if it does not have any dependents.
 */
public synchronized void deleteSecondaryId(@NonNull SecondaryIdDescription secondaryId) {
    final Namespace namespace = datasetRegistry.get(secondaryId.getDataset().getId());
    // Before we commit this deletion, we check if this SecondaryId still has dependent Columns.
    final List<Column> dependents = namespace.getStorage().getTables().stream().map(Table::getColumns).flatMap(Arrays::stream).filter(column -> secondaryId.equals(column.getSecondaryId())).collect(Collectors.toList());
    if (!dependents.isEmpty()) {
        final Set<TableId> tables = dependents.stream().map(Column::getTable).map(Identifiable::getId).collect(Collectors.toSet());
        log.error("SecondaryId[{}] still present on {}", secondaryId, tables);
        throw new ForbiddenException(String.format("SecondaryId still has dependencies. %s", tables));
    }
    log.info("Deleting SecondaryId[{}]", secondaryId);
    namespace.getStorage().removeSecondaryId(secondaryId.getId());
    namespace.sendToAll(new RemoveSecondaryId(secondaryId));
}
Also used : Arrays(java.util.Arrays) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) SneakyThrows(lombok.SneakyThrows) RequiredArgsConstructor(lombok.RequiredArgsConstructor) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap) Import(com.bakdata.conquery.models.datasets.Import) DictionaryId(com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) InternalOnly(com.bakdata.conquery.io.jackson.InternalOnly) RemoveImportJob(com.bakdata.conquery.models.messages.namespaces.specific.RemoveImportJob) NonNull(lombok.NonNull) Table(com.bakdata.conquery.models.datasets.Table) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) RemoveConcept(com.bakdata.conquery.models.messages.namespaces.specific.RemoveConcept) Set(java.util.Set) Validator(javax.validation.Validator) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) RemoveSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.RemoveSecondaryId) Dataset(com.bakdata.conquery.models.datasets.Dataset) Objects(java.util.Objects) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) JobManager(com.bakdata.conquery.models.jobs.JobManager) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) Jackson(com.bakdata.conquery.io.jackson.Jackson) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) Column(com.bakdata.conquery.models.datasets.Column) Namespace(com.bakdata.conquery.models.worker.Namespace) RemoveTable(com.bakdata.conquery.models.messages.namespaces.specific.RemoveTable) Getter(lombok.Getter) AddWorker(com.bakdata.conquery.models.messages.network.specific.AddWorker) UpdateTable(com.bakdata.conquery.models.messages.namespaces.specific.UpdateTable) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) UpdateSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.UpdateSecondaryId) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) IdMutex(com.bakdata.conquery.models.identifiable.IdMutex) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) CsvParser(com.univocity.parsers.csv.CsvParser) UpdateMatchingStatsMessage(com.bakdata.conquery.models.messages.namespaces.specific.UpdateMatchingStatsMessage) Identifiable(com.bakdata.conquery.models.identifiable.Identifiable) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) ForbiddenException(javax.ws.rs.ForbiddenException) ImportJob(com.bakdata.conquery.models.jobs.ImportJob) IOException(java.io.IOException) ValidatorHelper(com.bakdata.conquery.models.exceptions.ValidatorHelper) UpdateConcept(com.bakdata.conquery.models.messages.namespaces.specific.UpdateConcept) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) StructureNode(com.bakdata.conquery.models.datasets.concepts.StructureNode) FilterSearch(com.bakdata.conquery.apiv1.FilterSearch) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) Collections(java.util.Collections) InputStream(java.io.InputStream) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) ForbiddenException(javax.ws.rs.ForbiddenException) RemoveSecondaryId(com.bakdata.conquery.models.messages.namespaces.specific.RemoveSecondaryId) Column(com.bakdata.conquery.models.datasets.Column) Arrays(java.util.Arrays) Namespace(com.bakdata.conquery.models.worker.Namespace)

Aggregations

Namespace (com.bakdata.conquery.models.worker.Namespace)28 Dataset (com.bakdata.conquery.models.datasets.Dataset)11 Response (javax.ws.rs.core.Response)10 Slf4j (lombok.extern.slf4j.Slf4j)10 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)8 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)8 DatasetRegistry (com.bakdata.conquery.models.worker.DatasetRegistry)8 ValidatorHelper (com.bakdata.conquery.models.exceptions.ValidatorHelper)7 ExecutionState (com.bakdata.conquery.models.execution.ExecutionState)7 List (java.util.List)7 WebApplicationException (javax.ws.rs.WebApplicationException)7 Query (com.bakdata.conquery.apiv1.query.Query)6 ShardNode (com.bakdata.conquery.commands.ShardNode)6 IntegrationUtils (com.bakdata.conquery.integration.common.IntegrationUtils)5 LoadingUtil (com.bakdata.conquery.integration.common.LoadingUtil)5 LoadingUtil.importSecondaryIds (com.bakdata.conquery.integration.common.LoadingUtil.importSecondaryIds)5 JsonIntegrationTest (com.bakdata.conquery.integration.json.JsonIntegrationTest)5 QueryTest (com.bakdata.conquery.integration.json.QueryTest)5 ModificationShieldedWorkerStorage (com.bakdata.conquery.io.storage.ModificationShieldedWorkerStorage)5 SimpleJob (com.bakdata.conquery.models.jobs.SimpleJob)5