Package com.hazelcast.map

Examples of com.hazelcast.map.RecordStore


    public void run() {
        // near-cache clear will be called multiple times by each clear operation,
        // but it's still preferred to send a separate operation to clear near-cache.
        mapService.clearNearCache(name);

        final RecordStore recordStore = mapService.getExistingRecordStore(getPartitionId(), name);
        //if there is no recordStore, then there is nothing to clear.
        if(recordStore == null) {
            shouldBackup = false;
            return;
        }
        recordStore.clear();
    }
View Full Code Here


    public PartitionCheckIfLoadedOperation() {
    }

    public void run() {
        RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        isFinished = recordStore.isLoaded();
    }
View Full Code Here

    public MapEntrySetOperation() {
    }

    public void run() {
        RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        entrySet = recordStore.entrySetData();
        if (mapContainer.getMapConfig().isStatisticsEnabled()) {
            ((MapService) getService()).getLocalMapStatsImpl(name).incrementOtherOperations();
        }
    }
View Full Code Here

    public MapFlushOperation() {
    }

    public void run() {
        RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        recordStore.flush();
    }
View Full Code Here

    }

    @Override
    public void run() throws Exception {
        final InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        MapEntrySimple entry;

        for (Data key : keys) {
            if (partitionService.getPartitionId(key) != getPartitionId())
                continue;
            Object objectKey = mapService.toObject(key);
            final Map.Entry<Data, Object> mapEntry = recordStore.getMapEntry(key);
            final Object valueBeforeProcess = mapService.toObject(mapEntry.getValue());
            entry = new MapEntrySimple(objectKey, valueBeforeProcess);
            backupProcessor.processBackup(entry);
            if (!entry.isModified()) {
                continue;
            }
            if (entry.getValue() == null) {
                recordStore.deleteRecord(key);
            } else {
                recordStore.putBackup(key, entry.getValue());
            }
        }
    }
View Full Code Here

    @Override
    public void run() throws Exception {
        response = new MapEntrySet();
        final InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        final LocalMapStatsImpl mapStats = mapService.getLocalMapStatsImpl(name);
        MapEntrySimple entry;

        for (Data key : keys) {
            if (partitionService.getPartitionId(key) != getPartitionId())
                continue;
            long start = System.currentTimeMillis();
            Object objectKey = mapService.toObject(key);
            final Map.Entry<Data, Object> mapEntry = recordStore.getMapEntry(key);
            final Object valueBeforeProcess = mapEntry.getValue();
            final Object valueBeforeProcessObject = mapService.toObject(valueBeforeProcess);
            entry = new MapEntrySimple(objectKey, valueBeforeProcessObject);
            final Object result = entryProcessor.process(entry);
            final Object valueAfterProcess = entry.getValue();
            Data dataValue = null;
            if (result != null) {
                dataValue = mapService.toData(result);
                response.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(key, dataValue));
            }
            EntryEventType eventType;
            if (valueAfterProcess == null) {
                recordStore.remove(key);
                mapStats.incrementRemoves(getLatencyFrom(start));
                eventType = EntryEventType.REMOVED;
            } else {
                if (valueBeforeProcessObject == null) {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.ADDED;
                }
                // take this case as a read so no need to fire an event.
                else if (!entry.isModified()) {
                    mapStats.incrementGets(getLatencyFrom(start));
                    eventType = __NO_NEED_TO_FIRE_EVENT;
                } else {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.UPDATED;
                }
                // todo if this is a read only operation, record access operations should be done.
                if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                    recordStore.put(new AbstractMap.SimpleImmutableEntry<Data, Object>(key, valueAfterProcess));
                }
            }

            if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                final Data oldValue = mapService.toData(valueBeforeProcess);
                final Data value = mapService.toData(valueAfterProcess);
                mapService.publishEvent(getCallerAddress(), name, eventType, key, oldValue, value);
                if (mapService.isNearCacheAndInvalidationEnabled(name)) {
                    mapService.invalidateAllNearCaches(name, key);
                }
                if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
                    if (EntryEventType.REMOVED.equals(eventType)) {
                        mapService.publishWanReplicationRemove(name, key, Clock.currentTimeMillis());
                    } else {
                        Record record = recordStore.getRecord(key);
                        Data tempValue = mapService.toData(dataValue);
                        final SimpleEntryView entryView = mapService.createSimpleEntryView(key, tempValue, record);
                        mapService.publishWanReplicationUpdate(name, entryView);
                    }
                }
View Full Code Here

    }

    public void run() {
        response = new MapEntrySet();
        MapEntrySimple entry;
        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        final LocalMapStatsImpl mapStats = mapService.getLocalMapStatsImpl(name);
        final Map<Data, Record> records = recordStore.getReadonlyRecordMap();
        for (final Map.Entry<Data, Record> recordEntry : records.entrySet()) {
            final long start = System.currentTimeMillis();
            final Data dataKey = recordEntry.getKey();
            final Record record = recordEntry.getValue();
            final Object valueBeforeProcess = record.getValue();
            final Object valueBeforeProcessObject = mapService.toObject(valueBeforeProcess);
            Object objectKey = mapService.toObject(record.getKey());
            if (getPredicate() != null) {
                final SerializationService ss = getNodeEngine().getSerializationService();
                QueryEntry queryEntry = new QueryEntry(ss, dataKey, objectKey, valueBeforeProcessObject);
                if (!getPredicate().apply(queryEntry)) {
                    continue;
                }
            }
            entry = new MapEntrySimple(objectKey, valueBeforeProcessObject);
            final Object result = entryProcessor.process(entry);
            final Object valueAfterProcess = entry.getValue();
            Data dataValue = null;
            if (result != null) {
                dataValue = mapService.toData(result);
                response.add(new AbstractMap.SimpleImmutableEntry<Data, Data>(dataKey, dataValue));
            }

            EntryEventType eventType;
            if (valueAfterProcess == null) {
                recordStore.remove(dataKey);
                mapStats.incrementRemoves(getLatencyFrom(start));
                eventType = EntryEventType.REMOVED;
            } else {
                if (valueBeforeProcessObject == null) {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.ADDED;
                }
                // take this case as a read so no need to fire an event.
                else if (!entry.isModified()) {
                    mapStats.incrementGets(getLatencyFrom(start));
                    eventType = __NO_NEED_TO_FIRE_EVENT;
                } else {
                    mapStats.incrementPuts(getLatencyFrom(start));
                    eventType = EntryEventType.UPDATED;
                }
                // todo if this is a read only operation, record access operations should be done.
                if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                    recordStore.put(new AbstractMap.SimpleImmutableEntry<Data, Object>(dataKey, valueAfterProcess));
                }
            }
            if (eventType != __NO_NEED_TO_FIRE_EVENT) {
                final Data oldValue = mapService.toData(valueBeforeProcess);
                final Data value = mapService.toData(valueAfterProcess);
                mapService.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, value);
                if (mapService.isNearCacheAndInvalidationEnabled(name)) {
                    mapService.invalidateAllNearCaches(name, dataKey);
                }
                if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
                    if (EntryEventType.REMOVED.equals(eventType)) {
                        mapService.publishWanReplicationRemove(name, dataKey, Clock.currentTimeMillis());
                    } else {
                        Record r = recordStore.getRecord(dataKey);
                        final SimpleEntryView entryView = mapService.createSimpleEntryView(dataKey, dataValue, r);
                        mapService.publishWanReplicationUpdate(name, entryView);
                    }
                }
            }
View Full Code Here

    public void run() {
        backupRecordInfos = new ArrayList<RecordInfo>();
        backupEntrySet = new ArrayList<Map.Entry<Data,Data>>();
        int partitionId = getPartitionId();
        RecordStore recordStore = mapService.getRecordStore(partitionId, name);
        Set<Map.Entry<Data, Data>> entries = entrySet.getEntrySet();
        InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        Set<Data> keysToInvalidate = new HashSet<Data>();
        for (Map.Entry<Data, Data> entry : entries) {
            Data dataKey = entry.getKey();
            Data dataValue = entry.getValue();
            if (partitionId == partitionService.getPartitionId(dataKey)) {
                Data dataOldValue = null;
                if (initialLoad) {
                    recordStore.putFromLoad(dataKey, dataValue, -1);
                } else {
                    dataOldValue = mapService.toData(recordStore.put(dataKey, dataValue, -1));
                }
                mapService.interceptAfterPut(name, dataValue);
                EntryEventType eventType = dataOldValue == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
                mapService.publishEvent(getCallerAddress(), name, eventType, dataKey, dataOldValue, dataValue);
                keysToInvalidate.add(dataKey);
                if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
                    Record record = recordStore.getRecord(dataKey);
                    final SimpleEntryView entryView = mapService.createSimpleEntryView(dataKey,mapService.toData(dataValue),record);
                    mapService.publishWanReplicationUpdate(name, entryView);
                }
                backupEntrySet.add(entry);
                RecordInfo replicationInfo = mapService.createRecordInfo(mapContainer,
                        recordStore.getRecord(dataKey));
                backupRecordInfos.add(replicationInfo);
            }
        }
        invalidateNearCaches(keysToInvalidate);
    }
View Full Code Here

    public MapSizeOperation() {
    }

    public void run() {
        RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        recordStore.checkIfLoaded();
        size = recordStore.size();
        if (mapContainer.getMapConfig().isStatisticsEnabled()) {
            ((MapService) getService()).getLocalMapStatsImpl(name).incrementOtherOperations();
        }
    }
View Full Code Here

    public GetEntryViewOperation() {
    }

    public void run() {
        MapService mapService = (MapService) getService();
        RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        Record record = recordStore.getRecord(dataKey);
        if (record != null){
            result = mapService.createSimpleEntryView(record.getKey(),mapService.toData(record.getValue()),record);
        }
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.map.RecordStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.