Search in sources :

Example 11 with ReplicatedRecord

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

the class EntrySetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    List<Map.Entry<Object, ReplicatedRecord>> entries = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        entries.addAll(store.entrySet(false));
    }
    ArrayList<Map.Entry<Data, Data>> dataEntries = new ArrayList<>(entries.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (Map.Entry<Object, ReplicatedRecord> entry : entries) {
        Data key = serializationService.toData(entry.getKey());
        Data value = serializationService.toData(entry.getValue().getValue());
        dataEntries.add(new AbstractMap.SimpleImmutableEntry<>(key, value));
    }
    response = new MapEntries(dataEntries);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) AbstractMap(java.util.AbstractMap) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) MapEntries(com.hazelcast.map.impl.MapEntries) AbstractMap(java.util.AbstractMap) Map(java.util.Map)

Example 12 with ReplicatedRecord

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

the class GetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, getPartitionId());
    if (store != null) {
        ReplicatedRecord record = store.getReplicatedRecord(key);
        if (record != null) {
            response = record.getValue();
        }
    }
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService)

Example 13 with ReplicatedRecord

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

the class ReplicationOperation method fetchReplicatedMapRecords.

private void fetchReplicatedMapRecords(PartitionContainer container) {
    int storeCount = container.getStores().size();
    data = createHashMap(storeCount);
    versions = createHashMap(storeCount);
    for (Map.Entry<String, ReplicatedRecordStore> entry : container.getStores().entrySet()) {
        String name = entry.getKey();
        ReplicatedRecordStore store = entry.getValue();
        Set<RecordMigrationInfo> recordSet = createHashSet(store.size());
        Iterator<ReplicatedRecord> iterator = store.recordIterator();
        while (iterator.hasNext()) {
            ReplicatedRecord record = iterator.next();
            Data dataKey = serializationService.toData(record.getKeyInternal());
            Data dataValue = serializationService.toData(record.getValueInternal());
            RecordMigrationInfo migrationInfo = new RecordMigrationInfo();
            migrationInfo.setKey(dataKey);
            migrationInfo.setValue(dataValue);
            migrationInfo.setTtl(record.getTtlMillis());
            migrationInfo.setHits(record.getHits());
            migrationInfo.setCreationTime(record.getCreationTime());
            migrationInfo.setLastAccessTime(record.getLastAccessTime());
            migrationInfo.setLastUpdateTime(record.getUpdateTime());
            recordSet.add(migrationInfo);
        }
        data.put(name, recordSet);
        versions.put(name, store.getVersion());
    }
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) AbstractReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) Data(com.hazelcast.internal.serialization.Data) RecordMigrationInfo(com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map)

Example 14 with ReplicatedRecord

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

the class ValuesOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    Collection<ReplicatedRecord> values = new ArrayList<>();
    for (ReplicatedRecordStore store : stores) {
        values.addAll(store.values(false));
    }
    Collection<Data> dataValues = new ArrayList<>(values.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (ReplicatedRecord value : values) {
        dataValues.add(serializationService.toData(value.getValue()));
    }
    response = new DataCollection(dataValues);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) 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

ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)14 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Data (com.hazelcast.internal.serialization.Data)4 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)4 AssertTask (com.hazelcast.test.AssertTask)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)3 AbstractReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)1 EmptyLocalReplicatedMapStats (com.hazelcast.internal.monitor.impl.EmptyLocalReplicatedMapStats)1 LocalReplicatedMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 ILogger (com.hazelcast.logging.ILogger)1 DataCollection (com.hazelcast.map.impl.DataCollection)1 MapEntries (com.hazelcast.map.impl.MapEntries)1 LocalReplicatedMapStatsImpl (com.hazelcast.monitor.impl.LocalReplicatedMapStatsImpl)1