@Override public Map<K, Object> executeOnEntries(com.hazelcast.map.EntryProcessor entryProcessor) { return map.executeOnEntries(entryProcessor); }
@Override public Map<K, Object> executeOnEntries(EntryProcessor entryProcessor, Predicate predicate) { return map.executeOnEntries(entryProcessor, predicate); }
@Override public Map<K, Object> executeOnEntries(com.hazelcast.map.EntryProcessor entryProcessor, Predicate predicate) { return map.executeOnEntries(entryProcessor, predicate); }
@Override public Map<K, Object> executeOnEntries(com.hazelcast.map.EntryProcessor entryProcessor, Predicate predicate) { return map.executeOnEntries(entryProcessor, predicate); }
@Override public Map<K, Object> executeOnEntries(EntryProcessor entryProcessor) { return map.executeOnEntries(entryProcessor); }
@Override public Map<K, Object> executeOnEntries(com.hazelcast.map.EntryProcessor entryProcessor) { return map.executeOnEntries(entryProcessor); }
@Override public long processDistances(Position position) { DistanceProcessor processor = new DistanceProcessor(position); IMap<String, Position> map = client.getMap(GPS); Map<String, Object> processed = map.executeOnEntries(processor); return processed.values() .stream() .filter(Position.class::isInstance) .map(Position.class::cast) .filter(it -> !Double.isNaN(it.getDistance())) .count(); } }
@Override public void removeAll() { // increment all entry versions to trigger a cluster-wide invalidation versionMap.executeOnEntries(IncrementVersionEntryProcessor.getInstance()); localCache.removeAll(); }
public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<String, Employee> employees = hz.getMap("employees"); employees.put("John", new Employee(1000)); employees.put("Mark", new Employee(1000)); employees.put("Spencer", new Employee(1000)); employees.executeOnEntries(new EmployeeRaiseEntryProcessor()); for (Map.Entry<String, Employee> entry : employees.entrySet()) { System.out.println(entry.getKey() + " salary: " + entry.getValue().getSalary()); } Hazelcast.shutdownAll(); }
@Override public void removeLayer(String layername) { if (configured) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Removing Layer:" + layername); } // Creation of the Predicate EntryObject e = new PredicateBuilder().getEntryObject(); Predicate predicate = e.get("layer_name").equal(layername); // Creation of the processor CacheEntryProcessor entryProcessor = new CacheEntryProcessor(); // Execution of the Processor map.executeOnEntries(entryProcessor, predicate); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Cache not configured"); } } }
@Override public void removeLayer(String layername) { if (configured) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Removing Layer:" + layername); } // Creation of the Predicate EntryObject e = new PredicateBuilder().getEntryObject(); Predicate predicate = e.get("layer_name").equal(layername); // Creation of the processor CacheEntryProcessor entryProcessor = new CacheEntryProcessor(); // Execution of the Processor map.executeOnEntries(entryProcessor, predicate); } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Cache not configured"); } } }
public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IMap<String, Position> positions = hz.getMap("positions"); Position poi = new Position(52.5200d, 13.4050d); positions.put("Paris", new Position(48.8566d, 2.3522d)); positions.put("New York", new Position(40.7128d, 74.0059d)); positions.put("London", new Position(51.5074d, 0.1278d)); positions.executeOnEntries(new DistanceProcessor(poi)); for (Map.Entry<String, Position> entry : positions.entrySet()) { final double distance = entry.getValue().getDistance(); System.out.println(entry.getKey() + " distance to POI is " + distance); } Hazelcast.shutdownAll(); } }
public static void main(String[] args) throws InterruptedException { ClientConfig clientConfig = new ClientConfig(); ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig(); clientUserCodeDeploymentConfig.addClass("IncrementingEntryProcessor"); clientUserCodeDeploymentConfig.setEnabled(true); clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig); HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); IncrementingEntryProcessor incrementingEntryProcessor = new IncrementingEntryProcessor(); int keyCount = 10; IMap<Integer, Integer> map = client.getMap("sample map"); for (int i = 0; i < keyCount; i++) { map.put(i, 0); } map.executeOnEntries(incrementingEntryProcessor); for (int i = 0; i < keyCount; i++) { System.out.println(map.get(i)); } } }