Search in sources :

Example 1 with RemotingServer

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));
}
Also used : ChannelHandlerAdapter(org.apache.dubbo.remoting.transport.ChannelHandlerAdapter) RemotingServer(org.apache.dubbo.remoting.RemotingServer) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Example 2 with RemotingServer

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();
}
Also used : ProtocolServer(org.apache.dubbo.rpc.ProtocolServer) ArrayList(java.util.ArrayList) RemotingServer(org.apache.dubbo.remoting.RemotingServer) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with RemotingServer

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);
        }
    };
}
Also used : ProtocolServer(org.apache.dubbo.rpc.ProtocolServer) GenericService(org.apache.dubbo.rpc.service.GenericService) HessianSkeleton(com.caucho.hessian.server.HessianSkeleton) RemotingServer(org.apache.dubbo.remoting.RemotingServer)

Example 4 with RemotingServer

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);
    };
}
Also used : ProtocolServer(org.apache.dubbo.rpc.ProtocolServer) JsonRpcServer(com.googlecode.jsonrpc4j.JsonRpcServer) RemotingServer(org.apache.dubbo.remoting.RemotingServer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with RemotingServer

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);
}
Also used : RemotingServer(org.apache.dubbo.remoting.RemotingServer)

Aggregations

RemotingServer (org.apache.dubbo.remoting.RemotingServer)10 ProtocolServer (org.apache.dubbo.rpc.ProtocolServer)6 URL (org.apache.dubbo.common.URL)3 Test (org.junit.jupiter.api.Test)3 ChannelHandlerAdapter (org.apache.dubbo.remoting.transport.ChannelHandlerAdapter)2 HessianSkeleton (com.caucho.hessian.server.HessianSkeleton)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonRpcServer (com.googlecode.jsonrpc4j.JsonRpcServer)1 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1 SoapTransportFactory (org.apache.cxf.binding.soap.SoapTransportFactory)1 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)1 DestinationRegistryImpl (org.apache.cxf.transport.http.DestinationRegistryImpl)1 Status (org.apache.dubbo.common.status.Status)1 RpcException (org.apache.dubbo.rpc.RpcException)1 GenericService (org.apache.dubbo.rpc.service.GenericService)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1