Search in sources :

Example 1 with MapIndexConfig

use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.

the class ClusterMembershipTest method testNodesAbleToJoinFromMultipleThreads_whenPostJoinOperationPresent.

@Test
public void testNodesAbleToJoinFromMultipleThreads_whenPostJoinOperationPresent() throws InterruptedException {
    final int instanceCount = 6;
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(instanceCount);
    final Config config = new Config();
    config.setProperty(GroupProperty.WAIT_SECONDS_BEFORE_JOIN.getName(), "0");
    final String mapName = randomMapName();
    // index config is added since it was blocking post join operations.
    config.getMapConfig(mapName).addMapIndexConfig(new MapIndexConfig("name", false));
    final CountDownLatch latch = new CountDownLatch(instanceCount);
    for (int i = 0; i < instanceCount; i++) {
        executorService.execute(new Runnable() {

            public void run() {
                HazelcastInstance hz = factory.newHazelcastInstance(config);
                hz.getMap(mapName);
                latch.countDown();
            }
        });
    }
    assertOpenEventually(latch);
    Collection<HazelcastInstance> instances = factory.getAllHazelcastInstances();
    for (HazelcastInstance instance : instances) {
        assertClusterSize(instanceCount, instance);
    }
}
Also used : MapIndexConfig(com.hazelcast.config.MapIndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ListenerConfig(com.hazelcast.config.ListenerConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with MapIndexConfig

use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.

the class EntryProcessorBouncingNodesTest method newInstance.

private HazelcastInstance newInstance(boolean withIndex) {
    Config config = getConfig();
    MapConfig mapConfig = config.getMapConfig(MAP_NAME);
    mapConfig.setBackupCount(2);
    if (withIndex) {
        mapConfig.addMapIndexConfig(new MapIndexConfig("__key", true));
    }
    return instanceFactory.newHazelcastInstance(config);
}
Also used : 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)

Example 3 with MapIndexConfig

use of com.hazelcast.config.MapIndexConfig in project microservices by pwillhan.

the class AverageCityPopulationCallableExample method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    MapConfig citiesConf = conf.getMapConfig("cities");
    citiesConf.addMapIndexConfig(new MapIndexConfig("country", false));
    HazelcastInstance hz = Hazelcast.newHazelcastInstance(conf);
    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));
    }
    ExecutorService exec = hz.getExecutorService("exec");
    Future<Integer> avgTask = exec.submit(new AverageCityPopulationCallable("GB"));
    Integer avgPop = avgTask.get();
    System.err.println("Average GB city population: " + avgPop);
}
Also used : AverageCityPopulationCallable(tasks.AverageCityPopulationCallable) MapIndexConfig(com.hazelcast.config.MapIndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapIndexConfig(com.hazelcast.config.MapIndexConfig) ExecutorService(java.util.concurrent.ExecutorService) MapConfig(com.hazelcast.config.MapConfig) City(data.City) CityKey(data.CityKey)

Example 4 with MapIndexConfig

use of com.hazelcast.config.MapIndexConfig 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)

Example 5 with MapIndexConfig

use of com.hazelcast.config.MapIndexConfig in project hazelcast by hazelcast.

the class QueryCacheConfigBuilderHelper method queryCacheIndexesHandle.

private void queryCacheIndexesHandle(Node n, QueryCacheConfig queryCacheConfig) {
    for (Node indexNode : childElements(n)) {
        if ("index".equals(cleanNodeName(indexNode))) {
            final NamedNodeMap attrs = indexNode.getAttributes();
            boolean ordered = getBooleanValue(getTextContent(attrs.getNamedItem("ordered")));
            String attribute = getTextContent(indexNode);
            queryCacheConfig.addIndexConfig(new MapIndexConfig(attribute, ordered));
        }
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) MapIndexConfig(com.hazelcast.config.MapIndexConfig) Node(org.w3c.dom.Node)

Aggregations

MapIndexConfig (com.hazelcast.config.MapIndexConfig)10 Config (com.hazelcast.config.Config)8 MapConfig (com.hazelcast.config.MapConfig)4 MapAttributeConfig (com.hazelcast.config.MapAttributeConfig)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 Bean (org.springframework.context.annotation.Bean)3 QuickTest (com.hazelcast.test.annotation.QuickTest)2 City (data.City)2 CityKey (data.CityKey)2 Test (org.junit.Test)2 PrincipalNameExtractor (org.springframework.session.hazelcast.PrincipalNameExtractor)2 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1 GroupConfig (com.hazelcast.config.GroupConfig)1 ListenerConfig (com.hazelcast.config.ListenerConfig)1 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)1 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)1 SerializerConfig (com.hazelcast.config.SerializerConfig)1 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1