Search in sources :

Example 26 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapProxy method containsKey.

@Override
public boolean containsKey(@Nonnull Object key) {
    ensureNoSplitBrain(READ);
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    int partitionId = partitionService.getPartitionId(key);
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, partitionId);
    return store != null && store.containsKey(key);
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 27 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapProxy method get.

@Override
public V get(@Nonnull Object key) {
    ensureNoSplitBrain(READ);
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    int partitionId = partitionService.getPartitionId(key);
    ReplicatedRecordStore store = service.getReplicatedRecordStore(getName(), false, partitionId);
    if (store == null) {
        return null;
    }
    return (V) store.get(key);
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 28 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapProxy method isEmpty.

@Override
public boolean isEmpty() {
    ensureNoSplitBrain(READ);
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(getName());
    for (ReplicatedRecordStore store : stores) {
        if (!store.isEmpty()) {
            return false;
        }
    }
    return true;
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 29 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class CheckReplicaVersionOperation method run.

@Override
public void run() throws Exception {
    ILogger logger = getLogger();
    int partitionId = getPartitionId();
    ReplicatedMapService service = getService();
    PartitionContainer container = service.getPartitionContainer(getPartitionId());
    ConcurrentMap<String, ReplicatedRecordStore> stores = container.getStores();
    for (Map.Entry<String, Long> entry : versions.entrySet()) {
        String name = entry.getKey();
        Long version = entry.getValue();
        ReplicatedRecordStore store = stores.get(name);
        if (store == null) {
            if (logger.isFineEnabled()) {
                logger.fine("Missing store on the replica of replicated map '" + name + "' (partitionId " + partitionId + ") (owner version " + version + ")");
            }
            requestDataFromOwner(name);
        } else if (store.isStale(version)) {
            if (logger.isFineEnabled()) {
                logger.fine("Stale replica on replicated map '" + name + "' (partitionId " + partitionId + ") (owner version " + version + ") (replica version " + store.getVersion() + ")");
            }
            requestDataFromOwner(name);
        }
    }
}
Also used : PartitionContainer(com.hazelcast.replicatedmap.impl.PartitionContainer) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) MapUtil.createConcurrentHashMap(com.hazelcast.internal.util.MapUtil.createConcurrentHashMap) Map(java.util.Map)

Example 30 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class KeySetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    List<Object> keys = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        keys.addAll(store.keySet(false));
    }
    ArrayList<Data> dataKeys = new ArrayList<>(keys.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (Object key : keys) {
        dataKeys.add(serializationService.toData(key));
    }
    response = new DataCollection(dataKeys);
}
Also used : DataCollection(com.hazelcast.map.impl.DataCollection) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data)

Aggregations

ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)38 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)19 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)7 ArrayList (java.util.ArrayList)7 Data (com.hazelcast.internal.serialization.Data)5 ILogger (com.hazelcast.logging.ILogger)4 Nonnull (javax.annotation.Nonnull)4 Address (com.hazelcast.cluster.Address)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 ReplicatedMapProxy (com.hazelcast.replicatedmap.impl.ReplicatedMapProxy)3 Map (java.util.Map)3 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)2 LocalReplicatedMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl)2 DataCollection (com.hazelcast.map.impl.DataCollection)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2 AbstractBaseReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractBaseReplicatedRecordStore)2 AbstractReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore)2 RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)2 BitSet (java.util.BitSet)2 Member (com.hazelcast.cluster.Member)1