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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
20 package org
.apache
.thrift
.test
;
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
;
29 import thrift
.test
.ThriftTest
;
32 public class TestNonblockingServer
extends TestServer
{
33 public static void main(String
[] args
) {
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")) {
45 //@TODO add other protocol and transport types
48 TestHandler testHandler
=
50 ThriftTest
.Processor testProcessor
=
51 new ThriftTest
.Processor(testHandler
);
54 TNonblockingServerSocket tServerSocket
=
55 new TNonblockingServerSocket(new TNonblockingServerSocket
.NonblockingAbstractServerSocketArgs().port(port
));
61 serverEngine
= new THsHaServer(new Args(tServerSocket
).processor(testProcessor
));
64 serverEngine
= new TNonblockingServer(new Args(tServerSocket
).processor(testProcessor
));
68 System
.out
.println("Starting the server on port " + port
+ "...");
71 } catch (Exception x
) {
74 System
.out
.println("done.");