protected static void printNearCacheStats(ICache<?, ?> cache, String message) { NearCacheStats stats = cache.getLocalCacheStatistics().getNearCacheStatistics(); System.out.printf("%s (%d entries, %d hits, %d misses, %d evictions, %d expirations)%n", message, stats.getOwnedEntryCount(), stats.getHits(), stats.getMisses(), stats.getEvictions(), stats.getExpirations()); }
private boolean isScheduled(NearCache nearCache, long now) { NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); if (nearCacheStats.getLastPersistenceTime() == 0) { // check initial delay seconds for first persistence long runningSeconds = MILLISECONDS.toSeconds(now - started); if (runningSeconds < preloaderConfig.getStoreInitialDelaySeconds()) { return false; } } else { // check interval seconds for all other persistences long elapsedSeconds = MILLISECONDS.toSeconds(now - nearCacheStats.getLastPersistenceTime()); if (elapsedSeconds < preloaderConfig.getStoreIntervalSeconds()) { return false; } } return true; } }
protected static void printNearCacheStats(ICache<Integer, Article> cache) { NearCacheStats stats = cache.getLocalCacheStatistics().getNearCacheStatistics(); System.out.printf("The Near Cache contains %d entries.%n", stats.getOwnedEntryCount()); System.out.printf("The first article instance was retrieved from the remote instance (Near Cache misses: %d).%n", stats.getMisses()); System.out.printf( "The second and third article instance were retrieved from the local Near Cache (Near Cache hits: %d).%n", stats.getHits()); }
@Override public void run(String... arg0) { Instant after = Instant.now(); Duration duration = Duration.between(before.getBefore(), after); IMap<String, Airport> airportsMap = hazelcastInstance.getMap(MyConstants.MAP_NAME_AIRPORTS); NearCacheStats airportsMapNearCacheStats = airportsMap.getLocalMapStats().getNearCacheStats(); System.out.printf("===================================== %n"); System.out.printf("=== R E S U L T S === %n"); System.out.printf("===================================== %n"); System.out.printf("=== Map : '%s'%n", airportsMap.getName()); System.out.printf("=== Calls............. : '%d'%n", fraudService.getCalls()); System.out.printf("=== Alerts............ : '%d'%n", fraudService.getAlerts()); if (airportsMapNearCacheStats != null) { System.out.printf("=== Near Cache hits... : '%d'%n", airportsMapNearCacheStats.getHits()); System.out.printf("=== Near Cache misses. : '%d'%n", airportsMapNearCacheStats.getMisses()); } System.out.printf("===================================== %n"); System.out.printf("=== Run time for tests : '%s'%n", duration); System.out.printf("===================================== %n"); } }
while (stats.getLastPersistenceKeyCount() != MAP_SIZE) { sleepMillis(500); while (stats.getOwnedEntryCount() != MAP_SIZE) { sleepMillis(500);
public static void main(String[] args) { HazelcastInstance node = Hazelcast.newHazelcastInstance(newConfig()); IMap<String, String> map = node.getMap("default"); for (int i = 0; i < 1000; i++) { map.put("key-" + i, "value-" + i); } // first get() populates the Near cache with the remote entry for (int i = 0; i < 1000; i++) { map.get("key-" + i); } long ownedEntryCount = map.getLocalMapStats().getNearCacheStats().getOwnedEntryCount(); System.out.println("Near Cache includes " + ownedEntryCount + " entries"); node.shutdown(); }
private long usedHeapInBytes(String mapName) { long usedHeapInBytes = 0L; for (int partitionId = 0; partitionId < partitionCount; partitionId++) { usedHeapInBytes += getRecordStoreHeapCost(mapName, containers[partitionId]); } NearCache nearCache = mapNearCacheManager.getNearCache(mapName); if (nearCache != null) { NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); usedHeapInBytes += nearCacheStats.getOwnedEntryMemoryCost(); } return usedHeapInBytes; }
root.add("merkleTreesCost", merkleTreesCost); if (nearCacheStats != null) { root.add("nearCacheStats", nearCacheStats.toJson());
if (jsonNearCacheStats != null) { nearCacheStats = new NearCacheStatsImpl(); nearCacheStats.fromJson(jsonNearCacheStats.asObject());
@SuppressWarnings("SameParameterValue") protected static void waitForNearCacheEvictionCount(IMap<?, Article> map, int expectedEvictionCount) { long evictionCount; do { NearCacheStats stats = map.getLocalMapStats().getNearCacheStats(); evictionCount = stats.getEvictions(); } while (evictionCount > expectedEvictionCount); }
protected static void printNearCacheStats(IMap<?, Article> map) { NearCacheStats stats = map.getLocalMapStats().getNearCacheStats(); System.out.printf("The Near Cache contains %d entries.%n", stats.getOwnedEntryCount()); System.out.printf("The first article instance was retrieved from the remote instance (Near Cache misses: %d).%n", stats.getMisses()); System.out.printf( "The second and third article instance were retrieved from the local Near Cache (Near Cache hits: %d).%n", stats.getHits()); }
public static void main(String[] args) { // start server HazelcastInstance server = Hazelcast.newHazelcastInstance(newConfig()); // start client HazelcastInstance client = HazelcastClient.newHazelcastClient(newClientConfig("mapName")); IMap<String, String> map = client.getMap("mapName"); for (int i = 0; i < 1000; i++) { map.put("key-" + i, "value-" + i); } // first get() populates the Near cache with the remote entry for (int i = 0; i < 1000; i++) { map.get("key-" + i); } long ownedEntryCount = map.getLocalMapStats().getNearCacheStats().getOwnedEntryCount(); System.out.println("Near cache includes " + ownedEntryCount + " entries"); client.shutdown(); server.shutdown(); }
private void addNearCacheStats(String mapName, LocalMapStatsImpl localMapStats, LocalMapOnDemandCalculatedStats onDemandStats) { NearCache nearCache = mapNearCacheManager.getNearCache(mapName); if (nearCache == null) { return; } NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); localMapStats.setNearCacheStats(nearCacheStats); onDemandStats.incrementHeapCost(nearCacheStats.getOwnedEntryMemoryCost()); }
root.add("merkleTreesCost", merkleTreesCost); if (nearCacheStats != null) { root.add("nearCacheStats", nearCacheStats.toJson());
if (jsonNearCacheStats != null) { nearCacheStats = new NearCacheStatsImpl(); nearCacheStats.fromJson(jsonNearCacheStats.asObject());
protected static void printNearCacheStats(IMap<?, Article> map, String message) { NearCacheStats stats = map.getLocalMapStats().getNearCacheStats(); System.out.printf("%s (%d entries, %d hits, %d misses, %d evictions, %d expirations)%n", message, stats.getOwnedEntryCount(), stats.getHits(), stats.getMisses(), stats.getEvictions(), stats.getExpirations()); }
private void addNearCacheStats(String mapName, LocalMapStatsImpl localMapStats, LocalMapOnDemandCalculatedStats onDemandStats) { NearCache nearCache = mapNearCacheManager.getNearCache(mapName); if (nearCache == null) { return; } NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); localMapStats.setNearCacheStats(nearCacheStats); if (NATIVE != nearCache.getInMemoryFormat()) { onDemandStats.incrementHeapCost(nearCacheStats.getOwnedEntryMemoryCost()); } }
private boolean isScheduled(NearCache nearCache, long now) { NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); NearCachePreloaderConfig preloaderConfig = nearCache.getPreloaderConfig(); if (nearCacheStats.getLastPersistenceTime() == 0) { // check initial delay seconds for first persistence long runningSeconds = MILLISECONDS.toSeconds(now - started); if (runningSeconds < preloaderConfig.getStoreInitialDelaySeconds()) { return false; } } else { // check interval seconds for all other persistences long elapsedSeconds = MILLISECONDS.toSeconds(now - nearCacheStats.getLastPersistenceTime()); if (elapsedSeconds < preloaderConfig.getStoreIntervalSeconds()) { return false; } } return true; } }
protected long getUsedHeapInBytes(String mapName) { long heapCost = 0L; final List<Integer> partitionIds = findPartitionIds(); for (int partitionId : partitionIds) { final PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId); if (container == null) { continue; } heapCost += getRecordStoreHeapCost(mapName, container); } MapContainer mapContainer = mapServiceContext.getMapContainer(mapName); if (!mapContainer.getMapConfig().isNearCacheEnabled()) { return heapCost; } MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager(); NearCache nearCache = mapNearCacheManager.getNearCache(mapName); NearCacheStats nearCacheStats = nearCache.getNearCacheStats(); heapCost += nearCacheStats.getOwnedEntryMemoryCost(); return heapCost; }