use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method putTransient.
@Override
public Object putTransient(Data key, Object value, long ttl) {
checkIfLoaded();
final long now = getNow();
markRecordStoreExpirable(ttl);
Record record = getRecordOrNull(key, now, false);
Object oldValue = null;
if (record == null) {
value = mapServiceContext.interceptPut(name, null, value);
record = createRecord(value, ttl, now);
storage.put(key, record);
} else {
oldValue = record.getValue();
value = mapServiceContext.interceptPut(name, oldValue, value);
updateRecord(key, record, value, now);
updateExpiryTime(record, ttl, mapContainer.getMapConfig());
}
saveIndex(record, oldValue);
mapDataStore.addTransient(key, now);
return oldValue;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method keySet.
@Override
public Set<Data> keySet() {
checkIfLoaded();
long now = getNow();
Collection<Record> records = storage.values();
Set<Data> keySet = EMPTY_SET;
for (Record record : records) {
Data key = record.getKey();
record = getOrNullIfExpired(record, now, false);
if (record == null) {
continue;
}
if (keySet == EMPTY_SET) {
keySet = new HashSet<Data>();
}
keySet.add(key);
}
return keySet;
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method clearPartition.
@Override
public void clearPartition(boolean onShutdown) {
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
LockService lockService = nodeEngine.getSharedService(LockService.SERVICE_NAME);
if (lockService != null) {
final DefaultObjectNamespace namespace = new DefaultObjectNamespace(MapService.SERVICE_NAME, name);
lockService.clearLockStore(partitionId, namespace);
}
Indexes indexes = mapContainer.getIndexes();
if (indexes.hasIndex()) {
for (Record record : storage.values()) {
Data key = record.getKey();
Object value = Records.getValueOrCachedValue(record, serializationService);
indexes.removeEntryIndex(key, value);
}
}
mapDataStore.reset();
if (onShutdown) {
NativeMemoryConfig nativeMemoryConfig = nodeEngine.getConfig().getNativeMemoryConfig();
boolean shouldClear = (nativeMemoryConfig != null && nativeMemoryConfig.getAllocatorType() != POOLED);
if (shouldClear) {
storage.clear(true);
}
storage.destroy(true);
} else {
storage.clear(false);
}
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class TxnSetOperation method run.
@Override
public void run() {
recordStore.unlock(dataKey, ownerUuid, threadId, getCallId());
Record record = recordStore.getRecordOrNull(dataKey);
if (record == null || version == record.getVersion()) {
EventService eventService = getNodeEngine().getEventService();
if (eventService.hasEventRegistration(MapService.SERVICE_NAME, getName())) {
dataOldValue = record == null ? null : mapServiceContext.toData(record.getValue());
}
eventType = record == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
recordStore.set(dataKey, dataValue, ttl);
shouldBackup = true;
}
}
use of com.hazelcast.map.impl.record.Record in project hazelcast by hazelcast.
the class DefaultRecordStore method delete.
@Override
public boolean delete(Data key) {
checkIfLoaded();
final long now = getNow();
final Record record = getRecordOrNull(key, now, false);
if (record == null) {
mapDataStore.remove(key, now);
} else {
return removeRecord(key, record, now) != null;
}
return false;
}
Aggregations