software.amazon.awssdk.services.elasticache.model.NodeGroupConfiguration Maven / Gradle / Ivy
Show all versions of elasticache Show documentation
/*
* 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. Each node group (shard) configuration has the following: Slots
, PrimaryAvailabilityZone
, ReplicaAvailabilityZones
, ReplicaCount
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class NodeGroupConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NODE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(NodeGroupConfiguration::nodeGroupId)).setter(setter(Builder::nodeGroupId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupId").build()).build();
private static final SdkField SLOTS_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(NodeGroupConfiguration::slots)).setter(setter(Builder::slots))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Slots").build()).build();
private static final SdkField REPLICA_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(NodeGroupConfiguration::replicaCount)).setter(setter(Builder::replicaCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaCount").build()).build();
private static final SdkField PRIMARY_AVAILABILITY_ZONE_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(NodeGroupConfiguration::primaryAvailabilityZone)).setter(setter(Builder::primaryAvailabilityZone))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryAvailabilityZone").build())
.build();
private static final SdkField> REPLICA_AVAILABILITY_ZONES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(NodeGroupConfiguration::replicaAvailabilityZones))
.setter(setter(Builder::replicaAvailabilityZones))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReplicaAvailabilityZones").build(),
ListTrait
.builder()
.memberLocationName("AvailabilityZone")
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("AvailabilityZone").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NODE_GROUP_ID_FIELD,
SLOTS_FIELD, REPLICA_COUNT_FIELD, PRIMARY_AVAILABILITY_ZONE_FIELD, REPLICA_AVAILABILITY_ZONES_FIELD));
private static final long serialVersionUID = 1L;
private final String nodeGroupId;
private final String slots;
private final Integer replicaCount;
private final String primaryAvailabilityZone;
private final List replicaAvailabilityZones;
private NodeGroupConfiguration(BuilderImpl builder) {
this.nodeGroupId = builder.nodeGroupId;
this.slots = builder.slots;
this.replicaCount = builder.replicaCount;
this.primaryAvailabilityZone = builder.primaryAvailabilityZone;
this.replicaAvailabilityZones = builder.replicaAvailabilityZones;
}
/**
*
* Either the ElastiCache for Redis supplied 4-digit id or a user supplied id for the node group these configuration
* values apply to.
*
*
* @return Either the ElastiCache for Redis supplied 4-digit id or a user supplied id for the node group these
* configuration values apply to.
*/
public String nodeGroupId() {
return nodeGroupId;
}
/**
*
* A string that specifies the keyspace for a particular node group. Keyspaces range from 0 to 16,383. The string is
* in the format startkey-endkey
.
*
*
* Example: "0-3999"
*
*
* @return A string that specifies the keyspace for a particular node group. Keyspaces range from 0 to 16,383. The
* string is in the format startkey-endkey
.
*
* Example: "0-3999"
*/
public String slots() {
return slots;
}
/**
*
* The number of read replica nodes in this node group (shard).
*
*
* @return The number of read replica nodes in this node group (shard).
*/
public Integer replicaCount() {
return replicaCount;
}
/**
*
* The Availability Zone where the primary node of this node group (shard) is launched.
*
*
* @return The Availability Zone where the primary node of this node group (shard) is launched.
*/
public String primaryAvailabilityZone() {
return primaryAvailabilityZone;
}
/**
*
* A list of Availability Zones to be used for the read replicas. The number of Availability Zones in this list must
* match the value of ReplicaCount
or ReplicasPerNodeGroup
if not specified.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of Availability Zones to be used for the read replicas. The number of Availability Zones in this
* list must match the value of ReplicaCount
or ReplicasPerNodeGroup
if not
* specified.
*/
public List replicaAvailabilityZones() {
return replicaAvailabilityZones;
}
@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(slots());
hashCode = 31 * hashCode + Objects.hashCode(replicaCount());
hashCode = 31 * hashCode + Objects.hashCode(primaryAvailabilityZone());
hashCode = 31 * hashCode + Objects.hashCode(replicaAvailabilityZones());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof NodeGroupConfiguration)) {
return false;
}
NodeGroupConfiguration other = (NodeGroupConfiguration) obj;
return Objects.equals(nodeGroupId(), other.nodeGroupId()) && Objects.equals(slots(), other.slots())
&& Objects.equals(replicaCount(), other.replicaCount())
&& Objects.equals(primaryAvailabilityZone(), other.primaryAvailabilityZone())
&& Objects.equals(replicaAvailabilityZones(), other.replicaAvailabilityZones());
}
/**
* 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("NodeGroupConfiguration").add("NodeGroupId", nodeGroupId()).add("Slots", slots())
.add("ReplicaCount", replicaCount()).add("PrimaryAvailabilityZone", primaryAvailabilityZone())
.add("ReplicaAvailabilityZones", replicaAvailabilityZones()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "NodeGroupId":
return Optional.ofNullable(clazz.cast(nodeGroupId()));
case "Slots":
return Optional.ofNullable(clazz.cast(slots()));
case "ReplicaCount":
return Optional.ofNullable(clazz.cast(replicaCount()));
case "PrimaryAvailabilityZone":
return Optional.ofNullable(clazz.cast(primaryAvailabilityZone()));
case "ReplicaAvailabilityZones":
return Optional.ofNullable(clazz.cast(replicaAvailabilityZones()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function