use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class PutAllOperation method put.
private void put(Data dataKey, Data dataValue) {
Object oldValue = putToRecordStore(dataKey, dataValue);
dataValue = getValueOrPostProcessedValue(dataKey, dataValue);
mapServiceContext.interceptAfterPut(name, dataValue);
if (hasMapListener) {
EntryEventType eventType = (oldValue == null ? ADDED : UPDATED);
mapEventPublisher.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, dataValue);
}
Record record = (hasWanReplication || hasBackups) ? recordStore.getRecord(dataKey) : null;
if (hasWanReplication) {
EntryView entryView = createSimpleEntryView(dataKey, dataValue, record);
mapEventPublisher.publishWanReplicationUpdate(name, entryView);
}
if (hasBackups) {
RecordInfo replicationInfo = buildRecordInfo(record);
backupRecordInfos.add(replicationInfo);
}
evict(dataKey);
if (hasInvalidation) {
invalidationKeys.add(dataKey);
}
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class PutFromLoadAllBackupOperation method publishWanReplicationEvent.
private void publishWanReplicationEvent(Data key, Data value, Record record) {
if (record == null) {
return;
}
if (mapContainer.getWanReplicationPublisher() != null && mapContainer.getWanMergePolicy() != null) {
EntryView entryView = EntryViews.createSimpleEntryView(key, value, record);
mapEventPublisher.publishWanReplicationUpdateBackup(name, entryView);
}
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class GetMapEntryRequest method writeResponse.
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
IMap map = mcs.getHazelcastInstance().getMap(mapName);
JsonObject result = new JsonObject();
EntryView entry = null;
if (type.equals("string")) {
entry = map.getEntryView(key);
} else if (type.equals("long")) {
entry = map.getEntryView(Long.valueOf(key));
} else if (type.equals("integer")) {
entry = map.getEntryView(Integer.valueOf(key));
}
if (entry != null) {
Object value = entry.getValue();
result.add("browse_value", value != null ? value.toString() : "null");
result.add("browse_class", value != null ? value.getClass().getName() : "null");
result.add("memory_cost", Long.toString(entry.getCost()));
result.add("date_creation_time", Long.toString(entry.getCreationTime()));
result.add("date_expiration_time", Long.toString(entry.getExpirationTime()));
result.add("browse_hits", Long.toString(entry.getHits()));
result.add("date_access_time", Long.toString(entry.getLastAccessTime()));
result.add("date_update_time", Long.toString(entry.getLastUpdateTime()));
result.add("browse_version", Long.toString(entry.getVersion()));
}
root.add("result", result);
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class DefaultRecordStore method merge.
@Override
public boolean merge(Data key, EntryView mergingEntry, MapMergePolicy mergePolicy) {
checkIfLoaded();
final long now = getNow();
Record record = getRecordOrNull(key, now, false);
mergingEntry = EntryViews.convertToLazyEntryView(mergingEntry, serializationService, mergePolicy);
Object newValue;
Object oldValue = null;
if (record == null) {
final Object notExistingKey = mapServiceContext.toObject(key);
final EntryView nullEntryView = EntryViews.createNullEntryView(notExistingKey);
newValue = mergePolicy.merge(name, mergingEntry, nullEntryView);
if (newValue == null) {
return false;
}
newValue = mapDataStore.add(key, newValue, now);
record = createRecord(newValue, DEFAULT_TTL, now);
mergeRecordExpiration(record, mergingEntry);
storage.put(key, record);
} else {
oldValue = record.getValue();
EntryView existingEntry = EntryViews.createLazyEntryView(record.getKey(), record.getValue(), record, serializationService, mergePolicy);
newValue = mergePolicy.merge(name, mergingEntry, existingEntry);
// existing entry will be removed
if (newValue == null) {
removeIndex(record);
mapDataStore.remove(key, now);
onStore(record);
storage.removeRecord(record);
updateStatsOnRemove(record.getHits());
return true;
}
if (newValue == mergingEntry.getValue()) {
mergeRecordExpiration(record, mergingEntry);
}
// same with the existing entry so no need to map-store etc operations.
if (recordFactory.isEquals(newValue, oldValue)) {
return true;
}
newValue = mapDataStore.add(key, newValue, now);
onStore(record);
storage.updateRecordValue(key, record, newValue);
}
saveIndex(record, oldValue);
return newValue != null;
}
use of com.hazelcast.core.EntryView in project hazelcast by hazelcast.
the class MapProxySupport method getEntryViewInternal.
protected EntryView getEntryViewInternal(Data key) {
int partitionId = partitionService.getPartitionId(key);
MapOperation operation = operationProvider.createGetEntryViewOperation(name, key);
operation.setThreadId(ThreadUtil.getThreadId());
operation.setServiceName(SERVICE_NAME);
try {
Future future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
return (EntryView) toObject(future.get());
} catch (Throwable t) {
throw rethrow(t);
}
}
Aggregations