Search in sources :

Example 1 with ClientIdRequiredFilter

use of com.twitter.finagle.thrift.ClientIdRequiredFilter in project distributedlog by twitter.

the class DistributedLogServer method runServer.

static Pair<DistributedLogServiceImpl, Server> runServer(ServerConfiguration serverConf, DistributedLogConfiguration dlConf, DynamicDistributedLogConfiguration dynDlConf, URI dlUri, StreamPartitionConverter partitionConverter, StatsProvider provider, int port, CountDownLatch keepAliveLatch, StatsReceiver statsReceiver, boolean thriftmux, StreamConfigProvider streamConfProvider) throws IOException {
    logger.info("Running server @ uri {}.", dlUri);
    boolean perStreamStatsEnabled = serverConf.isPerStreamStatEnabled();
    StatsLogger perStreamStatsLogger;
    if (perStreamStatsEnabled) {
        perStreamStatsLogger = provider.getStatsLogger("stream");
    } else {
        perStreamStatsLogger = NullStatsLogger.INSTANCE;
    }
    // dl service
    DistributedLogServiceImpl dlService = new DistributedLogServiceImpl(serverConf, dlConf, dynDlConf, streamConfProvider, dlUri, partitionConverter, provider.getStatsLogger(""), perStreamStatsLogger, keepAliveLatch);
    StatsReceiver serviceStatsReceiver = statsReceiver.scope("service");
    StatsLogger serviceStatsLogger = provider.getStatsLogger("service");
    ServerBuilder serverBuilder = ServerBuilder.get().name("DistributedLogServer").codec(ThriftServerFramedCodec.get()).reportTo(statsReceiver).keepAlive(true).bindTo(new InetSocketAddress(port));
    if (thriftmux) {
        logger.info("Using thriftmux.");
        Tuple2<Transport.Liveness, Stack.Param<Transport.Liveness>> livenessParam = new Transport.Liveness(Duration.Top(), Duration.Top(), Option.apply((Object) Boolean.valueOf(true))).mk();
        serverBuilder = serverBuilder.stack(ThriftMuxServer$.MODULE$.configured(livenessParam._1(), livenessParam._2()));
    }
    logger.info("DistributedLogServer running with the following configuration : \n{}", dlConf.getPropsAsString());
    // starts dl server
    Server server = ServerBuilder.safeBuild(new ClientIdRequiredFilter<byte[], byte[]>(serviceStatsReceiver).andThen(new StatsFilter<byte[], byte[]>(serviceStatsLogger).andThen(new DistributedLogService.Service(dlService, new TBinaryProtocol.Factory()))), serverBuilder);
    logger.info("Started DistributedLog Server.");
    return Pair.of(dlService, server);
}
Also used : DistributedLogService(com.twitter.distributedlog.thrift.service.DistributedLogService) NullStatsLogger(org.apache.bookkeeper.stats.NullStatsLogger) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) NullStatsReceiver(com.twitter.finagle.stats.NullStatsReceiver) StatsReceiver(com.twitter.finagle.stats.StatsReceiver) Server(com.twitter.finagle.builder.Server) InetSocketAddress(java.net.InetSocketAddress) LoggerFactory(org.slf4j.LoggerFactory) DynamicConfigurationFactory(com.twitter.distributedlog.config.DynamicConfigurationFactory) ClientIdRequiredFilter(com.twitter.finagle.thrift.ClientIdRequiredFilter) Transport(com.twitter.finagle.transport.Transport) ServerBuilder(com.twitter.finagle.builder.ServerBuilder)

Aggregations

DynamicConfigurationFactory (com.twitter.distributedlog.config.DynamicConfigurationFactory)1 DistributedLogService (com.twitter.distributedlog.thrift.service.DistributedLogService)1 Server (com.twitter.finagle.builder.Server)1 ServerBuilder (com.twitter.finagle.builder.ServerBuilder)1 NullStatsReceiver (com.twitter.finagle.stats.NullStatsReceiver)1 StatsReceiver (com.twitter.finagle.stats.StatsReceiver)1 ClientIdRequiredFilter (com.twitter.finagle.thrift.ClientIdRequiredFilter)1 Transport (com.twitter.finagle.transport.Transport)1 InetSocketAddress (java.net.InetSocketAddress)1 NullStatsLogger (org.apache.bookkeeper.stats.NullStatsLogger)1 StatsLogger (org.apache.bookkeeper.stats.StatsLogger)1 LoggerFactory (org.slf4j.LoggerFactory)1