use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MergePolicySerializationTest method testIssue2665.
@Test
public void testIssue2665() {
String name = randomString();
String serviceName = "hz:impl:mapService";
HazelcastInstance instance = createHazelcastInstance(getConfig());
IMap<String, MyObject> map = instance.getMap(name);
MyObject myObjectExisting = new MyObject();
map.put("key", myObjectExisting);
NodeEngineImpl nodeEngine = HazelcastTestSupport.getNode(instance).getNodeEngine();
MapService mapService = nodeEngine.getService(serviceName);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
int partitionId = nodeEngine.getPartitionService().getPartitionId("key");
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(partitionId, name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PutIfAbsentMapMergePolicy.class.getName());
EntryView<String, MyObject> mergingEntryView = new SimpleEntryView<String, MyObject>("key", new MyObject());
recordStore.merge(dataKey, mergingEntryView, mergePolicy);
int deSerializedCount = MyObject.deserializedCount;
assertEquals(0, deSerializedCount);
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMergePolicyQuickTest method testLatestUpdateMapMergePolicy.
@Test
public void testLatestUpdateMapMergePolicy() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
String name = randomString();
IMap<String, String> map = instance.getMap(name);
MapServiceContext mapServiceContext = getMapServiceContext(instance);
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(LatestUpdateMapMergePolicy.class.getName());
long now = Clock.currentTimeMillis();
SimpleEntryView<String, String> initialEntry = new SimpleEntryView<String, String>("key", "value1");
initialEntry.setCreationTime(now);
initialEntry.setLastUpdateTime(now);
// need some latency to be sure that target members time is greater than now
sleepMillis(100);
recordStore.merge(dataKey, initialEntry, mergePolicy);
SimpleEntryView<String, String> mergingEntry = new SimpleEntryView<String, String>("key", "value2");
now = Clock.currentTimeMillis();
mergingEntry.setCreationTime(now);
mergingEntry.setLastUpdateTime(now);
recordStore.merge(dataKey, mergingEntry, mergePolicy);
assertEquals("value2", map.get("key"));
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapMergePolicyQuickTest method testPassThroughMapMergePolicy.
@Test
public void testPassThroughMapMergePolicy() {
HazelcastInstance instance = createHazelcastInstance(getConfig());
String name = randomString();
IMap<String, String> map = instance.getMap(name);
MapServiceContext mapServiceContext = getMapServiceContext(instance);
Data dataKey = mapServiceContext.toData("key");
RecordStore recordStore = mapServiceContext.getRecordStore(getPartitionId(instance, "key"), name);
MapMergePolicy mergePolicy = mapServiceContext.getMergePolicyProvider().getMergePolicy(PassThroughMergePolicy.class.getName());
SimpleEntryView<String, String> initialEntry = new SimpleEntryView<String, String>("key", "value1");
recordStore.merge(dataKey, initialEntry, mergePolicy);
SimpleEntryView<String, String> mergingEntry = new SimpleEntryView<String, String>("key", "value2");
recordStore.merge(dataKey, mergingEntry, mergePolicy);
assertEquals("value2", map.get("key"));
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class MapDestroyTest method assertAllPartitionContainersAreEmpty.
private void assertAllPartitionContainersAreEmpty(HazelcastInstance instance) {
MapServiceContext context = getMapServiceContext(instance);
int partitionCount = getPartitionCount(instance);
for (int i = 0; i < partitionCount; i++) {
PartitionContainer container = context.getPartitionContainer(i);
ConcurrentMap<String, RecordStore> maps = container.getMaps();
assertTrue(maps.isEmpty());
}
}
use of com.hazelcast.map.impl.recordstore.RecordStore in project hazelcast by hazelcast.
the class WriteBehindOnBackupsTest method writeBehindQueueSize.
public static int writeBehindQueueSize(HazelcastInstance node, String mapName) {
int size = 0;
final NodeEngineImpl nodeEngine = getNode(node).getNodeEngine();
MapService mapService = nodeEngine.getService(MapService.SERVICE_NAME);
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
for (int i = 0; i < partitionCount; i++) {
final RecordStore recordStore = mapServiceContext.getExistingRecordStore(i, mapName);
if (recordStore == null) {
continue;
}
final MapDataStore mapDataStore = recordStore.getMapDataStore();
if (mapDataStore instanceof WriteBehindStore) {
size += ((WriteBehindStore) mapDataStore).getWriteBehindQueue().size();
}
}
return size;
}
Aggregations