Search in sources :

Example 1 with ChunkReader

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

the class ManagerNode method start.

@Override
public void start() throws Exception {
    acceptor = new NioSocketAcceptor();
    ObjectMapper om = Jackson.copyMapperAndInjectables(Jackson.BINARY_MAPPER);
    config.configureObjectMapper(om);
    BinaryJacksonCoder coder = new BinaryJacksonCoder(datasetRegistry, validator, om);
    acceptor.getFilterChain().addLast("codec", new CQProtocolCodecFilter(new ChunkWriter(coder), new ChunkReader(coder, om)));
    acceptor.setHandler(this);
    acceptor.getSessionConfig().setAll(config.getCluster().getMina());
    acceptor.bind(new InetSocketAddress(config.getCluster().getPort()));
    log.info("Started ManagerNode @ {}", acceptor.getLocalAddress());
}
Also used : ChunkWriter(com.bakdata.conquery.io.mina.ChunkWriter) BinaryJacksonCoder(com.bakdata.conquery.io.mina.BinaryJacksonCoder) InetSocketAddress(java.net.InetSocketAddress) NioSocketAcceptor(org.apache.mina.transport.socket.nio.NioSocketAcceptor) ChunkReader(com.bakdata.conquery.io.mina.ChunkReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CQProtocolCodecFilter(com.bakdata.conquery.io.mina.CQProtocolCodecFilter)

Example 2 with ChunkReader

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

the class ShardNode method start.

@Override
public void start() throws Exception {
    for (Worker value : workers.getWorkers().values()) {
        value.getJobManager().addSlowJob(new SimpleJob("Update Bucket Manager", value.getBucketManager()::fullUpdate));
    }
    ObjectMapper om = Jackson.copyMapperAndInjectables(Jackson.BINARY_MAPPER);
    config.configureObjectMapper(om);
    BinaryJacksonCoder coder = new BinaryJacksonCoder(workers, validator, om);
    connector.getFilterChain().addLast("codec", new CQProtocolCodecFilter(new ChunkWriter(coder), new ChunkReader(coder, om)));
    connector.setHandler(this);
    connector.getSessionConfig().setAll(config.getCluster().getMina());
    InetSocketAddress address = new InetSocketAddress(config.getCluster().getManagerURL().getHostAddress(), config.getCluster().getPort());
    while (true) {
        try {
            log.info("Trying to connect to {}", address);
            // Try opening a connection (Note: This fails immediately instead of waiting a minute to try and connect)
            ConnectFuture future = connector.connect(address);
            future.awaitUninterruptibly();
            if (future.isConnected()) {
                break;
            }
            future.cancel();
            // Sleep thirty seconds then retry.
            TimeUnit.SECONDS.sleep(30);
        } catch (RuntimeIoException e) {
            log.warn("Failed to connect to " + address, e);
        }
    }
}
Also used : ChunkWriter(com.bakdata.conquery.io.mina.ChunkWriter) BinaryJacksonCoder(com.bakdata.conquery.io.mina.BinaryJacksonCoder) InetSocketAddress(java.net.InetSocketAddress) Worker(com.bakdata.conquery.models.worker.Worker) RegisterWorker(com.bakdata.conquery.models.messages.network.specific.RegisterWorker) SimpleJob(com.bakdata.conquery.models.jobs.SimpleJob) ConnectFuture(org.apache.mina.core.future.ConnectFuture) ChunkReader(com.bakdata.conquery.io.mina.ChunkReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RuntimeIoException(org.apache.mina.core.RuntimeIoException) CQProtocolCodecFilter(com.bakdata.conquery.io.mina.CQProtocolCodecFilter)

Aggregations

BinaryJacksonCoder (com.bakdata.conquery.io.mina.BinaryJacksonCoder)2 CQProtocolCodecFilter (com.bakdata.conquery.io.mina.CQProtocolCodecFilter)2 ChunkReader (com.bakdata.conquery.io.mina.ChunkReader)2 ChunkWriter (com.bakdata.conquery.io.mina.ChunkWriter)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InetSocketAddress (java.net.InetSocketAddress)2 SimpleJob (com.bakdata.conquery.models.jobs.SimpleJob)1 RegisterWorker (com.bakdata.conquery.models.messages.network.specific.RegisterWorker)1 Worker (com.bakdata.conquery.models.worker.Worker)1 RuntimeIoException (org.apache.mina.core.RuntimeIoException)1 ConnectFuture (org.apache.mina.core.future.ConnectFuture)1 NioSocketAcceptor (org.apache.mina.transport.socket.nio.NioSocketAcceptor)1