Search in sources :

Example 6 with Namespace

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

the class AdminDatasetProcessor method addDataset.

/**
 * Creates and initializes a new dataset if it does not already exist.
 */
public synchronized Dataset addDataset(Dataset dataset) {
    final String name = dataset.getName();
    if (datasetRegistry.get(new DatasetId(name)) != null) {
        throw new WebApplicationException("Dataset already exists", Response.Status.CONFLICT);
    }
    NamespaceStorage datasetStorage = new NamespaceStorage(validator, "dataset_" + name);
    datasetStorage.openStores(config.getStorage());
    datasetStorage.loadData();
    datasetStorage.setMetaStorage(storage);
    datasetStorage.updateDataset(dataset);
    datasetStorage.updateIdMapping(new EntityIdMap());
    Namespace ns = new Namespace(datasetStorage, config.isFailOnError(), config.configureObjectMapper(Jackson.copyMapperAndInjectables(Jackson.BINARY_MAPPER)).writerWithView(InternalOnly.class));
    datasetRegistry.add(ns);
    // for now we just add one worker to every ShardNode
    for (ShardNodeInformation node : datasetRegistry.getShardNodes().values()) {
        node.send(new AddWorker(dataset));
    }
    return dataset;
}
Also used : AddWorker(com.bakdata.conquery.models.messages.network.specific.AddWorker) WebApplicationException(javax.ws.rs.WebApplicationException) NamespaceStorage(com.bakdata.conquery.io.storage.NamespaceStorage) InternalOnly(com.bakdata.conquery.io.jackson.InternalOnly) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) Namespace(com.bakdata.conquery.models.worker.Namespace) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap)

Example 7 with Namespace

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

the class AdminDatasetProcessor method deleteConcept.

/**
 * Deletes a concept.
 */
public synchronized void deleteConcept(Concept<?> concept) {
    final Namespace namespace = datasetRegistry.get(concept.getDataset().getId());
    namespace.getStorage().removeConcept(concept.getId());
    getJobManager().addSlowJob(new SimpleJob("sendToAll: remove " + concept.getId(), () -> namespace.sendToAll(new RemoveConcept(concept))));
}
Also used : RemoveConcept(com.bakdata.conquery.models.messages.namespaces.specific.RemoveConcept) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) Namespace(com.bakdata.conquery.models.worker.Namespace)

Example 8 with Namespace

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

the class AdminDatasetProcessor method updateMatchingStats.

/**
 * Issues all Shards to do an UpdateMatchingStats.
 *
 * @implNote This intentionally submits a SlowJob so that it will be queued after all jobs that are already in the queue (usually import jobs).
 */
public void updateMatchingStats(Dataset dataset) {
    final Namespace ns = getDatasetRegistry().get(dataset.getId());
    ns.getJobManager().addSlowJob(new SimpleJob("Initiate Update Matching Stats and FilterSearch", () -> {
        ns.sendToAll(new UpdateMatchingStatsMessage());
        FilterSearch.updateSearch(getDatasetRegistry(), Collections.singleton(ns.getDataset()), getJobManager(), config.getCsv());
    }));
}
Also used : UpdateMatchingStatsMessage(com.bakdata.conquery.models.messages.namespaces.specific.UpdateMatchingStatsMessage) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) Namespace(com.bakdata.conquery.models.worker.Namespace)

Example 9 with Namespace

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

the class DatasetsUIResource method getIdMapping.

@GET
@Path("{" + DATASET + "}/mapping")
public View getIdMapping(@PathParam(DATASET) Dataset dataset) {
    final Namespace namespace = uiProcessor.getDatasetRegistry().get(dataset.getId());
    EntityIdMap mapping = namespace.getStorage().getIdMapping();
    if (mapping != null && mapping.getInternalToPrint() != null) {
        return new UIView<>("idmapping.html.ftl", uiProcessor.getUIContext(), mapping.getInternalToPrint());
    }
    return new UIView<>("add_idmapping.html.ftl", uiProcessor.getUIContext(), namespace.getDataset().getId());
}
Also used : UIView(com.bakdata.conquery.resources.admin.ui.model.UIView) Namespace(com.bakdata.conquery.models.worker.Namespace) EntityIdMap(com.bakdata.conquery.models.identifiable.mapping.EntityIdMap) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 10 with Namespace

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

the class ManagerNode method loadMetaStorage.

private void loadMetaStorage() {
    log.info("Opening MetaStorage");
    storage.openStores(config.getStorage());
    log.info("Loading MetaStorage");
    storage.loadData();
    log.info("MetaStorage loaded {}", storage);
    datasetRegistry.setMetaStorage(storage);
    for (Namespace sn : datasetRegistry.getDatasets()) {
        sn.getStorage().setMetaStorage(storage);
    }
}
Also used : 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