Search in sources :

Example 6 with WanSyncConfig

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

the class WanBatchPublisherConfigDTO method toJson.

@Override
@SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity" })
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("clusterName", config.getClusterName());
    if (config.getPublisherId() != null) {
        root.add("publisherId", config.getPublisherId());
    }
    root.add("batchSize", config.getBatchSize());
    root.add("batchMaxDelayMillis", config.getBatchMaxDelayMillis());
    root.add("responseTimeoutMillis", config.getResponseTimeoutMillis());
    if (config.getAcknowledgeType() != null) {
        root.add("acknowledgeType", config.getAcknowledgeType().getId());
    }
    if (config.getInitialPublisherState() != null) {
        root.add("initialPublisherState", config.getInitialPublisherState().getId());
    }
    root.add("snapshotEnabled", config.isSnapshotEnabled());
    root.add("idleMaxParkNs", config.getIdleMaxParkNs());
    root.add("idleMinParkNs", config.getIdleMinParkNs());
    root.add("maxConcurrentInvocations", config.getMaxConcurrentInvocations());
    root.add("discoveryPeriodSeconds", config.getDiscoveryPeriodSeconds());
    root.add("useEndpointPrivateAddress", config.isUseEndpointPrivateAddress());
    if (config.getQueueFullBehavior() != null) {
        root.add("queueFullBehavior", config.getQueueFullBehavior().getId());
    }
    root.add("maxTargetEndpoints", config.getMaxTargetEndpoints());
    root.add("queueCapacity", config.getQueueCapacity());
    if (config.getTargetEndpoints() != null) {
        root.add("targetEndpoints", config.getTargetEndpoints());
    }
    serializeAliasedDiscoveryConfig(root, "aws", config.getAwsConfig());
    serializeAliasedDiscoveryConfig(root, "gcp", config.getGcpConfig());
    serializeAliasedDiscoveryConfig(root, "azure", config.getAzureConfig());
    serializeAliasedDiscoveryConfig(root, "kubernetes", config.getKubernetesConfig());
    serializeAliasedDiscoveryConfig(root, "eureka", config.getEurekaConfig());
    DiscoveryConfig discoveryConfig = config.getDiscoveryConfig();
    if (discoveryConfig != null) {
        root.add("discovery", new DiscoveryConfigDTO(discoveryConfig).toJson());
    }
    WanSyncConfig syncConfig = config.getSyncConfig();
    if (syncConfig != null) {
        root.add("sync", new WanSyncConfigDTO(syncConfig).toJson());
    }
    if (config.getEndpoint() != null) {
        root.add("endpoint", config.getEndpoint());
    }
    if (!isNullOrEmpty(config.getProperties())) {
        root.add("properties", toJsonObject(config.getProperties()));
    }
    return root;
}
Also used : WanSyncConfig(com.hazelcast.config.WanSyncConfig) JsonObject(com.hazelcast.internal.json.JsonObject) JsonUtil.fromJsonObject(com.hazelcast.internal.util.JsonUtil.fromJsonObject) JsonUtil.toJsonObject(com.hazelcast.internal.util.JsonUtil.toJsonObject) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) AliasedDiscoveryConfig(com.hazelcast.config.AliasedDiscoveryConfig)

Example 7 with WanSyncConfig

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

the class WanSyncConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = new WanSyncConfig();
    JsonValue consistencyCheckStrategy = json.get("consistencyCheckStrategy");
    if (consistencyCheckStrategy != null && !consistencyCheckStrategy.isNull()) {
        config.setConsistencyCheckStrategy(ConsistencyCheckStrategy.getById((byte) consistencyCheckStrategy.asInt()));
    }
}
Also used : WanSyncConfig(com.hazelcast.config.WanSyncConfig) JsonValue(com.hazelcast.internal.json.JsonValue)

Example 8 with WanSyncConfig

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

the class WanSyncConfigDTOTest method testSerialization.

@Test
public void testSerialization() {
    WanSyncConfig expected = new WanSyncConfig().setConsistencyCheckStrategy(ConsistencyCheckStrategy.MERKLE_TREES);
    WanSyncConfig actual = cloneThroughJson(expected);
    assertTrue("Expected: " + expected + ", got:" + actual, WAN_SYNC_CONFIG_CHECKER.check(expected, actual));
}
Also used : WanSyncConfig(com.hazelcast.config.WanSyncConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

WanSyncConfig (com.hazelcast.config.WanSyncConfig)8 WanBatchPublisherConfig (com.hazelcast.config.WanBatchPublisherConfig)4 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 AwsConfig (com.hazelcast.config.AwsConfig)2 AzureConfig (com.hazelcast.config.AzureConfig)2 EurekaConfig (com.hazelcast.config.EurekaConfig)2 GcpConfig (com.hazelcast.config.GcpConfig)2 KubernetesConfig (com.hazelcast.config.KubernetesConfig)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 HashMap (java.util.HashMap)2 AliasedDiscoveryConfig (com.hazelcast.config.AliasedDiscoveryConfig)1 AttributeConfig (com.hazelcast.config.AttributeConfig)1 BitmapIndexOptions (com.hazelcast.config.BitmapIndexOptions)1 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)1 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)1 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)1 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)1