Java Code Examples for org.apache.thrift.transport.TTransportException#printStackTrace()

The following examples show how to use org.apache.thrift.transport.TTransportException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DKSearchService.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
/**
 *
 * 简单的单线程模式
 *
 */
public  void  startService(){
    System.out.println( " start ...." );
    //单接口声明
    //TProcessor tProcessor=new DKSearchOutput.Processor<DKSearchOutput.Iface>( new DKSearchOutputImpl() );
    //多接口声明
    TMultiplexedProcessor processor = new TMultiplexedProcessor();
    processor.registerProcessor( "DKSearchOutput",new DKSearchOutput.Processor<DKSearchOutput.Iface>( new DKSearchOutputImpl() ) );
    processor.registerProcessor( "DKSearchInput",new DKSearchInput.Processor<DKSearchInput.Iface>(new DKSearchInputImpl()  ) );
    processor.registerProcessor( "DKSearchService",new SearchService.Processor<SearchService.Iface>(new SearchServiceImpl() ) );
    try {
        TServerSocket serverSocket=new TServerSocket( Integer.valueOf(prop.get("dkSearch.port")) );
        TServer.Args targs=new TServer.Args( serverSocket );
        targs.processor( processor );
        //二进制TBinaryProtocol
        //二进制高密度TCompactProtocol
        targs.protocolFactory( new TCompactProtocol.Factory(  ) );
        TServer tServer=new TSimpleServer( targs );
        tServer.serve();
    } catch (TTransportException e) {
        System.err.println("Service Start error");
        e.printStackTrace();
    }
}
 
Example 2
Source File: ThriftServerApplication.java    From spring-boot-demo with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SpringApplication.run(ThriftServerApplication.class, args);

    try {
        System.out.println("服务端开启....");
        TProcessor tprocessor = new Hello.Processor<Hello.Iface>(new HelloServiceImpl());
        // 简单的单线程服务模型
        TServerSocket serverTransport = new TServerSocket(9898);
        TServer.Args tArgs = new TServer.Args(serverTransport);
        tArgs.processor(tprocessor);
        tArgs.protocolFactory(new TBinaryProtocol.Factory());
        TServer server = new TSimpleServer(tArgs);
        server.serve();
    } catch (TTransportException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: IoTDBDataSource.java    From incubator-iotdb with Apache License 2.0 5 votes vote down vote up
@Override
public Connection getConnection() throws SQLException {
    try {
        return new IoTDBConnection(url, properties);
    } catch (TTransportException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 4
Source File: ExampleServer.java    From Thrift-Connection-Pool with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	try {
		int port = 9119;
		TServerTransport serverTransport = new TServerSocket(port);
		Factory proFactory = new TBinaryProtocol.Factory();
		Processor<Iface> processor = new Example.Processor<Example.Iface>(new Example.Iface() {

			@Override
			public void pong() throws TException {
				System.out.println("pong");
			}

			@Override
			public void ping() throws TException {
				System.out.println("ping");
			}
		});
		Args thriftArgs = new Args(serverTransport);
		thriftArgs.processor(processor);
		thriftArgs.protocolFactory(proFactory);
		TServer tserver = new TThreadPoolServer(thriftArgs);
		System.out.println("启动监听:" + port);
		tserver.serve();
	} catch (TTransportException e) {
		e.printStackTrace();
	}
}