Search in sources :

Example 11 with ListContainer

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

the class ListKeyValueSource method open.

@Override
public boolean open(NodeEngine nodeEngine) {
    NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
    ss = nei.getSerializationService();
    Address thisAddress = nei.getThisAddress();
    IPartitionService ps = nei.getPartitionService();
    Data data = ss.toData(listName, StringAndPartitionAwarePartitioningStrategy.INSTANCE);
    int partitionId = ps.getPartitionId(data);
    Address partitionOwner = ps.getPartitionOwner(partitionId);
    if (partitionOwner == null) {
        return false;
    }
    if (thisAddress.equals(partitionOwner)) {
        ListService listService = nei.getService(ListService.SERVICE_NAME);
        ListContainer listContainer = listService.getOrCreateContainer(listName, false);
        List<CollectionItem> items = new ArrayList<CollectionItem>(listContainer.getCollection());
        iterator = items.iterator();
    }
    return true;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ListService(com.hazelcast.collection.impl.list.ListService) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data) 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