Search in sources :

Example 1 with SerializationServiceSupport

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);
}
Also used : HashMap(java.util.HashMap) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) NearCache(com.hazelcast.internal.nearcache.NearCache) SerializationService(com.hazelcast.spi.serialization.SerializationService) NearCacheStats(com.hazelcast.monitor.NearCacheStats) SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) AssertTask(com.hazelcast.test.AssertTask)

Example 2 with SerializationServiceSupport

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));
}
Also used : SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) SerializationService(com.hazelcast.internal.serialization.SerializationService)

Example 3 with SerializationServiceSupport

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;
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) DataWriter(com.hazelcast.internal.nio.DataWriter)

Example 4 with SerializationServiceSupport

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);
    }
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationService(com.hazelcast.internal.serialization.SerializationService) SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) SerializationServiceAware(com.hazelcast.internal.serialization.SerializationServiceAware) UnknownHostException(java.net.UnknownHostException)

Example 5 with SerializationServiceSupport

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;
}
Also used : DataReader(com.hazelcast.internal.nio.DataReader) SerializationServiceSupport(com.hazelcast.spi.impl.SerializationServiceSupport) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Aggregations

SerializationServiceSupport (com.hazelcast.spi.impl.SerializationServiceSupport)5 SerializationService (com.hazelcast.internal.serialization.SerializationService)2 NearCache (com.hazelcast.internal.nearcache.NearCache)1 DataReader (com.hazelcast.internal.nio.DataReader)1 DataWriter (com.hazelcast.internal.nio.DataWriter)1 SerializationServiceAware (com.hazelcast.internal.serialization.SerializationServiceAware)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 NearCachedMapProxyImpl (com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl)1 NearCacheStats (com.hazelcast.monitor.NearCacheStats)1 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)1 SerializationService (com.hazelcast.spi.serialization.SerializationService)1 AssertTask (com.hazelcast.test.AssertTask)1 UnknownHostException (java.net.UnknownHostException)1 HashMap (java.util.HashMap)1