Search in sources :

Example 1 with WanReplicationEndpoint

use of com.hazelcast.wan.WanReplicationEndpoint in project hazelcast by hazelcast.

the class WanReplicationServiceImpl method getWanReplicationPublisher.

@Override
@SuppressWarnings("SynchronizeOnThis")
public WanReplicationPublisher getWanReplicationPublisher(String name) {
    WanReplicationPublisherDelegate wr = wanReplications.get(name);
    if (wr != null) {
        return wr;
    }
    synchronized (this) {
        wr = wanReplications.get(name);
        if (wr != null) {
            return wr;
        }
        WanReplicationConfig wanReplicationConfig = node.getConfig().getWanReplicationConfig(name);
        if (wanReplicationConfig == null) {
            return null;
        }
        List<WanPublisherConfig> publisherConfigs = wanReplicationConfig.getWanPublisherConfigs();
        WanReplicationEndpoint[] targetEndpoints = new WanReplicationEndpoint[publisherConfigs.size()];
        int count = 0;
        for (WanPublisherConfig publisherConfig : publisherConfigs) {
            WanReplicationEndpoint target;
            try {
                if (publisherConfig.getImplementation() != null) {
                    target = (WanReplicationEndpoint) publisherConfig.getImplementation();
                } else {
                    target = ClassLoaderUtil.newInstance(node.getConfigClassLoader(), publisherConfig.getClassName());
                }
            } catch (Exception e) {
                throw ExceptionUtil.rethrow(e);
            }
            target.init(node, wanReplicationConfig, publisherConfig);
            targetEndpoints[count++] = target;
        }
        wr = new WanReplicationPublisherDelegate(name, targetEndpoints);
        wanReplications.put(name, wr);
        return wr;
    }
}
Also used : WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanReplicationEndpoint(com.hazelcast.wan.WanReplicationEndpoint) WanPublisherConfig(com.hazelcast.config.WanPublisherConfig) WanReplicationEndpoint(com.hazelcast.wan.WanReplicationEndpoint)

Aggregations

WanPublisherConfig (com.hazelcast.config.WanPublisherConfig)1 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)1 WanReplicationEndpoint (com.hazelcast.wan.WanReplicationEndpoint)1