Search in sources :

Example 1 with AddWorker

use of com.bakdata.conquery.models.messages.network.specific.AddWorker 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)

Aggregations

InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 EntityIdMap (com.bakdata.conquery.models.identifiable.mapping.EntityIdMap)1 AddWorker (com.bakdata.conquery.models.messages.network.specific.AddWorker)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 ShardNodeInformation (com.bakdata.conquery.models.worker.ShardNodeInformation)1 WebApplicationException (javax.ws.rs.WebApplicationException)1