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