Flume源代码解读四

来源:互联网 发布:淘宝联盟鹊桥 编辑:程序博客网 时间:2024/05/29 02:57
 [ xcly原创于iteye,见http://xcly.iteye.com ]

 

    今天介绍Flume里面用到的BackoffAlgo算法,接口由BackoffPolicy定义,让我们看看下面的几个关键的方法

reset:Reset backoff state. Call this after successful attempts.每一次成功调用之后reset状态。

backoff:Modify state as if a backoff had just happened. Call this after failed attempts。失败发生时调用的回退犯法。

isFailed:Has so much time passed that we assume the failure is irrecoverable? 如果返回true,不再尝试。

sleepIncrement:Wait time in millis until RetryOk should be true

waitUntilRetryOk:Wait until it's ok to retry.

 

    在InsistentAppendDecorator, InsistentOpenDecorator中调用了BackoffPolicy的子类CumulativeCappedExponentialBackoff,CumulativeCappedExponentialBackoff中的isfailed总是返回true,永远不会失败;总是不断尝试。

原创粉丝点击