Search in sources :

Example 1 with DelegatingSerializationService

use of com.hazelcast.jet.impl.serialization.DelegatingSerializationService in project hazelcast by hazelcast.

the class WriteMapP method init.

@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) {
    map = instance().getMap(mapName);
    boolean hasCustomSerializers = serializationService instanceof DelegatingSerializationService && ((DelegatingSerializationService) serializationService).hasAddedSerializers();
    boolean hasNearCache = map instanceof NearCachedMapProxyImpl;
    if (hasNearCache && hasCustomSerializers) {
        // See https://github.com/hazelcast/hazelcast-jet/issues/3046
        throw new JetException("Writing into IMap with both near cache and custom serializers not supported");
    }
    if (!hasCustomSerializers) {
        addToBuffer = item -> buffer.add(new SimpleEntry<>(key(item), value(item)));
    } else if (map instanceof MapProxyImpl) {
        PartitioningStrategy<?> partitionStrategy = ((MapProxyImpl<K, V>) map).getPartitionStrategy();
        addToBuffer = item -> {
            Data key = serializationService.toData(key(item), partitionStrategy);
            Data value = serializationService.toData(value(item));
            buffer.add(new SimpleEntry<>(key, value));
        };
    } else if (map instanceof ClientMapProxy) {
        // TODO: add strategy/unify after https://github.com/hazelcast/hazelcast/issues/13950 is fixed
        addToBuffer = item -> {
            Data key = serializationService.toData(key(item));
            Data value = serializationService.toData(value(item));
            buffer.add(new SimpleEntry<>(key, value));
        };
    } else {
        throw new RuntimeException("Unexpected map class: " + map.getClass().getName());
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) FunctionEx(com.hazelcast.function.FunctionEx) EdgeConfig(com.hazelcast.jet.config.EdgeConfig) DelegatingSerializationService(com.hazelcast.jet.impl.serialization.DelegatingSerializationService) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) PartitioningStrategy(com.hazelcast.partition.PartitioningStrategy) Outbox(com.hazelcast.jet.core.Outbox) Data(com.hazelcast.internal.serialization.Data) Processor(com.hazelcast.jet.core.Processor) Collections.singletonList(java.util.Collections.singletonList) JetException(com.hazelcast.jet.JetException) Consumer(java.util.function.Consumer) ArrayMap(com.hazelcast.jet.impl.connector.HazelcastWriters.ArrayMap) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) PermissionsUtil.mapPutPermission(com.hazelcast.security.PermissionsUtil.mapPutPermission) Integer.max(java.lang.Integer.max) List(java.util.List) Permission(java.security.Permission) SerializationService(com.hazelcast.internal.serialization.SerializationService) ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) Inbox(com.hazelcast.jet.core.Inbox) Nonnull(javax.annotation.Nonnull) SimpleEntry(java.util.AbstractMap.SimpleEntry) IMap(com.hazelcast.map.IMap) DelegatingSerializationService(com.hazelcast.jet.impl.serialization.DelegatingSerializationService) SimpleEntry(java.util.AbstractMap.SimpleEntry) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) Data(com.hazelcast.internal.serialization.Data) JetException(com.hazelcast.jet.JetException) ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) PartitioningStrategy(com.hazelcast.partition.PartitioningStrategy)

Aggregations

ClientMapProxy (com.hazelcast.client.impl.proxy.ClientMapProxy)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 FunctionEx (com.hazelcast.function.FunctionEx)1 Data (com.hazelcast.internal.serialization.Data)1 SerializationService (com.hazelcast.internal.serialization.SerializationService)1 JetException (com.hazelcast.jet.JetException)1 EdgeConfig (com.hazelcast.jet.config.EdgeConfig)1 Inbox (com.hazelcast.jet.core.Inbox)1 Outbox (com.hazelcast.jet.core.Outbox)1 Processor (com.hazelcast.jet.core.Processor)1 ArrayMap (com.hazelcast.jet.impl.connector.HazelcastWriters.ArrayMap)1 DelegatingSerializationService (com.hazelcast.jet.impl.serialization.DelegatingSerializationService)1 IMap (com.hazelcast.map.IMap)1 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)1 NearCachedMapProxyImpl (com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl)1 PartitioningStrategy (com.hazelcast.partition.PartitioningStrategy)1 PermissionsUtil.mapPutPermission (com.hazelcast.security.PermissionsUtil.mapPutPermission)1 Integer.max (java.lang.Integer.max)1 Permission (java.security.Permission)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1