use of org.apache.dubbo.rpc.ProtocolServer in project dubbo by alibaba.
the class DubboMonitorFactoryTest method tearDownAfterClass.
@AfterEach
public void tearDownAfterClass() {
DubboProtocol.getDubboProtocol().destroy();
List<ProtocolServer> servers = DubboProtocol.getDubboProtocol().getServers();
for (ProtocolServer server : servers) {
server.close();
}
}
use of org.apache.dubbo.rpc.ProtocolServer in project dubbo by alibaba.
the class DubboProtocol method destroy.
@Override
@SuppressWarnings("unchecked")
public void destroy() {
for (String key : new ArrayList<>(serverMap.keySet())) {
ProtocolServer protocolServer = serverMap.remove(key);
if (protocolServer == null) {
continue;
}
RemotingServer server = protocolServer.getRemotingServer();
try {
if (logger.isInfoEnabled()) {
logger.info("Close dubbo server: " + server.getLocalAddress());
}
server.close(ConfigurationUtils.getServerShutdownTimeout());
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
}
for (String key : new ArrayList<>(referenceClientMap.keySet())) {
Object clients = referenceClientMap.remove(key);
if (clients instanceof List) {
List<ReferenceCountExchangeClient> typedClients = (List<ReferenceCountExchangeClient>) clients;
if (CollectionUtils.isEmpty(typedClients)) {
continue;
}
for (ReferenceCountExchangeClient client : typedClients) {
closeReferenceCountExchangeClient(client);
}
}
}
super.destroy();
}
use of org.apache.dubbo.rpc.ProtocolServer in project dubbo by alibaba.
the class DubboProtocol method openServer.
private void openServer(URL url) {
// find server.
String key = url.getAddress();
// client can export a service which's only for server to invoke
boolean isServer = url.getParameter(IS_SERVER_KEY, true);
if (isServer) {
ProtocolServer server = serverMap.get(key);
if (server == null) {
synchronized (this) {
server = serverMap.get(key);
if (server == null) {
serverMap.put(key, createServer(url));
}
}
} else {
// server supports reset, use together with override
server.reset(url);
}
}
}
use of org.apache.dubbo.rpc.ProtocolServer in project dubbo by alibaba.
the class ProtocolUtils method closeAll.
public static void closeAll() {
DubboProtocol.getDubboProtocol().destroy();
List<ProtocolServer> servers = DubboProtocol.getDubboProtocol().getServers();
for (ProtocolServer server : servers) {
server.close();
}
}
use of org.apache.dubbo.rpc.ProtocolServer in project dubbo by alibaba.
the class HessianProtocol method doExport.
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
String addr = getAddr(url);
ProtocolServer protocolServer = serverMap.get(addr);
if (protocolServer == null) {
RemotingServer remotingServer = httpBinder.bind(url, new HessianHandler());
serverMap.put(addr, new ProxyProtocolServer(remotingServer));
}
final String path = url.getAbsolutePath();
final HessianSkeleton skeleton = new HessianSkeleton(impl, type);
skeletonMap.put(path, skeleton);
final String genericPath = path + "/" + GENERIC_KEY;
skeletonMap.put(genericPath, new HessianSkeleton(impl, GenericService.class));
return new Runnable() {
@Override
public void run() {
skeletonMap.remove(path);
skeletonMap.remove(genericPath);
}
};
}
Aggregations