use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapPartitionIteratorTest method test_Remove.
@Test
public void test_Remove() 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);
iterator.next();
iterator.remove();
assertEquals(0, proxy.size());
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class DynamicMapConfigTest method isRecordStoreExpirable.
private boolean isRecordStoreExpirable(IMap map) {
MapProxyImpl mapProxy = (MapProxyImpl) map;
MapService mapService = (MapService) mapProxy.getService();
MapServiceContext mapServiceContext = (MapServiceContext) mapService.getMapServiceContext();
PartitionContainer container = mapServiceContext.getPartitionContainer(0);
RecordStore recordStore = container.getExistingRecordStore(map.getName());
return recordStore.isExpirable();
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapRemoveFailingBackupTest method testMapRemoveFailingBackupShouldNotLeadToStaleDataWhenReadBackupIsEnabled.
@Test
public void testMapRemoveFailingBackupShouldNotLeadToStaleDataWhenReadBackupIsEnabled() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final String mapName = randomMapName();
final String key = "2";
final String value = "value2";
Config config = getConfig();
config.getSerializationConfig().addDataSerializableFactory(100, new Factory());
config.setProperty(GroupProperty.PARTITION_BACKUP_SYNC_INTERVAL.getName(), "5");
config.getMapConfig(mapName).setReadBackupData(true);
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
HazelcastInstance hz2 = factory.newHazelcastInstance(config);
final HazelcastInstanceImpl hz1Impl = TestUtil.getHazelcastInstanceImpl(hz1);
final IMap<Object, Object> map1 = hz1.getMap(mapName);
final IMap<Object, Object> map2 = hz2.getMap(mapName);
MapProxyImpl<Object, Object> mock1 = (MapProxyImpl<Object, Object>) spy(map1);
when(mock1.remove(anyString())).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
NodeEngineImpl nodeEngine = hz1Impl.node.nodeEngine;
Object object = invocation.getArguments()[0];
final Data key = nodeEngine.toData(object);
RemoveOperation operation = new RemoveOperation(mapName, key);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operation.setThreadId(ThreadUtil.getThreadId());
OperationService operationService = nodeEngine.getOperationService();
InternalCompletableFuture<Data> f = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).invoke();
Data result = f.get();
return nodeEngine.toObject(result);
}
});
mock1.put(key, value);
mock1.remove(key);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertNull(map1.get(key));
assertNull(map2.get(key));
}
}, 30);
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapPartitionIteratorTest method test_HasNext_Returns_False_On_EmptyPartition.
@Test
public void test_HasNext_Returns_False_On_EmptyPartition() 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);
assertFalse(iterator.hasNext());
}
use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.
the class MapPartitionIteratorTest method test_DoesNotReturn_DuplicateEntry_When_Rehashing_Happens.
@Test
@Ignore
public void test_DoesNotReturn_DuplicateEntry_When_Rehashing_Happens() throws Exception {
HazelcastInstance instance = createHazelcastInstance();
MapProxyImpl<String, String> proxy = (MapProxyImpl<String, String>) instance.<String, String>getMap(randomMapName());
HashSet<String> readKeys = new HashSet<String>();
String value = "initialValue";
putValuesToPartition(instance, proxy, value, 1, 100);
Iterator<Map.Entry<String, String>> iterator = proxy.iterator(10, 1, prefetchValues);
assertUniques(readKeys, iterator, 50);
// force rehashing
putValuesToPartition(instance, proxy, randomString(), 1, 150);
assertUniques(readKeys, iterator);
}
Aggregations