@Override public StatsLogger getStatsLogger(String scope) { return new OstrichStatsLoggerImpl(scope, com.twitter.ostrich.stats.Stats.get(collectionName)); } });
public static void main(String[] args) { try { String serverHostName = InetAddress.getLocalHost().getHostName(); PinLaterQueueConfig queueConfig = new PinLaterQueueConfig(CONFIGURATION); queueConfig.initialize(); String backend = CONFIGURATION.getString("PINLATER_BACKEND"); PinLaterBackendIface backendIFace = getBackendIface(backend, serverHostName); PinLaterServiceImpl serviceImpl = new PinLaterServiceImpl(backendIFace, queueConfig); PinLater.Service service = new PinLater.Service(serviceImpl, new TBinaryProtocol.Factory()); ServiceShutdownHook.register(ServerBuilder.safeBuild( service, ServerBuilder.get() .name("PinLaterService") .codec(ThriftServerFramedCodec.get()) .hostConnectionMaxIdleTime(Duration.fromTimeUnit( CONFIGURATION.getInt("SERVER_CONN_MAX_IDLE_TIME_MINUTES"), TimeUnit.MINUTES)) .maxConcurrentRequests(CONFIGURATION.getInt("MAX_CONCURRENT_REQUESTS")) .reportTo(new OstrichStatsReceiver(Stats.get(""))) .bindTo(new InetSocketAddress(CONFIGURATION.getInt("THRIFT_PORT"))))); new OstrichAdminService(CONFIGURATION.getInt("OSTRICH_PORT")).start(); LOG.info("\n#######################################" + "\n# Ready To Serve Requests. #" + "\n#######################################"); } catch (Exception e) { LOG.error("Failed to start the pinlater server", e); System.exit(1); } } }