Dubbo学习源码总结系列四--集群容错机制

时间:2022-11-05 16:17:59

Dubbo提供了哪些集群容错机制?如何实现的?

        提供了六种集群容错机制,包括Failover(失败自动切换,尝试其他服务器)、Failfast(失败立即抛出异常)、Failsafe(失败忽略异常)、Failback(失败自动恢复,记录日志并定时重试)、Forking(并行调用多个服务,一个成功立即返回)、Broadcast(广播调用所有提供者,任意一个报错则报错);

下面我们看看基础类的实现:

        1、ClusterInvoker默认实现类:AbstractClusterInvoker,给ClusterInvoker子类提供了实现框架。

Dubbo学习源码总结系列四--集群容错机制

主要方法有以下几个:

invoke()方法,给子类的doInvoke()方法准备输入参数invoker列表和loadbalance实例,实现逻辑为:

(1)首先判断当前invoker是否被销毁(销毁则直接抛出异常);

(2)从Directory目录(通常是注册中心返回的服务列表)中得到invoker列表,调用directory.list()方法;

(3)根据invoker列表中的第一个invoker的Url负载均衡配置信息,动态加载并实例化一个loadbalance子类(如果没有配置则使用缺省loadbalance);

(4)设置invokerId;

(5)调用子类的doInvoke()方法执行调用过程。

 1     public Result invoke(final Invocation invocation) throws RpcException {
2
3 checkWhetherDestroyed();
4
5 LoadBalance loadbalance;
6
7 List<Invoker<T>> invokers = list(invocation);
8 if (invokers != null && invokers.size() > 0) {
9 loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(invokers.get(0).getUrl()
10 .getMethodParameter(invocation.getMethodName(), Constants.LOADBALANCE_KEY, Constants.DEFAULT_LOADBALANCE));
11 } else {
12 loadbalance = ExtensionLoader.getExtensionLoader(LoadBalance.class).getExtension(Constants.DEFAULT_LOADBALANCE);
13 }
14 RpcUtils.attachInvocationIdIfAsync(getUrl(), invocation);
15 return doInvoke(invocation, invokers, loadbalance);
16 }

select()方法在子类的doInvoke()方法中调用,通过负载均衡策略选择一个invoker,实现逻辑为:

a)首先通过负载均衡策略选择一个invoker,如果这个invoker在之前维护的selected列表中(将使用过的invoker记录在selected本地缓存中),或者这个invoker不可用,则跳转到步骤b重新选择;否则直接返回这个invoker;

b)重新选择reselect()方法,先从给定的invokers列表中选出不在selected(使用过)列表中的invoker列表reselectInvokers,在reselectInvokers中通过负载均衡策略选出一个invoker返回;如果之前给定的invokes列表都在selected中(都使用过),则筛选出selected列表中所有可用的invoker,再使用负载均衡策略选择出一个invoker返回;这种策略将重复选择的几率降到最低。

 1     /**
2 * Select a invoker using loadbalance policy.</br>
3 * a)Firstly, select an invoker using loadbalance. If this invoker is in previously selected list, or, if this invoker is unavailable, then continue step b (reselect), otherwise return the first selected invoker</br>
4 * b)Reslection, the validation rule for reselection: selected > available. This rule guarantees that the selected invoker has the minimum chance to be one in the previously selected list, and also guarantees this invoker is available.
5 *
6 * @param loadbalance load balance policy
7 * @param invocation
8 * @param invokers invoker candidates
9 * @param selected exclude selected invokers or not
10 * @return
11 * @throws RpcExceptione
12 */
13 protected Invoker<T> select(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
14 if (invokers == null || invokers.size() == 0)
15 return null;
16 String methodName = invocation == null ? "" : invocation.getMethodName();
17
18 boolean sticky = invokers.get(0).getUrl().getMethodParameter(methodName, Constants.CLUSTER_STICKY_KEY, Constants.DEFAULT_CLUSTER_STICKY);
19 {
20 //ignore overloaded method
21 if (stickyInvoker != null && !invokers.contains(stickyInvoker)) {
22 stickyInvoker = null;
23 }
24 //ignore cucurrent problem
25 if (sticky && stickyInvoker != null && (selected == null || !selected.contains(stickyInvoker))) {
26 if (availablecheck && stickyInvoker.isAvailable()) {
27 return stickyInvoker;
28 }
29 }
30 }
31 Invoker<T> invoker = doselect(loadbalance, invocation, invokers, selected);
32
33 if (sticky) {
34 stickyInvoker = invoker;
35 }
36 return invoker;
37 }

        

 1     private Invoker<T> doselect(LoadBalance loadbalance, Invocation invocation, List<Invoker<T>> invokers, List<Invoker<T>> selected) throws RpcException {
2 if (invokers == null || invokers.size() == 0)
3 return null;
4 if (invokers.size() == 1)
5 return invokers.get(0);
6 // If we only have two invokers, use round-robin instead.
7 if (invokers.size() == 2 && selected != null && selected.size() > 0) {
8 return selected.get(0) == invokers.get(0) ? invokers.get(1) : invokers.get(0);
9 }
10 Invoker<T> invoker = loadbalance.select(invokers, getUrl(), invocation);
11
12 //If the `invoker` is in the `selected` or invoker is unavailable && availablecheck is true, reselect.
13 if ((selected != null && selected.contains(invoker))
14 || (!invoker.isAvailable() && getUrl() != null && availablecheck)) {
15 try {
16 Invoker<T> rinvoker = reselect(loadbalance, invocation, invokers, selected, availablecheck);
17 if (rinvoker != null) {
18 invoker = rinvoker;
19 } else {
20 //Check the index of current selected invoker, if it's not the last one, choose the one at index+1.
21 int index = invokers.indexOf(invoker);
22 try {
23 //Avoid collision
24 invoker = index < invokers.size() - 1 ? invokers.get(index + 1) : invoker;
25 } catch (Exception e) {
26 logger.warn(e.getMessage() + " may because invokers list dynamic change, ignore.", e);
27 }
28 }
29 } catch (Throwable t) {
30 logger.error("clustor relselect fail reason is :" + t.getMessage() + " if can not slove ,you can set cluster.availablecheck=false in url", t);
31 }
32 }
33 return invoker;
34 }
 1     /**
2 * Reselect, use invokers not in `selected` first, if all invokers are in `selected`, just pick an available one using loadbalance policy.
3 *
4 * @param loadbalance
5 * @param invocation
6 * @param invokers
7 * @param selected
8 * @return
9 * @throws RpcException
10 */
11 private Invoker<T> reselect(LoadBalance loadbalance, Invocation invocation,
12 List<Invoker<T>> invokers, List<Invoker<T>> selected, boolean availablecheck)
13 throws RpcException {
14
15 //Allocating one in advance, this list is certain to be used.
16 List<Invoker<T>> reselectInvokers = new ArrayList<Invoker<T>>(invokers.size() > 1 ? (invokers.size() - 1) : invokers.size());
17
18 //First, try picking a invoker not in `selected`.
19 if (availablecheck) { // invoker.isAvailable() should be checked
20 for (Invoker<T> invoker : invokers) {
21 if (invoker.isAvailable()) {
22 if (selected == null || !selected.contains(invoker)) {
23 reselectInvokers.add(invoker);
24 }
25 }
26 }
27 if (reselectInvokers.size() > 0) {
28 return loadbalance.select(reselectInvokers, getUrl(), invocation);
29 }
30 } else { // do not check invoker.isAvailable()
31 for (Invoker<T> invoker : invokers) {
32 if (selected == null || !selected.contains(invoker)) {
33 reselectInvokers.add(invoker);
34 }
35 }
36 if (reselectInvokers.size() > 0) {
37 return loadbalance.select(reselectInvokers, getUrl(), invocation);
38 }
39 }
40 // Just pick an available invoker using loadbalance policy
41 {
42 if (selected != null) {
43 for (Invoker<T> invoker : selected) {
44 if ((invoker.isAvailable()) // available first
45 && !reselectInvokers.contains(invoker)) {
46 reselectInvokers.add(invoker);
47 }
48 }
49 }
50 if (reselectInvokers.size() > 0) {
51 return loadbalance.select(reselectInvokers, getUrl(), invocation);
52 }
53 }
54 return null;
55 }

2、Failover Cluster:失败自动切换,当出现失败,重试其它服务器 。

通常用于读操作,但重试会带来更长延迟。可通过 retries="2" 来设置重试次数(不含第一次)。

集群配置如下(该配置为缺省配置):

<dubbo:service cluster="failover" />或<dubbo:reference cluster="failover" />

重试次数配置有三种方式:

<dubbo:service retries="2" />

<dubbo:reference retries="2" />

<dubbo:reference>

<dubbo:method name="findFoo" retries="2" />

</dubbo:reference>

源码详解如下:

FailoverCluster类,实际使用了FailoverClusterInvoker类;

 1 /**
2 * {@link FailoverClusterInvoker}
3 *
4 */
5 public class FailoverCluster implements Cluster {
6
7 public final static String NAME = "failover";
8
9 public <T> Invoker<T> join(Directory<T> directory) throws RpcException {
10 return new FailoverClusterInvoker<T>(directory);
11 }
12
13 }

FailoverClusterInvoker类,继承了AbstractClusterInvoker类,通过doInvoke()方法实现了Failover机制:失败自动切换,当出现失败,重试其它服务器。

doInvoke()被父类AbstractClusterInvoker的invoke()方法调用,实现逻辑为:

(1)根据参数retries得到重试次数(默认0),设置循环最大次数len=retries+1;

(2)以最大次数len开始循环:

(3)首次循环,执行父类的select()方法,使用负载均衡机制选出一个invoker,执行invoker.invoke(invocation)返回结果;如果执行成功则返回退出;如果抛出异常,记录异常,继续循环;

(4)检查invokers是否有效,重新执行步骤3,直到成功返回,或者循环到达最大次数len;

 1     public Result doInvoke(Invocation invocation, final List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
2 List<Invoker<T>> copyinvokers = invokers;
3 checkInvokers(copyinvokers, invocation);
//根据参数retries得到重试次数(默认0),设置循环最大次数len=retries+1
4 int len = getUrl().getMethodParameter(invocation.getMethodName(), Constants.RETRIES_KEY, Constants.DEFAULT_RETRIES) + 1;
5 if (len <= 0) {
6 len = 1;
7 }
8 // retry loop.
9 RpcException le = null; // last exception.
10 List<Invoker<T>> invoked = new ArrayList<Invoker<T>>(copyinvokers.size()); // invoked invokers.
11 Set<String> providers = new HashSet<String>(len);
12 for (int i = 0; i < len; i++) {
13 //Reselect before retry to avoid a change of candidate `invokers`.
14 //NOTE: if `invokers` changed, then `invoked` also lose accuracy.
//检查invokers是否有效
15 if (i > 0) {
16 checkWhetherDestroyed();
17 copyinvokers = list(invocation);
18 // check again
19 checkInvokers(copyinvokers, invocation);
20 }
//执行父类的select()方法,使用负载均衡机制选出一个invoker,执行invoker.invoke(invocation)返回结果;如果执行成功则返回退出;如果抛出异常,记录异常,继续循环
21 Invoker<T> invoker = select(loadbalance, invocation, copyinvokers, invoked);
22 invoked.add(invoker);
23 RpcContext.getContext().setInvokers((List) invoked);
24 try {
25 Result result = invoker.invoke(invocation);
26 if (le != null && logger.isWarnEnabled()) {
27 logger.warn("Although retry the method " + invocation.getMethodName()
28 + " in the service " + getInterface().getName()
29 + " was successful by the provider " + invoker.getUrl().getAddress()
30 + ", but there have been failed providers " + providers
31 + " (" + providers.size() + "/" + copyinvokers.size()
32 + ") from the registry " + directory.getUrl().getAddress()
33 + " on the consumer " + NetUtils.getLocalHost()
34 + " using the dubbo version " + Version.getVersion() + ". Last error is: "
35 + le.getMessage(), le);
36 }
37 return result;
38 } catch (RpcException e) {
39 if (e.isBiz()) { // biz exception.
40 throw e;
41 }
42 le = e;
43 } catch (Throwable e) {
44 le = new RpcException(e.getMessage(), e);
45 } finally {
46 providers.add(invoker.getUrl().getAddress());
47 }
48 }
49 throw new RpcException(le != null ? le.getCode() : 0, "Failed to invoke the method "
50 + invocation.getMethodName() + " in the service " + getInterface().getName()
51 + ". Tried " + len + " times of the providers " + providers
52 + " (" + providers.size() + "/" + copyinvokers.size()
53 + ") from the registry " + directory.getUrl().getAddress()
54 + " on the consumer " + NetUtils.getLocalHost() + " using the dubbo version "
55 + Version.getVersion() + ". Last error is: "
56 + (le != null ? le.getMessage() : ""), le != null && le.getCause() != null ? le.getCause() : le);
57 }

3、Failfast Cluster,快速失败,只发起一次调用,失败立即报错。通常用于非幂等性的写操作,比如新增记录。

FailfastClusterInvoker类,继承了AbstractClusterInvoker类,通过doInvoke()方法实现了Failfast机制:失败立即抛出异常。

doInvoke()被父类AbstractClusterInvoker的invoke()方法调用:

 1     public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
2 checkInvokers(invokers, invocation);
3 Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
4 try {
5 return invoker.invoke(invocation);
6 } catch (Throwable e) {
7 if (e instanceof RpcException && ((RpcException) e).isBiz()) { // biz exception.
8 throw (RpcException) e;
9 }
10 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);
11 }
12 }

4、Failsafe Cluster,失败安全,出现异常时,直接忽略。通常用于写入审计日志等操作。

FailfastClusterInvoker类,继承了AbstractClusterInvoker类,通过doInvoke()方法实现了Failsafe机制:失败出现异常直接忽略。

doInvoke()被父类AbstractClusterInvoker的invoke()方法调用:

 1     public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
2 try {
3 checkInvokers(invokers, invocation);
4 Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
5 return invoker.invoke(invocation);
6 } catch (Throwable e) {
7 logger.error("Failsafe ignore exception: " + e.getMessage(), e);
8 return new RpcResult(); // ignore
9 }
10 }

5、Failback Cluster,失败自动恢复,后台记录失败请求,定时重发。通常用于消息通知操作。

FailbackClusterInvoker类,继承了AbstractClusterInvoker类,通过doInvoke()方法实现了Failback机制。

doInvoke()被父类AbstractClusterInvoker的invoke()方法调用,记录每次失败的调用到failed这个map里,用一个定时任务执行器重试失败的任务;

 1     private void addFailed(Invocation invocation, AbstractClusterInvoker<?> router) {
2 if (retryFuture == null) {
3 synchronized (this) {
4 if (retryFuture == null) {
5 retryFuture = scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
6
7 public void run() {
8 // collect retry statistics
9 try {
10 retryFailed();
11 } catch (Throwable t) { // Defensive fault tolerance
12 logger.error("Unexpected error occur at collect statistic", t);
13 }
14 }
15 }, RETRY_FAILED_PERIOD, RETRY_FAILED_PERIOD, TimeUnit.MILLISECONDS);
16 }
17 }
18 }
19 failed.put(invocation, router);
20 }
21
22 void retryFailed() {
23 if (failed.size() == 0) {
24 return;
25 }
26 for (Map.Entry<Invocation, AbstractClusterInvoker<?>> entry : new HashMap<Invocation, AbstractClusterInvoker<?>>(
27 failed).entrySet()) {
28 Invocation invocation = entry.getKey();
29 Invoker<?> invoker = entry.getValue();
30 try {
31 invoker.invoke(invocation);
32 failed.remove(invocation);
33 } catch (Throwable e) {
34 logger.error("Failed retry to invoke method " + invocation.getMethodName() + ", waiting again.", e);
35 }
36 }
37 }
38
39 protected Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
40 try {
41 checkInvokers(invokers, invocation);
42 Invoker<T> invoker = select(loadbalance, invocation, invokers, null);
43 return invoker.invoke(invocation);
44 } catch (Throwable e) {
45 logger.error("Failback to invoke method " + invocation.getMethodName() + ", wait for retry in background. Ignored exception: "
46 + e.getMessage() + ", ", e);
47 addFailed(invocation, this);
48 return new RpcResult(); // ignore
49 }
50 }

6、Forking Cluster,并行调用多个服务器,只要一个成功即返回。通常用于实时性要求较高的读操作,但需要浪费更多服务资源。可通过 forks="2" 来设置最大并行数。

ForkingClusterInvoker类,继承了AbstractClusterInvoker类,通过doInvoke()方法实现了Forking机制。

doInvoke()被父类AbstractClusterInvoker的invoke()方法调用,调用逻辑为:

(1)通过select()获得足够多的invoker加入selected;

(2)循环selected,每次从线程池获得一个线程对一个invoker发起调用请求,每次将返回的结果放入一个阻塞队列中,如果有异常,将最后一个invoker发生的异常放入阻塞队列;

(3)从阻塞队列弹出第一个结果,如果不是异常,就直接返回,否则抛出异常;

 1     public Result doInvoke(final Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
2 checkInvokers(invokers, invocation);
3 final List<Invoker<T>> selected;
4 final int forks = getUrl().getParameter(Constants.FORKS_KEY, Constants.DEFAULT_FORKS);
5 final int timeout = getUrl().getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
6 if (forks <= 0 || forks >= invokers.size()) {
7 selected = invokers;
8 } else {
9 selected = new ArrayList<Invoker<T>>();
10 for (int i = 0; i < forks; i++) {
11 // TODO. Add some comment here, refer chinese version for more details.
12 Invoker<T> invoker = select(loadbalance, invocation, invokers, selected);
13 if (!selected.contains(invoker)) {//Avoid add the same invoker several times.
14 selected.add(invoker);
15 }
16 }
17 }
18 RpcContext.getContext().setInvokers((List) selected);
19 final AtomicInteger count = new AtomicInteger();
20 final BlockingQueue<Object> ref = new LinkedBlockingQueue<Object>();
21 for (final Invoker<T> invoker : selected) {
22 executor.execute(new Runnable() {
23 public void run() {
24 try {
25 Result result = invoker.invoke(invocation);
26 ref.offer(result);
27 } catch (Throwable e) {
28 int value = count.incrementAndGet();
29 if (value >= selected.size()) {
30 ref.offer(e);
31 }
32 }
33 }
34 });
35 }
36 try {
37 Object ret = ref.poll(timeout, TimeUnit.MILLISECONDS);
38 if (ret instanceof Throwable) {
39 Throwable e = (Throwable) ret;
40 throw new RpcException(e instanceof RpcException ? ((RpcException) e).getCode() : 0, "Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e.getCause() != null ? e.getCause() : e);
41 }
42 return (Result) ret;
43 } catch (InterruptedException e) {
44 throw new RpcException("Failed to forking invoke provider " + selected + ", but no luck to perform the invocation. Last error is: " + e.getMessage(), e);
45 }
46 }

Dubbo学习源码总结系列四--集群容错机制的更多相关文章

  1. Dubbo学习源码总结系列五--集群负载均衡

            Dubbo提供了哪些负载均衡机制?如何实现的?          LoadBalance接口:可以看出,通过SPI机制默认为RandomLoadBalance,生成的适配器类执行sel ...

  2. Alamofire源码解读系列&lpar;四&rpar;之参数编码&lpar;ParameterEncoding&rpar;

    本篇讲解参数编码的内容 前言 我们在开发中发的每一个请求都是通过URLRequest来进行封装的,可以通过一个URL生成URLRequest.那么如果我有一个参数字典,这个参数字典又是如何从客户端传递 ...

  3. MyCat源码分析系列之——BufferPool与缓存机制

    更多MyCat源码分析,请戳MyCat源码分析系列 BufferPool MyCat的缓冲区采用的是java.nio.ByteBuffer,由BufferPool类统一管理,相关的设置在SystemC ...

  4. spring源码分析系列 &lpar;8&rpar; FactoryBean工厂类机制

    更多文章点击--spring源码分析系列 1.FactoryBean设计目的以及使用 2.FactoryBean工厂类机制运行机制分析 1.FactoryBean设计目的以及使用 FactoryBea ...

  5. Dubbo负载均衡与集群容错机制

    1  Dubbo简介 Dubbo是一款高性能.轻量级的开源Java RPC框架,它提供了三大核心能力:面向接口的远程方法调用,智能容错和负载均衡,以及服务自动注册和发现. 作为一个轻量级RPC框架,D ...

  6. Dubbo学习-源码学习

    Dubbo概述 dubbo框架提供多协议远程调用,服务提供方可以是分布式部署.dubbo框架可以很简单的帮我们实现微服务. 此处援引官网上图片 dubbo分为客户端和服务提供方 服务方将服务注册到注册 ...

  7. Redis源码解析:28集群&lpar;四&rpar;手动故障转移、从节点迁移

    一:手动故障转移 Redis集群支持手动故障转移.也就是向从节点发送"CLUSTER  FAILOVER"命令,使其在主节点未下线的情况下,发起故障转移流程,升级为新的主节点,而原 ...

  8. Centos7 源码安装PostgreSQL Citus集群 (转载)

    citus的分布式集群目前在苏宁大规模应用,苏宁陈华军也做了很多技术分享和博客介绍.目前所有的教程都是rpm和pg一起安装,个人不喜欢,毕竟citus定位是个插件,我想在我已安装的pg上源码装一个ci ...

  9. Redis源码解析:26集群&lpar;二&rpar;键的分配与迁移

    Redis集群通过分片的方式来保存数据库中的键值对:一个集群中,每个键都通过哈希函数映射到一个槽位,整个集群共分16384个槽位,集群中每个主节点负责其中的一部分槽位. 当数据库中的16384个槽位都 ...

随机推荐

  1. centos主机建立ssh互信

    ssh-keygen 生成密钥 1.ssh-keygen -t rsa 可以加密和签名 rsa 只能加密不能签名 2.ssh-copy-id -i /root/.ssh/id_rsa.pub USER ...

  2. JavaScript中的call&lpar;&rpar;、apply&lpar;&rpar;与bind&lpar;&rpar;&colon;

    关于call()与apply(): 在JavaScript中,每个函数都有call与apply(),这两个函数都是用来改变函数体内this的指向,并调用相关的参数. 看一个例子: 定义一个animal ...

  3. &lpar;数组&rpar; leetcode 66&period; Plus One

    Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The ...

  4. 图表管理账单的NABCD

    首先,我们团队的项目目标是记账本.就我个人理解,记账本中心功能有两项,第一,记录:第二,显示.而本篇博客主要描述用各种不同的图表来显示的NABCD. 首先是N(need),用户的需求就是我们的动力!利 ...

  5. 【原创】Linux系统不能上互联网情况下软件更新安装方法

    实际工作中,遇到了Linux 服务器在一台被隔离互联网的PC服务器上运行,使用Virtual Box,在解决此Linux更新的问题上,自己尝试了如下几种策略: 1.将DVD安装盘作为Linux更新源, ...

  6. 隐藏Nginx或Apache以及PHP的版本号的方法

    当黑客入侵一台服务器时,首先会”踩点”, 这里的”踩点”,指的是了解服务器中运行的一些服务的详细情况,比如说:版本号,当黑客知道相应服务的版本号后,就可以寻找该服务相应版本的一些漏洞来入侵,攻击,所以 ...

  7. 【转】JS中的call&lpar;&rpar;和apply&lpar;&rpar;方法

    原文:http://uule.iteye.com/blog/1158829 1.方法定义 call方法: 语法:call([thisObj[,arg1[, arg2[,   [,.argN]]]]]) ...

  8. Linux下JDK到底应该安装在哪儿?

    1 Linux 目录结构 即使这是个菜鸟级的问题,也经常难住老鸟.我就见过很资深的程序员把JDK不合适地安装到/home目录下.虽然不一定有最正确的安装位置,但一定有不适当的安装位置.为了确定我们到底 ...

  9. can&sol;socket can

    1. 概念 参考:Linux-CAN编程详解 can引脚: cn2: 15:CAN1_H 19 CAN1_L 根据每组报文开头的 11 位标识符(扩展帧为29位标识符.CAN 2.0A 规范)解释数据 ...

  10. linux的chmod&comma;chown命令详解

    指令名称 : chmod 使用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... 说明 : Linux/Unix 的档案 ...