AbstractDOMRpcRoutingTableEntry.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:hashsdn-controller 作者:
/**
 *
 * @param implementation
 * @param newRpcs List of new RPCs, must be mutable
 * @return
 */
final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation,
        final List<YangInstanceIdentifier> newRpcs) {
    final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
    for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : impls.entrySet()) {
        if (newRpcs.remove(ve.getKey())) {
            final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue().size() + 1);
            i.addAll(ve.getValue());
            i.add(implementation);

            // New implementation is at the end, this will move it to be the last among implementations
            // with equal cost -- relying on sort() being stable.
            i.sort(Comparator.comparingLong(DOMRpcImplementation::invocationCost));
            vb.put(ve.getKey(), i);
        } else {
            vb.put(ve);
        }
    }
    for(final YangInstanceIdentifier ii : newRpcs) {
        final List<DOMRpcImplementation> impl = new ArrayList<>(1);
        impl.add(implementation);
        vb.put(ii, impl);
    }

    return newInstance(vb.build());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号