Tools for write behind queue, which provides following functions
- Get current write behind queue size in the cluster
- Clear retaining data in write behind queue in the cluster
Add dependency to pom.xml like this:
<dependency>
<groupId>io.github.simukappu</groupId>
<artifactId>write-behind-tools</artifactId>
<version>1.0.0</version>
</dependency>
Invoke Write Behind Tools Processor from invokeAll method in NamedCache<Object, Object>.
For example, use as follows:
NamedCache<Object, Object> namedCache = CacheFactory.getCache("CacheName");
// Get current write behind queue size in the cluster
{
// Invoke GetWriteQueueSizeProcessor to all local-storage enabled nodes
Map<Object, Map.Entry<Integer, Integer>> mapResults = targetCache
.invokeAll(new AlwaysFilter<Object>(),
new GetWriteQueueSizeProcessor(targetCacheName));
// Sort result map set by keys
List<Map.Entry<Integer, Integer>> resultList = new ArrayList<>(
mapResults.values());
resultList.sort((a, b) -> a.getKey() - b.getKey());
// Display results
System.out.println("Size of write behind queue:");
resultList.forEach(resultEntry -> {
System.out.println(" " + resultEntry.getValue()
+ " entries in Node# " + resultEntry.getKey());
});
}
// Clear retaining data in write behind queue in the cluster
{
// Invoke ClearWriteQueueProcessor to all local-storage enabled nodes
Map<Object, Map.Entry<Integer, Integer>> mapResults = targetCache
.invokeAll(new AlwaysFilter<Object>(),
new ClearWriteQueueProcessor(targetCacheName));
// Sort result map set by keys
List<Map.Entry<Integer, Integer>> resultList = new ArrayList<>(
mapResults.values());
resultList.sort((a, b) -> a.getKey() - b.getKey());
// Display results
System.out.println("Removed entries from write behind queue:");
resultList.forEach(resultEntry -> {
System.out.println(" " + resultEntry.getValue()
+ " entries from Node# " + resultEntry.getKey());
});
}
See Javadoc for more details.
Just run test.com.simukappu.coherence.writequeue.IntegrationTest as JUnit Test.
You can run this test as stand-alone or multi-processes cluster by running CacheServer before the test.
CacheServer joining this cluster can be started by test.com.simukappu.coherence.writequeue.server.CacheServer.
https://simukappu.github.io/coherence-tools/write-behind-tools/docs/project-reports.html