Search in sources :

Example 16 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapPartitionIteratorTest method test_remove_Throws_Exception_When_Called_Without_Next.

@Test(expected = IllegalStateException.class)
public void test_remove_Throws_Exception_When_Called_Without_Next() throws Exception {
    HazelcastInstance instance = createHazelcastInstance();
    MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
    Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
    iterator.remove();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapPartitionIteratorTest method test_Next_Returns_Values_When_FetchSizeExceeds_On_NonEmptyPartition.

@Test
public void test_Next_Returns_Values_When_FetchSizeExceeds_On_NonEmptyPartition() throws Exception {
    HazelcastInstance instance = createHazelcastInstance();
    MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
    String value = randomString();
    for (int i = 0; i < 100; i++) {
        String key = generateKeyForPartition(instance, 1);
        proxy.put(key, value);
    }
    Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
    for (int i = 0; i < 100; i++) {
        Map.Entry entry = iterator.next();
        assertEquals(value, entry.getValue());
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 18 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapPartitionIteratorTest method test_DoesNotReturn_DuplicateEntry_When_Migration_Happens.

@Test
@Ignore
public void test_DoesNotReturn_DuplicateEntry_When_Migration_Happens() throws Exception {
    Config config = getConfig();
    config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "2");
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    MapProxyImpl<String, String> proxy = (MapProxyImpl<String, String>) instance.<String, String>getMap(randomMapName());
    HashSet<String> readKeysP1 = new HashSet<String>();
    HashSet<String> readKeysP2 = new HashSet<String>();
    String value = "value";
    putValuesToPartition(instance, proxy, value, 0, 100);
    putValuesToPartition(instance, proxy, value, 1, 100);
    Iterator<Map.Entry<String, String>> iteratorP1 = proxy.iterator(10, 0, prefetchValues);
    Iterator<Map.Entry<String, String>> iteratorP2 = proxy.iterator(10, 1, prefetchValues);
    assertUniques(readKeysP1, iteratorP1, 50);
    assertUniques(readKeysP2, iteratorP2, 50);
    // force migration
    factory.newHazelcastInstance(config);
    // force rehashing
    putValuesToPartition(instance, proxy, randomString(), 0, 150);
    putValuesToPartition(instance, proxy, randomString(), 1, 150);
    assertUniques(readKeysP1, iteratorP1);
    assertUniques(readKeysP2, iteratorP2);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HashSet(java.util.HashSet) Ignore(org.junit.Ignore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 19 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapPartitionIteratorTest method test_Next_Returns_Value_On_NonEmptyPartition.

@Test
public void test_Next_Returns_Value_On_NonEmptyPartition() throws Exception {
    HazelcastInstance instance = createHazelcastInstance();
    MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
    String key = generateKeyForPartition(instance, 1);
    String value = randomString();
    proxy.put(key, value);
    Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
    Map.Entry entry = iterator.next();
    assertEquals(value, entry.getValue());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapPartitionIteratorTest method test_Next_Returns_Value_On_NonEmptyPartition_and_HasNext_Returns_False_when_Item_Consumed.

@Test
public void test_Next_Returns_Value_On_NonEmptyPartition_and_HasNext_Returns_False_when_Item_Consumed() throws Exception {
    HazelcastInstance instance = createHazelcastInstance();
    MapProxyImpl<Object, Object> proxy = (MapProxyImpl<Object, Object>) instance.getMap(randomMapName());
    String key = generateKeyForPartition(instance, 1);
    String value = randomString();
    proxy.put(key, value);
    Iterator<Map.Entry<Object, Object>> iterator = proxy.iterator(10, 1, prefetchValues);
    Map.Entry entry = iterator.next();
    assertEquals(value, entry.getValue());
    boolean hasNext = iterator.hasNext();
    assertFalse(hasNext);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)24 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 ParallelTest (com.hazelcast.test.annotation.ParallelTest)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 MapService (com.hazelcast.map.impl.MapService)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)7 Config (com.hazelcast.config.Config)3 DistributedObject (com.hazelcast.core.DistributedObject)3 MapContainer (com.hazelcast.map.impl.MapContainer)3 Map (java.util.Map)3 MapConfig (com.hazelcast.config.MapConfig)2 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)2 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)2 Address (com.hazelcast.nio.Address)2 NodeEngine (com.hazelcast.spi.NodeEngine)2 IPartitionService (com.hazelcast.spi.partition.IPartitionService)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 HashSet (java.util.HashSet)2 Ignore (org.junit.Ignore)2