Search in sources :

Example 1 with WanPublisherConfig

use of com.hazelcast.config.WanPublisherConfig in project hazelcast by hazelcast.

the class WanReplicationTest method getPublisherConfig.

private WanPublisherConfig getPublisherConfig() {
    WanPublisherConfig publisherConfig = new WanPublisherConfig();
    publisherConfig.setClassName(DummyWanReplication.class.getName());
    return publisherConfig;
}
Also used : WanPublisherConfig(com.hazelcast.config.WanPublisherConfig)

Example 2 with WanPublisherConfig

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

Example 3 with WanPublisherConfig

use of com.hazelcast.config.WanPublisherConfig in project hazelcast by hazelcast.

the class WanPublisherConfigDTOTest method testSerialization.

@Test
public void testSerialization() {
    Map<String, Comparable> properties = new HashMap<String, Comparable>();
    properties.put("key1", "value1");
    properties.put("key2", "value2");
    WanPublisherConfig expected = new WanPublisherConfig().setGroupName("myGroupName").setQueueCapacity(23).setClassName("myClassName").setQueueFullBehavior(WANQueueFullBehavior.THROW_EXCEPTION).setProperties(properties);
    WanPublisherConfigDTO dto = new WanPublisherConfigDTO(expected);
    JsonObject json = dto.toJson();
    WanPublisherConfigDTO deserialized = new WanPublisherConfigDTO(null);
    deserialized.fromJson(json);
    WanPublisherConfig actual = deserialized.getConfig();
    assertEquals(expected.getGroupName(), actual.getGroupName());
    assertEquals(expected.getQueueCapacity(), actual.getQueueCapacity());
    assertEquals(expected.getClassName(), actual.getClassName());
    assertEquals(expected.getQueueFullBehavior(), actual.getQueueFullBehavior());
    assertEquals(expected.getProperties(), actual.getProperties());
}
Also used : HashMap(java.util.HashMap) JsonObject(com.eclipsesource.json.JsonObject) WanPublisherConfig(com.hazelcast.config.WanPublisherConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with WanPublisherConfig

use of com.hazelcast.config.WanPublisherConfig in project hazelcast by hazelcast.

the class WanPublisherConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = new WanPublisherConfig();
    config.setGroupName(json.get("groupName").asString());
    config.setQueueCapacity(json.get("queueCapacity").asInt());
    config.setClassName(json.get("className").asString());
    int queueFullBehavior = json.get("queueFullBehavior").asInt();
    config.setQueueFullBehavior(WANQueueFullBehavior.getByType(queueFullBehavior));
    JsonObject properties = (JsonObject) json.get("properties");
    Map<String, Comparable> configProperties = config.getProperties();
    for (String propertyName : properties.names()) {
        configProperties.put(propertyName, properties.get(propertyName).asString());
    }
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) WanPublisherConfig(com.hazelcast.config.WanPublisherConfig)

Example 5 with WanPublisherConfig

use of com.hazelcast.config.WanPublisherConfig in project hazelcast by hazelcast.

the class WanReplicationTest method programmaticImplCreationTest.

@Test
public void programmaticImplCreationTest() {
    Config config = getConfig();
    WanPublisherConfig publisherConfig = config.getWanReplicationConfig("dummyWan").getWanPublisherConfigs().get(0);
    DummyWanReplication dummyWanReplication = new DummyWanReplication();
    publisherConfig.setImplementation(dummyWanReplication);
    instance1 = factory.newHazelcastInstance(config);
    assertEquals(dummyWanReplication, getWanReplicationImpl(instance1));
}
Also used : WanPublisherConfig(com.hazelcast.config.WanPublisherConfig) Config(com.hazelcast.config.Config) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) WanPublisherConfig(com.hazelcast.config.WanPublisherConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

WanPublisherConfig (com.hazelcast.config.WanPublisherConfig)5 JsonObject (com.eclipsesource.json.JsonObject)2 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 Config (com.hazelcast.config.Config)1 WanReplicationEndpoint (com.hazelcast.wan.WanReplicationEndpoint)1 HashMap (java.util.HashMap)1