Search in sources :

Example 1 with AbstractWanPublisherConfig

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;
}
Also used : WanPublisher(com.hazelcast.wan.WanPublisher) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) AbstractWanPublisherConfig(com.hazelcast.config.AbstractWanPublisherConfig) ManagedContext(com.hazelcast.core.ManagedContext) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

AbstractWanPublisherConfig (com.hazelcast.config.AbstractWanPublisherConfig)1 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 WanCustomPublisherConfig (com.hazelcast.config.WanCustomPublisherConfig)1 ManagedContext (com.hazelcast.core.ManagedContext)1 WanPublisher (com.hazelcast.wan.WanPublisher)1