@Test public void test() { ThriftTransportService thriftTransportService = new ThriftTransportService(); thriftTransportService.setClient(new ThriftClient()); thriftTransportService.setDiscoveryClient(new LocalDiscoveryClient()); thriftTransportService.setProperties(new ThriftTransportProperties()); thriftTransportService.setResources(Arrays.asList(new NodeContract() { @Override public void close() throws Exception { } @Override public void shutdown() { } @Override public Node dhis() { return null; } })); thriftTransportService.setServices(Arrays.asList(new Service() { @Override public String getServiceName() { return "toto"; } })); thriftTransportService.setTransportProperties(new TransportProperties()); thriftTransportService.init(); }
@PostConstruct public void init() { ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager(new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, ImmutableSet.of()); NiftyProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.of(), resources); properties.setPort(transportProperties.getPort()); properties.setBindAddress(transportProperties.getBindAddress()); properties.setWorkerThreads(10); properties.setTaskExpirationTimeout(Duration.valueOf("10s")); server = new ThriftServer(processor, properties, new NiftyTimer("thrift"), ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES, ThriftServer.DEFAULT_PROTOCOL_FACTORIES, ThriftServer.DEFAULT_WORKER_EXECUTORS, ThriftServer.DEFAULT_SECURITY_FACTORY, transportProperties.isLocal()); server.start(); services.add(new Service() { @Override public String getServiceName() { return ServiceIds.node(); } }); services.forEach(service -> { log.debug("Registering service {}", service.getServiceName()); ServiceInstance instance = ServiceInstance.builder().host(transportProperties.getBindAddress()).port(transportProperties.getPort()) .name(service.getServiceName()).build(); discoveryClient.register(instance); }); Event event = Event.forNode(); event.getNode().setNodeId(discoveryClient.getInstanceId()).setType(NodeEventType.NODE_STARTED); send(event); }
ThriftTransportService implements TransportService { @PostConstruct public void init() { ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager(new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, ImmutableSet.of()); NiftyProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.of(), resources); properties.setPort(transportProperties.getPort()); properties.setBindAddress(transportProperties.getBindAddress()); properties.setWorkerThreads(10); properties.setTaskExpirationTimeout(Duration.valueOf("10s")); server = new ThriftServer(processor, properties, new NiftyTimer("thrift"), ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES, ThriftServer.DEFAULT_PROTOCOL_FACTORIES, ThriftServer.DEFAULT_WORKER_EXECUTORS, ThriftServer.DEFAULT_SECURITY_FACTORY, transportProperties.isLocal()); server.start(); services.add(new Service() { @Override public String getServiceName() { return ServiceIds.node(); } }); services.forEach(service -> { log.debug("Registering service {}", service.getServiceName()); ServiceInstance instance = ServiceInstance.builder().host(transportProperties.getBindAddress()).port(transportProperties.getPort()) .name(service.getServiceName()).build(); discoveryClient.register(instance); }); Event event = Event.forNode(); event.getNode().setNodeId(discoveryClient.getInstanceId()).setType(NodeEventType.NODE_STARTED); send(event); } }
ThriftTransportService implements TransportService { @PostConstruct public void init() { ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager(new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, ImmutableSet.of()); NiftyProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.of(), resources); properties.setPort(transportProperties.getPort()); properties.setBindAddress(transportProperties.getBindAddress()); properties.setWorkerThreads(10); properties.setTaskExpirationTimeout(Duration.valueOf("10s")); server = new ThriftServer(processor, properties, new NiftyTimer("thrift"), ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES, ThriftServer.DEFAULT_PROTOCOL_FACTORIES, ThriftServer.DEFAULT_WORKER_EXECUTORS, ThriftServer.DEFAULT_SECURITY_FACTORY, transportProperties.isLocal()); server.start(); services.add(new Service() { @Override public String getServiceName() { return ServiceIds.node(); } }); services.forEach(service -> { log.debug("Registering service {}", service.getServiceName()); ServiceInstance instance = ServiceInstance.builder().host(transportProperties.getBindAddress()).port(transportProperties.getPort()) .name(service.getServiceName()).build(); discoveryClient.register(instance); }); Event event = Event.forNode(); event.getNode().setNodeId(discoveryClient.getInstanceId()).setType(NodeEventType.NODE_STARTED); send(event); }  }
ThriftTransportService implements TransportService { @PostConstruct public void init() { ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager(new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, ImmutableSet.of()); NiftyProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.of(), resources); properties.setPort(transportProperties.getPort()); properties.setBindAddress(transportProperties.getBindAddress()); properties.setWorkerThreads(10); properties.setTaskExpirationTimeout(Duration.valueOf("10s")); server = new ThriftServer(processor, properties, new NiftyTimer("thrift"), ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES, ThriftServer.DEFAULT_PROTOCOL_FACTORIES, ThriftServer.DEFAULT_WORKER_EXECUTORS, ThriftServer.DEFAULT_SECURITY_FACTORY, transportProperties.isLocal()); server.start(); services.add(new Service() { @Override public String getServiceName() { return ServiceIds.node(); } }); services.forEach(service -> { log.debug("Registering service {}", service.getServiceName()); ServiceInstance instance = ServiceInstance.builder().host(transportProperties.getBindAddress()).port(transportProperties.getPort()) .name(service.getServiceName()).build(); discoveryClient.register(instance); }); Event event = Event.forNode(); event.getNode().setNodeId(discoveryClient.getInstanceId()).setType(NodeEventType.NODE_STARTED); send(event); }  @PostConstruct void init(); @PreDestroy void destroy(); }
ThriftTransportService implements TransportService { @PostConstruct public void init() { ThriftCatalog catalog = new ThriftCatalog(); catalog.addDefaultCoercions(MandrelCoercions.class); ThriftCodecManager codecManager = new ThriftCodecManager(new CompilerThriftCodecFactory(ThriftCodecManager.class.getClassLoader()), catalog, ImmutableSet.of()); NiftyProcessor processor = new ThriftServiceProcessor(codecManager, ImmutableList.of(), resources); properties.setPort(transportProperties.getPort()); properties.setBindAddress(transportProperties.getBindAddress()); properties.setWorkerThreads(10); properties.setTaskExpirationTimeout(Duration.valueOf("10s")); server = new ThriftServer(processor, properties, new NiftyTimer("thrift"), ThriftServer.DEFAULT_FRAME_CODEC_FACTORIES, ThriftServer.DEFAULT_PROTOCOL_FACTORIES, ThriftServer.DEFAULT_WORKER_EXECUTORS, ThriftServer.DEFAULT_SECURITY_FACTORY, transportProperties.isLocal()); server.start(); services.add(new Service() { @Override public String getServiceName() { return ServiceIds.node(); } }); services.forEach(service -> { log.debug("Registering service {}", service.getServiceName()); ServiceInstance instance = ServiceInstance.builder().host(transportProperties.getBindAddress()).port(transportProperties.getPort()) .name(service.getServiceName()).build(); discoveryClient.register(instance); }); Event event = Event.forNode(); event.getNode().setNodeId(discoveryClient.getInstanceId()).setType(NodeEventType.NODE_STARTED); send(event); }  @PostConstruct void init(); @PreDestroy void destroy();  }