Search in sources :

Example 1 with ShardNodeInformation

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;
}
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 2 with ShardNodeInformation

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());
}
Also used : ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) RequestConsistency(com.bakdata.conquery.models.messages.namespaces.specific.RequestConsistency)

Example 3 with ShardNodeInformation

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());
}
Also used : NetworkSession(com.bakdata.conquery.io.mina.NetworkSession) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation)

Aggregations

ShardNodeInformation (com.bakdata.conquery.models.worker.ShardNodeInformation)3 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)1 NetworkSession (com.bakdata.conquery.io.mina.NetworkSession)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 RequestConsistency (com.bakdata.conquery.models.messages.namespaces.specific.RequestConsistency)1 AddWorker (com.bakdata.conquery.models.messages.network.specific.AddWorker)1 Namespace (com.bakdata.conquery.models.worker.Namespace)1 WebApplicationException (javax.ws.rs.WebApplicationException)1