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


Java URL.getMethodParameter方法代码示例

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


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

示例1: ConsistentHashSelector

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public ConsistentHashSelector(List<Invoker<T>> invokers, String methodName, int identityHashCode) {
    this.virtualInvokers = new TreeMap<Long, Invoker<T>>();
    this.identityHashCode = System.identityHashCode(invokers);
    URL url = invokers.get(0).getUrl();
    this.replicaNumber = url.getMethodParameter(methodName, "hash.nodes", 160);
    String[] index = Constants.COMMA_SPLIT_PATTERN.split(url.getMethodParameter(methodName, "hash.arguments", "0"));
    argumentIndex = new int[index.length];
    for (int i = 0; i < index.length; i ++) {
        argumentIndex[i] = Integer.parseInt(index[i]);
    }
    for (Invoker<T> invoker : invokers) {
        for (int i = 0; i < replicaNumber / 4; i++) {
            byte[] digest = md5(invoker.getUrl().toFullString() + i);
            for (int h = 0; h < 4; h++) {
                long m = hash(digest, h);
                virtualInvokers.put(m, invoker);
            }
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:ConsistentHashLoadBalance.java

示例2: ConsistentHashSelector

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
ConsistentHashSelector(List<Invoker<T>> invokers, String methodName, int identityHashCode) {
    this.virtualInvokers = new TreeMap<Long, Invoker<T>>();
    this.identityHashCode = identityHashCode;
    URL url = invokers.get(0).getUrl();
    this.replicaNumber = url.getMethodParameter(methodName, "hash.nodes", 160);
    String[] index = Constants.COMMA_SPLIT_PATTERN.split(url.getMethodParameter(methodName, "hash.arguments", "0"));
    argumentIndex = new int[index.length];
    for (int i = 0; i < index.length; i++) {
        argumentIndex[i] = Integer.parseInt(index[i]);
    }
    for (Invoker<T> invoker : invokers) {
        String address = invoker.getUrl().getAddress();
        for (int i = 0; i < replicaNumber / 4; i++) {
            byte[] digest = md5(address + i);
            for (int h = 0; h < 4; h++) {
                long m = hash(digest, h);
                virtualInvokers.put(m, invoker);
            }
        }
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:ConsistentHashLoadBalance.java

示例3: isAttachInvocationId

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private static boolean isAttachInvocationId(URL url , Invocation invocation) {
	String value = url.getMethodParameter(invocation.getMethodName(), Constants.AUTO_ATTACH_INVOCATIONID_KEY);
	if ( value == null ) {
		//异步操作默认添加invocationid
		return isAsync(url,invocation) ;
	} else if (Boolean.TRUE.toString().equalsIgnoreCase(value)) {
		//设置为添加,则一定添加
		return true;
	} else {
		//value为false时,不添加
		return false;
	}
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:14,代码来源:RpcUtils.java

示例4: invoke

import com.alibaba.dubbo.common.URL; //导入方法依赖的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:dachengxi,项目名称:EatDubbo,代码行数:30,代码来源:ExecuteLimitFilter.java


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