use of com.hazelcast.multimap.impl.MultiMapService in project hazelcast by hazelcast.
the class AbstractMultiMapAddEntryListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
final MultiMapService service = getService(MultiMapService.SERVICE_NAME);
EntryAdapter listener = new MultiMapListener();
final String name = getDistributedObjectName();
Data key = getKey();
boolean includeValue = shouldIncludeValue();
if (isLocalOnly()) {
return newCompletedFuture(service.addLocalListener(name, listener, key, includeValue));
}
return service.addListenerAsync(name, listener, key, includeValue);
}
use of com.hazelcast.multimap.impl.MultiMapService in project hazelcast by hazelcast.
the class MultiMapClearMessageTask method reduce.
@Override
protected Object reduce(Map<Integer, Object> map) {
int totalAffectedEntries = 0;
for (Object affectedEntries : map.values()) {
totalAffectedEntries += (Integer) affectedEntries;
}
updateStats(LocalMapStatsImpl::incrementOtherOperations);
final MultiMapService service = getService(MultiMapService.SERVICE_NAME);
service.publishMultiMapEvent(parameters, EntryEventType.CLEAR_ALL, totalAffectedEntries);
return null;
}
use of com.hazelcast.multimap.impl.MultiMapService in project hazelcast by hazelcast.
the class MultiMapTestUtil method getBackupMultiMap.
/**
* Returns all backup entries of an {@link MultiMap} by a given map name.
* <p>
* Note: This method returns all backups from all nodes and doesn't consider the replica indexes.
*
* @param instances the {@link HazelcastInstance} array to gather the data from
* @param multiMapName the MultiMap name
* @param <K> type of the key
* @param <V> type of the value
* @return a {@link Map} with the backup entries
*/
public static <K, V> Map<K, Collection<V>> getBackupMultiMap(HazelcastInstance[] instances, String multiMapName) {
Map<K, Collection<V>> map = new HashMap<K, Collection<V>>();
for (HazelcastInstance instance : instances) {
NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
MultiMapService mapService = nodeEngine.getService(MultiMapService.SERVICE_NAME);
InternalPartitionService partitionService = nodeEngine.getPartitionService();
SerializationService serializationService = nodeEngine.getSerializationService();
for (int partitionId = 0; partitionId < partitionService.getPartitionCount(); partitionId++) {
if (partitionService.isPartitionOwner(partitionId)) {
continue;
}
MultiMapPartitionContainer partitionContainer = mapService.getPartitionContainer(partitionId);
MultiMapContainer multiMapContainer = partitionContainer.getMultiMapContainer(multiMapName, false);
if (multiMapContainer == null) {
continue;
}
for (Map.Entry<Data, MultiMapValue> entry : multiMapContainer.getMultiMapValues().entrySet()) {
K key = serializationService.toObject(entry.getKey());
Collection<MultiMapRecord> collection = entry.getValue().getCollection(false);
Collection<V> values = new ArrayList<V>(collection.size());
for (MultiMapRecord record : collection) {
V value = serializationService.toObject(record.getObject());
values.add(value);
}
map.put(key, values);
}
}
}
return map;
}
use of com.hazelcast.multimap.impl.MultiMapService in project hazelcast by hazelcast.
the class MultiMapContainerStatisticsTest method getMultiMapContainer.
private static MultiMapContainer getMultiMapContainer(HazelcastInstance hz, String key) {
NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
MultiMapService mapService = nodeEngine.getService(MultiMapService.SERVICE_NAME);
Data dataKey = nodeEngine.getSerializationService().toData(key);
int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey);
return mapService.getOrCreateCollectionContainerWithoutAccess(partitionId, MULTI_MAP_NAME);
}
Aggregations