use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class WanReplicationRefTest method testSerialization.
@Test
public void testSerialization() {
ref.setName("myWanReplicationRef");
ref.setMergePolicy("myMergePolicy");
ref.setRepublishingEnabled(true);
ref.addFilter("myFilter");
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Data serialized = serializationService.toData(ref);
WanReplicationRef deserialized = serializationService.toObject(serialized);
assertEquals(ref.getName(), deserialized.getName());
assertEquals(ref.getMergePolicy(), deserialized.getMergePolicy());
assertEquals(ref.isRepublishingEnabled(), deserialized.isRepublishingEnabled());
assertEquals(ref.getFilters(), deserialized.getFilters());
assertEquals(ref.toString(), deserialized.toString());
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class ClientListenersTest method testEntryMergeListener_withPortableNotRegisteredInNode.
@Test
public void testEntryMergeListener_withPortableNotRegisteredInNode() throws Exception {
final IMap<Object, Object> map = client.getMap(randomMapName());
final CountDownLatch latch = new CountDownLatch(1);
map.addEntryListener(new EntryMergedListener<Object, Object>() {
@Override
public void entryMerged(EntryEvent<Object, Object> event) {
latch.countDown();
}
}, true);
Node node = getNode(server);
NodeEngineImpl nodeEngine = node.nodeEngine;
OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
SerializationService serializationService = getSerializationService(server);
Data key = serializationService.toData(1);
Data value = serializationService.toData(new ClientRegressionWithMockNetworkTest.SamplePortable(1));
EntryView entryView = EntryViews.createSimpleEntryView(key, value, Mockito.mock(Record.class));
MergeOperation op = new MergeOperation(map.getName(), key, entryView, new PassThroughMergePolicy());
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
assertOpenEventually(latch);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class DurableExecutorServiceProxy method submitToPartition.
private <T> DurableExecutorServiceFuture<T> submitToPartition(Callable<T> task, int partitionId, T defaultValue) {
checkNotNull(task, "task can't be null");
SerializationService serializationService = getNodeEngine().getSerializationService();
Data taskData = serializationService.toData(task);
TaskOperation operation = new TaskOperation(name, taskData);
operation.setPartitionId(partitionId);
InternalCompletableFuture<Integer> future = invokeOnPartition(operation);
int sequence;
try {
sequence = future.get();
} catch (Throwable t) {
CompletedFuture<T> completedFuture = new CompletedFuture<T>(serializationService, t, getAsyncExecutor());
return new DurableExecutorServiceDelegateFuture<T>(completedFuture, serializationService, null, -1);
}
Operation op = new RetrieveResultOperation(name, sequence).setPartitionId(partitionId);
InternalCompletableFuture<T> internalCompletableFuture = invokeOnPartition(op);
long taskId = Bits.combineToLong(partitionId, sequence);
return new DurableExecutorServiceDelegateFuture<T>(internalCompletableFuture, serializationService, defaultValue, taskId);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class MultipleEntryBackupOperation method run.
@Override
public void run() throws Exception {
boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
SerializationService serializationService = getNodeEngine().getSerializationService();
for (Data key : keys) {
if (!isKeyProcessable(key)) {
continue;
}
Object oldValue = recordStore.get(key, true);
Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
Map.Entry entry = createMapEntry(key, value);
if (!isEntryProcessable(entry)) {
continue;
}
processBackup(entry);
if (noOp(entry, oldValue)) {
continue;
}
if (entryRemovedBackup(entry, key)) {
continue;
}
entryAddedOrUpdatedBackup(entry, key);
evict(key);
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class MultipleEntryOperation method innerBeforeRun.
@Override
public void innerBeforeRun() throws Exception {
super.innerBeforeRun();
final SerializationService serializationService = getNodeEngine().getSerializationService();
final ManagedContext managedContext = serializationService.getManagedContext();
managedContext.initialize(entryProcessor);
}
Aggregations