public void in(MetaInAlarm meta, Metrics metrics) {
        if (!includeMetrics.contains(meta.getMetricsName())) {
            //Don't match rule, exit.
            if (log.isTraceEnabled()) {
                log.trace("Metric name not in the expression, {}-{}", expression, meta.getMetricsName());
            }
            return;
        }

        final String metaName = meta.getName();
        if (!validate(metaName, includeNames, excludeNames, includeNamesRegex, excludeNamesRegex)) {
            return;
        }

        AlarmEntity entity = new AlarmEntity(
            meta.getScope(), meta.getScopeId(), meta.getName(), meta.getId0(), meta.getId1());

        Window window = windows.computeIfAbsent(entity, ignored -> new Window(this.period, this.additionalPeriod));
        window.add(meta.getMetricsName(), metrics);
    }
@Test
    public void testInitAndStart() throws IllegalExpressionException {
        AlarmRule alarmRule = new AlarmRule();
        alarmRule.setAlarmRuleName("mix_rule");
        alarmRule.setExpression("sum((increase(endpoint_cpm,5) + increase(endpoint_percent,2)) > 0) >= 1");
        alarmRule.getIncludeMetrics().add("endpoint_percent");
        alarmRule.getIncludeMetrics().add("endpoint_cpm");
        alarmRule.setPeriod(10);
        alarmRule.setTags(new HashMap<String, String>() {{
            put("key", "value");
        }});
        RunningRule runningRule = new RunningRule(alarmRule);

        DateTime startTime = DateTime.now();
        long timeInPeriod1 = TimeBucket.getMinuteTimeBucket(startTime.getMillis());
        DateTime targetTime = new DateTime(TimeBucket.getTimestamp(timeInPeriod1));

        runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70));

        Map<AlarmEntity, RunningRule.Window> windows = Whitebox.getInternalState(runningRule, "windows");

        RunningRule.Window window = windows.get(getAlarmEntity(123));
        LocalDateTime endTime = Whitebox.getInternalState(window, "endTime");
        int additionalPeriod = Whitebox.getInternalState(window, "additionalPeriod");
        LinkedList<Metrics> metricsBuffer = Whitebox.getInternalState(window, "values");

        Assertions.assertTrue(targetTime.equals(endTime.toDateTime()));
        Assertions.assertEquals(5, additionalPeriod);
        Assertions.assertEquals(15, metricsBuffer.size());
    }