Commit 3b610597 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'nc-byon' into 'proactive-dev'

Add node candidates model support for BYON

See merge request !132
parents 4dc4ea2f 367cabb9
......@@ -70,6 +70,10 @@ public class NodeCandidate implements Serializable {
@JsonProperty("nodeCandidateType")
private NodeCandidateTypeEnum nodeCandidateType = null;
@Column(name = "JOB_ID_FOR_BYON")
@JsonProperty("nodeType")
private String jobIdForBYON;
@Column(name = "PRICE")
@JsonProperty("price")
private Double price = null;
......@@ -136,6 +140,18 @@ public class NodeCandidate implements Serializable {
this.nodeCandidateType = nodeCandidateType;
}
/**
* Get jobIdForBYON
* @return jobIdForBYON
**/
public String getJobIdForBYON() {
return jobIdForBYON;
}
public void setJobIdForBYON(String jobIdForBYON) {
this.jobIdForBYON = jobIdForBYON;
}
public NodeCandidate price(Double price) {
this.price = price;
return this;
......@@ -284,6 +300,7 @@ public class NodeCandidate implements Serializable {
NodeCandidate nodeCandidate = (NodeCandidate) o;
return Objects.equals(this.id, nodeCandidate.id) &&
Objects.equals(this.nodeCandidateType, nodeCandidate.nodeCandidateType) &&
Objects.equals(this.jobIdForBYON, nodeCandidate.jobIdForBYON) &&
Objects.equals(this.price, nodeCandidate.price) &&
Objects.equals(this.cloud, nodeCandidate.cloud) &&
Objects.equals(this.image, nodeCandidate.image) &&
......@@ -296,7 +313,7 @@ public class NodeCandidate implements Serializable {
@Override
public int hashCode() {
return Objects.hash(id, nodeCandidateType, price, cloud, image, hardware, location, pricePerInvocation, memoryPrice, environment);
return Objects.hash(id, nodeCandidateType, jobIdForBYON, price, cloud, image, hardware, location, pricePerInvocation, memoryPrice, environment);
}
@Override
......@@ -306,6 +323,7 @@ public class NodeCandidate implements Serializable {
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" nodeCandidateType: ").append(toIndentedString(nodeCandidateType)).append("\n");
sb.append(" jobIdForBYON: ").append(toIndentedString(jobIdForBYON)).append("\n");
sb.append(" price: ").append(toIndentedString(price)).append("\n");
sb.append(" cloud: ").append(toIndentedString(cloud)).append("\n");
sb.append(" image: ").append(toIndentedString(image)).append("\n");
......
package org.activeeon.morphemic.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Objects;
/**
* Subtype of Requirement
*/
@Getter
@Setter
public class NodeTypeRequirement extends Requirement {
@JsonProperty("nodeType")
private NodeType nodeType;
private List<NodeType> nodeTypes;
@JsonProperty("nodeType")
private String jobIdForBYON;
/**
* Get nodeType
* @return nodeType
**/
public NodeType getNodeType() {
return nodeType;
}
public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType;
}
@Override
......@@ -33,13 +34,14 @@ public class NodeTypeRequirement extends Requirement {
return false;
}
NodeTypeRequirement nodeTypeRequirement = (NodeTypeRequirement) o;
return Objects.equals(this.nodeType, nodeTypeRequirement.nodeType) &&
return Objects.equals(this.nodeTypes, nodeTypeRequirement.nodeTypes) &&
Objects.equals(this.jobIdForBYON, nodeTypeRequirement.jobIdForBYON) &&
super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(nodeType, super.hashCode());
return Objects.hash(nodeTypes, jobIdForBYON, super.hashCode());
}
@Override
......@@ -47,7 +49,8 @@ public class NodeTypeRequirement extends Requirement {
StringBuilder sb = new StringBuilder();
sb.append("class NodeTypeRequirement {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" nodeType: ").append(toIndentedString(nodeType)).append("\n");
sb.append(" nodeType: ").append(toIndentedString(nodeTypes)).append("\n");
sb.append(" jobIdForBYON: ").append(toIndentedString(jobIdForBYON)).append("\n");
sb.append("}");
return sb.toString();
}
......
......@@ -100,7 +100,14 @@ public class NodeCandidateUtils {
}
private static boolean satisfyNodeTypeRequirement(NodeTypeRequirement requirement, NodeCandidate nodeCandidate) {
return (requirement.getNodeType().getLiteral().equals(nodeCandidate.getNodeCandidateType().name()));
return (requirement.getNodeTypes().stream().anyMatch(nodeType -> {
if (nodeType.getLiteral().equals(nodeCandidate.getNodeCandidateType().name()) &&
nodeType.equals(NodeType.BYON) &&
requirement.getJobIdForBYON().equals(nodeCandidate.getJobIdForBYON())) {
return true;
} else return nodeType.getLiteral().equals(nodeCandidate.getNodeCandidateType().name()) &&
!nodeType.equals(NodeType.BYON);
}));
}
private Hardware createHardware(JSONObject nodeCandidateJSON, PACloud paCloud) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment