All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.elasticache.model.NodeGroup Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon ElastiCache module holds the client classes that are used for communicating with Amazon ElastiCache Service

There is a newer version: 2.29.39
Show newest version
/*
 * Copyright 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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Represents a collection of cache nodes in a replication group. One node in the node group is the read/write primary * node. All the other nodes are read-only Replica nodes. *

*/ @Generated("software.amazon.awssdk:codegen") public final class NodeGroup implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField NODE_GROUP_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("NodeGroupId").getter(getter(NodeGroup::nodeGroupId)).setter(setter(Builder::nodeGroupId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupId").build()).build(); private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status") .getter(getter(NodeGroup::status)).setter(setter(Builder::status)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build(); private static final SdkField PRIMARY_ENDPOINT_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("PrimaryEndpoint").getter(getter(NodeGroup::primaryEndpoint)).setter(setter(Builder::primaryEndpoint)) .constructor(Endpoint::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrimaryEndpoint").build()).build(); private static final SdkField READER_ENDPOINT_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("ReaderEndpoint").getter(getter(NodeGroup::readerEndpoint)).setter(setter(Builder::readerEndpoint)) .constructor(Endpoint::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ReaderEndpoint").build()).build(); private static final SdkField SLOTS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Slots") .getter(getter(NodeGroup::slots)).setter(setter(Builder::slots)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Slots").build()).build(); private static final SdkField> NODE_GROUP_MEMBERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("NodeGroupMembers") .getter(getter(NodeGroup::nodeGroupMembers)) .setter(setter(Builder::nodeGroupMembers)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NodeGroupMembers").build(), ListTrait .builder() .memberLocationName("NodeGroupMember") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(NodeGroupMember::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("NodeGroupMember").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NODE_GROUP_ID_FIELD, STATUS_FIELD, PRIMARY_ENDPOINT_FIELD, READER_ENDPOINT_FIELD, SLOTS_FIELD, NODE_GROUP_MEMBERS_FIELD)); private static final long serialVersionUID = 1L; private final String nodeGroupId; private final String status; private final Endpoint primaryEndpoint; private final Endpoint readerEndpoint; private final String slots; private final List nodeGroupMembers; private NodeGroup(BuilderImpl builder) { this.nodeGroupId = builder.nodeGroupId; this.status = builder.status; this.primaryEndpoint = builder.primaryEndpoint; this.readerEndpoint = builder.readerEndpoint; this.slots = builder.slots; this.nodeGroupMembers = builder.nodeGroupMembers; } /** *

* The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains only 1 node * group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication group contains 1 to 90 * node groups numbered 0001 to 0090. Optionally, the user can provide the id for a node group. *

* * @return The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains * only 1 node group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication group * contains 1 to 90 node groups numbered 0001 to 0090. Optionally, the user can provide the id for a node * group. */ public final String nodeGroupId() { return nodeGroupId; } /** *

* The current state of this replication group - creating, available, * modifying, deleting. *

* * @return The current state of this replication group - creating, available, * modifying, deleting. */ public final String status() { return status; } /** *

* The endpoint of the primary node in this node group (shard). *

* * @return The endpoint of the primary node in this node group (shard). */ public final Endpoint primaryEndpoint() { return primaryEndpoint; } /** *

* The endpoint of the replica nodes in this node group (shard). *

* * @return The endpoint of the replica nodes in this node group (shard). */ public final Endpoint readerEndpoint() { return readerEndpoint; } /** *

* The keyspace for this node group (shard). *

* * @return The keyspace for this node group (shard). */ public final String slots() { return slots; } /** * Returns true if the NodeGroupMembers property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasNodeGroupMembers() { return nodeGroupMembers != null && !(nodeGroupMembers instanceof SdkAutoConstructList); } /** *

* A list containing information about individual nodes within the node group (shard). *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasNodeGroupMembers()} to see if a value was sent in this field. *

* * @return A list containing information about individual nodes within the node group (shard). */ public final List nodeGroupMembers() { return nodeGroupMembers; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(nodeGroupId()); hashCode = 31 * hashCode + Objects.hashCode(status()); hashCode = 31 * hashCode + Objects.hashCode(primaryEndpoint()); hashCode = 31 * hashCode + Objects.hashCode(readerEndpoint()); hashCode = 31 * hashCode + Objects.hashCode(slots()); hashCode = 31 * hashCode + Objects.hashCode(hasNodeGroupMembers() ? nodeGroupMembers() : null); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof NodeGroup)) { return false; } NodeGroup other = (NodeGroup) obj; return Objects.equals(nodeGroupId(), other.nodeGroupId()) && Objects.equals(status(), other.status()) && Objects.equals(primaryEndpoint(), other.primaryEndpoint()) && Objects.equals(readerEndpoint(), other.readerEndpoint()) && Objects.equals(slots(), other.slots()) && hasNodeGroupMembers() == other.hasNodeGroupMembers() && Objects.equals(nodeGroupMembers(), other.nodeGroupMembers()); } /** * 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 final String toString() { return ToString.builder("NodeGroup").add("NodeGroupId", nodeGroupId()).add("Status", status()) .add("PrimaryEndpoint", primaryEndpoint()).add("ReaderEndpoint", readerEndpoint()).add("Slots", slots()) .add("NodeGroupMembers", hasNodeGroupMembers() ? nodeGroupMembers() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "NodeGroupId": return Optional.ofNullable(clazz.cast(nodeGroupId())); case "Status": return Optional.ofNullable(clazz.cast(status())); case "PrimaryEndpoint": return Optional.ofNullable(clazz.cast(primaryEndpoint())); case "ReaderEndpoint": return Optional.ofNullable(clazz.cast(readerEndpoint())); case "Slots": return Optional.ofNullable(clazz.cast(slots())); case "NodeGroupMembers": return Optional.ofNullable(clazz.cast(nodeGroupMembers())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((NodeGroup) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains only 1 * node group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication group contains 1 * to 90 node groups numbered 0001 to 0090. Optionally, the user can provide the id for a node group. *

* * @param nodeGroupId * The identifier for the node group (shard). A Redis (cluster mode disabled) replication group contains * only 1 node group; therefore, the node group ID is 0001. A Redis (cluster mode enabled) replication * group contains 1 to 90 node groups numbered 0001 to 0090. Optionally, the user can provide the id for * a node group. * @return Returns a reference to this object so that method calls can be chained together. */ Builder nodeGroupId(String nodeGroupId); /** *

* The current state of this replication group - creating, available, * modifying, deleting. *

* * @param status * The current state of this replication group - creating, available, * modifying, deleting. * @return Returns a reference to this object so that method calls can be chained together. */ Builder status(String status); /** *

* The endpoint of the primary node in this node group (shard). *

* * @param primaryEndpoint * The endpoint of the primary node in this node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder primaryEndpoint(Endpoint primaryEndpoint); /** *

* The endpoint of the primary node in this node group (shard). *

* This is a convenience that creates an instance of the {@link Endpoint.Builder} avoiding the need to create * one manually via {@link Endpoint#builder()}. * * When the {@link Consumer} completes, {@link Endpoint.Builder#build()} is called immediately and its result is * passed to {@link #primaryEndpoint(Endpoint)}. * * @param primaryEndpoint * a consumer that will call methods on {@link Endpoint.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #primaryEndpoint(Endpoint) */ default Builder primaryEndpoint(Consumer primaryEndpoint) { return primaryEndpoint(Endpoint.builder().applyMutation(primaryEndpoint).build()); } /** *

* The endpoint of the replica nodes in this node group (shard). *

* * @param readerEndpoint * The endpoint of the replica nodes in this node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder readerEndpoint(Endpoint readerEndpoint); /** *

* The endpoint of the replica nodes in this node group (shard). *

* This is a convenience that creates an instance of the {@link Endpoint.Builder} avoiding the need to create * one manually via {@link Endpoint#builder()}. * * When the {@link Consumer} completes, {@link Endpoint.Builder#build()} is called immediately and its result is * passed to {@link #readerEndpoint(Endpoint)}. * * @param readerEndpoint * a consumer that will call methods on {@link Endpoint.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #readerEndpoint(Endpoint) */ default Builder readerEndpoint(Consumer readerEndpoint) { return readerEndpoint(Endpoint.builder().applyMutation(readerEndpoint).build()); } /** *

* The keyspace for this node group (shard). *

* * @param slots * The keyspace for this node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder slots(String slots); /** *

* A list containing information about individual nodes within the node group (shard). *

* * @param nodeGroupMembers * A list containing information about individual nodes within the node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder nodeGroupMembers(Collection nodeGroupMembers); /** *

* A list containing information about individual nodes within the node group (shard). *

* * @param nodeGroupMembers * A list containing information about individual nodes within the node group (shard). * @return Returns a reference to this object so that method calls can be chained together. */ Builder nodeGroupMembers(NodeGroupMember... nodeGroupMembers); /** *

* A list containing information about individual nodes within the node group (shard). *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need * to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and * its result is passed to {@link #nodeGroupMembers(List)}. * * @param nodeGroupMembers * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #nodeGroupMembers(List) */ Builder nodeGroupMembers(Consumer... nodeGroupMembers); } static final class BuilderImpl implements Builder { private String nodeGroupId; private String status; private Endpoint primaryEndpoint; private Endpoint readerEndpoint; private String slots; private List nodeGroupMembers = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(NodeGroup model) { nodeGroupId(model.nodeGroupId); status(model.status); primaryEndpoint(model.primaryEndpoint); readerEndpoint(model.readerEndpoint); slots(model.slots); nodeGroupMembers(model.nodeGroupMembers); } public final String getNodeGroupId() { return nodeGroupId; } @Override public final Builder nodeGroupId(String nodeGroupId) { this.nodeGroupId = nodeGroupId; return this; } public final void setNodeGroupId(String nodeGroupId) { this.nodeGroupId = nodeGroupId; } public final String getStatus() { return status; } @Override public final Builder status(String status) { this.status = status; return this; } public final void setStatus(String status) { this.status = status; } public final Endpoint.Builder getPrimaryEndpoint() { return primaryEndpoint != null ? primaryEndpoint.toBuilder() : null; } @Override public final Builder primaryEndpoint(Endpoint primaryEndpoint) { this.primaryEndpoint = primaryEndpoint; return this; } public final void setPrimaryEndpoint(Endpoint.BuilderImpl primaryEndpoint) { this.primaryEndpoint = primaryEndpoint != null ? primaryEndpoint.build() : null; } public final Endpoint.Builder getReaderEndpoint() { return readerEndpoint != null ? readerEndpoint.toBuilder() : null; } @Override public final Builder readerEndpoint(Endpoint readerEndpoint) { this.readerEndpoint = readerEndpoint; return this; } public final void setReaderEndpoint(Endpoint.BuilderImpl readerEndpoint) { this.readerEndpoint = readerEndpoint != null ? readerEndpoint.build() : null; } public final String getSlots() { return slots; } @Override public final Builder slots(String slots) { this.slots = slots; return this; } public final void setSlots(String slots) { this.slots = slots; } public final Collection getNodeGroupMembers() { if (nodeGroupMembers instanceof SdkAutoConstructList) { return null; } return nodeGroupMembers != null ? nodeGroupMembers.stream().map(NodeGroupMember::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder nodeGroupMembers(Collection nodeGroupMembers) { this.nodeGroupMembers = NodeGroupMemberListCopier.copy(nodeGroupMembers); return this; } @Override @SafeVarargs public final Builder nodeGroupMembers(NodeGroupMember... nodeGroupMembers) { nodeGroupMembers(Arrays.asList(nodeGroupMembers)); return this; } @Override @SafeVarargs public final Builder nodeGroupMembers(Consumer... nodeGroupMembers) { nodeGroupMembers(Stream.of(nodeGroupMembers).map(c -> NodeGroupMember.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setNodeGroupMembers(Collection nodeGroupMembers) { this.nodeGroupMembers = NodeGroupMemberListCopier.copyFromBuilder(nodeGroupMembers); } @Override public NodeGroup build() { return new NodeGroup(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy