use of com.hazelcast.config.AbstractWanPublisherConfig 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