Code example for MapMaker

0
 */ 
public class DefaultAlarmController implements AlarmController { 
 
    // seconds 
    private Long                    DEFAULT_THRESHOLD = 1800L;
    private Map<PoolKey, PoolValue> pool              = new MapMaker().expireAfterWrite(1, TimeUnit.HOURS).makeMap();
    private AlarmRecovery           restartAlarmRecovery;
 
    @Override 
    public AlarmMessage control(AlarmRule rule, String message, AlarmMessage data) {
        // rule为空不控制 
        if (rule == null) {
            return data;
        } 
 
        // second 
        Long threshold = rule.getIntervalTime() == null ? DEFAULT_THRESHOLD : rule.getIntervalTime();
 
        PoolKey key = new PoolKey(rule, message, data);
        PoolValue value = pool.get(key);