Search in sources :

Example 1 with NetworkSession

use of com.bakdata.conquery.io.mina.NetworkSession in project conquery by bakdata.

the class ManagerNode method messageReceived.

@Override
public void messageReceived(IoSession session, Object message) throws Exception {
    ConqueryMDC.setLocation("ManagerNode[" + session.getLocalAddress().toString() + "]");
    if (message instanceof MessageToManagerNode) {
        MessageToManagerNode mrm = (MessageToManagerNode) message;
        log.trace("ManagerNode received {} from {}", message.getClass().getSimpleName(), session.getRemoteAddress());
        ReactingJob<MessageToManagerNode, NetworkMessageContext.ManagerNodeNetworkContext> job = new ReactingJob<>(mrm, new NetworkMessageContext.ManagerNodeNetworkContext(jobManager, new NetworkSession(session), datasetRegistry, config.getCluster().getBackpressure()));
        // TODO: 01.07.2020 FK: distribute messages/jobs to their respective JobManagers (if they have one)
        if (mrm.isSlowMessage()) {
            ((SlowMessage) mrm).setProgressReporter(job.getProgressReporter());
            jobManager.addSlowJob(job);
        } else {
            jobManager.addFastJob(job);
        }
    } else {
        log.error("Unknown message type {} in {}", message.getClass(), message);
    }
}
Also used : MessageToManagerNode(com.bakdata.conquery.models.messages.network.MessageToManagerNode) ReactingJob(com.bakdata.conquery.models.jobs.ReactingJob) NetworkSession(com.bakdata.conquery.io.mina.NetworkSession) NetworkMessageContext(com.bakdata.conquery.models.messages.network.NetworkMessageContext) SlowMessage(com.bakdata.conquery.models.messages.SlowMessage)

Example 2 with NetworkSession

use of com.bakdata.conquery.io.mina.NetworkSession in project conquery by bakdata.

the class ShardNode method sessionOpened.

@Override
public void sessionOpened(IoSession session) throws Exception {
    setLocation(session);
    NetworkSession networkSession = new NetworkSession(session);
    context = new NetworkMessageContext.ShardNodeNetworkContext(jobManager, networkSession, workers, config, validator);
    log.info("Connected to ManagerNode @ {}", session.getRemoteAddress());
    // Authenticate with ManagerNode
    context.send(new AddShardNode());
    for (Worker w : workers.getWorkers().values()) {
        w.setSession(new NetworkSession(session));
        WorkerInformation info = w.getInfo();
        log.info("Sending worker identity '{}'", info.getName());
        networkSession.send(new RegisterWorker(info));
    }
}
Also used : WorkerInformation(com.bakdata.conquery.models.worker.WorkerInformation) NetworkSession(com.bakdata.conquery.io.mina.NetworkSession) RegisterWorker(com.bakdata.conquery.models.messages.network.specific.RegisterWorker) NetworkMessageContext(com.bakdata.conquery.models.messages.network.NetworkMessageContext) AddShardNode(com.bakdata.conquery.models.messages.network.specific.AddShardNode) Worker(com.bakdata.conquery.models.worker.Worker) RegisterWorker(com.bakdata.conquery.models.messages.network.specific.RegisterWorker) ShardNodeNetworkContext(com.bakdata.conquery.models.messages.network.NetworkMessageContext.ShardNodeNetworkContext)

Example 3 with NetworkSession

use of com.bakdata.conquery.io.mina.NetworkSession 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

NetworkSession (com.bakdata.conquery.io.mina.NetworkSession)3 NetworkMessageContext (com.bakdata.conquery.models.messages.network.NetworkMessageContext)2 ReactingJob (com.bakdata.conquery.models.jobs.ReactingJob)1 SlowMessage (com.bakdata.conquery.models.messages.SlowMessage)1 MessageToManagerNode (com.bakdata.conquery.models.messages.network.MessageToManagerNode)1 ShardNodeNetworkContext (com.bakdata.conquery.models.messages.network.NetworkMessageContext.ShardNodeNetworkContext)1 AddShardNode (com.bakdata.conquery.models.messages.network.specific.AddShardNode)1 RegisterWorker (com.bakdata.conquery.models.messages.network.specific.RegisterWorker)1 ShardNodeInformation (com.bakdata.conquery.models.worker.ShardNodeInformation)1 Worker (com.bakdata.conquery.models.worker.Worker)1 WorkerInformation (com.bakdata.conquery.models.worker.WorkerInformation)1