Search in sources :

Example 1 with TxnReserveOfferOperation

use of com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation in project hazelcast by hazelcast.

the class QueueDataSerializerHook method createFactory.

public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[TXN_COMMIT_BACKUP + 1];
    constructors[OFFER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new OfferOperation();
        }
    };
    constructors[OFFER_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new OfferBackupOperation();
        }
    };
    constructors[POLL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new PollOperation();
        }
    };
    constructors[POLL_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new PollBackupOperation();
        }
    };
    constructors[PEEK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new PeekOperation();
        }
    };
    constructors[ADD_ALL_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new AddAllBackupOperation();
        }
    };
    constructors[ADD_ALL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new AddAllOperation();
        }
    };
    constructors[CLEAR_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ClearBackupOperation();
        }
    };
    constructors[CLEAR] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ClearOperation();
        }
    };
    constructors[COMPARE_AND_REMOVE_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new CompareAndRemoveBackupOperation();
        }
    };
    constructors[COMPARE_AND_REMOVE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new CompareAndRemoveOperation();
        }
    };
    constructors[CONTAINS] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ContainsOperation();
        }
    };
    constructors[DRAIN_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new DrainBackupOperation();
        }
    };
    constructors[DRAIN] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new DrainOperation();
        }
    };
    constructors[ITERATOR] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new IteratorOperation();
        }
    };
    constructors[QUEUE_EVENT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueEvent();
        }
    };
    constructors[QUEUE_EVENT_FILTER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueEventFilter();
        }
    };
    constructors[QUEUE_ITEM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueItem();
        }
    };
    constructors[QUEUE_REPLICATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueReplicationOperation();
        }
    };
    constructors[REMOVE_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RemoveBackupOperation();
        }
    };
    constructors[REMOVE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RemoveOperation();
        }
    };
    constructors[SIZE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new SizeOperation();
        }
    };
    constructors[TXN_OFFER_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnOfferBackupOperation();
        }
    };
    constructors[TXN_OFFER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnOfferOperation();
        }
    };
    constructors[TXN_POLL_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnPollBackupOperation();
        }
    };
    constructors[TXN_POLL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnPollOperation();
        }
    };
    constructors[TXN_PREPARE_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnPrepareBackupOperation();
        }
    };
    constructors[TXN_PREPARE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnPrepareOperation();
        }
    };
    constructors[TXN_RESERVE_OFFER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnReserveOfferOperation();
        }
    };
    constructors[TXN_RESERVE_OFFER_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnReserveOfferBackupOperation();
        }
    };
    constructors[TXN_RESERVE_POLL] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnReservePollOperation();
        }
    };
    constructors[TXN_RESERVE_POLL_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnReservePollBackupOperation();
        }
    };
    constructors[TXN_ROLLBACK_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnRollbackBackupOperation();
        }
    };
    constructors[TXN_ROLLBACK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnRollbackOperation();
        }
    };
    constructors[CHECK_EVICT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new CheckAndEvictOperation();
        }
    };
    constructors[QUEUE_CONTAINER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueContainer(null);
        }
    };
    constructors[TRANSACTION_ROLLBACK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueTransactionRollbackOperation();
        }
    };
    constructors[TX_QUEUE_ITEM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxQueueItem();
        }
    };
    constructors[TXN_PEEK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnPeekOperation();
        }
    };
    constructors[IS_EMPTY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new IsEmptyOperation();
        }
    };
    constructors[REMAINING_CAPACITY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RemainingCapacityOperation();
        }
    };
    constructors[TXN_COMMIT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnCommitOperation();
        }
    };
    constructors[TXN_COMMIT_BACKUP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new TxnCommitBackupOperation();
        }
    };
    return new ArrayDataSerializableFactory(constructors);
}
Also used : TxnPollBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPollBackupOperation) TxnReservePollBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReservePollBackupOperation) PollBackupOperation(com.hazelcast.collection.impl.queue.operations.PollBackupOperation) ClearBackupOperation(com.hazelcast.collection.impl.queue.operations.ClearBackupOperation) DrainOperation(com.hazelcast.collection.impl.queue.operations.DrainOperation) IteratorOperation(com.hazelcast.collection.impl.queue.operations.IteratorOperation) CompareAndRemoveBackupOperation(com.hazelcast.collection.impl.queue.operations.CompareAndRemoveBackupOperation) TxnReservePollOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReservePollOperation) TxnCommitOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnCommitOperation) TxnPrepareOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPrepareOperation) TxnReserveOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem) TxnOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnOfferOperation) SizeOperation(com.hazelcast.collection.impl.queue.operations.SizeOperation) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) TxnRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnRollbackOperation) ContainsOperation(com.hazelcast.collection.impl.queue.operations.ContainsOperation) TxnPeekOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPeekOperation) CompareAndRemoveOperation(com.hazelcast.collection.impl.queue.operations.CompareAndRemoveOperation) RemoveOperation(com.hazelcast.collection.impl.queue.operations.RemoveOperation) CompareAndRemoveOperation(com.hazelcast.collection.impl.queue.operations.CompareAndRemoveOperation) TxnPeekOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPeekOperation) PeekOperation(com.hazelcast.collection.impl.queue.operations.PeekOperation) PollOperation(com.hazelcast.collection.impl.queue.operations.PollOperation) TxnReservePollOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReservePollOperation) TxnPollOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPollOperation) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem) TxnRollbackBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnRollbackBackupOperation) RemoveBackupOperation(com.hazelcast.collection.impl.queue.operations.RemoveBackupOperation) CompareAndRemoveBackupOperation(com.hazelcast.collection.impl.queue.operations.CompareAndRemoveBackupOperation) RemainingCapacityOperation(com.hazelcast.collection.impl.queue.operations.RemainingCapacityOperation) TxnPollOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPollOperation) TxnReserveOfferBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferBackupOperation) TxnOfferBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnOfferBackupOperation) OfferBackupOperation(com.hazelcast.collection.impl.queue.operations.OfferBackupOperation) AddAllOperation(com.hazelcast.collection.impl.queue.operations.AddAllOperation) QueueReplicationOperation(com.hazelcast.collection.impl.queue.operations.QueueReplicationOperation) TxnPrepareBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPrepareBackupOperation) AddAllBackupOperation(com.hazelcast.collection.impl.queue.operations.AddAllBackupOperation) IsEmptyOperation(com.hazelcast.collection.impl.queue.operations.IsEmptyOperation) TxnPollBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnPollBackupOperation) TxnReserveOfferBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferBackupOperation) TxnReservePollBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReservePollBackupOperation) CheckAndEvictOperation(com.hazelcast.collection.impl.queue.operations.CheckAndEvictOperation) TxnReserveOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation) TxnOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnOfferOperation) OfferOperation(com.hazelcast.collection.impl.queue.operations.OfferOperation) TxnOfferBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnOfferBackupOperation) ClearOperation(com.hazelcast.collection.impl.queue.operations.ClearOperation) ConstructorFunction(com.hazelcast.util.ConstructorFunction) QueueTransactionRollbackOperation(com.hazelcast.collection.impl.txnqueue.operations.QueueTransactionRollbackOperation) TxnCommitBackupOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnCommitBackupOperation) DrainBackupOperation(com.hazelcast.collection.impl.queue.operations.DrainBackupOperation) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)

Example 2 with TxnReserveOfferOperation

use of com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation in project hazelcast by hazelcast.

the class TransactionalQueueProxySupport method offerInternal.

public boolean offerInternal(Data data, long timeout) {
    TxnReserveOfferOperation operation = new TxnReserveOfferOperation(name, timeout, offeredQueue.size(), tx.getTxnId());
    operation.setCallerUuid(tx.getOwnerUuid());
    try {
        Future<Long> f = invoke(operation);
        Long itemId = f.get();
        if (itemId != null) {
            if (!itemIdSet.add(itemId)) {
                throw new TransactionException("Duplicate itemId: " + itemId);
            }
            offeredQueue.offer(new QueueItem(null, itemId, data));
            TxnOfferOperation txnOfferOperation = new TxnOfferOperation(name, itemId, data);
            putToRecord(txnOfferOperation);
            return true;
        }
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
    return false;
}
Also used : TransactionException(com.hazelcast.transaction.TransactionException) TxnReserveOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation) QueueItem(com.hazelcast.collection.impl.queue.QueueItem) TxnOfferOperation(com.hazelcast.collection.impl.txnqueue.operations.TxnOfferOperation)

Aggregations

TxnOfferOperation (com.hazelcast.collection.impl.txnqueue.operations.TxnOfferOperation)2 TxnReserveOfferOperation (com.hazelcast.collection.impl.txnqueue.operations.TxnReserveOfferOperation)2 QueueItem (com.hazelcast.collection.impl.queue.QueueItem)1 AddAllBackupOperation (com.hazelcast.collection.impl.queue.operations.AddAllBackupOperation)1 AddAllOperation (com.hazelcast.collection.impl.queue.operations.AddAllOperation)1 CheckAndEvictOperation (com.hazelcast.collection.impl.queue.operations.CheckAndEvictOperation)1 ClearBackupOperation (com.hazelcast.collection.impl.queue.operations.ClearBackupOperation)1 ClearOperation (com.hazelcast.collection.impl.queue.operations.ClearOperation)1 CompareAndRemoveBackupOperation (com.hazelcast.collection.impl.queue.operations.CompareAndRemoveBackupOperation)1 CompareAndRemoveOperation (com.hazelcast.collection.impl.queue.operations.CompareAndRemoveOperation)1 ContainsOperation (com.hazelcast.collection.impl.queue.operations.ContainsOperation)1 DrainBackupOperation (com.hazelcast.collection.impl.queue.operations.DrainBackupOperation)1 DrainOperation (com.hazelcast.collection.impl.queue.operations.DrainOperation)1 IsEmptyOperation (com.hazelcast.collection.impl.queue.operations.IsEmptyOperation)1 IteratorOperation (com.hazelcast.collection.impl.queue.operations.IteratorOperation)1 OfferBackupOperation (com.hazelcast.collection.impl.queue.operations.OfferBackupOperation)1 OfferOperation (com.hazelcast.collection.impl.queue.operations.OfferOperation)1 PeekOperation (com.hazelcast.collection.impl.queue.operations.PeekOperation)1 PollBackupOperation (com.hazelcast.collection.impl.queue.operations.PollBackupOperation)1 PollOperation (com.hazelcast.collection.impl.queue.operations.PollOperation)1