Rev 4500 | Rev 4637 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/****/package in.shop2020.warehouse.service;import in.shop2020.thrift.clients.config.ConfigClient;import in.shop2020.utils.ConfigClientKeys;import in.shop2020.warehouse.WarehouseService.Iface;import in.shop2020.warehouse.WarehouseService.Processor;import in.shop2020.warehouse.service.handler.WarehouseServiceHandler;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.thrift.protocol.TBinaryProtocol;import org.apache.thrift.protocol.TProtocolFactory;import org.apache.thrift.server.TServer;import org.apache.thrift.server.TThreadPoolServer;import org.apache.thrift.server.TThreadPoolServer.Args;import org.apache.thrift.transport.TFramedTransport;import org.apache.thrift.transport.TServerSocket;import org.apache.thrift.transport.TServerTransport;import org.apache.thrift.transport.TTransportFactory;/*** @author mandeep**/public class WarehouseServer {private static Log log = LogFactory.getLog(WarehouseServer.class);private static WarehouseServiceHandler handler;private static Processor<Iface> processor;public static void main(String[] args){try {handler = new WarehouseServiceHandler();processor = new Processor<Iface>(handler);int port = 9013;try {String portNo = ConfigClient.getClient().get(ConfigClientKeys.warehouse_service_server_port.toString());port = Integer.parseInt(portNo);} catch(Exception e) {log.warn("Unable to get port number from the Config server because of:", e);}TServerTransport serverTransport = new TServerSocket(port);TTransportFactory tFactory = new TFramedTransport.Factory();TProtocolFactory pFactory = new TBinaryProtocol.Factory();Args serverParams = new Args(serverTransport);serverParams.processor(processor);serverParams.transportFactory(tFactory);serverParams.protocolFactory(pFactory);TServer server = new TThreadPoolServer(serverParams);log.info("Warehouse service started on port " + port);server.serve();}catch(Exception ex){ex.printStackTrace();}}}