| 779 |
rajveer |
1 |
package in.shop2020.test;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.test.TestService.Processor;
|
|
|
4 |
|
|
|
5 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
|
|
6 |
import org.apache.thrift.protocol.TCompactProtocol;
|
|
|
7 |
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
|
|
|
8 |
import org.apache.thrift.server.THsHaServer;
|
|
|
9 |
import org.apache.thrift.server.TServer;
|
|
|
10 |
import org.apache.thrift.server.TSimpleServer;
|
|
|
11 |
import org.apache.thrift.server.TThreadPoolServer;
|
|
|
12 |
import org.apache.thrift.server.TThreadPoolServer.Options;
|
|
|
13 |
import org.apache.thrift.transport.TFramedTransport;
|
|
|
14 |
import org.apache.thrift.transport.TNonblockingServerSocket;
|
|
|
15 |
import org.apache.thrift.transport.TServerSocket;
|
|
|
16 |
import org.apache.thrift.transport.TServerTransport;
|
|
|
17 |
import org.apache.thrift.transport.TSocket;
|
|
|
18 |
import org.apache.thrift.transport.TTransport;
|
|
|
19 |
import org.apache.thrift.transport.TTransportException;
|
|
|
20 |
import org.apache.thrift.transport.TTransportFactory;
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
public class TestServer {
|
|
|
24 |
private String port = null;
|
|
|
25 |
|
|
|
26 |
public TestServer(){
|
|
|
27 |
port = "9009";
|
|
|
28 |
}
|
|
|
29 |
|
|
|
30 |
public void startServer(){
|
|
|
31 |
try {
|
|
|
32 |
//TServerSocket socket = new TServerSocket(Integer.parseInt(port));
|
|
|
33 |
Processor p = new Processor(new TestHandler());
|
|
|
34 |
TServerSocket t = new TServerSocket(Integer.parseInt(port));
|
|
|
35 |
|
|
|
36 |
//TNonblockingServerSocket socket = new TNonblockingServerSocket(Integer.parseInt(port));
|
|
|
37 |
//TServerTransport t = new TServerSocket(Integer.parseInt(port));
|
|
|
38 |
//Factory protFactory = new TBinaryProtocol.Factory();
|
|
|
39 |
System.out.println("Starting server at port 9009");
|
|
|
40 |
TServer server = new TThreadPoolServer(p, t, new TFramedTransport.Factory(), new TBinaryProtocol.Factory());
|
|
|
41 |
//TServer server = new TThreadPoolServer(processor, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory, options)
|
|
|
42 |
//TServer server = new THsHaServer(p,socket, new TFramedTransport.Factory(), new TCompactProtocol.Factory());
|
|
|
43 |
server.serve();
|
|
|
44 |
} catch (NumberFormatException e) {
|
|
|
45 |
// TODO Auto-generated catch block
|
|
|
46 |
e.printStackTrace();
|
|
|
47 |
} catch (TTransportException e) {
|
|
|
48 |
// TODO Auto-generated catch block
|
|
|
49 |
e.printStackTrace();
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
public static void main(String[] args){
|
|
|
54 |
TestServer server = new TestServer();
|
|
|
55 |
server.startServer();
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|