use of org.apache.dubbo.remoting.RemotingServer in project dubbo by alibaba.
the class GrizzlyTransporterTest method shouldAbleToBindGrizzly.
@Test
public void shouldAbleToBindGrizzly() throws Exception {
int port = NetUtils.getAvailablePort();
URL url = new URL("telnet", "localhost", port, new String[] { BIND_PORT_KEY, String.valueOf(port) });
RemotingServer server = new GrizzlyTransporter().bind(url, new ChannelHandlerAdapter());
assertThat(server.isBound(), is(true));
}
use of org.apache.dubbo.remoting.RemotingServer 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.remoting.RemotingServer 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);
}
};
}
use of org.apache.dubbo.remoting.RemotingServer in project dubbo by alibaba.
the class HttpProtocol method doExport.
@Override
protected <T> Runnable doExport(final 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 InternalHandler(url.getParameter("cors", false)));
serverMap.put(addr, new ProxyProtocolServer(remotingServer));
}
final String path = url.getAbsolutePath();
final String genericPath = path + "/" + GENERIC_KEY;
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonRpcServer skeleton = new JsonRpcServer(mapper, impl, type);
JsonRpcServer genericServer = new JsonRpcServer(mapper, impl, GenericService.class);
skeletonMap.put(path, skeleton);
skeletonMap.put(genericPath, genericServer);
return () -> {
skeletonMap.remove(path);
skeletonMap.remove(genericPath);
};
}
use of org.apache.dubbo.remoting.RemotingServer in project dubbo by alibaba.
the class AbstractGroup method join.
@Override
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
RemotingServer server = servers.get(url);
if (server == null) {
// TODO exist concurrent gap
server = Transporters.bind(url, handler);
servers.put(url, server);
dispatcher.addChannelHandler(handler);
}
return new ServerPeer(server, clients, this);
}
Aggregations