Skip to content

Commit

Permalink
Enh 35911455 - [35551414->24.03] ENH: Add an attribute to Cache MBean…
Browse files Browse the repository at this point in the history
… to record when clear() method is called on the NamedCache

[git-p4: depot-paths = "//dev/coherence-ce/main/": change = 104261]
  • Loading branch information
tmiddlet2666 committed Oct 26, 2023
1 parent 31e0209 commit 69e809c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ protected java.util.Map get_PropertyInfo()
"rest.collector=sum,metrics.value=_default",
});
}

// property ClearCount
{
mapInfo.put("ClearCount", new Object[]
{
"The number of clear() operations since the last time statistics were reset.",
"getClearCount",
null,
"J",
"rest.collector=sum,metrics.value=_default",
});
}

// property TriggerInfo
{
Expand Down Expand Up @@ -598,7 +610,19 @@ public int getListenerFilterCount()
{
return 0;
}


// Accessor for the property "ClearCount"
/**
* Getter for property ClearCount.<p>
* The number of clear() operations since the last time statistics were reset.
*
* @descriptor rest.collector=set,metrics.value=_default
*/
public long getClearCount()
{
return 0L;
}

// Accessor for the property "ListenerKeyCount"
/**
* Getter for property ListenerKeyCount.<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
import com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache;
import com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.partitionedCache.Storage;

import com.tangosol.internal.util.VersionHelper;

import com.tangosol.net.NamedCache;
import com.tangosol.net.events.internal.StorageDispatcher;

import com.tangosol.util.Base;
import com.tangosol.util.ExternalizableHelper;
import com.tangosol.util.MapIndex;

import java.lang.ref.WeakReference;

import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
Expand Down Expand Up @@ -624,7 +629,20 @@ public long getRemoveCount()
Storage storage = get_Storage();
return storage == null ? -1L : storage.getStatsRemoves().get();
}


// Accessor for the property "ClearCount"
/**
* Getter for property ClearCount.<p>
* The number of `clear` operations since the last time statistics were reset.
*/
public long getClearCount()
{
// import Component.Util.Daemon.QueueProcessor.Service.Grid.PartitionedService.PartitionedCache$Storage as Storage;

Storage storage = get_Storage();
return storage == null ? -1L : storage.getStatsClears().get();
}

// Accessor for the property "TriggerInfo"
/**
* Getter for property TriggerInfo.<p>
Expand Down Expand Up @@ -710,6 +728,14 @@ public void readExternal(java.io.DataInput in)
{
mapSnapshot.put("IndexingTotalMillis", Base.makeLong(ExternalizableHelper.readLong(in)));
}

// added in 14.1.2.0.0 / 26.06.7 / 23.09.1
if (ExternalizableHelper.isVersionCompatible(in, VersionHelper.VERSION_14_1_2_0)
|| ExternalizableHelper.isPatchCompatible(in, VersionHelper.VERSION_14_1_1_2206_7)
|| ExternalizableHelper.isPatchCompatible(in, VersionHelper.VERSION_23_09_1))
{
mapSnapshot.put("ClearCount", ExternalizableHelper.readLong(in));
}
}

public void resetStatistics()
Expand Down Expand Up @@ -846,5 +872,13 @@ public void writeExternal(java.io.DataOutput out)
{
ExternalizableHelper.writeLong(out, getIndexingTotalMillis());
}

// added in 14.1.2.0.0 / 22.06.7 / 23.09.1
if (ExternalizableHelper.isVersionCompatible(out, VersionHelper.VERSION_14_1_2_0)
|| ExternalizableHelper.isPatchCompatible(out, VersionHelper.VERSION_14_1_1_2206_7)
|| ExternalizableHelper.isPatchCompatible(out, VersionHelper.VERSION_23_09_1))
{
ExternalizableHelper.writeLong(out, getClearCount());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,14 @@ public class Storage
*/
private transient java.util.concurrent.atomic.AtomicLong __m_StatsRemoves;

/**
* Property StatsClears
*
* A counter for the number of clear operations on the backing map.
* This counter gets incremented during clear operations.
*/
private transient java.util.concurrent.atomic.AtomicLong __m_StatsClears;

/**
* Property TempBinaryEntry
*
Expand Down Expand Up @@ -799,6 +807,7 @@ public void __init()
setStatsOptimizedQueryTotalMillis(new java.util.concurrent.atomic.AtomicLong());
setStatsQueryContentionCount(new java.util.concurrent.atomic.AtomicLong());
setStatsRemoves(new java.util.concurrent.atomic.AtomicLong());
setStatsClears(new java.util.concurrent.atomic.AtomicLong());
setValid(false);
setVersion(new com.tangosol.net.internal.StorageVersion());
}
Expand Down Expand Up @@ -1812,6 +1821,7 @@ public void clear(PartitionedCache.InvocationContext ctxInvoke, com.tangosol.net
}
}
ctxInvoke.postInvoke();
getStatsClears().incrementAndGet();
}

/**
Expand Down Expand Up @@ -4496,6 +4506,17 @@ public java.util.concurrent.atomic.AtomicLong getStatsRemoves()
return __m_StatsRemoves;
}

// Accessor for the property "StatsClears"
/**
* Getter for property StatsClears.<p>
* A counter for the number of clear operations on the backing map.
* This counter gets incremented during clear operations.
*/
public java.util.concurrent.atomic.AtomicLong getStatsClears()
{
return __m_StatsClears;
}

// Accessor for the property "TempBinaryEntry"
/**
* Getter for property TempBinaryEntry.<p>
Expand Down Expand Up @@ -9003,6 +9024,7 @@ public void resetStats()
getStatsOptimizedQueryTotalMillis().set(0L);
getStatsOptimizedQueryCount().set(0);
getStatsQueryContentionCount().set(0L);
getStatsClears().set(0L);

getStatsIndexingTotalMillis().set(0L);

Expand Down Expand Up @@ -9787,6 +9809,17 @@ protected void setStatsRemoves(java.util.concurrent.atomic.AtomicLong counter)
__m_StatsRemoves = counter;
}

// Accessor for the property "StatsClears"
/**
* Setter for property StatsClears.<p>
* A counter for the number of clear operations on the backing map.
* This counter gets incremented during clear operations.
*/
protected void setStatsClears(java.util.concurrent.atomic.AtomicLong counter)
{
__m_StatsClears = counter;
}

// Accessor for the property "TempBinaryEntry"
/**
* Setter for property TempBinaryEntry.<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ public void shouldGetStorageManagerMetrics()
"Coherence.StorageManager.OptimizedQueryCount",
"Coherence.StorageManager.OptimizedQueryTotalMillis",
"Coherence.StorageManager.QueryContentionCount",
"Coherence.StorageManager.ClearCount",
"Coherence.StorageManager.RemoveCount");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public void entryDeleted(MapEvent<Integer, Integer> evt)
server.invoke(name, "clearCache", null, null);
Eventually.assertDeferred(cache::size, is(0));
Eventually.assertDeferred(atomicDelete::get, is(100));
Long ClearCount = (Long) server.getAttribute(name, "ClearCount");
assertEquals("expected ClearCount to be 1", Long.valueOf(1), ClearCount);
}

/**
Expand Down

0 comments on commit 69e809c

Please sign in to comment.