use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class PermissionConfigDTO method fromJson.
@Override
public void fromJson(JsonObject json) {
permissionConfig = new PermissionConfig();
permissionConfig.setType(PermissionConfig.PermissionType.getType(json.getString("permissionType", null)));
permissionConfig.setName(json.get("name").asString());
permissionConfig.setPrincipal(json.getString("principal", "*"));
JsonValue endpointsVal = json.get("endpoints");
if (endpointsVal != null) {
Set<String> endpoints = new HashSet<>();
for (JsonValue endpoint : endpointsVal.asArray().values()) {
endpoints.add(endpoint.asString());
}
permissionConfig.setEndpoints(endpoints);
}
JsonValue actionsVal = json.get("actions");
if (actionsVal != null) {
Set<String> actions = new HashSet<>();
for (JsonValue action : actionsVal.asArray().values()) {
actions.add(action.asString());
}
permissionConfig.setActions(actions);
}
}
use of com.hazelcast.internal.json.JsonValue 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")));
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class WanBatchPublisherConfigDTO method deserializeAliasedDiscoveryConfig.
/**
* Deserializes the aliased discovery config nested under the {@code tag} in the provided JSON.
*
* @param json the JSON object containing the serialized config
* @param tag the tag under which the config is nested
* @return the deserialized config or {@code null} if the serialized config
* was missing in the JSON object
*/
private AliasedDiscoveryConfig deserializeAliasedDiscoveryConfig(JsonObject json, String tag) {
JsonValue configJson = json.get(tag);
if (configJson != null && !configJson.isNull()) {
AliasedDiscoveryConfigDTO dto = new AliasedDiscoveryConfigDTO(tag);
dto.fromJson(configJson.asObject());
return dto.getConfig();
}
return null;
}
use of com.hazelcast.internal.json.JsonValue 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")));
}
use of com.hazelcast.internal.json.JsonValue in project hazelcast by hazelcast.
the class WanReplicationConfigDTO method fromJson.
@Override
public void fromJson(JsonObject json) {
config = new WanReplicationConfig();
JsonValue name = json.get("name");
if (name != null) {
config.setName(name.asString());
}
JsonValue batchPublishers = json.get("batchPublishers");
if (batchPublishers != null && !batchPublishers.isNull()) {
for (JsonValue jsonValue : batchPublishers.asArray()) {
WanBatchPublisherConfigDTO dto = new WanBatchPublisherConfigDTO();
dto.fromJson(jsonValue.asObject());
config.addBatchReplicationPublisherConfig(dto.getConfig());
}
}
JsonValue customPublishers = json.get("customPublishers");
if (customPublishers != null && !customPublishers.isNull()) {
for (JsonValue jsonValue : customPublishers.asArray()) {
CustomWanPublisherConfigDTO dto = new CustomWanPublisherConfigDTO();
dto.fromJson(jsonValue.asObject());
config.addCustomPublisherConfig(dto.getConfig());
}
}
JsonValue consumer = json.get("consumer");
if (consumer != null && !consumer.isNull()) {
WanConsumerConfigDTO consumerDTO = new WanConsumerConfigDTO();
consumerDTO.fromJson(consumer.asObject());
config.setConsumerConfig(consumerDTO.getConfig());
}
}
Aggregations