Search in sources :

Example 11 with MultiMapContainer

use of com.hazelcast.multimap.impl.MultiMapContainer in project hazelcast by hazelcast.

the class RemoveAllOperation method onWaitExpire.

@Override
public void onWaitExpire() {
    MultiMapContainer container = getOrCreateContainer();
    MultiMapConfig.ValueCollectionType valueCollectionType = getValueCollectionType(container);
    sendResponse(new MultiMapResponse(null, valueCollectionType));
}
Also used : MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer) MultiMapConfig(com.hazelcast.config.MultiMapConfig)

Example 12 with MultiMapContainer

use of com.hazelcast.multimap.impl.MultiMapContainer in project hazelcast by hazelcast.

the class TxnRemoveAllBackupOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
    response = true;
    for (Long recordId : recordIds) {
        if (!multiMapValue.containsRecordId(recordId)) {
            response = false;
            return;
        }
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    for (Long recordId : recordIds) {
        Iterator<MultiMapRecord> iter = coll.iterator();
        while (iter.hasNext()) {
            MultiMapRecord record = iter.next();
            if (record.getRecordId() == recordId) {
                iter.remove();
                break;
            }
        }
    }
    if (coll.isEmpty()) {
        delete();
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 13 with MultiMapContainer

use of com.hazelcast.multimap.impl.MultiMapContainer in project hazelcast by hazelcast.

the class TxnRemoveAllOperation method run.

@Override
public void run() throws Exception {
    begin = Clock.currentTimeMillis();
    MultiMapContainer container = getOrCreateContainer();
    MultiMapValue multiMapValue = container.getOrCreateMultiMapValue(dataKey);
    response = true;
    for (Long recordId : recordIds) {
        if (!multiMapValue.containsRecordId(recordId)) {
            response = false;
            return;
        }
    }
    Collection<MultiMapRecord> coll = multiMapValue.getCollection(false);
    removed = new LinkedList<MultiMapRecord>();
    for (Long recordId : recordIds) {
        Iterator<MultiMapRecord> iter = coll.iterator();
        while (iter.hasNext()) {
            MultiMapRecord record = iter.next();
            if (record.getRecordId() == recordId) {
                iter.remove();
                removed.add(record);
                break;
            }
        }
    }
    if (coll.isEmpty()) {
        delete();
    }
}
Also used : MultiMapRecord(com.hazelcast.multimap.impl.MultiMapRecord) MultiMapValue(com.hazelcast.multimap.impl.MultiMapValue) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Example 14 with MultiMapContainer

use of com.hazelcast.multimap.impl.MultiMapContainer 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)

Example 15 with MultiMapContainer

use of com.hazelcast.multimap.impl.MultiMapContainer in project hazelcast by hazelcast.

the class TxnPrepareOperation method run.

@Override
public void run() throws Exception {
    MultiMapContainer container = getOrCreateContainer();
    if (!container.extendLock(dataKey, getCallerUuid(), threadId, LOCK_EXTENSION_TIME_IN_MILLIS)) {
        throw new TransactionException("Lock is not owned by the transaction! -> " + container.getLockOwnerInfo(dataKey));
    }
    response = true;
}
Also used : TransactionException(com.hazelcast.transaction.TransactionException) MultiMapContainer(com.hazelcast.multimap.impl.MultiMapContainer)

Aggregations

MultiMapContainer (com.hazelcast.multimap.impl.MultiMapContainer)21 MultiMapValue (com.hazelcast.multimap.impl.MultiMapValue)9 MultiMapRecord (com.hazelcast.multimap.impl.MultiMapRecord)8 TransactionException (com.hazelcast.transaction.TransactionException)2 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 MultiMapResponse (com.hazelcast.multimap.impl.operations.MultiMapResponse)1 Collection (java.util.Collection)1 List (java.util.List)1