| Line 1... |
Line 1... |
| 1 |
package in.shop2020.test;
|
1 |
package in.shop2020.test;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.test.TestService.Iface;
|
| 3 |
import in.shop2020.test.TestService.Processor;
|
4 |
import in.shop2020.test.TestService.Processor;
|
| 4 |
|
5 |
|
| 5 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
6 |
import org.apache.thrift.protocol.TBinaryProtocol;
|
| 6 |
import org.apache.thrift.protocol.TCompactProtocol;
|
- |
|
| 7 |
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
|
7 |
import org.apache.thrift.protocol.TProtocolFactory;
|
| 8 |
import org.apache.thrift.server.THsHaServer;
|
- |
|
| 9 |
import org.apache.thrift.server.TServer;
|
8 |
import org.apache.thrift.server.TServer;
|
| 10 |
import org.apache.thrift.server.TSimpleServer;
|
- |
|
| 11 |
import org.apache.thrift.server.TThreadPoolServer;
|
9 |
import org.apache.thrift.server.TThreadPoolServer;
|
| 12 |
import org.apache.thrift.server.TThreadPoolServer.Options;
|
10 |
import org.apache.thrift.server.TThreadPoolServer.Args;
|
| 13 |
import org.apache.thrift.transport.TFramedTransport;
|
11 |
import org.apache.thrift.transport.TFramedTransport;
|
| 14 |
import org.apache.thrift.transport.TNonblockingServerSocket;
|
- |
|
| 15 |
import org.apache.thrift.transport.TServerSocket;
|
12 |
import org.apache.thrift.transport.TServerSocket;
|
| 16 |
import org.apache.thrift.transport.TServerTransport;
|
13 |
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;
|
14 |
import org.apache.thrift.transport.TTransportException;
|
| 20 |
import org.apache.thrift.transport.TTransportFactory;
|
15 |
import org.apache.thrift.transport.TTransportFactory;
|
| 21 |
|
16 |
|
| 22 |
|
17 |
|
| 23 |
public class TestServer {
|
18 |
public class TestServer {
|
| 24 |
private String port = null;
|
19 |
private String port = null;
|
| 25 |
|
20 |
|
| 26 |
public TestServer(){
|
21 |
public TestServer(){
|
| 27 |
port = "9009";
|
22 |
port = "9000";
|
| 28 |
}
|
23 |
}
|
| 29 |
|
24 |
|
| 30 |
public void startServer(){
|
25 |
public void startServer(){
|
| 31 |
try {
|
26 |
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 |
|
27 |
|
| 36 |
//TNonblockingServerSocket socket = new TNonblockingServerSocket(Integer.parseInt(port));
|
28 |
TServerTransport t1 = new TServerSocket(Integer.parseInt(port));
|
| 37 |
//TServerTransport t = new TServerSocket(Integer.parseInt(port));
|
29 |
TTransportFactory tFactory = new TFramedTransport.Factory();
|
| 38 |
//Factory protFactory = new TBinaryProtocol.Factory();
|
30 |
TProtocolFactory pFactory = new TBinaryProtocol.Factory();
|
| - |
|
31 |
|
| - |
|
32 |
Processor<Iface> p = new Processor<TestService.Iface>(new TestHandler());
|
| - |
|
33 |
|
| 39 |
System.out.println("Starting server at port 9009");
|
34 |
System.out.println("Starting server at port 9000");
|
| - |
|
35 |
|
| - |
|
36 |
Args args = new Args(t1);
|
| - |
|
37 |
args.processor(p);
|
| 40 |
TServer server = new TThreadPoolServer(p, t, new TFramedTransport.Factory(), new TBinaryProtocol.Factory());
|
38 |
args.transportFactory(tFactory);
|
| - |
|
39 |
args.protocolFactory(pFactory);
|
| 41 |
//TServer server = new TThreadPoolServer(processor, serverTransport, inputTransportFactory, outputTransportFactory, inputProtocolFactory, outputProtocolFactory, options)
|
40 |
TServer server = new TThreadPoolServer(args);
|
| - |
|
41 |
|
| 42 |
//TServer server = new THsHaServer(p,socket, new TFramedTransport.Factory(), new TCompactProtocol.Factory());
|
42 |
// TServer server = new TThreadPoolServer(p, t, new TFramedTransport.Factory(), new TBinaryProtocol.Factory());
|
| 43 |
server.serve();
|
43 |
server.serve();
|
| 44 |
} catch (NumberFormatException e) {
|
44 |
} catch (NumberFormatException e) {
|
| 45 |
// TODO Auto-generated catch block
|
45 |
// TODO Auto-generated catch block
|
| 46 |
e.printStackTrace();
|
46 |
e.printStackTrace();
|
| 47 |
} catch (TTransportException e) {
|
47 |
} catch (TTransportException e) {
|