use of com.hazelcast.multimap.impl.MultiMapRecord 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;
}
use of com.hazelcast.multimap.impl.MultiMapRecord 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;
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class RemoveBackupOperation method run.
@Override
public void run() throws Exception {
MultiMapValue multiMapValue = getMultiMapValueOrNull();
response = false;
if (multiMapValue == null) {
return;
}
Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
Iterator<MultiMapRecord> iter = coll.iterator();
while (iter.hasNext()) {
if (iter.next().getRecordId() == recordId) {
iter.remove();
response = true;
if (coll.isEmpty()) {
delete();
}
break;
}
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class RemoveOperation method run.
@Override
public void run() throws Exception {
response = false;
MultiMapValue multiMapValue = getMultiMapValueOrNull();
if (multiMapValue == null) {
return;
}
Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
MultiMapRecord record = new MultiMapRecord(isBinary() ? value : toObject(value));
Iterator<MultiMapRecord> iter = coll.iterator();
while (iter.hasNext()) {
MultiMapRecord r = iter.next();
if (r.equals(record)) {
iter.remove();
recordId = r.getRecordId();
response = true;
if (coll.isEmpty()) {
delete();
}
break;
}
}
}
use of com.hazelcast.multimap.impl.MultiMapRecord in project hazelcast by hazelcast.
the class TransactionalMultiMapProxy method get.
@Override
public Collection<V> get(K key) {
checkTransactionActive();
Data dataKey = getNodeEngine().toData(key);
Collection<MultiMapRecord> coll = getInternal(dataKey);
Collection<V> collection = new ArrayList<V>(coll.size());
for (MultiMapRecord record : coll) {
collection.add((V) toObjectIfNeeded(record.getObject()));
}
return collection;
}
Aggregations