use of com.hazelcast.wan.WanPublisher in project hazelcast by hazelcast.
the class WanEventContainerReplicationOperation method forAllReplicationContainers.
private void forAllReplicationContainers(BiConsumer<WanPublisher, Object> publisherContainerConsumer) {
WanReplicationService service = getWanReplicationService();
for (Entry<String, Map<String, Object>> wanReplicationSchemeEntry : eventContainers.entrySet()) {
String wanReplicationScheme = wanReplicationSchemeEntry.getKey();
Map<String, Object> eventContainersByPublisherId = wanReplicationSchemeEntry.getValue();
for (Entry<String, Object> publisherEventContainer : eventContainersByPublisherId.entrySet()) {
String publisherId = publisherEventContainer.getKey();
Object eventContainer = publisherEventContainer.getValue();
WanPublisher publisher = service.getPublisherOrFail(wanReplicationScheme, publisherId);
publisherContainerConsumer.accept(publisher, eventContainer);
}
}
}
use of com.hazelcast.wan.WanPublisher in project hazelcast by hazelcast.
the class DelegatingWanScheme method prepareEventContainerReplicationData.
/**
* Collect all replication data matching the replication event and collection
* of namespaces being replicated.
* Returns containers for WAN replication events grouped by WAN publisher ID.
* Silently skips publishers not supporting replication.
*
* @param event the replication event
* @param namespaces the object namespaces which are being replicated
* @return a map from WAN publisher ID to container object for WAN replication events
*/
public Map<String, Object> prepareEventContainerReplicationData(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces) {
Map<String, Object> eventContainers = createHashMap(publishers.size());
for (Entry<String, WanPublisher> publisherEntry : publishers.entrySet()) {
WanPublisher publisher = publisherEntry.getValue();
if (publisher instanceof WanMigrationAwarePublisher) {
Object eventContainer = ((WanMigrationAwarePublisher) publisher).prepareEventContainerReplicationData(event, namespaces);
if (eventContainer != null) {
String publisherId = publisherEntry.getKey();
eventContainers.put(publisherId, eventContainer);
}
}
}
return eventContainers;
}
use of com.hazelcast.wan.WanPublisher in project hazelcast by hazelcast.
the class DelegatingWanScheme method getStats.
/**
* Silently skips publishers not supporting statistics.
*
* @return publisher statistics, grouped by publisher ID
*/
public Map<String, LocalWanPublisherStats> getStats() {
final Map<String, LocalWanPublisherStats> statsMap = createHashMap(publishers.size());
for (Entry<String, WanPublisher> publisherEntry : publishers.entrySet()) {
WanPublisher publisher = publisherEntry.getValue();
if (publisher instanceof InternalWanPublisher) {
String publisherId = publisherEntry.getKey();
LocalWanPublisherStats stats = ((InternalWanPublisher) publisher).getStats();
if (stats != null) {
statsMap.put(publisherId, stats);
}
}
}
return statsMap;
}
use of com.hazelcast.wan.WanPublisher in project hazelcast by hazelcast.
the class WanReplicationServiceImpl method createPublishers.
private ConcurrentMap<String, WanPublisher> createPublishers(WanReplicationConfig wanReplicationConfig) {
List<WanCustomPublisherConfig> customPublisherConfigs = wanReplicationConfig.getCustomPublisherConfigs();
int publisherCount = customPublisherConfigs.size();
if (publisherCount == 0) {
return createConcurrentHashMap(1);
}
ConcurrentMap<String, WanPublisher> publishers = createConcurrentHashMap(publisherCount);
Map<String, AbstractWanPublisherConfig> publisherConfigs = createHashMap(publisherCount);
customPublisherConfigs.forEach(publisherConfig -> {
String publisherId = getWanPublisherId(publisherConfig);
if (publishers.containsKey(publisherId)) {
throw new InvalidConfigurationException("Detected duplicate publisher ID '" + publisherId + "' for a single WAN replication config");
}
WanPublisher publisher = createPublisher(publisherConfig);
publishers.put(publisherId, publisher);
publisherConfigs.put(publisherId, publisherConfig);
});
for (Entry<String, WanPublisher> publisherEntry : publishers.entrySet()) {
String publisherId = publisherEntry.getKey();
WanPublisher publisher = publisherEntry.getValue();
ManagedContext managedContext = node.getSerializationService().getManagedContext();
publisher = (WanPublisher) managedContext.initialize(publisher);
publisher.init(wanReplicationConfig, publisherConfigs.get(publisherId));
}
return publishers;
}
Aggregations