PersionalRateLimitConfig.java
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.yoho.search.aop.downgrade;
public class PersionalRateLimitConfig {
private int limit;
private int second;
public PersionalRateLimitConfig(int limit, int second) {
this.limit = limit;
this.second = second;
}
public PersionalRateLimitConfig(PersionalRateLimit rateLimit) {
super();
this.limit = rateLimit.limit();
this.second = rateLimit.second();
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
public PersionalRateLimitConfig(String zkConfigValue) {
String[] values = zkConfigValue.split(":");
this.limit = Integer.valueOf(values[0]);
this.second = Integer.valueOf(values[1]);
}
public String toZkValue() {
return this.limit + ":" + this.second;
}
public String toLogInfo() {
StringBuilder sb = new StringBuilder();
sb.append(this.limit).append("c/").append(this.second).append("s");
return sb.toString();
}
}