Search in sources :

Example 81 with MapConfig

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

the class ObjectRecordTest method setup.

@Before
public void setup() {
    String mapName = randomMapName();
    Config config = new Config();
    MapConfig mapConfig = config.getMapConfig(mapName);
    mapConfig.setInMemoryFormat(InMemoryFormat.OBJECT);
    mapConfig.setStatisticsEnabled(false);
    HazelcastInstance instance = createHazelcastInstance(config);
    map = instance.getMap(mapName);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) MapConfig(com.hazelcast.config.MapConfig) Before(org.junit.Before)

Example 82 with MapConfig

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

the class QuorumTest method testCustomQuorumFunctionFailsThenSuccess.

@Test
public void testCustomQuorumFunctionFailsThenSuccess() {
    final AtomicInteger count = new AtomicInteger(1);
    String mapName = randomMapName();
    String quorumName = randomString();
    MapConfig mapConfig = new MapConfig(mapName).setQuorumName(quorumName);
    QuorumConfig quorumConfig = new QuorumConfig().setName(quorumName).setEnabled(true).setQuorumFunctionImplementation(new QuorumFunction() {

        @Override
        public boolean apply(Collection<Member> members) {
            if (count.get() == 1) {
                count.incrementAndGet();
                return false;
            } else {
                return true;
            }
        }
    });
    Config config = new Config().addMapConfig(mapConfig).addQuorumConfig(quorumConfig);
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(2);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance(config);
    IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
    try {
        map.put("1", "1");
        fail();
    } catch (Exception e) {
        e.printStackTrace();
    }
    factory.newHazelcastInstance(config);
    map.put("1", "1");
    factory.shutdownAll();
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) MapConfig(com.hazelcast.config.MapConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) Config(com.hazelcast.config.Config) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapConfig(com.hazelcast.config.MapConfig) Member(com.hazelcast.core.Member) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 83 with MapConfig

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

the class QuorumTest method testCustomQuorumFunctionFails.

@Test(expected = QuorumException.class)
public void testCustomQuorumFunctionFails() {
    String mapName = randomMapName();
    String quorumName = randomString();
    MapConfig mapConfig = new MapConfig(mapName).setQuorumName(quorumName);
    QuorumConfig quorumConfig = new QuorumConfig().setName(quorumName).setEnabled(true).setQuorumFunctionImplementation(new QuorumFunction() {

        @Override
        public boolean apply(Collection<Member> members) {
            return false;
        }
    });
    Config config = new Config().addQuorumConfig(quorumConfig).addMapConfig(mapConfig);
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    IMap<Object, Object> map = hazelcastInstance.getMap(mapName);
    map.put("1", "1");
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 84 with MapConfig

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

the class MapReadWriteQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 85 with MapConfig

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

the class MapWriteQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setEnabled(true);
    quorumConfig.setType(QuorumType.WRITE);
    quorumConfig.setSize(3);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)182 Config (com.hazelcast.config.Config)125 HazelcastInstance (com.hazelcast.core.HazelcastInstance)78 Test (org.junit.Test)75 QuickTest (com.hazelcast.test.annotation.QuickTest)68 ParallelTest (com.hazelcast.test.annotation.ParallelTest)62 MapStoreConfig (com.hazelcast.config.MapStoreConfig)43 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)41 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)28 NearCacheConfig (com.hazelcast.config.NearCacheConfig)27 MapIndexConfig (com.hazelcast.config.MapIndexConfig)20 QuorumConfig (com.hazelcast.config.QuorumConfig)19 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)18 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 BeforeClass (org.junit.BeforeClass)10 AssertTask (com.hazelcast.test.AssertTask)9