• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / rocketmq / 7926

pending completion
7926

push

travis-ci-com

GitHub
[ISSUE #5965] Fix lmqTopicQueueTable initialization (#5967)

10 of 10 new or added lines in 2 files covered. (100.0%)

22455 of 43079 relevant lines covered (52.13%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.1
/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17

18
package org.apache.rocketmq.common.stats;
19

20
import java.util.concurrent.ScheduledExecutorService;
21
import java.util.concurrent.TimeUnit;
22
import java.util.concurrent.atomic.AtomicLong;
23
import org.apache.rocketmq.common.UtilAll;
24
import org.apache.rocketmq.logging.InternalLogger;
25

26
public class MomentStatsItem {
27

28
    private final AtomicLong value = new AtomicLong(0);
2✔
29

30
    private final String statsName;
31
    private final String statsKey;
32
    private final ScheduledExecutorService scheduledExecutorService;
33
    private final InternalLogger log;
34

35
    public MomentStatsItem(String statsName, String statsKey,
36
        ScheduledExecutorService scheduledExecutorService, InternalLogger log) {
2✔
37
        this.statsName = statsName;
2✔
38
        this.statsKey = statsKey;
2✔
39
        this.scheduledExecutorService = scheduledExecutorService;
2✔
40
        this.log = log;
2✔
41
    }
2✔
42

43
    public void init() {
44
        this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
×
45
            @Override
46
            public void run() {
47
                try {
48
                    printAtMinutes();
×
49

50
                    MomentStatsItem.this.value.set(0);
×
51
                } catch (Throwable e) {
×
52
                }
×
53
            }
×
54
        }, Math.abs(UtilAll.computeNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
×
55
    }
×
56

57
    public void printAtMinutes() {
58
        log.info(String.format("[%s] [%s] Stats Every 5 Minutes, Value: %d",
×
59
            this.statsName,
60
            this.statsKey,
61
            this.value.get()));
×
62
    }
×
63

64
    public AtomicLong getValue() {
65
        return value;
2✔
66
    }
67

68
    public String getStatsKey() {
69
        return statsKey;
×
70
    }
71

72
    public String getStatsName() {
73
        return statsName;
×
74
    }
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc