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

com.arakelian.elastic.model.ImmutableClusterHealth Maven / Gradle / Ivy

package com.arakelian.elastic.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link ClusterHealth}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableClusterHealth.builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableClusterHealth implements ClusterHealth { private final Integer activePrimaryShards; private final Integer activeShards; private final Double activeShardsPercentAsNumber; private final String clusterName; private final Integer delayedUnassignedShards; private final Integer initializingShards; private final Integer numberOfDataNodes; private final Integer numberOfInFlightFetch; private final Integer numberOfNodes; private final Integer numberOfPendingTasks; private final Integer relocatingShards; private final ClusterHealth.Status status; private final Integer taskMaxWaitingInQueueMillis; private final Boolean timedOut; private final Integer unassignedShards; private ImmutableClusterHealth(ImmutableClusterHealth.Builder builder) { this.activePrimaryShards = builder.activePrimaryShards; this.activeShards = builder.activeShards; this.activeShardsPercentAsNumber = builder.activeShardsPercentAsNumber; this.clusterName = builder.clusterName; this.delayedUnassignedShards = builder.delayedUnassignedShards; this.initializingShards = builder.initializingShards; this.numberOfDataNodes = builder.numberOfDataNodes; this.numberOfInFlightFetch = builder.numberOfInFlightFetch; this.numberOfNodes = builder.numberOfNodes; this.numberOfPendingTasks = builder.numberOfPendingTasks; this.relocatingShards = builder.relocatingShards; this.status = builder.status; this.taskMaxWaitingInQueueMillis = builder.taskMaxWaitingInQueueMillis; this.timedOut = builder.timedOut; this.unassignedShards = builder.unassignedShards; } /** * @return The value of the {@code activePrimaryShards} attribute */ @JsonProperty("active_primary_shards") @Override public Integer getActivePrimaryShards() { return activePrimaryShards; } /** * @return The value of the {@code activeShards} attribute */ @JsonProperty("active_shards") @Override public Integer getActiveShards() { return activeShards; } /** * @return The value of the {@code activeShardsPercentAsNumber} attribute */ @JsonProperty("active_shards_percent_as_number") @Override public Double getActiveShardsPercentAsNumber() { return activeShardsPercentAsNumber; } /** * @return The value of the {@code clusterName} attribute */ @JsonProperty("cluster_name") @Override public String getClusterName() { return clusterName; } /** * @return The value of the {@code delayedUnassignedShards} attribute */ @JsonProperty("delayed_unassigned_shards") @Override public Integer getDelayedUnassignedShards() { return delayedUnassignedShards; } /** * @return The value of the {@code initializingShards} attribute */ @JsonProperty("initializing_shards") @Override public Integer getInitializingShards() { return initializingShards; } /** * @return The value of the {@code numberOfDataNodes} attribute */ @JsonProperty("number_of_data_nodes") @Override public Integer getNumberOfDataNodes() { return numberOfDataNodes; } /** * @return The value of the {@code numberOfInFlightFetch} attribute */ @JsonProperty("number_of_in_flight_fetch") @Override public Integer getNumberOfInFlightFetch() { return numberOfInFlightFetch; } /** * @return The value of the {@code numberOfNodes} attribute */ @JsonProperty("number_of_nodes") @Override public Integer getNumberOfNodes() { return numberOfNodes; } /** * @return The value of the {@code numberOfPendingTasks} attribute */ @JsonProperty("number_of_pending_tasks") @Override public Integer getNumberOfPendingTasks() { return numberOfPendingTasks; } /** * @return The value of the {@code relocatingShards} attribute */ @JsonProperty("relocating_shards") @Override public Integer getRelocatingShards() { return relocatingShards; } /** * @return The value of the {@code status} attribute */ @JsonProperty("status") @Override public ClusterHealth.Status getStatus() { return status; } /** * @return The value of the {@code taskMaxWaitingInQueueMillis} attribute */ @JsonProperty("task_max_waiting_in_queue_millis") @Override public Integer getTaskMaxWaitingInQueueMillis() { return taskMaxWaitingInQueueMillis; } /** * @return The value of the {@code timedOut} attribute */ @JsonProperty("timed_out") @Override public Boolean getTimedOut() { return timedOut; } /** * @return The value of the {@code unassignedShards} attribute */ @JsonProperty("unassigned_shards") @Override public Integer getUnassignedShards() { return unassignedShards; } /** * This instance is equal to all instances of {@code ImmutableClusterHealth} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableClusterHealth && equalTo((ImmutableClusterHealth) another); } private boolean equalTo(ImmutableClusterHealth another) { return activePrimaryShards.equals(another.activePrimaryShards) && activeShards.equals(another.activeShards) && activeShardsPercentAsNumber.equals(another.activeShardsPercentAsNumber) && clusterName.equals(another.clusterName) && delayedUnassignedShards.equals(another.delayedUnassignedShards) && initializingShards.equals(another.initializingShards) && numberOfDataNodes.equals(another.numberOfDataNodes) && numberOfInFlightFetch.equals(another.numberOfInFlightFetch) && numberOfNodes.equals(another.numberOfNodes) && numberOfPendingTasks.equals(another.numberOfPendingTasks) && relocatingShards.equals(another.relocatingShards) && status.equals(another.status) && taskMaxWaitingInQueueMillis.equals(another.taskMaxWaitingInQueueMillis) && timedOut.equals(another.timedOut) && unassignedShards.equals(another.unassignedShards); } /** * Computes a hash code from attributes: {@code activePrimaryShards}, {@code activeShards}, {@code activeShardsPercentAsNumber}, {@code clusterName}, {@code delayedUnassignedShards}, {@code initializingShards}, {@code numberOfDataNodes}, {@code numberOfInFlightFetch}, {@code numberOfNodes}, {@code numberOfPendingTasks}, {@code relocatingShards}, {@code status}, {@code taskMaxWaitingInQueueMillis}, {@code timedOut}, {@code unassignedShards}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + activePrimaryShards.hashCode(); h += (h << 5) + activeShards.hashCode(); h += (h << 5) + activeShardsPercentAsNumber.hashCode(); h += (h << 5) + clusterName.hashCode(); h += (h << 5) + delayedUnassignedShards.hashCode(); h += (h << 5) + initializingShards.hashCode(); h += (h << 5) + numberOfDataNodes.hashCode(); h += (h << 5) + numberOfInFlightFetch.hashCode(); h += (h << 5) + numberOfNodes.hashCode(); h += (h << 5) + numberOfPendingTasks.hashCode(); h += (h << 5) + relocatingShards.hashCode(); h += (h << 5) + status.hashCode(); h += (h << 5) + taskMaxWaitingInQueueMillis.hashCode(); h += (h << 5) + timedOut.hashCode(); h += (h << 5) + unassignedShards.hashCode(); return h; } /** * Prints the immutable value {@code ClusterHealth} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("ClusterHealth") .omitNullValues() .add("activePrimaryShards", activePrimaryShards) .add("activeShards", activeShards) .add("activeShardsPercentAsNumber", activeShardsPercentAsNumber) .add("clusterName", clusterName) .add("delayedUnassignedShards", delayedUnassignedShards) .add("initializingShards", initializingShards) .add("numberOfDataNodes", numberOfDataNodes) .add("numberOfInFlightFetch", numberOfInFlightFetch) .add("numberOfNodes", numberOfNodes) .add("numberOfPendingTasks", numberOfPendingTasks) .add("relocatingShards", relocatingShards) .add("status", status) .add("taskMaxWaitingInQueueMillis", taskMaxWaitingInQueueMillis) .add("timedOut", timedOut) .add("unassignedShards", unassignedShards) .toString(); } /** * Creates a builder for {@link ImmutableClusterHealth ImmutableClusterHealth}. * @return A new ImmutableClusterHealth builder */ public static ImmutableClusterHealth.Builder builder() { return new ImmutableClusterHealth.Builder(); } /** * Builds instances of type {@link ImmutableClusterHealth ImmutableClusterHealth}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ACTIVE_PRIMARY_SHARDS = 0x1L; private static final long INIT_BIT_ACTIVE_SHARDS = 0x2L; private static final long INIT_BIT_ACTIVE_SHARDS_PERCENT_AS_NUMBER = 0x4L; private static final long INIT_BIT_CLUSTER_NAME = 0x8L; private static final long INIT_BIT_DELAYED_UNASSIGNED_SHARDS = 0x10L; private static final long INIT_BIT_INITIALIZING_SHARDS = 0x20L; private static final long INIT_BIT_NUMBER_OF_DATA_NODES = 0x40L; private static final long INIT_BIT_NUMBER_OF_IN_FLIGHT_FETCH = 0x80L; private static final long INIT_BIT_NUMBER_OF_NODES = 0x100L; private static final long INIT_BIT_NUMBER_OF_PENDING_TASKS = 0x200L; private static final long INIT_BIT_RELOCATING_SHARDS = 0x400L; private static final long INIT_BIT_STATUS = 0x800L; private static final long INIT_BIT_TASK_MAX_WAITING_IN_QUEUE_MILLIS = 0x1000L; private static final long INIT_BIT_TIMED_OUT = 0x2000L; private static final long INIT_BIT_UNASSIGNED_SHARDS = 0x4000L; private long initBits = 0x7fffL; private @Nullable Integer activePrimaryShards; private @Nullable Integer activeShards; private @Nullable Double activeShardsPercentAsNumber; private @Nullable String clusterName; private @Nullable Integer delayedUnassignedShards; private @Nullable Integer initializingShards; private @Nullable Integer numberOfDataNodes; private @Nullable Integer numberOfInFlightFetch; private @Nullable Integer numberOfNodes; private @Nullable Integer numberOfPendingTasks; private @Nullable Integer relocatingShards; private @Nullable ClusterHealth.Status status; private @Nullable Integer taskMaxWaitingInQueueMillis; private @Nullable Boolean timedOut; private @Nullable Integer unassignedShards; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ClusterHealth} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(ClusterHealth instance) { Objects.requireNonNull(instance, "instance"); activePrimaryShards(instance.getActivePrimaryShards()); activeShards(instance.getActiveShards()); activeShardsPercentAsNumber(instance.getActiveShardsPercentAsNumber()); clusterName(instance.getClusterName()); delayedUnassignedShards(instance.getDelayedUnassignedShards()); initializingShards(instance.getInitializingShards()); numberOfDataNodes(instance.getNumberOfDataNodes()); numberOfInFlightFetch(instance.getNumberOfInFlightFetch()); numberOfNodes(instance.getNumberOfNodes()); numberOfPendingTasks(instance.getNumberOfPendingTasks()); relocatingShards(instance.getRelocatingShards()); status(instance.getStatus()); taskMaxWaitingInQueueMillis(instance.getTaskMaxWaitingInQueueMillis()); timedOut(instance.getTimedOut()); unassignedShards(instance.getUnassignedShards()); return this; } /** * Initializes the value for the {@link ClusterHealth#getActivePrimaryShards() activePrimaryShards} attribute. * @param activePrimaryShards The value for activePrimaryShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("active_primary_shards") public final Builder activePrimaryShards(Integer activePrimaryShards) { this.activePrimaryShards = Objects.requireNonNull(activePrimaryShards, "activePrimaryShards"); initBits &= ~INIT_BIT_ACTIVE_PRIMARY_SHARDS; return this; } /** * Initializes the value for the {@link ClusterHealth#getActiveShards() activeShards} attribute. * @param activeShards The value for activeShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("active_shards") public final Builder activeShards(Integer activeShards) { this.activeShards = Objects.requireNonNull(activeShards, "activeShards"); initBits &= ~INIT_BIT_ACTIVE_SHARDS; return this; } /** * Initializes the value for the {@link ClusterHealth#getActiveShardsPercentAsNumber() activeShardsPercentAsNumber} attribute. * @param activeShardsPercentAsNumber The value for activeShardsPercentAsNumber * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("active_shards_percent_as_number") public final Builder activeShardsPercentAsNumber(Double activeShardsPercentAsNumber) { this.activeShardsPercentAsNumber = Objects.requireNonNull(activeShardsPercentAsNumber, "activeShardsPercentAsNumber"); initBits &= ~INIT_BIT_ACTIVE_SHARDS_PERCENT_AS_NUMBER; return this; } /** * Initializes the value for the {@link ClusterHealth#getClusterName() clusterName} attribute. * @param clusterName The value for clusterName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("cluster_name") public final Builder clusterName(String clusterName) { this.clusterName = Objects.requireNonNull(clusterName, "clusterName"); initBits &= ~INIT_BIT_CLUSTER_NAME; return this; } /** * Initializes the value for the {@link ClusterHealth#getDelayedUnassignedShards() delayedUnassignedShards} attribute. * @param delayedUnassignedShards The value for delayedUnassignedShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("delayed_unassigned_shards") public final Builder delayedUnassignedShards(Integer delayedUnassignedShards) { this.delayedUnassignedShards = Objects.requireNonNull(delayedUnassignedShards, "delayedUnassignedShards"); initBits &= ~INIT_BIT_DELAYED_UNASSIGNED_SHARDS; return this; } /** * Initializes the value for the {@link ClusterHealth#getInitializingShards() initializingShards} attribute. * @param initializingShards The value for initializingShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("initializing_shards") public final Builder initializingShards(Integer initializingShards) { this.initializingShards = Objects.requireNonNull(initializingShards, "initializingShards"); initBits &= ~INIT_BIT_INITIALIZING_SHARDS; return this; } /** * Initializes the value for the {@link ClusterHealth#getNumberOfDataNodes() numberOfDataNodes} attribute. * @param numberOfDataNodes The value for numberOfDataNodes * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("number_of_data_nodes") public final Builder numberOfDataNodes(Integer numberOfDataNodes) { this.numberOfDataNodes = Objects.requireNonNull(numberOfDataNodes, "numberOfDataNodes"); initBits &= ~INIT_BIT_NUMBER_OF_DATA_NODES; return this; } /** * Initializes the value for the {@link ClusterHealth#getNumberOfInFlightFetch() numberOfInFlightFetch} attribute. * @param numberOfInFlightFetch The value for numberOfInFlightFetch * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("number_of_in_flight_fetch") public final Builder numberOfInFlightFetch(Integer numberOfInFlightFetch) { this.numberOfInFlightFetch = Objects.requireNonNull(numberOfInFlightFetch, "numberOfInFlightFetch"); initBits &= ~INIT_BIT_NUMBER_OF_IN_FLIGHT_FETCH; return this; } /** * Initializes the value for the {@link ClusterHealth#getNumberOfNodes() numberOfNodes} attribute. * @param numberOfNodes The value for numberOfNodes * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("number_of_nodes") public final Builder numberOfNodes(Integer numberOfNodes) { this.numberOfNodes = Objects.requireNonNull(numberOfNodes, "numberOfNodes"); initBits &= ~INIT_BIT_NUMBER_OF_NODES; return this; } /** * Initializes the value for the {@link ClusterHealth#getNumberOfPendingTasks() numberOfPendingTasks} attribute. * @param numberOfPendingTasks The value for numberOfPendingTasks * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("number_of_pending_tasks") public final Builder numberOfPendingTasks(Integer numberOfPendingTasks) { this.numberOfPendingTasks = Objects.requireNonNull(numberOfPendingTasks, "numberOfPendingTasks"); initBits &= ~INIT_BIT_NUMBER_OF_PENDING_TASKS; return this; } /** * Initializes the value for the {@link ClusterHealth#getRelocatingShards() relocatingShards} attribute. * @param relocatingShards The value for relocatingShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("relocating_shards") public final Builder relocatingShards(Integer relocatingShards) { this.relocatingShards = Objects.requireNonNull(relocatingShards, "relocatingShards"); initBits &= ~INIT_BIT_RELOCATING_SHARDS; return this; } /** * Initializes the value for the {@link ClusterHealth#getStatus() status} attribute. * @param status The value for status * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("status") public final Builder status(ClusterHealth.Status status) { this.status = Objects.requireNonNull(status, "status"); initBits &= ~INIT_BIT_STATUS; return this; } /** * Initializes the value for the {@link ClusterHealth#getTaskMaxWaitingInQueueMillis() taskMaxWaitingInQueueMillis} attribute. * @param taskMaxWaitingInQueueMillis The value for taskMaxWaitingInQueueMillis * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("task_max_waiting_in_queue_millis") public final Builder taskMaxWaitingInQueueMillis(Integer taskMaxWaitingInQueueMillis) { this.taskMaxWaitingInQueueMillis = Objects.requireNonNull(taskMaxWaitingInQueueMillis, "taskMaxWaitingInQueueMillis"); initBits &= ~INIT_BIT_TASK_MAX_WAITING_IN_QUEUE_MILLIS; return this; } /** * Initializes the value for the {@link ClusterHealth#getTimedOut() timedOut} attribute. * @param timedOut The value for timedOut * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("timed_out") public final Builder timedOut(Boolean timedOut) { this.timedOut = Objects.requireNonNull(timedOut, "timedOut"); initBits &= ~INIT_BIT_TIMED_OUT; return this; } /** * Initializes the value for the {@link ClusterHealth#getUnassignedShards() unassignedShards} attribute. * @param unassignedShards The value for unassignedShards * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("unassigned_shards") public final Builder unassignedShards(Integer unassignedShards) { this.unassignedShards = Objects.requireNonNull(unassignedShards, "unassignedShards"); initBits &= ~INIT_BIT_UNASSIGNED_SHARDS; return this; } /** * Builds a new {@link ImmutableClusterHealth ImmutableClusterHealth}. * @return An immutable instance of ClusterHealth * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableClusterHealth build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableClusterHealth(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ACTIVE_PRIMARY_SHARDS) != 0) attributes.add("activePrimaryShards"); if ((initBits & INIT_BIT_ACTIVE_SHARDS) != 0) attributes.add("activeShards"); if ((initBits & INIT_BIT_ACTIVE_SHARDS_PERCENT_AS_NUMBER) != 0) attributes.add("activeShardsPercentAsNumber"); if ((initBits & INIT_BIT_CLUSTER_NAME) != 0) attributes.add("clusterName"); if ((initBits & INIT_BIT_DELAYED_UNASSIGNED_SHARDS) != 0) attributes.add("delayedUnassignedShards"); if ((initBits & INIT_BIT_INITIALIZING_SHARDS) != 0) attributes.add("initializingShards"); if ((initBits & INIT_BIT_NUMBER_OF_DATA_NODES) != 0) attributes.add("numberOfDataNodes"); if ((initBits & INIT_BIT_NUMBER_OF_IN_FLIGHT_FETCH) != 0) attributes.add("numberOfInFlightFetch"); if ((initBits & INIT_BIT_NUMBER_OF_NODES) != 0) attributes.add("numberOfNodes"); if ((initBits & INIT_BIT_NUMBER_OF_PENDING_TASKS) != 0) attributes.add("numberOfPendingTasks"); if ((initBits & INIT_BIT_RELOCATING_SHARDS) != 0) attributes.add("relocatingShards"); if ((initBits & INIT_BIT_STATUS) != 0) attributes.add("status"); if ((initBits & INIT_BIT_TASK_MAX_WAITING_IN_QUEUE_MILLIS) != 0) attributes.add("taskMaxWaitingInQueueMillis"); if ((initBits & INIT_BIT_TIMED_OUT) != 0) attributes.add("timedOut"); if ((initBits & INIT_BIT_UNASSIGNED_SHARDS) != 0) attributes.add("unassignedShards"); return "Cannot build ClusterHealth, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy