software.amazon.awssdk.services.elasticache.model.ConfigureShard Maven / Gradle / Ivy
/*
* Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.elasticache.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Node group (shard) configuration options when adding or removing replicas. Each node group (shard) configuration has
* the following members: NodeGroupId, NewReplicaCount, and PreferredAvailabilityZones.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ConfigureShard implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NODE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(ConfigureShard::nodeGroupId)).setter(setter(Builder::nodeGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupId").build()).build();
private static final SdkField NEW_REPLICA_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(ConfigureShard::newReplicaCount)).setter(setter(Builder::newReplicaCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NewReplicaCount").build()).build();
private static final SdkField> PREFERRED_AVAILABILITY_ZONES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(ConfigureShard::preferredAvailabilityZones))
.setter(setter(Builder::preferredAvailabilityZones))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PreferredAvailabilityZones").build(),
ListTrait
.builder()
.memberLocationName("PreferredAvailabilityZone")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("PreferredAvailabilityZone").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NODE_GROUP_ID_FIELD,
NEW_REPLICA_COUNT_FIELD, PREFERRED_AVAILABILITY_ZONES_FIELD));
private static final long serialVersionUID = 1L;
private final String nodeGroupId;
private final Integer newReplicaCount;
private final List preferredAvailabilityZones;
private ConfigureShard(BuilderImpl builder) {
this.nodeGroupId = builder.nodeGroupId;
this.newReplicaCount = builder.newReplicaCount;
this.preferredAvailabilityZones = builder.preferredAvailabilityZones;
}
/**
*
* The 4-digit id for the node group you are configuring. For Redis (cluster mode disabled) replication groups, the
* node group id is always 0001. To find a Redis (cluster mode enabled)'s node group's (shard's) id, see Finding a Shard's Id.
*
*
* @return The 4-digit id for the node group you are configuring. For Redis (cluster mode disabled) replication
* groups, the node group id is always 0001. To find a Redis (cluster mode enabled)'s node group's (shard's)
* id, see Finding
* a Shard's Id.
*/
public String nodeGroupId() {
return nodeGroupId;
}
/**
*
* The number of replicas you want in this node group at the end of this operation. The maximum value for
* NewReplicaCount
is 5. The minimum value depends upon the type of Redis replication group you are
* working with.
*
*
* The minimum number of replicas in a shard or replication group is:
*
*
* -
*
* Redis (cluster mode disabled)
*
*
* -
*
* If Multi-AZ with Automatic Failover is enabled: 1
*
*
* -
*
* If Multi-AZ with Automatic Failover is not enable: 0
*
*
*
*
* -
*
* Redis (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary node fails)
*
*
*
*
* @return The number of replicas you want in this node group at the end of this operation. The maximum value for
* NewReplicaCount
is 5. The minimum value depends upon the type of Redis replication group you
* are working with.
*
* The minimum number of replicas in a shard or replication group is:
*
*
* -
*
* Redis (cluster mode disabled)
*
*
* -
*
* If Multi-AZ with Automatic Failover is enabled: 1
*
*
* -
*
* If Multi-AZ with Automatic Failover is not enable: 0
*
*
*
*
* -
*
* Redis (cluster mode enabled): 0 (though you will not be able to failover to a replica if your primary
* node fails)
*
*
*/
public Integer newReplicaCount() {
return newReplicaCount;
}
/**
*
* A list of PreferredAvailabilityZone
strings that specify which availability zones the replication
* group's nodes are to be in. The nummber of PreferredAvailabilityZone
values must equal the value of
* NewReplicaCount
plus 1 to account for the primary node. If this member of
* ReplicaConfiguration
is omitted, ElastiCache for Redis selects the availability zone for each of the
* replicas.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of PreferredAvailabilityZone
strings that specify which availability zones the
* replication group's nodes are to be in. The nummber of PreferredAvailabilityZone
values must
* equal the value of NewReplicaCount
plus 1 to account for the primary node. If this member of
* ReplicaConfiguration
is omitted, ElastiCache for Redis selects the availability zone for
* each of the replicas.
*/
public List preferredAvailabilityZones() {
return preferredAvailabilityZones;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(nodeGroupId());
hashCode = 31 * hashCode + Objects.hashCode(newReplicaCount());
hashCode = 31 * hashCode + Objects.hashCode(preferredAvailabilityZones());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ConfigureShard)) {
return false;
}
ConfigureShard other = (ConfigureShard) obj;
return Objects.equals(nodeGroupId(), other.nodeGroupId()) && Objects.equals(newReplicaCount(), other.newReplicaCount())
&& Objects.equals(preferredAvailabilityZones(), other.preferredAvailabilityZones());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("ConfigureShard").add("NodeGroupId", nodeGroupId()).add("NewReplicaCount", newReplicaCount())
.add("PreferredAvailabilityZones", preferredAvailabilityZones()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "NodeGroupId":
return Optional.ofNullable(clazz.cast(nodeGroupId()));
case "NewReplicaCount":
return Optional.ofNullable(clazz.cast(newReplicaCount()));
case "PreferredAvailabilityZones":
return Optional.ofNullable(clazz.cast(preferredAvailabilityZones()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function