Search in sources :

Example 1 with ClientMapProxy

use of com.hazelcast.client.impl.proxy.ClientMapProxy 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)

Example 2 with ClientMapProxy

use of com.hazelcast.client.impl.proxy.ClientMapProxy in project hazelcast by hazelcast.

the class ClientQueryCacheRecoveryUponEventLossTest method setTestSequencer.

private void setTestSequencer(IMap map, int eventCount) {
    ClientMapProxy proxy = (ClientMapProxy) map;
    QueryCacheContext queryCacheContext = proxy.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestClientSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) TestClientSubscriberContext(com.hazelcast.client.map.impl.querycache.subscriber.TestClientSubscriberContext)

Example 3 with ClientMapProxy

use of com.hazelcast.client.impl.proxy.ClientMapProxy in project hazelcast by hazelcast.

the class ClientQueryCacheContextTest method setUp.

@Before
public void setUp() {
    factory = new TestHazelcastFactory();
    factory.newHazelcastInstance();
    HazelcastInstance hz = factory.newHazelcastClient();
    ClientMapProxy proxy = (ClientMapProxy) hz.getMap("test");
    context = proxy.getQueryCacheContext();
}
Also used : ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) Before(org.junit.Before)

Example 4 with ClientMapProxy

use of com.hazelcast.client.impl.proxy.ClientMapProxy in project hazelcast by hazelcast.

the class ClientQueryCacheEventLostListenerTest method setTestSequencer.

private void setTestSequencer(IMap map, int eventCount) {
    ClientMapProxy proxy = (ClientMapProxy) map;
    QueryCacheContext queryCacheContext = proxy.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestClientSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) TestClientSubscriberContext(com.hazelcast.client.map.impl.querycache.subscriber.TestClientSubscriberContext)

Example 5 with ClientMapProxy

use of com.hazelcast.client.impl.proxy.ClientMapProxy in project hazelcast by hazelcast.

the class ClientQueryCacheMemoryLeakTest method removes_internal_query_caches_upon_map_destroy.

@Test
public void removes_internal_query_caches_upon_map_destroy() {
    factory.newHazelcastInstance();
    HazelcastInstance client = factory.newHazelcastClient();
    String mapName = "test";
    IMap<Integer, Integer> map = client.getMap(mapName);
    populateMap(map);
    for (int j = 0; j < 10; j++) {
        map.getQueryCache(j + "-test-QC", Predicates.alwaysTrue(), true);
    }
    map.destroy();
    ClientQueryCacheContext queryCacheContext = ((ClientMapProxy) map).getQueryCacheContext();
    SubscriberContext subscriberContext = queryCacheContext.getSubscriberContext();
    QueryCacheEndToEndProvider provider = subscriberContext.getEndToEndQueryCacheProvider();
    QueryCacheFactory queryCacheFactory = subscriberContext.getQueryCacheFactory();
    assertEquals(0, provider.getQueryCacheCount(mapName));
    assertEquals(0, queryCacheFactory.getQueryCacheCount());
}
Also used : ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) QueryCacheFactory(com.hazelcast.map.impl.querycache.subscriber.QueryCacheFactory) QueryCacheEndToEndProvider(com.hazelcast.map.impl.querycache.subscriber.QueryCacheEndToEndProvider) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SubscriberContext(com.hazelcast.map.impl.querycache.subscriber.SubscriberContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientMapProxy (com.hazelcast.client.impl.proxy.ClientMapProxy)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 TestClientSubscriberContext (com.hazelcast.client.map.impl.querycache.subscriber.TestClientSubscriberContext)2 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)2 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)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 QueryCacheEndToEndProvider (com.hazelcast.map.impl.querycache.subscriber.QueryCacheEndToEndProvider)1 QueryCacheFactory (com.hazelcast.map.impl.querycache.subscriber.QueryCacheFactory)1