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

nats-io / nats.java / #1947

17 Apr 2025 05:31PM UTC coverage: 95.637% (+0.01%) from 95.626%
#1947

push

github

web-flow
Merge pull request #1305 from nats-io/api-stats-missed-long

Update account AccountTier with reserved memory and reserved storage

6 of 8 new or added lines in 2 files covered. (75.0%)

4 existing lines in 2 files now uncovered.

11639 of 12170 relevant lines covered (95.64%)

0.96 hits per line

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

90.48
/src/main/java/io/nats/client/api/AccountStatistics.java
1
// Copyright 2020 The NATS Authors
2
// Licensed under the Apache License, Version 2.0 (the "License");
3
// you may not use this file except in compliance with the License.
4
// You may obtain a copy of the License at:
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software
9
// distributed under the License is distributed on an "AS IS" BASIS,
10
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
// See the License for the specific language governing permissions and
12
// limitations under the License.
13

14
package io.nats.client.api;
15

16
import io.nats.client.Message;
17
import io.nats.client.support.JsonValue;
18

19
import java.util.HashMap;
20
import java.util.Map;
21

22
import static io.nats.client.support.ApiConstants.*;
23
import static io.nats.client.support.JsonValueUtils.readObject;
24
import static io.nats.client.support.JsonValueUtils.readString;
25

26
/**
27
 * The JetStream Account Statistics
28
 */
29
public class AccountStatistics
30
        extends ApiResponse<AccountStatistics> {
31

32
    private final AccountTier rollupTier;
33
    private final String domain;
34
    private final ApiStats api;
35
    private final Map<String, AccountTier> tiers;
36

37
    public AccountStatistics(Message msg) {
38
        super(msg);
1✔
39
        rollupTier = new AccountTier(jv);
1✔
40
        domain = readString(jv, DOMAIN);
1✔
41
        api = new ApiStats(readObject(jv, API));
1✔
42
        JsonValue vTiers = readObject(jv, TIERS);
1✔
43
        tiers = new HashMap<>();
1✔
44
        if (vTiers.map != null) {
1✔
45
            for (String key : vTiers.map.keySet()) {
1✔
46
                tiers.put(key, new AccountTier(vTiers.map.get(key)));
1✔
47
            }
1✔
48
        }
49
    }
1✔
50

51
    /**
52
     * Gets the amount of memory storage used by the JetStream deployment.
53
     * If the account has tiers, this will represent a rollup.
54
     * @return bytes
55
     */
56
    public long getMemory() {
57
        return rollupTier.getMemoryBytes();
1✔
58
    }
59

60
    /**
61
     * Gets the amount of file storage used by  the JetStream deployment.
62
     * If the account has tiers, this will represent a rollup.
63
     * @return bytes
64
     */
65
    public long getStorage() {
66
        return rollupTier.getStorageBytes();
1✔
67
    }
68

69
    /**
70
     * Bytes that is reserved for memory usage by this account on the server
71
     * @return the memory usage in bytes
72
     */
73
    public long getReservedMemory() {
NEW
74
        return rollupTier.getReservedMemoryBytes();
×
75
    }
76

77
    /**
78
     * Bytes that is reserved for disk usage by this account on the server
79
     * @return the disk usage in bytes
80
     */
81
    public long getReservedStorage() {
NEW
82
        return rollupTier.getReservedStorageBytes();
×
83
    }
84

85
    /**
86
     * Gets the number of streams used by the JetStream deployment.
87
     * If the account has tiers, this will represent a rollup.
88
     * @return stream maximum count
89
     */
90
    public long getStreams() {
91
        return rollupTier.getStreams();
1✔
92
    }
93

94
    /**
95
     * Gets the number of consumers used by the JetStream deployment.
96
     * If the account has tiers, this will represent a rollup.
97
     * @return consumer maximum count
98
     */
99
    public long getConsumers() {
100
        return rollupTier.getConsumers();
1✔
101
    }
102

103
    /**
104
     * Gets the Account Limits object. If the account has tiers,
105
     * the object will be present but all values will be zero.
106
     * See the Account Limits for the specific tier.
107
     * @return the AccountLimits object
108
     */
109
    public AccountLimits getLimits() {
110
        return rollupTier.getLimits();
1✔
111
    }
112

113
    /**
114
     * Gets the account domain
115
     * @return the domain
116
     */
117
    public String getDomain() {
118
        return domain;
1✔
119
    }
120

121
    /**
122
     * Gets the account api stats
123
     * @return the ApiStats object
124
     */
125
    public ApiStats getApi() {
126
        return api;
1✔
127
    }
128

129
    /**
130
     * Gets the map of the Account Tiers by tier name
131
     * @return the map
132
     */
133
    public Map<String, AccountTier> getTiers() {
134
        return tiers;
1✔
135
    }
136
}
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

© 2026 Coveralls, Inc