use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class PartitionWideEntryBackupOperation method run.
@Override
public void run() {
long now = getNow();
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
Iterator<Record> iterator = recordStore.iterator(now, true);
while (iterator.hasNext()) {
Record record = iterator.next();
Data dataKey = record.getKey();
Object oldValue = record.getValue();
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
if (!applyPredicate(dataKey, value)) {
continue;
}
Map.Entry entry = createMapEntry(dataKey, value);
processBackup(entry);
if (noOp(entry, oldValue)) {
continue;
}
if (entryRemovedBackup(entry, dataKey)) {
continue;
}
entryAddedOrUpdatedBackup(entry, dataKey);
evict(dataKey);
}
publishWanReplicationEventBackups();
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class PartitionWideEntryOperation method run.
@Override
public void run() {
long now = getNow();
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
responses = new MapEntries(recordStore.size());
Iterator<Record> iterator = recordStore.iterator(now, false);
while (iterator.hasNext()) {
Record record = iterator.next();
Data dataKey = record.getKey();
Object oldValue = record.getValue();
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
if (!applyPredicate(dataKey, value)) {
continue;
}
Map.Entry entry = createMapEntry(dataKey, value);
Data response = process(entry);
if (response != null) {
responses.add(dataKey, response);
}
// first call noOp, other if checks below depends on it.
if (noOp(entry, oldValue, now)) {
continue;
}
if (entryRemoved(entry, dataKey, oldValue, now)) {
continue;
}
entryAddedOrUpdated(entry, dataKey, oldValue, now);
evict(dataKey);
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class PartitionWideEntryOperation method innerBeforeRun.
@Override
public void innerBeforeRun() throws Exception {
super.innerBeforeRun();
SerializationService serializationService = getNodeEngine().getSerializationService();
ManagedContext managedContext = serializationService.getManagedContext();
managedContext.initialize(entryProcessor);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class MultipleEntryOperation method run.
@Override
@SuppressWarnings("checkstyle:npathcomplexity")
public void run() throws Exception {
long now = getNow();
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
responses = new MapEntries(keys.size());
for (Data key : keys) {
if (!isKeyProcessable(key)) {
continue;
}
Object oldValue = recordStore.get(key, false);
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
Map.Entry entry = createMapEntry(key, value);
if (!isEntryProcessable(entry)) {
continue;
}
Data response = process(entry);
if (response != null) {
responses.add(key, response);
}
// first call noOp, other if checks below depends on it.
if (noOp(entry, oldValue, now)) {
continue;
}
if (entryRemoved(entry, key, oldValue, now)) {
continue;
}
entryAddedOrUpdated(entry, key, oldValue, now);
evict(key);
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class TransactionalMapProxy method values.
@Override
@SuppressWarnings("unchecked")
public Collection values(Predicate predicate) {
checkTransactionState();
checkNotNull(predicate, "Predicate can not be null!");
checkNotInstanceOf(PagingPredicate.class, predicate, "Paging is not supported for Transactional queries");
MapQueryEngine queryEngine = mapServiceContext.getMapQueryEngine(name);
SerializationService serializationService = getNodeEngine().getSerializationService();
Query query = Query.of().mapName(name).predicate(predicate).iterationType(IterationType.ENTRY).build();
QueryResult queryResylt = queryEngine.execute(query, Target.ALL_NODES);
Set result = QueryResultUtils.transformToSet(serializationService, queryResylt, predicate, IterationType.ENTRY, true);
// TODO: Can't we just use the original set?
List<Object> valueSet = new ArrayList<Object>();
Set<Object> keyWontBeIncluded = new HashSet<Object>();
Extractors extractors = mapServiceContext.getExtractors(name);
// iterate over the txMap and see if the values are updated or removed
for (Map.Entry<Data, TxnValueWrapper> entry : txMap.entrySet()) {
boolean isRemoved = Type.REMOVED.equals(entry.getValue().type);
boolean isUpdated = Type.UPDATED.equals(entry.getValue().type);
Object keyObject = serializationService.toObject(entry.getKey());
if (isRemoved) {
keyWontBeIncluded.add(keyObject);
} else {
if (isUpdated) {
keyWontBeIncluded.add(keyObject);
}
Object entryValue = entry.getValue().value;
QueryableEntry queryEntry = new CachedQueryEntry((InternalSerializationService) serializationService, entry.getKey(), entryValue, extractors);
if (predicate.apply(queryEntry)) {
valueSet.add(queryEntry.getValue());
}
}
}
removeFromResultSet(result, valueSet, keyWontBeIncluded);
return valueSet;
}
Aggregations