Search in sources :

Example 1 with Exporter

use of com.weibo.api.motan.rpc.Exporter in project motan by weibocom.

the class DefaultRpcExporter method unexport.

@SuppressWarnings("unchecked")
@Override
public void unexport() {
    String protocolKey = MotanFrameworkUtil.getProtocolKey(url);
    String ipPort = url.getServerPortStr();
    Exporter<T> exporter = (Exporter<T>) exporterMap.remove(protocolKey);
    if (exporter != null) {
        exporter.destroy();
    }
    ProviderMessageRouter requestRouter = ipPort2RequestRouter.get(ipPort);
    if (requestRouter != null) {
        requestRouter.removeProvider(provider);
    }
    LoggerUtil.info("DefaultRpcExporter unexport Success: url={}", url);
}
Also used : ProviderMessageRouter(com.weibo.api.motan.transport.ProviderMessageRouter) AbstractExporter(com.weibo.api.motan.rpc.AbstractExporter) Exporter(com.weibo.api.motan.rpc.Exporter)

Example 2 with Exporter

use of com.weibo.api.motan.rpc.Exporter in project motan by weibocom.

the class YarRpcProtocol method unexport.

public void unexport(URL url, Provider<?> provider) {
    String protocolKey = MotanFrameworkUtil.getProtocolKey(url);
    String ipPort = url.getServerPortStr();
    Exporter<?> exporter = (Exporter<?>) exporterMap.remove(protocolKey);
    if (exporter != null) {
        exporter.destroy();
    }
    synchronized (ipPort2RequestRouter) {
        ProviderMessageRouter requestRouter = ipPort2RequestRouter.get(ipPort);
        if (requestRouter != null) {
            requestRouter.removeProvider(provider);
        }
    }
    LoggerUtil.info("yarRpcExporter unexport Success: url={}", url);
}
Also used : ProviderMessageRouter(com.weibo.api.motan.transport.ProviderMessageRouter) Exporter(com.weibo.api.motan.rpc.Exporter)

Example 3 with Exporter

use of com.weibo.api.motan.rpc.Exporter in project motan by weibocom.

the class ServiceConfigBeanTest method testGetProtocolAndPort.

@Test
public void testGetProtocolAndPort() {
    List<Exporter<ITest>> exporters = serviceTest.getExporters();
    assertEquals(2, exporters.size());
    boolean injvm = false;
    boolean motan = false;
    for (Exporter<ITest> exporter : exporters) {
        URL url = exporter.getUrl();
        if ("injvm".equals(url.getProtocol()) && url.getPort() == 0) {
            injvm = true;
        } else if ("motan".equals(url.getProtocol()) && url.getPort() == 7888) {
            motan = true;
        }
    }
    assertTrue(injvm && motan);
    exporters = serviceTest2.getExporters();
    URL url = exporters.get(0).getUrl();
    assertEquals(1, exporters.size());
    assertEquals("motan", url.getProtocol());
    assertEquals(18080, url.getPort().intValue());
}
Also used : Exporter(com.weibo.api.motan.rpc.Exporter) URL(com.weibo.api.motan.rpc.URL) Test(org.junit.Test)

Aggregations

Exporter (com.weibo.api.motan.rpc.Exporter)3 ProviderMessageRouter (com.weibo.api.motan.transport.ProviderMessageRouter)2 AbstractExporter (com.weibo.api.motan.rpc.AbstractExporter)1 URL (com.weibo.api.motan.rpc.URL)1 Test (org.junit.Test)1