当前位置: 首页>>代码示例>>Java>>正文


Java Invoker.getUrl方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.rpc.Invoker.getUrl方法的典型用法代码示例。如果您正苦于以下问题:Java Invoker.getUrl方法的具体用法?Java Invoker.getUrl怎么用?Java Invoker.getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.rpc.Invoker的用法示例。


在下文中一共展示了Invoker.getUrl方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DubboRegistry

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public DubboRegistry(Invoker<RegistryService> registryInvoker, RegistryService registryService) {
    super(registryInvoker.getUrl());
    this.registryInvoker = registryInvoker;
    this.registryService = registryService;
    // 启动重连定时器
    int reconnectPeriod = registryInvoker.getUrl().getParameter(Constants.REGISTRY_RECONNECT_PERIOD_KEY, RECONNECT_PERIOD_DEFAULT);
    reconnectFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
        public void run() {
            // 检测并连接注册中心
            try {
                connect();
            } catch (Throwable t) { // 防御性容错
                logger.error("Unexpected error occur at reconnect, cause: " + t.getMessage(), t);
            }
        }
    }, reconnectPeriod, reconnectPeriod, TimeUnit.MILLISECONDS);
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:18,代码来源:DubboRegistry.java

示例2: export

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
    URL url = invoker.getUrl();
    
    // export service.
    String key = serviceKey(url);
    DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
    exporterMap.put(key, exporter);
    
    //export an stub service for dispaching event
    Boolean isStubSupportEvent = url.getParameter(Constants.STUB_EVENT_KEY,Constants.DEFAULT_STUB_EVENT);
    Boolean isCallbackservice = url.getParameter(Constants.IS_CALLBACK_SERVICE, false);
    if (isStubSupportEvent && !isCallbackservice){
        String stubServiceMethods = url.getParameter(Constants.STUB_EVENT_METHODS_KEY);
        if (stubServiceMethods == null || stubServiceMethods.length() == 0 ){
            if (logger.isWarnEnabled()){
                logger.warn(new IllegalStateException("consumer [" +url.getParameter(Constants.INTERFACE_KEY) +
                        "], has set stubproxy support event ,but no stub methods founded."));
            }
        } else {
            stubServiceMethodsMap.put(url.getServiceKey(), stubServiceMethods);
        }
    }

    openServer(url);
    
    return exporter;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:28,代码来源:DubboProtocol.java

示例3: AbstractExporter

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public AbstractExporter(Invoker<T> invoker) {
    if (invoker == null)
        throw new IllegalStateException("service invoker == null");
    if (invoker.getInterface() == null)
        throw new IllegalStateException("service type == null");
    if (invoker.getUrl() == null)
        throw new IllegalStateException("service url == null");
    this.invoker = invoker;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:AbstractExporter.java

示例4: export

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
    URL url = invoker.getUrl();
    
    // export service.
    String key = serviceKey(url);
    DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
    exporterMap.put(key, exporter);
    
    //export an stub service for dispaching event
    Boolean isStubSupportEvent = url.getParameter(Constants.STUB_EVENT_KEY,Constants.DEFAULT_STUB_EVENT);
    Boolean isCallbackservice = url.getParameter(Constants.IS_CALLBACK_SERVICE, false);
    if (isStubSupportEvent && !isCallbackservice){
        String stubServiceMethods = url.getParameter(Constants.STUB_EVENT_METHODS_KEY);
        if (stubServiceMethods == null || stubServiceMethods.length() == 0 ){
            if (logger.isWarnEnabled()){
                logger.warn(new IllegalStateException("consumer [" +url.getParameter(Constants.INTERFACE_KEY) +
                        "], has set stubproxy support event ,but no stub methods founded."));
            }
        } else {
            stubServiceMethodsMap.put(url.getServiceKey(), stubServiceMethods);
        }
    }

    openServer(url);

    // modified by lishen
    optimizeSerialization(url);

    return exporter;
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:31,代码来源:DubboProtocol.java

示例5: doInvoke

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
    checkInvokers(invokers, invocation);
    Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
    try {
        return invoker.invoke(invocation);
    } catch (Throwable e) {
        if (e instanceof RpcException && ((RpcException)e).isBiz()) { // biz exception.
            throw (RpcException) e;
        }
        throw new RpcException(e instanceof RpcException ? ((RpcException)e).getCode() : 0, "Failfast invoke providers " + invoker.getUrl() + " " + loadbalance.getClass().getSimpleName() + " select from all providers " + invokers + " for service " + getInterface().getName() + " method " + invocation.getMethodName() + " on consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion() + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:FailfastClusterInvoker.java

示例6: invoke

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    long start = System.currentTimeMillis();
    Result result = invoker.invoke(invocation);
    long elapsed = System.currentTimeMillis() - start;
    if (invoker.getUrl() != null
            && elapsed > invoker.getUrl().getMethodParameter(invocation.getMethodName(),
                    "timeout", Integer.MAX_VALUE)) {
        if (logger.isWarnEnabled()) {
            logger.warn("invoke time out. method: " + invocation.getMethodName()
                    + "arguments: " + Arrays.toString(invocation.getArguments()) + " , url is "
                    + invoker.getUrl() + ", invoke elapsed " + elapsed + " ms.");
        }
    }
    return result;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:TimeoutFilter.java

示例7: getProviderUrl

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
/**
 * 通过invoker的url 获取 providerUrl的地址
 * @param origininvoker
 * @return
 */
private URL getProviderUrl(final Invoker<?> origininvoker){
    String export = origininvoker.getUrl().getParameterAndDecoded(Constants.EXPORT_KEY);
    if (export == null || export.length() == 0) {
        throw new IllegalArgumentException("The registry export url is null! registry: " + origininvoker.getUrl());
    }
    
    URL providerUrl = URL.valueOf(export);
    return providerUrl;
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:15,代码来源:RegistryProtocol.java

示例8: getRegistry

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
/**
 * 根据invoker的地址获取registry实例
 * @param originInvoker
 * @return
 */
private Registry getRegistry(final Invoker<?> originInvoker){
    URL registryUrl = originInvoker.getUrl();
    if (Constants.REGISTRY_PROTOCOL.equals(registryUrl.getProtocol())) {
        String protocol = registryUrl.getParameter(Constants.REGISTRY_KEY, Constants.DEFAULT_DIRECTORY);
        registryUrl = registryUrl.setProtocol(protocol).removeParameter(Constants.REGISTRY_KEY);
    }
    return registryFactory.getRegistry(registryUrl);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:14,代码来源:RegistryProtocol.java

示例9: invoke

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    URL url = invoker.getUrl();
    String methodName = invocation.getMethodName();
    int max = url.getMethodParameter(methodName, Constants.EXECUTES_KEY, 0);
    if (max > 0) {
        RpcStatus count = RpcStatus.getStatus(url, invocation.getMethodName());
        if (count.getActive() >= max) {
            throw new RpcException("Failed to invoke method " + invocation.getMethodName() + " in provider " + url + ", cause: The service using threads greater than <dubbo:service executes=\"" + max + "\" /> limited.");
        }
    }
    long begin = System.currentTimeMillis();
    boolean isException = false;
    RpcStatus.beginCount(url, methodName);
    try {
        Result result = invoker.invoke(invocation);
        return result;
    } catch (Throwable t) {
        isException = true;
        if(t instanceof RuntimeException) {
            throw (RuntimeException) t;
        }
        else {
            throw new RpcException("unexpected exception when ExecuteLimitFilter", t);
        }
    }
    finally {
        RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, isException);
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:30,代码来源:ExecuteLimitFilter.java

示例10: getProviderUrl

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
/**
 * 通过invoker的url 获取 providerUrl的地址
 *
 * @param origininvoker
 * @return
 */
private URL getProviderUrl(final Invoker<?> origininvoker) {
    String export = origininvoker.getUrl().getParameterAndDecoded(Constants.EXPORT_KEY);
    if (export == null || export.length() == 0) {
        throw new IllegalArgumentException("The registry export url is null! registry: " + origininvoker.getUrl());
    }

    URL providerUrl = URL.valueOf(export);
    return providerUrl;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:16,代码来源:RegistryProtocol.java

示例11: export

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException {
    throw new UnsupportedOperationException("Unsupported export memcached service. url: " + invoker.getUrl());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:4,代码来源:MemcachedProtocol.java

示例12: export

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException {
    throw new UnsupportedOperationException("Unsupported export redis service. url: " + invoker.getUrl());
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:4,代码来源:RedisProtocol.java

示例13: invoke

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    URL url = invoker.getUrl();
    String methodName = invocation.getMethodName();
    int max = invoker.getUrl().getMethodParameter(methodName, Constants.ACTIVES_KEY, 0);
    RpcStatus count = RpcStatus.getStatus(invoker.getUrl(), invocation.getMethodName());
    if (max > 0) {
        long timeout = invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.TIMEOUT_KEY, 0);
        long start = System.currentTimeMillis();
        long remain = timeout;
        int active = count.getActive();
        if (active >= max) {
            synchronized (count) {
                while ((active = count.getActive()) >= max) {
                    try {
                        count.wait(remain);
                    } catch (InterruptedException e) {
                    }
                    long elapsed = System.currentTimeMillis() - start;
                    remain = timeout - elapsed;
                    if (remain <= 0) {
                        throw new RpcException("Waiting concurrent invoke timeout in client-side for service:  "
                                               + invoker.getInterface().getName() + ", method: "
                                               + invocation.getMethodName() + ", elapsed: " + elapsed
                                               + ", timeout: " + timeout + ". concurrent invokes: " + active
                                               + ". max concurrent invoke limit: " + max);
                    }
                }
            }
        }
    }
    try {
        long begin = System.currentTimeMillis();
        RpcStatus.beginCount(url, methodName);
        try {
            Result result = invoker.invoke(invocation);
            RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, true);
            return result;
        } catch (RuntimeException t) {
            RpcStatus.endCount(url, methodName, System.currentTimeMillis() - begin, false);
            throw t;
        }
    } finally {
        if(max>0){
            synchronized (count) {
                count.notify();
            } 
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:50,代码来源:ActiveLimitFilter.java

示例14: fireThrowCallback

import com.alibaba.dubbo.rpc.Invoker; //导入方法依赖的package包/类
private void fireThrowCallback(final Invoker<?> invoker, final Invocation invocation, final Throwable exception) {
    final Method onthrowMethod = (Method)StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_METHOD_KEY));
    final Object onthrowInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_THROW_INSTANCE_KEY));

    //没有设置onthrow callback.
    if (onthrowMethod == null  &&  onthrowInst == null ){
        return ;
    }
    if (onthrowMethod == null  ||  onthrowInst == null ){
        throw new IllegalStateException("service:" + invoker.getUrl().getServiceKey() +" has a onthrow callback config , but no such "+(onthrowMethod == null ? "method" : "instance")+" found. url:"+invoker.getUrl());
    }
    if (onthrowMethod != null && ! onthrowMethod.isAccessible()) {
        onthrowMethod.setAccessible(true);
    }
    Class<?>[] rParaTypes = onthrowMethod.getParameterTypes() ;
    if (rParaTypes[0].isAssignableFrom(exception.getClass())){
        try {
            Object[] args = invocation.getArguments();
            Object[] params;
            
            if (rParaTypes.length >1 ) {
                if (rParaTypes.length == 2 && rParaTypes[1].isAssignableFrom(Object[].class)){
                    params = new Object[2];
                    params[0] = exception;
                    params[1] = args ;
                }else {
                    params = new Object[args.length + 1];
                    params[0] = exception;
                    System.arraycopy(args, 0, params, 1, args.length);
                }
            } else {
                params = new Object[] { exception };
            }
            onthrowMethod.invoke(onthrowInst,params);
        } catch (Throwable e) {
            logger.error(invocation.getMethodName() +".call back method invoke error . callback method :" + onthrowMethod + ", url:"+ invoker.getUrl(), e);
        } 
    } else {
        logger.error(invocation.getMethodName() +".call back method invoke error . callback method :" + onthrowMethod + ", url:"+ invoker.getUrl(), exception);
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:42,代码来源:FutureFilter.java


注:本文中的com.alibaba.dubbo.rpc.Invoker.getUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。