Search in sources :

Example 1 with CityGrowthEntryProcessor

use of tasks.CityGrowthEntryProcessor in project microservices by pwillhan.

the class CityGrowthExample method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    HazelcastInstance hz = Hazelcast.newHazelcastInstance(conf);
    MapConfig citiesConf = conf.getMapConfig("cities");
    citiesConf.addMapIndexConfig(new MapIndexConfig("country", false));
    IMap<CityKey, City> cities = hz.getMap("cities");
    if (cities.isEmpty()) {
        cities.put(new CityKey("London", "GB"), new City("London", "GB", 7322403, 2001));
        cities.put(new CityKey("Southampton", "GB"), new City("Southampton", "GB", 226698, 2006));
        cities.put(new CityKey("Plymouth", "GB"), new City("Plymouth", "GB", 244037, 2004));
        cities.put(new CityKey("York", "GB"), new City("York", "GB", 195070, 2010));
        cities.put(new CityKey("Paris", "FR"), new City("Paris", "FR", 2268265, 2013));
    }
    cities.executeOnEntries(new CityGrowthEntryProcessor(0.01), Predicates.equal("country", "GB"));
    for (City city : cities.values()) {
        System.err.println(city);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) MapConfig(com.hazelcast.config.MapConfig) City(data.City) CityKey(data.CityKey) CityGrowthEntryProcessor(tasks.CityGrowthEntryProcessor)

Aggregations

Config (com.hazelcast.config.Config)1 MapConfig (com.hazelcast.config.MapConfig)1 MapIndexConfig (com.hazelcast.config.MapIndexConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 City (data.City)1 CityKey (data.CityKey)1 CityGrowthEntryProcessor (tasks.CityGrowthEntryProcessor)1