private NearCacheStats getNearCacheStats(LocalInstanceStats localInstanceStats) { if (localInstanceStats instanceof LocalMapStatsImpl) { LocalMapStats localMapStats = (LocalMapStats) localInstanceStats; return localMapStats.getNearCacheStats(); } else if (localInstanceStats instanceof CacheStatistics) { CacheStatistics localMapStats = (CacheStatistics) localInstanceStats; return localMapStats.getNearCacheStatistics(); } else { return null; } }
private NearCacheStats getNearCacheStats(LocalInstanceStats localInstanceStats) { if (localInstanceStats instanceof LocalMapStatsImpl) { LocalMapStats localMapStats = (LocalMapStats) localInstanceStats; return localMapStats.getNearCacheStats(); } else if (localInstanceStats instanceof CacheStatistics) { CacheStatistics localMapStats = (CacheStatistics) localInstanceStats; return localMapStats.getNearCacheStatistics(); } else { return null; } }
@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()); }
@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"); } }
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(); }
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()); }
System.out.println("Near Cache from map 1: " + map1.getLocalMapStats().getNearCacheStats()); System.out.println("Near Cache from map 2: " + map2.getLocalMapStats().getNearCacheStats());
System.out.println("Near Cache from map 1: " + map1.getLocalMapStats().getNearCacheStats()); System.out.println("Near Cache from map 2: " + map2.getLocalMapStats().getNearCacheStats());
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(); }
NearCacheStats stats = map.getLocalMapStats().getNearCacheStats(); while (stats.getLastPersistenceKeyCount() != MAP_SIZE) { sleepMillis(500); stats = map.getLocalMapStats().getNearCacheStats(); while (stats.getOwnedEntryCount() != MAP_SIZE) { sleepMillis(500);