Search in sources :

Example 6 with MultiMapResponse

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

the class TransactionalMultiMapProxySupport method lockAndGet.

private MultiMapResponse lockAndGet(Data key, long timeout, long ttl) {
    final NodeEngine nodeEngine = getNodeEngine();
    boolean blockReads = tx.getTransactionType() == TransactionType.ONE_PHASE;
    TxnLockAndGetOperation operation = new TxnLockAndGetOperation(name, key, timeout, ttl, getThreadId(), blockReads);
    try {
        int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
        final OperationService operationService = nodeEngine.getOperationService();
        Future<MultiMapResponse> f = operationService.invokeOnPartition(MultiMapService.SERVICE_NAME, operation, partitionId);
        return f.get();
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) OperationService(com.hazelcast.spi.OperationService)

Example 7 with MultiMapResponse

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

the class MultiMapKeySetMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    List<Data> keys = new ArrayList<Data>();
    for (Object obj : map.values()) {
        if (obj == null) {
            continue;
        }
        MultiMapResponse response = (MultiMapResponse) obj;
        Collection<Data> coll = response.getCollection();
        if (coll != null) {
            keys.addAll(coll);
        }
    }
    return keys;
}
Also used : MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 8 with MultiMapResponse

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

the class MultiMapRemoveMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    MultiMapResponse multiMapResponse = (MultiMapResponse) response;
    Collection<MultiMapRecord> collection = multiMapResponse.getCollection();
    List<Data> resultCollection = new ArrayList<Data>(collection.size());
    for (MultiMapRecord multiMapRecord : collection) {
        resultCollection.add(serializationService.toData(multiMapRecord.getObject()));
    }
    return MultiMapRemoveCodec.encodeResponse(resultCollection);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 9 with MultiMapResponse

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

the class MultiMapGetMessageTask method encodeResponse.

@Override
protected ClientMessage encodeResponse(Object response) {
    List<Data> collection = new ArrayList<Data>();
    Collection<MultiMapRecord> responseCollection = ((MultiMapResponse) response).getCollection();
    if (responseCollection != null) {
        for (MultiMapRecord record : responseCollection) {
            collection.add(serializationService.toData(record.getObject()));
        }
    }
    return MultiMapGetCodec.encodeResponse(collection);
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 10 with MultiMapResponse

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

the class MultiMapValuesMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    List<Data> list = new ArrayList<Data>();
    for (Object obj : map.values()) {
        if (obj == null) {
            continue;
        }
        MultiMapResponse response = (MultiMapResponse) obj;
        Collection<MultiMapRecord> coll = response.getCollection();
        if (coll == null) {
            continue;
        }
        for (MultiMapRecord record : coll) {
            list.add(serializationService.toData(record.getObject()));
        }
    }
    return list;
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapResponse(com.hazelcast.multimap.impl.operations.MultiMapResponse) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

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