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);
}
}
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);
}
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);
}
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);
}
}
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));
}
}
}
Aggregations