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

com.yahoo.vespa.hosted.controller.api.integration.configserver.ApplicationReindexing Maven / Gradle / Ivy

There is a newer version: 8.253.3
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.configserver;

import java.time.Instant;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

/**
 * Reindexing status for a single Vespa application.
 *
 * @author jonmv
 */
public class ApplicationReindexing {

    private final boolean enabled;
    private final Map clusters;

    public ApplicationReindexing(boolean enabled, Map clusters) {
        this.enabled = enabled;
        this.clusters = Map.copyOf(clusters);
    }

    public boolean enabled() {
        return enabled;
    }

    public Map clusters() {
        return clusters;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ApplicationReindexing that = (ApplicationReindexing) o;
        return enabled == that.enabled &&
               clusters.equals(that.clusters);
    }

    @Override
    public int hashCode() {
        return Objects.hash(enabled, clusters);
    }

    @Override
    public String toString() {
        return "ApplicationReindexing{" +
               "enabled=" + enabled +
               ", clusters=" + clusters +
               '}';
    }


    public static class Cluster {

        private final Map pending;
        private final Map ready;

        public Cluster(Map pending, Map ready) {
            this.pending = Map.copyOf(pending);
            this.ready = Map.copyOf(ready);
        }

        public Map pending() {
            return pending;
        }

        public Map ready() {
            return ready;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Cluster cluster = (Cluster) o;
            return pending.equals(cluster.pending) &&
                   ready.equals(cluster.ready);
        }

        @Override
        public int hashCode() {
            return Objects.hash(pending, ready);
        }

        @Override
        public String toString() {
            return "Cluster{" +
                   "pending=" + pending +
                   ", ready=" + ready +
                   '}';
        }

    }


    public static class Status {

        private final Instant readyAt;
        private final Instant startedAt;
        private final Instant endedAt;
        private final State state;
        private final String message;
        private final Double progress;
        private final Double speed;
        private final String cause;

        public Status(Instant readyAt, Instant startedAt, Instant endedAt, State state, String message, Double progress, Double speed, String cause) {
            this.readyAt = readyAt;
            this.startedAt = startedAt;
            this.endedAt = endedAt;
            this.state = state;
            this.message = message;
            this.progress = progress;
            this.speed = speed;
            this.cause = cause;
        }

        public Status(Instant readyAt) {
            this(readyAt, null, null, null, null, null, 1.0, null);
        }

        public Optional readyAt() { return Optional.ofNullable(readyAt); }
        public Optional startedAt() { return Optional.ofNullable(startedAt); }
        public Optional endedAt() { return Optional.ofNullable(endedAt); }
        public Optional state() { return Optional.ofNullable(state); }
        public Optional message() { return Optional.ofNullable(message); }
        public Optional progress() { return Optional.ofNullable(progress); }
        public Optional speed() { return Optional.ofNullable(speed); }
        public Optional cause() { return Optional.ofNullable(cause); }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Status status = (Status) o;
            return Objects.equals(readyAt, status.readyAt) &&
                   Objects.equals(startedAt, status.startedAt) &&
                   Objects.equals(endedAt, status.endedAt) &&
                   state == status.state &&
                   Objects.equals(message, status.message) &&
                   Objects.equals(progress, status.progress) &&
                   Objects.equals(speed, status.speed) &&
                   Objects.equals(cause, status.cause);
        }

        @Override
        public int hashCode() {
            return Objects.hash(readyAt, startedAt, endedAt, state, message, progress, speed, cause);
        }

        @Override
        public String toString() {
            return "Status{" +
                   "readyAt=" + readyAt +
                   ", startedAt=" + startedAt +
                   ", endedAt=" + endedAt +
                   ", state=" + state +
                   ", message='" + message + '\'' +
                   ", progress=" + progress +
                   ", speed=" + speed +
                   ", cause='" + cause + '\'' +
                   '}';
        }

    }


    public enum State {

        PENDING, RUNNING, FAILED, SUCCESSFUL;

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy