PersionalRateLimitConfig.java 1.06 KB
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();
	}
}