All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.cache.impl.ClusterWideIterator Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.cache.impl;

import com.hazelcast.nio.serialization.Data;
import com.hazelcast.internal.serialization.SerializationService;
import com.hazelcast.spi.InternalCompletableFuture;
import com.hazelcast.spi.Operation;
import com.hazelcast.spi.OperationService;

import javax.cache.Cache;
import java.util.Iterator;

/**
 * Cluster-wide iterator for {@link com.hazelcast.cache.ICache}.
 * 

*

* This implementation is used for server or embedded mode. *

* Note: For more information on the iterator details, see {@link AbstractClusterWideIterator}. * * @param the type of key. * @param the type of value. * @see AbstractClusterWideIterator */ public class ClusterWideIterator extends AbstractClusterWideIterator implements Iterator> { private final SerializationService serializationService; private final CacheProxy cacheProxy; public ClusterWideIterator(CacheProxy cache) { super(cache, cache.getNodeEngine().getPartitionService().getPartitionCount()); this.cacheProxy = cache; this.serializationService = cache.getNodeEngine().getSerializationService(); advance(); } protected CacheKeyIteratorResult fetch() { Operation operation = cacheProxy.operationProvider.createKeyIteratorOperation(lastTableIndex, fetchSize); final OperationService operationService = cacheProxy.getNodeEngine().getOperationService(); final InternalCompletableFuture f = operationService .invokeOnPartition(CacheService.SERVICE_NAME, operation, partitionIndex); return f.getSafely(); } @Override protected Data toData(Object obj) { return serializationService.toData(obj); } @Override protected T toObject(Object data) { return serializationService.toObject(data); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy