com.azure.resourcemanager.servicefabricmanagedclusters.models.ServicePlacementRequireDomainDistributionPolicy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-servicefabricmanagedclusters Show documentation
Show all versions of azure-resourcemanager-servicefabricmanagedclusters Show documentation
This package contains Microsoft Azure SDK for Service Fabric Managed Clusters Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Service Fabric Managed Clusters Management Client. Package tag package-2024-04.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.servicefabricmanagedclusters.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* Describes the policy to be used for placement of a Service Fabric service where two replicas
* from the same partition should never be placed in the same fault or upgrade domain.
*
* While this is not common it can expose the service to an increased risk of concurrent failures
* due to unplanned outages or other cases of subsequent/concurrent failures. As an example, consider
* a case where replicas are deployed across different data center, with one replica per location.
* In the event that one of the datacenters goes offline, normally the replica that was placed in that
* datacenter will be packed into one of the remaining datacenters. If this is not desirable then this
* policy should be set.
*/
@Fluent
public final class ServicePlacementRequireDomainDistributionPolicy extends ServicePlacementPolicy {
/*
* The type of placement policy for a service fabric service. Following are the possible values.
*/
private ServicePlacementPolicyType type = ServicePlacementPolicyType.REQUIRED_DOMAIN_DISTRIBUTION;
/*
* The name of the domain that should used for placement as per this policy.
*/
private String domainName;
/**
* Creates an instance of ServicePlacementRequireDomainDistributionPolicy class.
*/
public ServicePlacementRequireDomainDistributionPolicy() {
}
/**
* Get the type property: The type of placement policy for a service fabric service. Following are the possible
* values.
*
* @return the type value.
*/
@Override
public ServicePlacementPolicyType type() {
return this.type;
}
/**
* Get the domainName property: The name of the domain that should used for placement as per this policy.
*
* @return the domainName value.
*/
public String domainName() {
return this.domainName;
}
/**
* Set the domainName property: The name of the domain that should used for placement as per this policy.
*
* @param domainName the domainName value to set.
* @return the ServicePlacementRequireDomainDistributionPolicy object itself.
*/
public ServicePlacementRequireDomainDistributionPolicy withDomainName(String domainName) {
this.domainName = domainName;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
super.validate();
if (domainName() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property domainName in model ServicePlacementRequireDomainDistributionPolicy"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ServicePlacementRequireDomainDistributionPolicy.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("domainName", this.domainName);
jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ServicePlacementRequireDomainDistributionPolicy from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ServicePlacementRequireDomainDistributionPolicy if the JsonReader was pointing to an
* instance of it, or null if it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the ServicePlacementRequireDomainDistributionPolicy.
*/
public static ServicePlacementRequireDomainDistributionPolicy fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ServicePlacementRequireDomainDistributionPolicy deserializedServicePlacementRequireDomainDistributionPolicy
= new ServicePlacementRequireDomainDistributionPolicy();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("domainName".equals(fieldName)) {
deserializedServicePlacementRequireDomainDistributionPolicy.domainName = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedServicePlacementRequireDomainDistributionPolicy.type
= ServicePlacementPolicyType.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedServicePlacementRequireDomainDistributionPolicy;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy