use of com.hazelcast.spi.impl.SerializationServiceSupport in project hazelcast by hazelcast.
the class NearCacheLiteMemberTest method testPutAll.
public static void testPutAll(HazelcastInstance instance, HazelcastInstance lite, String mapName) {
IMap<Object, Object> map = instance.getMap(mapName);
IMap<Object, Object> liteMap = lite.getMap(mapName);
NearCachedMapProxyImpl proxy = (NearCachedMapProxyImpl) liteMap;
NearCache liteNearCache = proxy.getNearCache();
SerializationService serializationService = ((SerializationServiceSupport) instance).getSerializationService();
int count = 100;
// fill the near cache with the same data as below so we can detect when it is emptied
for (int i = 0; i < count; i++) {
liteNearCache.put(serializationService.toData(i), i);
}
final NearCacheStats stats = liteNearCache.getNearCacheStats();
assertEquals(100, stats.getOwnedEntryCount());
Map<Object, Object> localMap = new HashMap<Object, Object>();
for (int i = 0; i < count; i++) {
localMap.put(i, i);
}
map.putAll(localMap);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, stats.getOwnedEntryCount());
}
});
for (int i = 0; i < count; i++) {
liteMap.get(i);
}
assertLiteMemberNearCacheNonEmpty(lite, mapName);
}
use of com.hazelcast.spi.impl.SerializationServiceSupport in project hazelcast by hazelcast.
the class PreJoinCacheConfig method writeFactories.
@Override
protected void writeFactories(ObjectDataOutput out) throws IOException {
assert (out instanceof SerializationServiceSupport) : "out must implement SerializationServiceSupport";
SerializationService serializationService = ((SerializationServiceSupport) out).getSerializationService();
IOUtil.writeData(out, cacheLoaderFactory.getSerializedValue(serializationService));
IOUtil.writeData(out, cacheWriterFactory.getSerializedValue(serializationService));
IOUtil.writeData(out, expiryPolicyFactory.getSerializedValue(serializationService));
}
use of com.hazelcast.spi.impl.SerializationServiceSupport in project hazelcast by hazelcast.
the class DataSerializableImplementsVersionedTest method getObjectDataOutput.
// overridden in EE
protected ObjectDataOutput getObjectDataOutput() {
ObjectDataOutput output = mock(ObjectDataOutput.class, withSettings().extraInterfaces(SerializationServiceSupport.class, DataWriter.class));
when(((SerializationServiceSupport) output).getSerializationService()).thenReturn(serializationService);
return output;
}
use of com.hazelcast.spi.impl.SerializationServiceSupport in project hazelcast by hazelcast.
the class TestSupport method initProcessor.
private void initProcessor(Processor processor, TestOutbox outbox) {
SerializationService serializationService;
if (hazelcastInstance != null && hazelcastInstance instanceof SerializationServiceSupport) {
SerializationServiceSupport impl = (SerializationServiceSupport) hazelcastInstance;
serializationService = impl.getSerializationService();
} else {
serializationService = new DefaultSerializationServiceBuilder().setManagedContext(e -> e).build();
}
TestProcessorContext context = new TestProcessorContext().setLogger(getLogger(processor.getClass().getName())).setManagedContext(serializationService.getManagedContext()).setLocalProcessorIndex(localProcessorIndex).setGlobalProcessorIndex(globalProcessorIndex).setLocalParallelism(localParallelism).setTotalParallelism(totalParallelism);
if (hazelcastInstance != null) {
context.setHazelcastInstance(hazelcastInstance);
}
if (jobConfig != null) {
context.setJobConfig(jobConfig);
}
if (processor instanceof SerializationServiceAware) {
((SerializationServiceAware) processor).setSerializationService(serializationService);
}
try {
processor.init(outbox, context);
} catch (Exception e) {
throw sneakyThrow(e);
}
}
use of com.hazelcast.spi.impl.SerializationServiceSupport in project hazelcast by hazelcast.
the class DataSerializableImplementsVersionedTest method getObjectDataInput.
// overridden in EE
protected ObjectDataInput getObjectDataInput() {
ObjectDataInput input = mock(ObjectDataInput.class, withSettings().extraInterfaces(SerializationServiceSupport.class, DataReader.class));
when(((SerializationServiceSupport) input).getSerializationService()).thenReturn(serializationService);
return input;
}
Aggregations