Skip to content

Update account AccountTier with reserved memory and reserved storage #1305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/main/java/io/nats/client/api/AccountStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public AccountStatistics(Message msg) {
* @return bytes
*/
public long getMemory() {
return rollupTier.getMemory();
return rollupTier.getMemoryBytes();
}

/**
Expand All @@ -63,7 +63,23 @@ public long getMemory() {
* @return bytes
*/
public long getStorage() {
return rollupTier.getStorage();
return rollupTier.getStorageBytes();
}

/**
* Bytes that is reserved for memory usage by this account on the server
* @return the memory usage in bytes
*/
public long getReservedMemory() {
return rollupTier.getReservedMemoryBytes();
}

/**
* Bytes that is reserved for disk usage by this account on the server
* @return the disk usage in bytes
*/
public long getReservedStorage() {
return rollupTier.getReservedStorageBytes();
}

/**
Expand Down
52 changes: 44 additions & 8 deletions src/main/java/io/nats/client/api/AccountTier.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
*/
public class AccountTier {

private final int memory;
private final int storage;
private final int reservedMemory;
private final int reservedStorage;
private final long memory;
private final long storage;
private final long reservedMemory;
private final long reservedStorage;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reserveds of type int have not been released so this is not breaking anything.

private final int streams;
private final int consumers;
private final AccountLimits limits;
Expand All @@ -46,31 +46,47 @@ public class AccountTier {
* Memory Storage being used for Stream Message storage in this tier.
* @return the memory storage in bytes
*/
public int getMemory() {
public long getMemoryBytes() {
return memory;
}

/**
* File Storage being used for Stream Message storage in this tier.
* @return the storage in bytes
*/
public int getStorage() {
public long getStorageBytes() {
return storage;
}

/**
* Bytes that is reserved for memory usage by this account on the server
* @return the memory usage in bytes
*/
public int getReservedMemory() {
public long getReservedMemory() {
return (int)reservedMemory;
}

/**
* Bytes that is reserved for disk usage by this account on the server
* @return the disk usage in bytes
*/
public long getReservedStorage() {
return reservedStorage;
}

/**
* Bytes that is reserved for memory usage by this account on the server
* @return the memory usage in bytes
*/
public long getReservedMemoryBytes() {
return reservedMemory;
}

/**
* Bytes that is reserved for disk usage by this account on the server
* @return the disk usage in bytes
*/
public int getReservedStorage() {
public long getReservedStorageBytes() {
return reservedStorage;
}

Expand All @@ -97,4 +113,24 @@ public int getConsumers() {
public AccountLimits getLimits() {
return limits;
}

/**
* @deprecated use getMemoryBytes instead
* Memory Storage being used for Stream Message storage in this tier.
* @return the memory storage in bytes
*/
@Deprecated
public int getMemory() {
return (int)memory;
}

/**
* @deprecated use getStorageBytes instead
* File Storage being used for Stream Message storage in this tier.
* @return the storage in bytes
*/
@Deprecated
public int getStorage() {
return (int)storage;
}
}
6 changes: 4 additions & 2 deletions src/test/java/io/nats/client/api/AccountStatisticsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ public void testAccountStatsImpl() {

private void validateTier(AccountTier tier, int tierBase, int limitsIdBase) {
assertNotNull(tier);
assertEquals(tierBase + 1, tier.getMemory());
assertEquals(tierBase + 2, tier.getStorage());
assertEquals(tierBase + 1, tier.getMemory()); // COVERAGE
assertEquals(tierBase + 1, tier.getMemoryBytes());
assertEquals(tierBase + 2, tier.getStorage()); // COVERAGE
assertEquals(tierBase + 2, tier.getStorageBytes());
assertEquals(tierBase + 3, tier.getStreams());
assertEquals(tierBase + 4, tier.getConsumers());
assertEquals(tierBase + 5, tier.getReservedMemory());
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy