use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class ContainsKeyOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, getPartitionId());
response = store.containsKey(key);
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class EntrySetOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
List<Map.Entry<Object, ReplicatedRecord>> entries = new ArrayList<Map.Entry<Object, ReplicatedRecord>>();
for (ReplicatedRecordStore store : stores) {
entries.addAll(store.entrySet(false));
}
ArrayList<Map.Entry<Data, Data>> dataEntries = new ArrayList<Map.Entry<Data, Data>>(entries.size());
SerializationService serializationService = getNodeEngine().getSerializationService();
for (Map.Entry<Object, ReplicatedRecord> entry : entries) {
Data key = serializationService.toData(entry.getKey());
Data value = serializationService.toData(entry.getValue().getValue());
dataEntries.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(key, value));
}
response = new ReplicatedMapEntries(dataEntries);
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class GetOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, getPartitionId());
ReplicatedRecord record = store.getReplicatedRecord(key);
if (record != null) {
response = record.getValue();
}
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class IsEmptyOperation method run.
@Override
public void run() throws Exception {
ReplicatedMapService service = getService();
Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
for (ReplicatedRecordStore store : stores) {
if (!store.isEmpty()) {
response = false;
return;
}
}
response = true;
}
use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.
the class ReplicatedMapReorderedReplicationTest method testNonConvergingReplicatedMaps.
@Test
public void testNonConvergingReplicatedMaps() throws Exception {
final int nodeCount = 4;
final int keyCount = 10000;
final int threadCount = 2;
updateFactory();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
final Config config = new Config();
final HazelcastInstance[] instances = factory.newInstances(config, nodeCount);
warmUpPartitions(instances);
final int partitionId = randomPartitionOwnedBy(instances[0]).getPartitionId();
final String mapName = randomMapName();
final NodeEngineImpl nodeEngine = getNodeEngineImpl(instances[0]);
final Thread[] threads = new Thread[threadCount];
for (int i = 0; i < threadCount; i++) {
final int startIndex = i;
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
for (int j = startIndex; j < keyCount; j += threadCount) {
put(nodeEngine, mapName, partitionId, j, j);
}
}
});
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
final ReplicatedRecordStore[] stores = new ReplicatedRecordStore[nodeCount];
for (int i = 0; i < nodeCount; i++) {
ReplicatedMapService service = getNodeEngineImpl(instances[i]).getService(ReplicatedMapService.SERVICE_NAME);
service.triggerAntiEntropy();
stores[i] = service.getReplicatedRecordStore(mapName, false, partitionId);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
long version = stores[0].getVersion();
for (ReplicatedRecordStore store : stores) {
assertEquals(version, store.getVersion());
assertFalse(store.isStale(version));
}
}
});
for (int i = 0; i < keyCount; i++) {
for (ReplicatedRecordStore store : stores) {
assertTrue(store.containsKey(i));
}
}
}
Aggregations