-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Feature/near cache stats #1458
Merged
Merged
Feature/near cache stats #1458
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
hazelcast/src/main/java/com/hazelcast/monitor/NearCacheStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.hazelcast.monitor; | ||
|
||
/** | ||
* User: eminn | ||
* Date: 03/12/13 | ||
* Time: 10:48 AM | ||
*/ | ||
public interface NearCacheStats extends LocalInstanceStats { | ||
/** | ||
* Returns the creation time of this NearCache on this member | ||
* | ||
* @return creation time of this NearCache on this member | ||
*/ | ||
long getCreationTime(); | ||
|
||
/** | ||
* Returns the number of entries owned by this member. | ||
* | ||
* @return number of entries owned by this member. | ||
*/ | ||
long getOwnedEntryCount(); | ||
|
||
|
||
/** | ||
* Returns memory cost (number of bytes) of entries in this cache. | ||
* | ||
* @return memory cost (number of bytes) of entries in this cache. | ||
*/ | ||
long getOwnedEntryMemoryCost(); | ||
|
||
/** | ||
* Returns the number of hits (reads) of the locally owned entries. | ||
* | ||
* @return number of hits (reads). | ||
*/ | ||
long getHits(); | ||
|
||
/** | ||
* Returns the number of misses of the locally owned entries. | ||
* | ||
* @return number of misses. | ||
*/ | ||
long getMisses(); | ||
|
||
/** | ||
* Returns the hit/miss ratio of the locally owned entries. | ||
* | ||
* @return hit/miss ratio. | ||
*/ | ||
double getRatio(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
hazelcast/src/main/java/com/hazelcast/monitor/impl/NearCacheStatsImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.hazelcast.monitor.impl; | ||
|
||
import com.hazelcast.monitor.NearCacheStats; | ||
import com.hazelcast.nio.ObjectDataInput; | ||
import com.hazelcast.nio.ObjectDataOutput; | ||
import com.hazelcast.util.Clock; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* User: eminn | ||
* Date: 03/12/13 | ||
* Time: 10:58 AM | ||
*/ | ||
public class NearCacheStatsImpl implements NearCacheStats { | ||
|
||
private long ownedEntryCount; | ||
private long ownedEntryMemoryCost; | ||
private long creationTime; | ||
private AtomicLong hits = new AtomicLong(0); | ||
private AtomicLong misses = new AtomicLong(0); | ||
|
||
public NearCacheStatsImpl() { | ||
this.creationTime = Clock.currentTimeMillis(); | ||
} | ||
|
||
@Override | ||
public long getCreationTime() { | ||
return creationTime; | ||
} | ||
|
||
@Override | ||
public long getOwnedEntryCount() { | ||
return ownedEntryCount; | ||
} | ||
|
||
public void setOwnedEntryCount(long ownedEntryCount) { | ||
this.ownedEntryCount = ownedEntryCount; | ||
} | ||
|
||
@Override | ||
public long getOwnedEntryMemoryCost() { | ||
return ownedEntryMemoryCost; | ||
} | ||
|
||
@Override | ||
public long getHits() { | ||
return hits.get(); | ||
} | ||
|
||
@Override | ||
public long getMisses() { | ||
return misses.get(); | ||
} | ||
|
||
public void setHits(long hits) { | ||
this.hits.set(hits); | ||
} | ||
|
||
public double getRatio() { | ||
return (double)hits.get() / misses.get() ; | ||
} | ||
|
||
|
||
public void setOwnedEntryMemoryCost(long ownedEntryMemoryCost) { | ||
|
||
this.ownedEntryMemoryCost = ownedEntryMemoryCost; | ||
} | ||
|
||
public void incrementMisses() | ||
{ | ||
misses.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void writeData(ObjectDataOutput out) throws IOException { | ||
out.writeLong(ownedEntryCount); | ||
out.writeLong(ownedEntryMemoryCost); | ||
out.writeLong(hits.get()); | ||
out.writeLong(misses.get()); | ||
} | ||
|
||
@Override | ||
public void readData(ObjectDataInput in) throws IOException { | ||
this.ownedEntryCount = in.readLong(); | ||
this.ownedEntryMemoryCost = in.readLong(); | ||
this.hits.set(in.readLong()); | ||
this.misses.set(in.readLong()); | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "NearCacheStatsImpl{" + | ||
"ownedEntryCount=" + ownedEntryCount + | ||
", ownedEntryMemoryCost=" + ownedEntryMemoryCost + | ||
", creationTime=" + creationTime + | ||
", hits=" + hits + | ||
", misses=" + misses + | ||
", ratio=" + getRatio() + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho, get() should just get. you may make create() public