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;
}
Aggregations