Skip to content

Commit

Permalink
Cluster status (#120)
Browse files Browse the repository at this point in the history
* introducing enum for ClusterStatus

* ClusterStatus and JobStatus usage

* ClusterStatus as string
  • Loading branch information
ankicabarisic authored Jan 28, 2025
1 parent 3442582 commit 46b6840
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 96 deletions.
3 changes: 1 addition & 2 deletions docker/Dockerfile.win
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ ENV DB_PLATFORM='org.hibernate.dialect.MariaDB53Dialect'
CMD ["catalina.sh", "jpda", "run"]
#RUN yum install -y nmap-ncat
#RUN chmod +x /usr/local/tomcat/bin/wait_for_db.sh
#CMD ["/bin/bash", "-c", "wait_for_db.sh && catalina.sh jpda run"]

#CMD ["/bin/bash", "-c", "wait_for_db.sh && catalina.sh jpda run"]
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public class Cluster {
@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true, cascade = CascadeType.REFRESH)
private List<ClusterNodeDefinition> nodes;

// TODO: Change this into Enum
@Column(name = "STATUS")
@Enumerated(EnumType.STRING)
@JsonProperty(JSON_STATUS)
private String status = "defined";
private ClusterStatus status = ClusterStatus.DEFINED;

@Column(name = "ENV", columnDefinition = "text", length = 65535)
@JsonProperty(JSON_ENV_VARS)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package org.ow2.proactive.sal.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;


/**
* @author ActiveEon Team
* @since 1/24/2025
*/
public enum ClusterStatus {

//this status is assinged to cluster after calling Define Cluster endpoint
DEFINED("Defined"),
//this status is assigned when all the nodes in cluster successfully finished their deployment (having corresponding JobStatus FINISHED for all nodes)
DEPLOYED("Deployed"),
//this status is assigned to cluster when one or more nodes were not successfuly deployed (having corresponding JobStatus FAILED, KILLED, IN_ERROR or CANCELED)
FAILED("Failed"),
//this status is assigned to the cluster when it is sent for the deployment by using Deploy Cluster endpoint
SUBMITTED("Submitted"),
//this status is assigned to the cluster when ScaleIn or ScaleOut operations are called.
SCALING("Scaling"),

OTHER("other"); // For any unknown status

private final String value;

ClusterStatus(String value) {
this.value = value;
}

@Override
@JsonValue
public String toString() {
return value;
}

@JsonCreator
public static ClusterStatus fromValue(String text) {
for (ClusterStatus type : ClusterStatus.values()) {
if (type.value.equalsIgnoreCase(text)) {
return type;
}
}
return OTHER; // Return a default type if the input is invalid
}

}
Loading

0 comments on commit 46b6840

Please sign in to comment.