use of org.apache.thrift.transport.TServerSocket in project dubbo by alibaba.
the class AbstractTest method init.
protected void init() throws Exception {
serverTransport = new TServerSocket(PORT);
TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();
server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).inputProtocolFactory(bFactory).outputProtocolFactory(bFactory).inputTransportFactory(getTransportFactory()).outputTransportFactory(getTransportFactory()).processor(getProcessor()));
Thread startTread = new Thread() {
@Override
public void run() {
server.serve();
}
};
startTread.setName("thrift-server");
startTread.start();
while (!server.isServing()) {
Thread.sleep(100);
}
protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(ThriftProtocol.NAME);
invoker = protocol.refer(getInterface(), getUrl());
}
use of org.apache.thrift.transport.TServerSocket in project dubbo by alibaba.
the class ServiceMethodNotFoundTest method init.
protected void init() throws Exception {
TServerTransport serverTransport = new TServerSocket(PORT);
DubboDemoImpl impl = new DubboDemoImpl();
$__DemoStub.Processor processor = new $__DemoStub.Processor(impl);
// for test
Field field = processor.getClass().getSuperclass().getDeclaredField("processMap");
field.setAccessible(true);
Object obj = field.get(processor);
if (obj instanceof Map) {
((Map) obj).remove("echoString");
}
// ~
TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();
MultiServiceProcessor wrapper = new MultiServiceProcessor();
wrapper.addProcessor(Demo.class, processor);
server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).inputProtocolFactory(bFactory).outputProtocolFactory(bFactory).inputTransportFactory(getTransportFactory()).outputTransportFactory(getTransportFactory()).processor(wrapper));
Thread startTread = new Thread() {
@Override
public void run() {
server.serve();
}
};
startTread.start();
while (!server.isServing()) {
Thread.sleep(100);
}
}
use of org.apache.thrift.transport.TServerSocket in project metacat by Netflix.
the class AbstractThriftServer method start.
/**
* Server initialization.
*
* @throws Exception error
*/
public void start() throws Exception {
log.info("initializing thrift server {}", getServerName());
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadPoolNameFormat).setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e)).build();
final ExecutorService executorService = new ThreadPoolExecutor(Math.min(2, config.getThriftServerMaxWorkerThreads()), config.getThriftServerMaxWorkerThreads(), 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory);
RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService);
final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
startServing(executorService, serverTransport);
}
use of org.apache.thrift.transport.TServerSocket in project vcell by virtualcell.
the class VCellProxyServer method startSimpleVCellProxyServer.
private static void startSimpleVCellProxyServer(VCellProxy.Processor<VCellProxyHandler> processor) {
try {
InetSocketAddress inetSocketAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 9090);
TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
TServer vcellProxyServer = new TSimpleServer(new org.apache.thrift.server.TServer.Args(serverTransport).processor(processor));
System.out.println("Starting the VCell-VisIt Data Server thread...");
vcellProxyServer.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.thrift.transport.TServerSocket in project accumulo by apache.
the class TServerUtilsTest method testStopTServer_NoES.
@Test
public void testStopTServer_NoES() {
TServerSocket socket = createNiceMock(TServerSocket.class);
TServerWithoutES s = new TServerWithoutES(socket);
TServerUtils.stopTServer(s);
assertTrue(s.stopCalled);
}
Aggregations