]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/java/test/org/apache/thrift/test/TestNonblockingServer.java
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / lib / java / test / org / apache / thrift / test / TestNonblockingServer.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.thrift.test;
21
22 import org.apache.thrift.server.THsHaServer;
23 import org.apache.thrift.server.TNonblockingServer;
24 import org.apache.thrift.server.TServer;
25 import org.apache.thrift.server.THsHaServer.Args;
26 import org.apache.thrift.transport.TNonblockingServerSocket;
27 import org.apache.thrift.server.ServerTestBase.TestHandler;
28
29 import thrift.test.ThriftTest;
30
31
32 public class TestNonblockingServer extends TestServer {
33 public static void main(String [] args) {
34 try {
35 int port = 9090;
36 boolean hsha = false;
37
38 for (int i = 0; i < args.length; i++) {
39 if (args[i].equals("-p")) {
40 port = Integer.valueOf(args[i++]);
41 } else if (args[i].equals("-hsha")) {
42 hsha = true;
43 }
44 }
45 //@TODO add other protocol and transport types
46
47 // Processor
48 TestHandler testHandler =
49 new TestHandler();
50 ThriftTest.Processor testProcessor =
51 new ThriftTest.Processor(testHandler);
52
53 // Transport
54 TNonblockingServerSocket tServerSocket =
55 new TNonblockingServerSocket(new TNonblockingServerSocket.NonblockingAbstractServerSocketArgs().port(port));
56
57 TServer serverEngine;
58
59 if (hsha) {
60 // HsHa Server
61 serverEngine = new THsHaServer(new Args(tServerSocket).processor(testProcessor));
62 } else {
63 // Nonblocking Server
64 serverEngine = new TNonblockingServer(new Args(tServerSocket).processor(testProcessor));
65 }
66
67 // Run it
68 System.out.println("Starting the server on port " + port + "...");
69 serverEngine.serve();
70
71 } catch (Exception x) {
72 x.printStackTrace();
73 }
74 System.out.println("done.");
75 }
76 }