Search in sources :

Example 1 with ProtocolServer

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();
    }
}
Also used : ProtocolServer(org.apache.dubbo.rpc.ProtocolServer) AfterEach(org.junit.jupiter.api.AfterEach)

Example 2 with ProtocolServer

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();
}
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 ProtocolServer

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

Example 4 with ProtocolServer

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

Example 5 with ProtocolServer

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);
        }
    };
}
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)

Aggregations

ProtocolServer (org.apache.dubbo.rpc.ProtocolServer)13 RemotingServer (org.apache.dubbo.remoting.RemotingServer)6 IOException (java.io.IOException)2 RpcException (org.apache.dubbo.rpc.RpcException)2 HessianSkeleton (com.caucho.hessian.server.HessianSkeleton)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonRpcServer (com.googlecode.jsonrpc4j.JsonRpcServer)1 Server (io.grpc.Server)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)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 URL (org.apache.dubbo.common.URL)1