Skip to content

Commit

Permalink
ISPN-9117 Expose PassivationManager passivateAll over JMX
Browse files Browse the repository at this point in the history
  • Loading branch information
tristantarrant authored and rvansa committed May 3, 2018
1 parent d1a3987 commit e2fa44a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -29,6 +29,9 @@ public interface PassivationManager extends JmxStatisticsExposer {
void passivate(InternalCacheEntry entry);

@Stop(priority = 9)
@ManagedOperation(
description = "Passivate all entries to the CacheStore",
displayName = "Passivate all")
void passivateAll() throws PersistenceException;

/**
Expand Down
Expand Up @@ -58,7 +58,7 @@ protected EmbeddedCacheManager createCacheManager() throws Exception {
.passivation(true)
.addStore(DummyInMemoryStoreConfigurationBuilder.class);

// Do not initiliaze this in instance declaration since a different
// Do not initialize this in instance declaration since a different
// thread will be used when running from maven, breaking the thread local
threadMBeanServer = PerThreadMBeanServerLookup.getThreadMBeanServer();

Expand All @@ -74,6 +74,11 @@ protected void setup() throws Exception {
@AfterMethod
public void resetStats() throws Exception {
threadMBeanServer.invoke(activationInterceptorObjName, "resetStatistics", new Object[0], new String[0]);
threadMBeanServer.invoke(passivationInterceptorObjName, "resetStatistics", new Object[0], new String[0]);
}

public void passivateAll() throws Exception {
threadMBeanServer.invoke(passivationInterceptorObjName, "passivateAll", new Object[0], new String[0]);
}

public void testDisableStatistics() throws Exception {
Expand Down Expand Up @@ -147,6 +152,15 @@ public void testPassivationOnEvict(Method m) throws Exception {
assertPassivationCount(2);
}

public void testPassivateAll(Method m) throws Exception {
assertPassivationCount(0);
for (int i = 0; i < 10; i++) {
cache.put(k(m, i), v(m, i));
}
passivateAll();
assertPassivationCount(9);
}

private void assertActivationCount(int activationCount) throws Exception {
assert Integer.valueOf(threadMBeanServer.getAttribute(
activationInterceptorObjName, "Activations").toString())
Expand Down

0 comments on commit e2fa44a

Please sign in to comment.