ccaominh commented on a change in pull request #8547: Add `sys.supervisors` table to system tables URL: https://github.com/apache/incubator-druid/pull/8547#discussion_r324943958
########## File path: server/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorStatus.java ########## @@ -0,0 +1,238 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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 org.apache.druid.indexing.overlord.supervisor; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.google.common.base.Preconditions; + +import java.util.Objects; + +/** + * This class contains the attributes of a supervisor task which are returned by the API's in {@link SupervisorResource} + * and used by {@link org.apache.druid.sql.calcite.schema.SystemSchema.SupervisorsTable} + */ +@JsonDeserialize(builder = SupervisorStatus.Builder.class) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SupervisorStatus +{ + private final String id; + private final String state; + private final String detailedState; + private final boolean healthy; + private final SupervisorSpec spec; + /** + * This is a stringified version of spec object + */ + private final String specString; + private final String type; + private final String source; + private final boolean suspended; + + private SupervisorStatus( + Builder builder + ) + { + this.id = Preconditions.checkNotNull(builder.id, "id"); + this.state = builder.state; + this.detailedState = builder.detailedState; + this.healthy = builder.healthy; + this.spec = builder.spec; + this.specString = builder.specString; + this.type = builder.type; + this.source = builder.source; + this.suspended = builder.suspended; + } + + @Override + public boolean equals(Object o) + { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SupervisorStatus that = (SupervisorStatus) o; + return healthy == that.healthy && + Objects.equals(id, that.id) && + Objects.equals(state, that.state) && + Objects.equals(detailedState, that.detailedState) && + Objects.equals(spec, that.spec) && + Objects.equals(specString, that.specString) && + Objects.equals(type, that.type) && + Objects.equals(source, that.source) && + suspended == that.suspended; + } + + @Override + public int hashCode() + { + return Objects.hash(id, state, detailedState, healthy, spec, specString, type, source, suspended); + } + + @JsonProperty + public String getId() + { + return id; + } + + @JsonProperty + public String getState() + { + return state; + } + + @JsonProperty + public String getDetailedState() + { + return detailedState; + } + + @JsonProperty + public boolean isHealthy() + { + return healthy; + } + + @JsonProperty + public SupervisorSpec getSpec() + { + return spec; + } + + @JsonProperty + public String getSpecString() + { + return specString; + } + + @JsonProperty + public String getType() + { + return type; + } + + @JsonProperty + public String getSource() + { + return source; + } + + @JsonProperty + public boolean isSuspended() + { + return suspended; + } + + @JsonPOJOBuilder Review comment: Cool! Didn't know you could could have Jackson use a builder. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
