Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.map.impl.event;
import com.hazelcast.cluster.Address;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.internal.partition.IPartitionService;
import com.hazelcast.internal.serialization.Data;
import com.hazelcast.internal.serialization.InternalSerializationService;
import com.hazelcast.logging.ILogger;
import com.hazelcast.map.impl.EntryEventFilter;
import com.hazelcast.map.impl.EventListenerFilter;
import com.hazelcast.map.impl.MapContainer;
import com.hazelcast.map.impl.MapPartitionLostEventFilter;
import com.hazelcast.map.impl.MapServiceContext;
import com.hazelcast.map.impl.query.QueryEventFilter;
import com.hazelcast.map.impl.wan.WanMapAddOrUpdateEvent;
import com.hazelcast.map.impl.wan.WanMapEntryView;
import com.hazelcast.map.impl.wan.WanMapRemoveEvent;
import com.hazelcast.spi.impl.NodeEngine;
import com.hazelcast.spi.impl.eventservice.EventFilter;
import com.hazelcast.spi.impl.eventservice.EventRegistration;
import com.hazelcast.spi.impl.eventservice.EventService;
import com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter;
import com.hazelcast.spi.merge.SplitBrainMergePolicy;
import com.hazelcast.spi.properties.HazelcastProperty;
import com.hazelcast.wan.WanPublisher;
import com.hazelcast.wan.impl.DelegatingWanScheme;
import com.hazelcast.wan.impl.InternalWanEvent;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import static com.hazelcast.internal.util.CollectionUtil.isEmpty;
import static com.hazelcast.map.impl.MapService.SERVICE_NAME;
import static com.hazelcast.map.impl.event.AbstractFilteringStrategy.FILTER_DOES_NOT_MATCH;
public class MapEventPublisherImpl implements MapEventPublisher {
/**
* When {@code true}, enables processing of entry events for
* listeners with predicates to fit with "query cache" concept: for
* example when the original event indicates an update from an old
* value that does not match the predicate to a new value that does
* match, then the entry listener will be notified with an ADDED
* event. This affects only map listeners with predicates and the
* way entry updates are handled. Put/remove operations are not
* affected, neither are listeners without predicates. Default value
* is {@code false}, to maintain compatible behavior with previous
* Hazelcast versions.
*/
public static final String PROP_LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES
= "hazelcast.map.entry.filtering.natural.event.types";
public static final HazelcastProperty LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES
= new HazelcastProperty(PROP_LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES, false);
protected final NodeEngine nodeEngine;
protected final EventService eventService;
protected final IPartitionService partitionService;
protected final MapServiceContext mapServiceContext;
protected final FilteringStrategy filteringStrategy;
protected final InternalSerializationService serializationService;
protected final QueryCacheEventPublisher queryCacheEventPublisher;
protected final ILogger logger;
public MapEventPublisherImpl(MapServiceContext mapServiceContext) {
this.mapServiceContext = mapServiceContext;
this.nodeEngine = mapServiceContext.getNodeEngine();
this.logger = nodeEngine.getLogger(MapEventPublisherImpl.class);
this.partitionService = nodeEngine.getPartitionService();
this.serializationService = ((InternalSerializationService) nodeEngine.getSerializationService());
this.eventService = nodeEngine.getEventService();
if (this.nodeEngine.getProperties().
getBoolean(LISTENER_WITH_PREDICATE_PRODUCES_NATURAL_EVENT_TYPES)) {
this.filteringStrategy = new QueryCacheNaturalFilteringStrategy(serializationService, mapServiceContext);
} else {
this.filteringStrategy = new DefaultEntryEventFilteringStrategy(serializationService, mapServiceContext);
}
this.queryCacheEventPublisher = new QueryCacheEventPublisher(filteringStrategy,
mapServiceContext.getQueryCacheContext(), serializationService);
}
@Override
public void publishWanUpdate(@Nonnull String mapName,
@Nonnull WanMapEntryView