Search in sources :

Example 16 with WanBatchPublisherConfig

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

the class DynamicConfigYamlGenerator method getWanBatchPublisherConfigsAsMap.

@SuppressWarnings("checkstyle:MethodLength")
private static Map<String, Object> getWanBatchPublisherConfigsAsMap(List<WanBatchPublisherConfig> wanBatchPublisherConfigs) {
    if (wanBatchPublisherConfigs == null || wanBatchPublisherConfigs.isEmpty()) {
        return null;
    }
    Map<String, Object> wanBatchPublisherConfigsAsMap = new LinkedHashMap<>();
    for (WanBatchPublisherConfig wanBatchPublisherConfig : wanBatchPublisherConfigs) {
        Map<String, Object> wanBatchPublisherConfigAsMap = new LinkedHashMap<>();
        addNonNullToMap(wanBatchPublisherConfigAsMap, "cluster-name", wanBatchPublisherConfig.getClusterName());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "batch-size", wanBatchPublisherConfig.getBatchSize());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "batch-max-delay-millis", wanBatchPublisherConfig.getBatchMaxDelayMillis());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "response-timeout-millis", wanBatchPublisherConfig.getResponseTimeoutMillis());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "acknowledge-type", wanBatchPublisherConfig.getAcknowledgeType().name());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "initial-publisher-state", wanBatchPublisherConfig.getInitialPublisherState().name());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "snapshot-enabled", wanBatchPublisherConfig.isSnapshotEnabled());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "idle-max-park-ns", wanBatchPublisherConfig.getIdleMaxParkNs());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "idle-min-park-ns", wanBatchPublisherConfig.getIdleMinParkNs());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "max-concurrent-invocations", wanBatchPublisherConfig.getMaxConcurrentInvocations());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "discovery-period-seconds", wanBatchPublisherConfig.getDiscoveryPeriodSeconds());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "use-endpoint-private-address", wanBatchPublisherConfig.isUseEndpointPrivateAddress());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "queue-full-behavior", wanBatchPublisherConfig.getQueueFullBehavior().name());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "max-target-endpoints", wanBatchPublisherConfig.getMaxTargetEndpoints());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "queue-capacity", wanBatchPublisherConfig.getQueueCapacity());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "properties", getPropertiesAsMap(wanBatchPublisherConfig.getProperties()));
        addNonNullToMap(wanBatchPublisherConfigAsMap, "target-endpoints", wanBatchPublisherConfig.getTargetEndpoints());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "endpoint", wanBatchPublisherConfig.getEndpoint());
        addNonNullToMap(wanBatchPublisherConfigAsMap, "sync", wrapObjectWithMap("consistency-check-strategy", wanBatchPublisherConfig.getSyncConfig().getConsistencyCheckStrategy().name()));
        addNonNullToMap(wanBatchPublisherConfigAsMap, "discovery-strategies", getDiscoveryConfigAsMap(wanBatchPublisherConfig.getDiscoveryConfig()));
        addNonNullToMap(wanBatchPublisherConfigAsMap, "discovery-strategies", getDiscoveryConfigAsMap(wanBatchPublisherConfig.getDiscoveryConfig()));
        for (AliasedDiscoveryConfig<?> aliasedDiscoveryConfig : aliasedDiscoveryConfigsFrom(wanBatchPublisherConfig)) {
            addNonNullToMap(wanBatchPublisherConfigAsMap, aliasedDiscoveryConfig.getTag(), getAliasedDiscoveryConfigAsMap(aliasedDiscoveryConfig));
        }
        wanBatchPublisherConfigsAsMap.put(wanBatchPublisherConfig.getPublisherId(), wanBatchPublisherConfigAsMap);
    }
    return wanBatchPublisherConfigsAsMap;
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with WanBatchPublisherConfig

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

the class WanBatchPublisherConfigDTO method fromJson.

@Override
@SuppressWarnings({ "checkstyle:methodlength", "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity" })
public void fromJson(JsonObject json) {
    config = new WanBatchPublisherConfig();
    consumeIfExists(json, "clusterName", v -> config.setClusterName(v.asString()));
    consumeIfExists(json, "publisherId", v -> config.setPublisherId(v.asString()));
    consumeIfExists(json, "batchSize", v -> config.setBatchSize(v.asInt()));
    consumeIfExists(json, "batchMaxDelayMillis", v -> config.setBatchMaxDelayMillis(v.asInt()));
    consumeIfExists(json, "responseTimeoutMillis", v -> config.setResponseTimeoutMillis(v.asInt()));
    consumeIfExists(json, "acknowledgeType", v -> config.setAcknowledgeType(WanAcknowledgeType.getById(v.asInt())));
    consumeIfExists(json, "initialPublisherState", v -> config.setInitialPublisherState(WanPublisherState.getByType((byte) v.asInt())));
    consumeIfExists(json, "snapshotEnabled", v -> config.setSnapshotEnabled(v.asBoolean()));
    consumeIfExists(json, "idleMaxParkNs", v -> config.setIdleMaxParkNs(v.asLong()));
    consumeIfExists(json, "idleMinParkNs", v -> config.setIdleMinParkNs(v.asLong()));
    consumeIfExists(json, "maxConcurrentInvocations", v -> config.setMaxConcurrentInvocations(v.asInt()));
    consumeIfExists(json, "discoveryPeriodSeconds", v -> config.setDiscoveryPeriodSeconds(v.asInt()));
    consumeIfExists(json, "useEndpointPrivateAddress", v -> config.setUseEndpointPrivateAddress(v.asBoolean()));
    consumeIfExists(json, "queueFullBehavior", v -> config.setQueueFullBehavior(WanQueueFullBehavior.getByType(v.asInt())));
    consumeIfExists(json, "maxTargetEndpoints", v -> config.setMaxTargetEndpoints(v.asInt()));
    consumeIfExists(json, "queueCapacity", v -> config.setQueueCapacity(v.asInt()));
    consumeIfExists(json, "targetEndpoints", v -> config.setTargetEndpoints(v.asString()));
    AwsConfig awsConfig = (AwsConfig) this.deserializeAliasedDiscoveryConfig(json, "aws");
    if (awsConfig != null) {
        config.setAwsConfig(awsConfig);
    }
    GcpConfig gcpConfig = (GcpConfig) this.deserializeAliasedDiscoveryConfig(json, "gcp");
    if (gcpConfig != null) {
        config.setGcpConfig(gcpConfig);
    }
    AzureConfig azureConfig = (AzureConfig) this.deserializeAliasedDiscoveryConfig(json, "azure");
    if (azureConfig != null) {
        config.setAzureConfig(azureConfig);
    }
    KubernetesConfig kubernetesConfig = (KubernetesConfig) this.deserializeAliasedDiscoveryConfig(json, "kubernetes");
    if (kubernetesConfig != null) {
        config.setKubernetesConfig(kubernetesConfig);
    }
    EurekaConfig eurekaConfig = (EurekaConfig) this.deserializeAliasedDiscoveryConfig(json, "eureka");
    if (eurekaConfig != null) {
        config.setEurekaConfig(eurekaConfig);
    }
    JsonValue discoveryJson = json.get("discovery");
    if (discoveryJson != null && !discoveryJson.isNull()) {
        DiscoveryConfigDTO discoveryDTO = new DiscoveryConfigDTO();
        discoveryDTO.fromJson(discoveryJson.asObject());
        config.setDiscoveryConfig(discoveryDTO.getConfig());
    }
    JsonValue syncJson = json.get("sync");
    if (syncJson != null && !syncJson.isNull()) {
        WanSyncConfigDTO syncDTO = new WanSyncConfigDTO();
        syncDTO.fromJson(syncJson.asObject());
        config.setSyncConfig(syncDTO.getConfig());
    }
    consumeIfExists(json, "endpoint", v -> config.setEndpoint(v.asString()));
    config.setProperties(fromJsonObject((JsonObject) json.get("properties")));
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EurekaConfig(com.hazelcast.config.EurekaConfig) AwsConfig(com.hazelcast.config.AwsConfig) AzureConfig(com.hazelcast.config.AzureConfig) KubernetesConfig(com.hazelcast.config.KubernetesConfig) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) JsonUtil.fromJsonObject(com.hazelcast.internal.util.JsonUtil.fromJsonObject) JsonUtil.toJsonObject(com.hazelcast.internal.util.JsonUtil.toJsonObject) GcpConfig(com.hazelcast.config.GcpConfig)

Example 18 with WanBatchPublisherConfig

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

the class WanBatchPublisherConfigDTOTest method testDefault.

@Test
public void testDefault() {
    WanBatchPublisherConfig expected = new WanBatchPublisherConfig();
    WanBatchPublisherConfig actual = cloneThroughJson(expected);
    assertTrue("Expected: " + expected + ", got:" + actual, WAN_PUBLISHER_CONFIG_CHECKER.check(expected, actual));
}
Also used : WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

WanBatchPublisherConfig (com.hazelcast.config.WanBatchPublisherConfig)18 WanReplicationConfig (com.hazelcast.config.WanReplicationConfig)11 WanCustomPublisherConfig (com.hazelcast.config.WanCustomPublisherConfig)8 Test (org.junit.Test)8 WanConsumerConfig (com.hazelcast.config.WanConsumerConfig)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 AwsConfig (com.hazelcast.config.AwsConfig)4 WanSyncConfig (com.hazelcast.config.WanSyncConfig)4 AzureConfig (com.hazelcast.config.AzureConfig)3 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)3 EurekaConfig (com.hazelcast.config.EurekaConfig)3 GcpConfig (com.hazelcast.config.GcpConfig)3 KubernetesConfig (com.hazelcast.config.KubernetesConfig)3 HashMap (java.util.HashMap)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)2 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)2 Config (com.hazelcast.config.Config)2