use of com.bakdata.conquery.models.worker.ShardNodeInformation 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;
}
use of com.bakdata.conquery.models.worker.ShardNodeInformation in project conquery by bakdata.
the class RegisterWorker method react.
@Override
public void react(ManagerNodeNetworkContext context) throws Exception {
ShardNodeInformation node = getShardNode(context);
Wait.builder().stepTime(Duration.ofMillis(5)).total(Duration.ofSeconds(10)).build().until(() -> getShardNode(context) != null);
if (node == null) {
throw new IllegalStateException("Could not find the slave " + context.getRemoteAddress() + " to register worker " + info.getId());
}
info.setConnectedShardNode(node);
context.getNamespaces().register(node, info);
// Request consistency report
context.getNamespaces().getWorkers().get(info.getId()).send(new RequestConsistency());
}
use of com.bakdata.conquery.models.worker.ShardNodeInformation in project conquery by bakdata.
the class AddShardNode method react.
@Override
public void react(NetworkMessageContext.ManagerNodeNetworkContext context) throws Exception {
final ShardNodeInformation nodeInformation = new ShardNodeInformation(new NetworkSession(context.getSession().getSession()), context.getBackpressure());
context.getNamespaces().getShardNodes().put(context.getRemoteAddress(), nodeInformation);
log.info("ShardNode `{}` registered.", context.getRemoteAddress());
}
Aggregations