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;
}
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;
}
}
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());
}
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());
}
}
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));
}
Aggregations