Skip to content

Commit 575eb6f

Browse files
authored
Merge pull request #1305 from nats-io/api-stats-missed-long
Update account AccountTier with reserved memory and reserved storage
2 parents 5f89d21 + e52e2a8 commit 575eb6f

File tree

3 files changed

+66
-12
lines changed

3 files changed

+66
-12
lines changed

src/main/java/io/nats/client/api/AccountStatistics.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public AccountStatistics(Message msg) {
5454
* @return bytes
5555
*/
5656
public long getMemory() {
57-
return rollupTier.getMemory();
57+
return rollupTier.getMemoryBytes();
5858
}
5959

6060
/**
@@ -63,7 +63,23 @@ public long getMemory() {
6363
* @return bytes
6464
*/
6565
public long getStorage() {
66-
return rollupTier.getStorage();
66+
return rollupTier.getStorageBytes();
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() {
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() {
82+
return rollupTier.getReservedStorageBytes();
6783
}
6884

6985
/**

src/main/java/io/nats/client/api/AccountTier.java

+44-8
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
*/
2525
public class AccountTier {
2626

27-
private final int memory;
28-
private final int storage;
29-
private final int reservedMemory;
30-
private final int reservedStorage;
27+
private final long memory;
28+
private final long storage;
29+
private final long reservedMemory;
30+
private final long reservedStorage;
3131
private final int streams;
3232
private final int consumers;
3333
private final AccountLimits limits;
@@ -46,31 +46,47 @@ public class AccountTier {
4646
* Memory Storage being used for Stream Message storage in this tier.
4747
* @return the memory storage in bytes
4848
*/
49-
public int getMemory() {
49+
public long getMemoryBytes() {
5050
return memory;
5151
}
5252

5353
/**
5454
* File Storage being used for Stream Message storage in this tier.
5555
* @return the storage in bytes
5656
*/
57-
public int getStorage() {
57+
public long getStorageBytes() {
5858
return storage;
5959
}
6060

6161
/**
6262
* Bytes that is reserved for memory usage by this account on the server
6363
* @return the memory usage in bytes
6464
*/
65-
public int getReservedMemory() {
65+
public long getReservedMemory() {
66+
return (int)reservedMemory;
67+
}
68+
69+
/**
70+
* Bytes that is reserved for disk usage by this account on the server
71+
* @return the disk usage in bytes
72+
*/
73+
public long getReservedStorage() {
74+
return reservedStorage;
75+
}
76+
77+
/**
78+
* Bytes that is reserved for memory usage by this account on the server
79+
* @return the memory usage in bytes
80+
*/
81+
public long getReservedMemoryBytes() {
6682
return reservedMemory;
6783
}
6884

6985
/**
7086
* Bytes that is reserved for disk usage by this account on the server
7187
* @return the disk usage in bytes
7288
*/
73-
public int getReservedStorage() {
89+
public long getReservedStorageBytes() {
7490
return reservedStorage;
7591
}
7692

@@ -97,4 +113,24 @@ public int getConsumers() {
97113
public AccountLimits getLimits() {
98114
return limits;
99115
}
116+
117+
/**
118+
* @deprecated use getMemoryBytes instead
119+
* Memory Storage being used for Stream Message storage in this tier.
120+
* @return the memory storage in bytes
121+
*/
122+
@Deprecated
123+
public int getMemory() {
124+
return (int)memory;
125+
}
126+
127+
/**
128+
* @deprecated use getStorageBytes instead
129+
* File Storage being used for Stream Message storage in this tier.
130+
* @return the storage in bytes
131+
*/
132+
@Deprecated
133+
public int getStorage() {
134+
return (int)storage;
135+
}
100136
}

src/test/java/io/nats/client/api/AccountStatisticsTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ public void testAccountStatsImpl() {
7878

7979
private void validateTier(AccountTier tier, int tierBase, int limitsIdBase) {
8080
assertNotNull(tier);
81-
assertEquals(tierBase + 1, tier.getMemory());
82-
assertEquals(tierBase + 2, tier.getStorage());
81+
assertEquals(tierBase + 1, tier.getMemory()); // COVERAGE
82+
assertEquals(tierBase + 1, tier.getMemoryBytes());
83+
assertEquals(tierBase + 2, tier.getStorage()); // COVERAGE
84+
assertEquals(tierBase + 2, tier.getStorageBytes());
8385
assertEquals(tierBase + 3, tier.getStreams());
8486
assertEquals(tierBase + 4, tier.getConsumers());
8587
assertEquals(tierBase + 5, tier.getReservedMemory());

0 commit comments

Comments
 (0)