Search in sources :

Example 96 with JsonObject

use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.

the class WanConsumerConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = new WanConsumerConfig();
    JsonValue persistWanReplicatedData = json.get("persistWanReplicatedData");
    if (persistWanReplicatedData != null && !persistWanReplicatedData.isNull()) {
        config.setPersistWanReplicatedData(persistWanReplicatedData.asBoolean());
    }
    JsonValue className = json.get("className");
    if (className != null && !className.isNull()) {
        config.setClassName(className.asString());
    }
    config.setProperties(fromJsonObject((JsonObject) json.get("properties")));
}
Also used : WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) 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)

Example 97 with JsonObject

use of com.hazelcast.internal.json.JsonObject 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 98 with JsonObject

use of com.hazelcast.internal.json.JsonObject 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 99 with JsonObject

use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.

the class WanConfigurationExtendedEvent method toJson.

@Override
public JsonObject toJson() {
    JsonObject json = super.toJson();
    JsonArray publisherIds = new JsonArray();
    for (String publisherId : wanPublisherIds) {
        publisherIds.add(publisherId);
    }
    json.add("wanPublisherIds", publisherIds);
    return json;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 100 with JsonObject

use of com.hazelcast.internal.json.JsonObject in project hazelcast by hazelcast.

the class WanConsistencyCheckFinishedEvent method toJson.

@Override
public JsonObject toJson() {
    JsonObject json = super.toJson();
    json.add("diffCount", diffCount);
    json.add("checkedCount", checkedCount);
    json.add("entriesToSync", entriesToSync);
    return json;
}
Also used : JsonObject(com.hazelcast.internal.json.JsonObject)

Aggregations

JsonObject (com.hazelcast.internal.json.JsonObject)151 Test (org.junit.Test)56 JsonArray (com.hazelcast.internal.json.JsonArray)41 QuickTest (com.hazelcast.test.annotation.QuickTest)38 JsonValue (com.hazelcast.internal.json.JsonValue)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)26 HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)23 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 JsonUtil.getString (com.hazelcast.internal.util.JsonUtil.getString)10 SlowTest (com.hazelcast.test.annotation.SlowTest)9 HashMap (java.util.HashMap)8 CPMember (com.hazelcast.cp.CPMember)7 ArrayList (java.util.ArrayList)7 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)6 NavigableJsonInputAdapter (com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter)6 JsonUtil.fromJsonObject (com.hazelcast.internal.util.JsonUtil.fromJsonObject)5 JsonUtil.toJsonObject (com.hazelcast.internal.util.JsonUtil.toJsonObject)5 Map (java.util.Map)5 ClusterService (com.hazelcast.internal.cluster.ClusterService)4 Address (com.hazelcast.cluster.Address)3