forked from eclipse-ee4j/grizzly-memcached
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented "Support grizzly-memcached's monitoring features using Gr…
…izzly JMX"(eclipse-ee4j#13) + Added stats(Keyed object which is generally related to network connection managed in the basic object pool).
- Loading branch information
Showing
3 changed files
with
145 additions
and
11 deletions.
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
81 changes: 81 additions & 0 deletions
81
src/main/java/org/glassfish/grizzly/memcached/pool/jmx/KeyedObject.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,81 @@ | ||
package org.glassfish.grizzly.memcached.pool.jmx; | ||
|
||
import org.glassfish.gmbal.Description; | ||
import org.glassfish.gmbal.GmbalMBean; | ||
import org.glassfish.gmbal.ManagedAttribute; | ||
import org.glassfish.gmbal.ManagedData; | ||
import org.glassfish.gmbal.ManagedObject; | ||
import org.glassfish.grizzly.jmxbase.GrizzlyJmxManager; | ||
import org.glassfish.grizzly.memcached.pool.BaseObjectPool; | ||
import org.glassfish.grizzly.monitoring.jmx.JmxObject; | ||
|
||
/** | ||
* JMX managed object for object pool's keyed object implementations. | ||
*/ | ||
@ManagedObject | ||
@Description("Keyed object managed in the basic object pool(generally related to network connection)") | ||
public class KeyedObject extends JmxObject { | ||
|
||
private final BaseObjectPool.QueuePool pool; | ||
|
||
public KeyedObject(final BaseObjectPool.QueuePool pool) { | ||
this.pool = pool; | ||
} | ||
|
||
@Override | ||
public String getJmxName() { | ||
return pool.getName(); | ||
} | ||
|
||
@Override | ||
protected void onRegister(GrizzlyJmxManager mom, GmbalMBean bean) { | ||
} | ||
|
||
@Override | ||
protected void onDeregister(GrizzlyJmxManager mom) { | ||
} | ||
|
||
/** | ||
* Returns the Java type of the managed object pool | ||
* | ||
* @return the Java type of the managed object pool. | ||
*/ | ||
@ManagedAttribute(id = "keyed-object-type") | ||
@Description("The Java type of the keyed object implementation being used.") | ||
public String getKeyedObjectType() { | ||
return pool.getClass().getName(); | ||
} | ||
|
||
@ManagedAttribute(id = "object-stat") | ||
@Description("The stat of objects in this pool.") | ||
public CompositeObjectStat getObjectStat() { | ||
return new CompositeObjectStat(pool.getPoolSize(), pool.getPeakCount(), pool.getActiveCount(), | ||
pool.getIdleCount()); | ||
} | ||
|
||
@ManagedData(name="Object Stat") | ||
private static class CompositeObjectStat { | ||
@ManagedAttribute(id = "objects") | ||
@Description("The total number of objects currently idle and active in this pool or a negative value if unsupported.") | ||
private final int objectSize; | ||
|
||
@ManagedAttribute(id = "peak") | ||
@Description("The peak number of objects or a negative value if unsupported.") | ||
private final int peakCount; | ||
|
||
@ManagedAttribute(id = "active") | ||
@Description("The number of objects currently borrowed in this pool or a negative value if unsupported.") | ||
private final int activeCount; | ||
|
||
@ManagedAttribute(id = "idle") | ||
@Description("The number of objects currently idle in this pool or a negative value if unsupported.") | ||
private final int idleCount; | ||
|
||
private CompositeObjectStat(int objectSize, int peakCount, int activeCount, int idleCount) { | ||
this.objectSize = objectSize; | ||
this.peakCount = peakCount; | ||
this.activeCount = activeCount; | ||
this.idleCount = idleCount; | ||
} | ||
} | ||
} |