Search in sources :

Example 36 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method putNewRecord.

@SuppressWarnings("checkstyle:parameternumber")
protected Record putNewRecord(Data key, Object oldValue, Object newValue, long ttl, long maxIdle, long expiryTime, long now, UUID transactionId, EntryEventType entryEventType, boolean store, boolean backup) {
    Record record = createRecord(key, newValue, now);
    if (mapDataStore != EMPTY_MAP_DATA_STORE && store) {
        putIntoMapStore(record, key, newValue, ttl, maxIdle, now, transactionId);
    }
    storage.put(key, record);
    expirySystem.add(key, ttl, maxIdle, expiryTime, now, now);
    if (entryEventType == EntryEventType.LOADED) {
        mutationObserver.onLoadRecord(key, record, backup);
    } else {
        mutationObserver.onPutRecord(key, record, oldValue, backup);
    }
    return record;
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 37 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class DefaultRecordStore method updateStoreStats.

private void updateStoreStats() {
    if (!(mapDataStore instanceof WriteBehindStore) || !mapContainer.getMapConfig().isPerEntryStatsEnabled()) {
        return;
    }
    long now = getNow();
    WriteBehindQueue<DelayedEntry> writeBehindQueue = ((WriteBehindStore) mapDataStore).getWriteBehindQueue();
    List<DelayedEntry> delayedEntries = writeBehindQueue.asList();
    for (DelayedEntry delayedEntry : delayedEntries) {
        Record record = getRecordOrNull(toData(delayedEntry.getKey()), now, false);
        onStore(record);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 38 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class TxnDeleteOperation method runInternal.

@Override
protected void runInternal() {
    recordStore.unlock(dataKey, ownerUuid, getThreadId(), getCallId());
    Record record = recordStore.getRecord(dataKey);
    if (record == null || version == record.getVersion()) {
        dataOldValue = getNodeEngine().toData(recordStore.removeTxn(dataKey, getCallerProvenance(), transactionId));
        successful = dataOldValue != null;
    }
    if (record == null) {
        wbqCapacityCounter().decrement(transactionId);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record)

Example 39 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class MapMigrationAwareService method populateIndexes.

@SuppressWarnings("checkstyle:NPathComplexity")
private void populateIndexes(PartitionMigrationEvent event, TargetIndexes targetIndexes, String stepName) {
    assert event.getMigrationEndpoint() == DESTINATION;
    assert targetIndexes != null;
    if (event.getNewReplicaIndex() != 0) {
        // backup partitions have no indexes to populate
        return;
    }
    PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
    for (RecordStore<Record> recordStore : container.getMaps().values()) {
        MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
        Indexes indexes = mapContainer.getIndexes(event.getPartitionId());
        indexes.createIndexesFromRecordedDefinitions();
        if (!indexes.haveAtLeastOneIndex()) {
            // no indexes to work with
            continue;
        }
        if (indexes.isGlobal() && targetIndexes == TargetIndexes.NON_GLOBAL) {
            continue;
        }
        if (!indexes.isGlobal() && targetIndexes == TargetIndexes.GLOBAL) {
            continue;
        }
        InternalIndex[] indexesSnapshot = indexes.getIndexes();
        Indexes.beginPartitionUpdate(indexesSnapshot);
        CacheDeserializedValues cacheDeserializedValues = mapContainer.getMapConfig().getCacheDeserializedValues();
        CachedQueryEntry<?, ?> cachedEntry = cacheDeserializedValues == NEVER ? new CachedQueryEntry<>(serializationService, mapContainer.getExtractors()) : null;
        recordStore.forEach((key, record) -> {
            Object value = Records.getValueOrCachedValue(record, serializationService);
            if (value != null) {
                QueryableEntry queryEntry = mapContainer.newQueryEntry(key, value);
                queryEntry.setRecord(record);
                CachedQueryEntry<?, ?> newEntry = cachedEntry == null ? (CachedQueryEntry<?, ?>) queryEntry : cachedEntry.init(key, value);
                indexes.putEntry(newEntry, null, queryEntry, Index.OperationSource.SYSTEM);
            }
        }, false);
        Indexes.markPartitionAsIndexed(event.getPartitionId(), indexesSnapshot);
    }
    if (logger.isFinestEnabled()) {
        logger.finest(String.format("Populated indexes at step `%s`:[%s]", stepName, event));
    }
}
Also used : InternalIndex(com.hazelcast.query.impl.InternalIndex) CacheDeserializedValues(com.hazelcast.config.CacheDeserializedValues) Record(com.hazelcast.map.impl.record.Record) Indexes(com.hazelcast.query.impl.Indexes) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Example 40 with Record

use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.

the class MapMigrationAwareService method depopulateIndexes.

private void depopulateIndexes(PartitionMigrationEvent event, String stepName) {
    assert event.getMigrationEndpoint() == SOURCE;
    assert event.getNewReplicaIndex() != 0 : "Invalid migration event: " + event;
    if (event.getCurrentReplicaIndex() != 0) {
        // backup partitions have no indexes to depopulate
        return;
    }
    PartitionContainer container = mapServiceContext.getPartitionContainer(event.getPartitionId());
    for (RecordStore<Record> recordStore : container.getMaps().values()) {
        MapContainer mapContainer = mapServiceContext.getMapContainer(recordStore.getName());
        Indexes indexes = mapContainer.getIndexes(event.getPartitionId());
        if (!indexes.haveAtLeastOneIndex()) {
            // no indexes to work with
            continue;
        }
        InternalIndex[] indexesSnapshot = indexes.getIndexes();
        Indexes.beginPartitionUpdate(indexesSnapshot);
        CachedQueryEntry<?, ?> entry = new CachedQueryEntry<>(serializationService, mapContainer.getExtractors());
        recordStore.forEach((key, record) -> {
            Object value = Records.getValueOrCachedValue(record, serializationService);
            entry.init(key, value);
            indexes.removeEntry(entry, Index.OperationSource.SYSTEM);
        }, false);
        Indexes.markPartitionAsUnindexed(event.getPartitionId(), indexesSnapshot);
    }
    if (logger.isFinestEnabled()) {
        logger.finest(String.format("Depopulated indexes at step `%s`:[%s]", stepName, event));
    }
}
Also used : InternalIndex(com.hazelcast.query.impl.InternalIndex) Record(com.hazelcast.map.impl.record.Record) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) Indexes(com.hazelcast.query.impl.Indexes)

Aggregations

Record (com.hazelcast.map.impl.record.Record)109 Data (com.hazelcast.internal.serialization.Data)27 Data (com.hazelcast.nio.serialization.Data)22 Map (java.util.Map)13 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)11 ExpiryMetadata (com.hazelcast.map.impl.recordstore.expiry.ExpiryMetadata)11 EntryView (com.hazelcast.core.EntryView)8 Indexes (com.hazelcast.query.impl.Indexes)8 ArrayList (java.util.ArrayList)7 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)6 MapContainer (com.hazelcast.map.impl.MapContainer)6 DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)6 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)6 EntryViews.createSimpleEntryView (com.hazelcast.map.impl.EntryViews.createSimpleEntryView)5 MapService (com.hazelcast.map.impl.MapService)5 List (java.util.List)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapEntries (com.hazelcast.map.impl.MapEntries)3