Search in sources :

Example 11 with MultiMapResponse

use of com.hazelcast.multimap.impl.operations.MultiMapResponse in project hazelcast by hazelcast.

the class ObjectMultiMapProxy method get.

@Override
public Collection<V> get(K key) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    final NodeEngine nodeEngine = getNodeEngine();
    Data dataKey = nodeEngine.toData(key);
    MultiMapResponse result = getAllInternal(dataKey);
    return result.getObjectCollection(nodeEngine);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) Data(com.hazelcast.nio.serialization.Data)

Example 12 with MultiMapResponse

use of com.hazelcast.multimap.impl.operations.MultiMapResponse in project hazelcast by hazelcast.

the class ObjectMultiMapProxy method values.

@Override
public Collection<V> values() {
    final NodeEngine nodeEngine = getNodeEngine();
    Map map = valuesInternal();
    Collection values = new LinkedList();
    for (Object obj : map.values()) {
        if (obj == null) {
            continue;
        }
        MultiMapResponse response = nodeEngine.toObject(obj);
        values.addAll(response.getObjectCollection(nodeEngine));
    }
    return values;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) Collection(java.util.Collection) InitializingObject(com.hazelcast.spi.InitializingObject) MultiMap(com.hazelcast.core.MultiMap) Map(java.util.Map) LinkedList(java.util.LinkedList)

Example 13 with MultiMapResponse

use of com.hazelcast.multimap.impl.operations.MultiMapResponse in project hazelcast by hazelcast.

the class TransactionalMultiMapProxySupport method getInternal.

protected Collection<MultiMapRecord> getInternal(Data key) {
    checkObjectNotNull(key);
    Collection<MultiMapRecord> coll = txMap.get(key);
    if (coll == null) {
        GetAllOperation operation = new GetAllOperation(name, key);
        operation.setThreadId(ThreadUtil.getThreadId());
        try {
            int partitionId = getNodeEngine().getPartitionService().getPartitionId(key);
            final OperationService operationService = getNodeEngine().getOperationService();
            Future<MultiMapResponse> f = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
            MultiMapResponse response = f.get();
            coll = response.getRecordCollection(getNodeEngine());
        } catch (Throwable t) {
            throw ExceptionUtil.rethrow(t);
        }
    }
    return coll;
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) GetAllOperation(com.hazelcast.multimap.impl.operations.GetAllOperation) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) OperationService(com.hazelcast.spi.OperationService)

Example 14 with MultiMapResponse

use of com.hazelcast.multimap.impl.operations.MultiMapResponse in project hazelcast by hazelcast.

the class TxnLockAndGetOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    if (!container.txnLock(dataKey, getCallerUuid(), threadId, getCallId(), ttl, blockReads)) {
        throw new TransactionException("Transaction couldn't obtain lock!");
    }
    MultiMapValue multiMapValue = getMultiMapValueOrNull();
    boolean isLocal = executedLocally();
    Collection<MultiMapRecord> collection = multiMapValue == null ? null : multiMapValue.getCollection(isLocal);
    MultiMapResponse multiMapResponse = new MultiMapResponse(collection, getValueCollectionType(container));
    multiMapResponse.setNextRecordId(container.nextId());
    response = multiMapResponse;
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) TransactionException(com.hazelcast.transaction.TransactionException) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse)

Aggregations

MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)14 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)8 Data (com.hazelcast.nio.serialization.Data)6 NodeEngine (com.hazelcast.spi.NodeEngine)4 ArrayList (java.util.ArrayList)4 ConcurrentModificationException (java.util.ConcurrentModificationException)3 GetAllOperation (com.hazelcast.multimap.impl.operations.GetAllOperation)2 MultiMapOperationFactory (com.hazelcast.multimap.impl.operations.MultiMapOperationFactory)2 MultiMap (com.hazelcast.core.MultiMap)1 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)1 MultiMapValue (com.hazelcast.multimap.impl.MultiMapValue)1 ClearBackupOperation (com.hazelcast.multimap.impl.operations.ClearBackupOperation)1 ClearOperation (com.hazelcast.multimap.impl.operations.ClearOperation)1 ContainsEntryOperation (com.hazelcast.multimap.impl.operations.ContainsEntryOperation)1 CountOperation (com.hazelcast.multimap.impl.operations.CountOperation)1 EntrySetOperation (com.hazelcast.multimap.impl.operations.EntrySetOperation)1 EntrySetResponse (com.hazelcast.multimap.impl.operations.EntrySetResponse)1 KeySetOperation (com.hazelcast.multimap.impl.operations.KeySetOperation)1 MultiMapMigrationOperation (com.hazelcast.multimap.impl.operations.MultiMapMigrationOperation)1