use of com.alipay.sofa.rpc.server.http.Http2ClearTextServer in project sofa-rpc by sofastack.
the class Http2ServerMain method main.
public static void main(String[] args) {
ApplicationConfig application = new ApplicationConfig().setAppName("test-server");
ServerConfig serverConfig = new ServerConfig().setProtocol("h2c").setPort(12300).setDaemon(false);
ProviderConfig<ProtoService> providerConfig = new ProviderConfig<ProtoService>().setInterfaceId(ProtoService.class.getName()).setApplication(application).setRef(new ProtoServiceImpl()).setServer(serverConfig);
providerConfig.export();
ProviderConfig<HelloService> providerConfig2 = new ProviderConfig<HelloService>().setInterfaceId(HelloService.class.getName()).setApplication(application).setRef(new HelloServiceImpl()).setServer(serverConfig).setRegister(false);
providerConfig2.export();
// http://127.0.0.1:12300/com.alipay.sofa.rpc.test.HelloService/sayHello
LOGGER.error("started at pid {}", RpcRuntimeContext.PID);
final AtomicInteger cnt = ((ProtoServiceImpl) providerConfig.getRef()).getCounter();
final ThreadPoolExecutor executor = ((Http2ClearTextServer) serverConfig.getServer()).getBizThreadPool();
Thread thread = new Thread(new Runnable() {
private long last = 0;
@Override
public void run() {
while (true) {
long count = cnt.get();
long tps = count - last;
LOGGER.error("last 1s invoke: {}, queue: {}", tps, executor.getQueue().size());
last = count;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
}, "Print-tps-THREAD");
thread.start();
}
Aggregations