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;
}
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);
}
}
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);
}
}
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));
}
}
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));
}
}
Aggregations