Search in sources :

Example 1 with ListContainer

use of com.hazelcast.collection.impl.list.ListContainer in project hazelcast by hazelcast.

the class CollectionDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[QUEUE_TRANSACTION_LOG_RECORD + 1];
    constructors[COLLECTION_ADD] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public IdentifiedDataSerializable createNew(Integer arg) {
            return new QueueTransactionLogRecord();
        }
    };
    return new ArrayDataSerializableFactory(constructors);
}
Also used : CollectionAddAllBackupOperation(com.hazelcast.collection.impl.collection.operations.CollectionAddAllBackupOperation) ListAddAllOperation(com.hazelcast.collection.impl.list.operations.ListAddAllOperation) CollectionTransactionLogRecord(com.hazelcast.collection.impl.txncollection.CollectionTransactionLogRecord) CollectionReserveAddOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionReserveAddOperation) ListSetBackupOperation(com.hazelcast.collection.impl.list.operations.ListSetBackupOperation) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) CollectionClearBackupOperation(com.hazelcast.collection.impl.collection.operations.CollectionClearBackupOperation) ListReplicationOperation(com.hazelcast.collection.impl.list.operations.ListReplicationOperation) CollectionPrepareBackupOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionPrepareBackupOperation) ListGetOperation(com.hazelcast.collection.impl.list.operations.ListGetOperation) CollectionTransactionRollbackOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTransactionRollbackOperation) CollectionRollbackOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionRollbackOperation) ListIndexOfOperation(com.hazelcast.collection.impl.list.operations.ListIndexOfOperation) SetReplicationOperation(com.hazelcast.collection.impl.set.operations.SetReplicationOperation) CollectionContainsOperation(com.hazelcast.collection.impl.collection.operations.CollectionContainsOperation) CollectionCompareAndRemoveOperation(com.hazelcast.collection.impl.collection.operations.CollectionCompareAndRemoveOperation) CollectionClearOperation(com.hazelcast.collection.impl.collection.operations.CollectionClearOperation) CollectionTxnAddBackupOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTxnAddBackupOperation) CollectionAddBackupOperation(com.hazelcast.collection.impl.collection.operations.CollectionAddBackupOperation) CollectionSizeOperation(com.hazelcast.collection.impl.collection.operations.CollectionSizeOperation) CollectionCommitOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionCommitOperation) CollectionGetAllOperation(com.hazelcast.collection.impl.collection.operations.CollectionGetAllOperation) CollectionAddOperation(com.hazelcast.collection.impl.collection.operations.CollectionAddOperation) SetContainer(com.hazelcast.collection.impl.set.SetContainer) CollectionTxnAddOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTxnAddOperation) CollectionRemoveOperation(com.hazelcast.collection.impl.collection.operations.CollectionRemoveOperation) ListContainer(com.hazelcast.collection.impl.list.ListContainer) ListAddOperation(com.hazelcast.collection.impl.list.operations.ListAddOperation) CollectionIsEmptyOperation(com.hazelcast.collection.impl.collection.operations.CollectionIsEmptyOperation) QueueTransactionLogRecord(com.hazelcast.collection.impl.txnqueue.QueueTransactionLogRecord) CollectionReserveRemoveOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionReserveRemoveOperation) CollectionTxnRemoveBackupOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTxnRemoveBackupOperation) CollectionRemoveBackupOperation(com.hazelcast.collection.impl.collection.operations.CollectionRemoveBackupOperation) CollectionPrepareOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionPrepareOperation) ConstructorFunction(com.hazelcast.util.ConstructorFunction) ListSubOperation(com.hazelcast.collection.impl.list.operations.ListSubOperation) CollectionTxnRemoveOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionTxnRemoveOperation) CollectionAddAllOperation(com.hazelcast.collection.impl.collection.operations.CollectionAddAllOperation) CollectionRollbackBackupOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionRollbackBackupOperation) ListSetOperation(com.hazelcast.collection.impl.list.operations.ListSetOperation) ListRemoveOperation(com.hazelcast.collection.impl.list.operations.ListRemoveOperation) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) CollectionCommitBackupOperation(com.hazelcast.collection.impl.txncollection.operations.CollectionCommitBackupOperation)

Example 2 with ListContainer

use of com.hazelcast.collection.impl.list.ListContainer in project hazelcast by hazelcast.

the class ListAddOperation method run.

@Override
public void run() throws Exception {
    final ListContainer listContainer = getOrCreateListContainer();
    response = false;
    if (!hasEnoughCapacity(1)) {
        return;
    }
    final CollectionItem item = listContainer.add(index, value);
    if (item != null) {
        itemId = item.getItemId();
        response = true;
    }
}
Also used : ListContainer(com.hazelcast.collection.impl.list.ListContainer) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem)

Example 3 with ListContainer

use of com.hazelcast.collection.impl.list.ListContainer in project hazelcast by hazelcast.

the class ListReplicationOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    int mapSize = in.readInt();
    migrationData = new HashMap<String, CollectionContainer>(mapSize);
    for (int i = 0; i < mapSize; i++) {
        String name = in.readUTF();
        ListContainer container = new ListContainer();
        container.readData(in);
        migrationData.put(name, container);
    }
}
Also used : CollectionContainer(com.hazelcast.collection.impl.collection.CollectionContainer) ListContainer(com.hazelcast.collection.impl.list.ListContainer)

Example 4 with ListContainer

use of com.hazelcast.collection.impl.list.ListContainer in project hazelcast by hazelcast.

the class ListAddAllOperation method run.

@Override
public void run() throws Exception {
    if (!hasEnoughCapacity(valueList.size())) {
        response = false;
        return;
    }
    ListContainer listContainer = getOrCreateListContainer();
    valueMap = listContainer.addAll(index, valueList);
    response = !valueMap.isEmpty();
}
Also used : ListContainer(com.hazelcast.collection.impl.list.ListContainer)

Example 5 with ListContainer

use of com.hazelcast.collection.impl.list.ListContainer in project hazelcast by hazelcast.

the class ListGetOperation method run.

@Override
public void run() throws Exception {
    ListContainer listContainer = getOrCreateListContainer();
    CollectionItem item = listContainer.get(index);
    response = item.getValue();
}
Also used : ListContainer(com.hazelcast.collection.impl.list.ListContainer) CollectionItem(com.hazelcast.collection.impl.collection.CollectionItem)

Aggregations

ListContainer (com.hazelcast.collection.impl.list.ListContainer)11 CollectionItem (com.hazelcast.collection.impl.collection.CollectionItem)5 Data (com.hazelcast.nio.serialization.Data)2 CollectionContainer (com.hazelcast.collection.impl.collection.CollectionContainer)1 CollectionAddAllBackupOperation (com.hazelcast.collection.impl.collection.operations.CollectionAddAllBackupOperation)1 CollectionAddAllOperation (com.hazelcast.collection.impl.collection.operations.CollectionAddAllOperation)1 CollectionAddBackupOperation (com.hazelcast.collection.impl.collection.operations.CollectionAddBackupOperation)1 CollectionAddOperation (com.hazelcast.collection.impl.collection.operations.CollectionAddOperation)1 CollectionClearBackupOperation (com.hazelcast.collection.impl.collection.operations.CollectionClearBackupOperation)1 CollectionClearOperation (com.hazelcast.collection.impl.collection.operations.CollectionClearOperation)1 CollectionCompareAndRemoveOperation (com.hazelcast.collection.impl.collection.operations.CollectionCompareAndRemoveOperation)1 CollectionContainsOperation (com.hazelcast.collection.impl.collection.operations.CollectionContainsOperation)1 CollectionGetAllOperation (com.hazelcast.collection.impl.collection.operations.CollectionGetAllOperation)1 CollectionIsEmptyOperation (com.hazelcast.collection.impl.collection.operations.CollectionIsEmptyOperation)1 CollectionRemoveBackupOperation (com.hazelcast.collection.impl.collection.operations.CollectionRemoveBackupOperation)1 CollectionRemoveOperation (com.hazelcast.collection.impl.collection.operations.CollectionRemoveOperation)1 CollectionSizeOperation (com.hazelcast.collection.impl.collection.operations.CollectionSizeOperation)1 ListService (com.hazelcast.collection.impl.list.ListService)1 ListAddAllOperation (com.hazelcast.collection.impl.list.operations.ListAddAllOperation)1 ListAddOperation (com.hazelcast.collection.impl.list.operations.ListAddOperation)1