Search in sources :

Example 1 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class AbstractCallableTaskOperation method getManagedContext.

private ManagedContext getManagedContext() {
    HazelcastInstanceImpl hazelcastInstance = (HazelcastInstanceImpl) getNodeEngine().getHazelcastInstance();
    SerializationService serializationService = hazelcastInstance.getSerializationService();
    return serializationService.getManagedContext();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.HazelcastInstanceImpl) SerializationService(com.hazelcast.spi.serialization.SerializationService)

Example 2 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class EntryBackupOperation method run.

@Override
public void run() {
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    oldValue = recordStore.get(dataKey, true);
    Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
    Map.Entry entry = createMapEntry(dataKey, value);
    entryProcessor.processBackup(entry);
    if (noOpBackup(entry)) {
        return;
    }
    if (entryRemovedBackup(entry)) {
        return;
    }
    entryAddedOrUpdatedBackup(entry);
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) Map(java.util.Map)

Example 3 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class EntryOperation method run.

@Override
public void run() {
    final long now = getNow();
    boolean shouldClone = mapContainer.shouldCloneOnEntryProcessing();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    oldValue = recordStore.get(dataKey, false);
    Object value = shouldClone ? serializationService.toObject(serializationService.toData(oldValue)) : oldValue;
    Map.Entry entry = createMapEntry(dataKey, value);
    response = process(entry);
    // first call noOp, other if checks below depends on it.
    if (noOp(entry)) {
        return;
    }
    if (entryRemoved(entry, now)) {
        return;
    }
    entryAddedOrUpdated(entry, now);
}
Also used : InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) Map(java.util.Map)

Example 4 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.

the class MapDataStores method createWriteThroughStore.

/**
     * Creates a write through data store.
     *
     * @param mapStoreContext context for map store operations.
     * @param <K>             type of key to store.
     * @param <V>             type of value to store.
     * @return new write through store manager.
     */
public static <K, V> MapDataStore<K, V> createWriteThroughStore(MapStoreContext mapStoreContext) {
    final MapStoreWrapper store = mapStoreContext.getMapStoreWrapper();
    final MapServiceContext mapServiceContext = mapStoreContext.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final SerializationService serializationService = nodeEngine.getSerializationService();
    return (MapDataStore<K, V>) new WriteThroughStore(store, serializationService);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) MapStoreWrapper(com.hazelcast.map.impl.MapStoreWrapper) WriteThroughStore(com.hazelcast.map.impl.mapstore.writethrough.WriteThroughStore) SerializationService(com.hazelcast.spi.serialization.SerializationService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 5 with SerializationService

use of com.hazelcast.spi.serialization.SerializationService 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)

Aggregations

SerializationService (com.hazelcast.spi.serialization.SerializationService)88 Test (org.junit.Test)44 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)40 QuickTest (com.hazelcast.test.annotation.QuickTest)39 Data (com.hazelcast.nio.serialization.Data)28 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)23 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)17 HeapData (com.hazelcast.internal.serialization.impl.HeapData)16 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)9 Map (java.util.Map)9 ClientDelegatingFuture (com.hazelcast.client.util.ClientDelegatingFuture)8 SerializationConfig (com.hazelcast.config.SerializationConfig)6 ArrayList (java.util.ArrayList)5 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)4 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)3 SerializerConfig (com.hazelcast.config.SerializerConfig)3 HazelcastException (com.hazelcast.core.HazelcastException)3 Record (com.hazelcast.map.impl.record.Record)3 Serializable (java.io.Serializable)3