Search in sources :

Example 31 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class MultiMapPartitionContainer method clearLockStore.

private void clearLockStore(String name) {
    NodeEngine nodeEngine = service.getNodeEngine();
    LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
    if (lockService != null) {
        DefaultObjectNamespace namespace = new DefaultObjectNamespace(MultiMapService.SERVICE_NAME, name);
        lockService.clearLockStore(partitionId, namespace);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) DefaultObjectNamespace(com.hazelcast.spi.DefaultObjectNamespace) LockService(com.hazelcast.concurrent.lock.LockService)

Example 32 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class MultiMapProxySupport method keySetInternal.

protected Set<Data> keySetInternal() {
    final NodeEngine nodeEngine = getNodeEngine();
    try {
        Map<Integer, Object> results = nodeEngine.getOperationService().invokeOnAllPartitions(MultiMapService.SERVICE_NAME, new MultiMapOperationFactory(name, OperationFactoryType.KEY_SET));
        Set<Data> keySet = new HashSet<Data>();
        for (Object result : results.values()) {
            if (result == null) {
                continue;
            }
            MultiMapResponse response = nodeEngine.toObject(result);
            if (response.getCollection() != null) {
                keySet.addAll(response.getCollection());
            }
        }
        return keySet;
    } catch (Throwable throwable) {
        throw ExceptionUtil.rethrow(throwable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MultiMapOperationFactory(com.hazelcast.multimap.impl.operations.MultiMapOperationFactory) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) Data(com.hazelcast.nio.serialization.Data) HashSet(java.util.HashSet)

Example 33 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class MultiMapProxySupport method invoke.

private <T> T invoke(Operation operation, Data dataKey) {
    final NodeEngine nodeEngine = getNodeEngine();
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(dataKey);
        Future f;
        Object o;
        if (config.isStatisticsEnabled()) {
            long time = System.currentTimeMillis();
            f = nodeEngine.getOperationService().invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
            o = f.get();
            if (operation instanceof PutOperation) {
                //TODO @ali should we remove statics from operations ?
                getService().getLocalMultiMapStatsImpl(name).incrementPuts(System.currentTimeMillis() - time);
            } else if (operation instanceof RemoveOperation || operation instanceof RemoveAllOperation) {
                getService().getLocalMultiMapStatsImpl(name).incrementRemoves(System.currentTimeMillis() - time);
            } else if (operation instanceof GetAllOperation) {
                getService().getLocalMultiMapStatsImpl(name).incrementGets(System.currentTimeMillis() - time);
            }
        } else {
            f = nodeEngine.getOperationService().invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
            o = f.get();
        }
        return nodeEngine.toObject(o);
    } catch (Throwable throwable) {
        throw ExceptionUtil.rethrow(throwable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) RemoveAllOperation(com.hazelcast.multimap.impl.operations.RemoveAllOperation) PutOperation(com.hazelcast.multimap.impl.operations.PutOperation) GetAllOperation(com.hazelcast.multimap.impl.operations.GetAllOperation) Future(java.util.concurrent.Future) RemoveOperation(com.hazelcast.multimap.impl.operations.RemoveOperation) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject)

Example 34 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class ObjectMultiMapProxy method containsKey.

@Override
public boolean containsKey(K key) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    final NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    return containsInternal(dataKey, null);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Data(com.hazelcast.nio.serialization.Data)

Example 35 with NodeEngine

use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.

the class ObjectMultiMapProxy method entrySet.

@Override
public Set<Map.Entry<K, V>> entrySet() {
    final NodeEngine nodeEngine = getNodeEngine();
    Map map = entrySetInternal();
    Set<Map.Entry<K, V>> entrySet = new HashSet<Map.Entry<K, V>>();
    for (Object obj : map.values()) {
        if (obj == null) {
            continue;
        }
        EntrySetResponse response = nodeEngine.toObject(obj);
        Set<Map.Entry<K, V>> entries = response.getObjectEntrySet(nodeEngine);
        entrySet.addAll(entries);
    }
    return entrySet;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InitializingObject(com.hazelcast.spi.InitializingObject) EntrySetResponse(com.hazelcast.multimap.impl.operations.EntrySetResponse) MultiMap(com.hazelcast.core.MultiMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)157 Data (com.hazelcast.nio.serialization.Data)50 OperationService (com.hazelcast.spi.OperationService)30 Address (com.hazelcast.nio.Address)20 ILogger (com.hazelcast.logging.ILogger)14 Operation (com.hazelcast.spi.Operation)14 Member (com.hazelcast.core.Member)12 Future (java.util.concurrent.Future)12 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)11 IPartitionService (com.hazelcast.spi.partition.IPartitionService)11 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)10 Test (org.junit.Test)10 InitializingObject (com.hazelcast.spi.InitializingObject)9 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)7 Config (com.hazelcast.config.Config)6 ArrayList (java.util.ArrayList)6