From 7383ef845232bf8cb30c64521f2ff519517b3eee Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Fri, 22 Nov 2024 14:38:41 +0100 Subject: [PATCH 1/8] exposing and reusing JSON property fields for edge --- .../org/ow2/proactive/sal/model/EdgeNode.java | 52 +++++++++++---- .../org/ow2/proactive/sal/model/Hardware.java | 62 ++++++++++++------ .../org/ow2/proactive/sal/model/Image.java | 29 +++++++-- .../org/ow2/proactive/sal/model/Location.java | 39 +++++++---- .../proactive/sal/model/LoginCredential.java | 31 +++++++-- .../proactive/sal/model/NodeCandidate.java | 58 ++++++++++++----- .../proactive/sal/model/NodeProperties.java | 65 +++++++++++-------- .../sal/service/nc/NodeCandidateUtils.java | 2 +- .../proactive/sal/service/util/ByonUtils.java | 2 +- 9 files changed, 236 insertions(+), 104 deletions(-) diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java index de1c187..72c376e 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java @@ -30,53 +30,81 @@ @Table(name = "EDGE_NODE") public class EdgeNode extends AbstractNode { + // Constants for JSON properties + public static final String JSON_NAME = "name"; + + public static final String JSON_LOGIN_CREDENTIAL = "loginCredential"; + + public static final String JSON_IP_ADDRESSES = "ipAddresses"; + + public static final String JSON_NODE_PROPERTIES = "nodeProperties"; + + public static final String JSON_PORT = "port"; + + public static final String JSON_REASON = "reason"; + + public static final String JSON_DIAGNOSTIC = "diagnostic"; + + public static final String JSON_USER_ID = "userId"; + + public static final String JSON_ALLOCATED = "allocated"; + + // edge jobID corresponds to the ProActive job name + public static final String JSON_JOB_ID = "jobId"; + + public static final String JSON_SYSTEM_ARCH = "systemArch"; + + public static final String JSON_SCRIPT_URL = "scriptURL"; + + public static final String JSON_JAR_URL = "jarURL"; + @Column(name = "NAME") - @JsonProperty("name") + @JsonProperty(JSON_NAME) private String name = null; @Embedded - @JsonProperty("loginCredential") + @JsonProperty(JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; @ElementCollection(targetClass = IpAddress.class) private List ipAddresses = null; @Embedded - @JsonProperty("nodeProperties") + @JsonProperty(JSON_NODE_PROPERTIES) private NodeProperties nodeProperties = null; @Column(name = "PORT") - @JsonProperty("port") + @JsonProperty(JSON_PORT) private String port = null; @Column(name = "REASON") - @JsonProperty("reason") + @JsonProperty(JSON_REASON) private String reason = null; @Column(name = "DIAGNOSTIC") - @JsonProperty("diagnostic") + @JsonProperty(JSON_DIAGNOSTIC) private String diagnostic = null; @Column(name = "USER_ID") - @JsonProperty("userId") + @JsonProperty(JSON_USER_ID) private String userId = null; @Column(name = "ALLOCATED") - @JsonProperty("allocated") + @JsonProperty(JSON_ALLOCATED) private Boolean allocated = null; @Column(name = "JOB_ID") - @JsonProperty("jobId") + @JsonProperty(JSON_JOB_ID) private String jobId; @Column(name = "SYSTEM_ARCH") - @JsonProperty("systemArch") + @JsonProperty(JSON_SYSTEM_ARCH) private String systemArch = null; - @JsonProperty("scriptURL") + @JsonProperty(JSON_SCRIPT_URL) private String scriptURL = null; - @JsonProperty("jarURL") + @JsonProperty(JSON_JAR_URL) private String jarURL = null; public EdgeNode name(String name) { diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java index 4fd5666..3fc9b8c 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java @@ -24,46 +24,67 @@ @Entity @Table(name = "HARDWARE") public class Hardware implements Serializable { + // Constants for JSON property names + public static final String JSON_ID = "id"; + + public static final String JSON_NAME = "name"; + + public static final String JSON_PROVIDER_ID = "providerId"; + + public static final String JSON_CORES = "cores"; + + public static final String JSON_RAM = "ram"; + + public static final String JSON_DISK = "disk"; + + public static final String JSON_FPGA = "fpga"; + + public static final String JSON_LOCATION = "location"; + + public static final String JSON_STATE = "state"; + + public static final String JSON_OWNER = "owner"; + @Id @Column(name = "ID") - @JsonProperty("id") + @JsonProperty(JSON_ID) private String id = null; @Column(name = "NAME") - @JsonProperty("name") + @JsonProperty(JSON_NAME) private String name = null; @Column(name = "PROVIDER_ID") - @JsonProperty("providerId") + @JsonProperty(JSON_PROVIDER_ID) private String providerId = null; @Column(name = "CORES") - @JsonProperty("cores") + @JsonProperty(JSON_CORES) private Integer cores = null; @Column(name = "RAM") - @JsonProperty("ram") + @JsonProperty(JSON_RAM) private Long ram = null; @Column(name = "DISK") - @JsonProperty("disk") + @JsonProperty(JSON_DISK) private Double disk = null; @Column(name = "FPGA") - @JsonProperty("fpga") + @JsonProperty(JSON_FPGA) private Integer fpga = null; @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @JsonProperty("location") + @JsonProperty(JSON_LOCATION) private Location location = null; @Column(name = "STATE") @Enumerated(EnumType.STRING) - @JsonProperty("state") + @JsonProperty(JSON_STATE) private DiscoveryItemState state = null; @Column(name = "OWNER") - @JsonProperty("owner") + @JsonProperty(JSON_OWNER) private String owner = null; public Hardware id(String id) { @@ -264,17 +285,16 @@ public int hashCode() { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Hardware {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" providerId: ").append(toIndentedString(providerId)).append("\n"); - sb.append(" cores: ").append(toIndentedString(cores)).append("\n"); - sb.append(" ram: ").append(toIndentedString(ram)).append("\n"); - sb.append(" disk: ").append(toIndentedString(disk)).append("\n"); - sb.append(" fpga: ").append(toIndentedString(fpga)).append("\n"); - sb.append(" location: ").append(toIndentedString(location)).append("\n"); - sb.append(" state: ").append(toIndentedString(state)).append("\n"); - sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); + sb.append(" ").append(JSON_ID).append(": ").append(toIndentedString(id)).append("\n"); + sb.append(" ").append(JSON_NAME).append(": ").append(toIndentedString(name)).append("\n"); + sb.append(" ").append(JSON_PROVIDER_ID).append(": ").append(toIndentedString(providerId)).append("\n"); + sb.append(" ").append(JSON_CORES).append(": ").append(toIndentedString(cores)).append("\n"); + sb.append(" ").append(JSON_RAM).append(": ").append(toIndentedString(ram)).append("\n"); + sb.append(" ").append(JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); + sb.append(" ").append(JSON_FPGA).append(": ").append(toIndentedString(fpga)).append("\n"); + sb.append(" ").append(JSON_LOCATION).append(": ").append(toIndentedString(location)).append("\n"); + sb.append(" ").append(JSON_STATE).append(": ").append(toIndentedString(state)).append("\n"); + sb.append(" ").append(JSON_OWNER).append(": ").append(toIndentedString(owner)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java index de3c38c..c4af3a0 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java @@ -24,34 +24,49 @@ @Entity @Table(name = "IMAGE") public class Image implements Serializable { + // Constants for JSON property names + public static final String JSON_ID = "id"; + + public static final String JSON_NAME = "name"; + + public static final String JSON_PROVIDER_ID = "providerId"; + + public static final String JSON_OPERATING_SYSTEM = "operatingSystem"; + + public static final String JSON_LOCATION = "location"; + + public static final String JSON_STATE = "state"; + + public static final String JSON_OWNER = "owner"; + @Id @Column(name = "ID") - @JsonProperty("id") + @JsonProperty(JSON_ID) private String id = null; @Column(name = "NAME") - @JsonProperty("name") + @JsonProperty(JSON_NAME) private String name = null; @Column(name = "PROVIDER_ID") - @JsonProperty("providerId") + @JsonProperty(JSON_PROVIDER_ID) private String providerId = null; @Embedded - @JsonProperty("operatingSystem") + @JsonProperty(JSON_OPERATING_SYSTEM) private OperatingSystem operatingSystem = null; @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) - @JsonProperty("location") + @JsonProperty(JSON_LOCATION) private Location location = null; @Column(name = "STATE") @Enumerated(EnumType.STRING) - @JsonProperty("state") + @JsonProperty(JSON_STATE) private DiscoveryItemState state = null; @Column(name = "OWNER") - @JsonProperty("owner") + @JsonProperty(JSON_OWNER) private String owner = null; public Image id(String id) { diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java index 4d75848..86c1d1e 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java @@ -27,17 +27,35 @@ @Entity @Table(name = "LOCATION") public class Location implements Serializable { + public static final String JSON_ID = "id"; + + public static final String JSON_NAME = "name"; + + public static final String JSON_PROVIDER_ID = "providerId"; + + public static final String JSON_LOCATION_SCOPE = "locationScope"; + + public static final String JSON_IS_ASSIGNABLE = "isAssignable"; + + public static final String JSON_GEO_LOCATION = "geoLocation"; + + public static final String JSON_PARENT = "parent"; + + public static final String JSON_STATE = "state"; + + public static final String JSON_OWNER = "owner"; + @Id @Column(name = "ID") - @JsonProperty("id") + @JsonProperty(JSON_ID) private String id = null; @Column(name = "NAME") - @JsonProperty("name") + @JsonProperty(JSON_NAME) private String name = null; @Column(name = "PROVIDER_ID") - @JsonProperty("providerId") + @JsonProperty(JSON_PROVIDER_ID) private String providerId = null; /** @@ -45,11 +63,8 @@ public class Location implements Serializable { */ public enum LocationScopeEnum { PROVIDER("PROVIDER"), - REGION("REGION"), - ZONE("ZONE"), - HOST("HOST"); private String value; @@ -77,28 +92,28 @@ public static LocationScopeEnum fromValue(String text) { @Column(name = "LOCATION_SCOPE") @Enumerated(EnumType.STRING) - @JsonProperty("locationScope") + @JsonProperty(JSON_LOCATION_SCOPE) private LocationScopeEnum locationScope = null; @Column(name = "IS_ASSIGNABLE") - @JsonProperty("isAssignable") + @JsonProperty(JSON_IS_ASSIGNABLE) private Boolean isAssignable = null; @Embedded - @JsonProperty("geoLocation") + @JsonProperty(JSON_GEO_LOCATION) private GeoLocation geoLocation = null; @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) - @JsonProperty("parent") + @JsonProperty(JSON_PARENT) private Location parent = null; @Column(name = "STATE") @Enumerated(EnumType.STRING) - @JsonProperty("state") + @JsonProperty(JSON_STATE) private DiscoveryItemState state = null; @Column(name = "OWNER") - @JsonProperty("owner") + @JsonProperty(JSON_OWNER) private String owner = null; public Location id(String id) { diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java index 21a7588..0c23ac7 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java @@ -23,13 +23,20 @@ @NoArgsConstructor @Embeddable public class LoginCredential implements Serializable { - @JsonProperty("username") + // JSON property constants + public static final String JSON_USERNAME = "username"; + + public static final String JSON_PASSWORD = "password"; + + public static final String JSON_PRIVATE_KEY = "privateKey"; + + @JsonProperty(JSON_USERNAME) private String username = null; - @JsonProperty("password") + @JsonProperty(JSON_PASSWORD) private String password = null; - @JsonProperty("privateKey") + @JsonProperty(JSON_PRIVATE_KEY) private String privateKey = null; public LoginCredential username(String username) { @@ -107,9 +114,21 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class LoginCredential {\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" privateKey: ").append(toIndentedString(privateKey)).append("\n"); + sb.append(" ") + .append(LoginCredential.JSON_USERNAME) + .append(": ") + .append(toIndentedString(username)) + .append("\n"); + sb.append(" ") + .append(LoginCredential.JSON_PASSWORD) + .append(": ") + .append(toIndentedString(password)) + .append("\n"); + sb.append(" ") + .append(LoginCredential.JSON_PRIVATE_KEY) + .append(": ") + .append(toIndentedString(privateKey)) + .append("\n"); sb.append("}"); return sb.toString(); } diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java index 1bfc8b5..64c3475 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java @@ -32,11 +32,38 @@ @Entity @Table(name = "NODE_CANDIDATE") public class NodeCandidate implements Serializable { + // JSON Property Constants + public static final String JSON_ID = "id"; + + public static final String JSON_NODE_CANDIDATE_TYPE = "nodeCandidateType"; + + public static final String JSON_JOB_ID_FOR_BYON = "jobIdForByon"; + + public static final String JSON_JOB_ID_FOR_EDGE = "jobIdForEdge"; + + public static final String JSON_PRICE = "price"; + + public static final String JSON_CLOUD = "cloud"; + + public static final String JSON_LOCATION = "location"; + + public static final String JSON_IMAGE = "image"; + + public static final String JSON_HARDWARE = "hardware"; + + public static final String JSON_PRICE_PER_INVOCATION = "pricePerInvocation"; + + public static final String JSON_MEMORY_PRICE = "memoryPrice"; + + public static final String JSON_NODE_ID = "nodeId"; + + public static final String JSON_ENVIRONMENT = "environment"; + @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") @Column(name = "ID") - @JsonProperty("id") + @JsonProperty(JSON_ID) private String id = null; /** @@ -44,15 +71,10 @@ public class NodeCandidate implements Serializable { */ public enum NodeCandidateTypeEnum { IAAS("IAAS"), - FAAS("FAAS"), - PAAS("PAAS"), - BYON("BYON"), - EDGE("EDGE"), - SIMULATION("SIMULATION"); private String value; @@ -80,51 +102,51 @@ public static NodeCandidateTypeEnum fromValue(String text) { @Column(name = "NODE_CANDIDATE_TYPE") @Enumerated(EnumType.STRING) - @JsonProperty("nodeCandidateType") + @JsonProperty(JSON_NODE_CANDIDATE_TYPE) private NodeCandidateTypeEnum nodeCandidateType = null; @Column(name = "JOB_ID_FOR_BYON") - @JsonProperty("jobIdForByon") + @JsonProperty(JSON_JOB_ID_FOR_BYON) private String jobIdForBYON; @Column(name = "JOB_ID_FOR_EDGE") - @JsonProperty("jobIdForEdge") + @JsonProperty(JSON_JOB_ID_FOR_EDGE) private String jobIdForEDGE; @Column(name = "PRICE") - @JsonProperty("price") + @JsonProperty(JSON_PRICE) private Double price = null; @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH }) - @JsonProperty("cloud") + @JsonProperty(JSON_CLOUD) private Cloud cloud = null; @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH }) - @JsonProperty("location") + @JsonProperty(JSON_LOCATION) private Location location = null; @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH }) - @JsonProperty("image") + @JsonProperty(JSON_IMAGE) private Image image = null; @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH }) - @JsonProperty("hardware") + @JsonProperty(JSON_HARDWARE) private Hardware hardware = null; @Column(name = "PRICE_PER_INVOCATION") - @JsonProperty("pricePerInvocation") + @JsonProperty(JSON_PRICE_PER_INVOCATION) private Double pricePerInvocation = null; @Column(name = "MEMORY_PRICE") - @JsonProperty("memoryPrice") + @JsonProperty(JSON_MEMORY_PRICE) private Double memoryPrice = null; @Column(name = "NODE_ID") - @JsonProperty("nodeId") + @JsonProperty(JSON_NODE_ID) private String nodeId = null; @Embedded - @JsonProperty("environment") + @JsonProperty(JSON_ENVIRONMENT) private Environment environment = null; public NodeCandidate id(String id) { diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java index f5c3e34..a86e4d6 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java @@ -24,27 +24,29 @@ @NoArgsConstructor @Embeddable public class NodeProperties implements Serializable { - @JsonProperty("price") - private Double price = null; - @JsonProperty("providerId") + // Fields + @JsonProperty(Hardware.JSON_PROVIDER_ID) private String providerId = null; - @JsonProperty("numberOfCores") - private Integer numberOfCores = null; + @JsonProperty(NodeCandidate.JSON_PRICE) + private Double price = null; + + @JsonProperty(Hardware.JSON_CORES) + private Integer cores = null; - @JsonProperty("memory") + @JsonProperty(Hardware.JSON_RAM) private Long memory = null; - @JsonProperty("disk") - private Float disk = null; + @JsonProperty(Hardware.JSON_DISK) + private Double disk = null; @Embedded - @JsonProperty("operatingSystem") + @JsonProperty(Image.JSON_OPERATING_SYSTEM) private OperatingSystem operatingSystem = null; @Embedded - @JsonProperty("geoLocation") + @JsonProperty(Location.JSON_GEO_LOCATION) private GeoLocation geoLocation = null; public NodeProperties providerId(String providerId) { @@ -73,7 +75,7 @@ public void setPrice(Double price) { } public NodeProperties numberOfCores(Integer numberOfCores) { - this.numberOfCores = numberOfCores; + this.cores = numberOfCores; return this; } @@ -81,12 +83,12 @@ public NodeProperties numberOfCores(Integer numberOfCores) { * Number of cores the node has. * @return numberOfCores **/ - public Integer getNumberOfCores() { - return numberOfCores; + public Integer getCores() { + return cores; } - public void setNumberOfCores(Integer numberOfCores) { - this.numberOfCores = numberOfCores; + public void setCores(Integer numberOfCores) { + this.cores = numberOfCores; } public NodeProperties memory(Long memory) { @@ -106,7 +108,7 @@ public void setMemory(Long memory) { this.memory = memory; } - public NodeProperties disk(Float disk) { + public NodeProperties disk(Double disk) { this.disk = disk; return this; } @@ -115,11 +117,11 @@ public NodeProperties disk(Float disk) { * Amount of disk space this node has (in GB). * @return disk **/ - public Float getDisk() { + public Double getDisk() { return disk; } - public void setDisk(Float disk) { + public void setDisk(Double disk) { this.disk = disk; } @@ -167,7 +169,8 @@ public boolean equals(Object o) { } NodeProperties nodeProperties = (NodeProperties) o; return Objects.equals(this.providerId, nodeProperties.providerId) && - Objects.equals(this.numberOfCores, nodeProperties.numberOfCores) && + Objects.equals(this.price, nodeProperties.price) && + Objects.equals(this.cores, nodeProperties.cores) && Objects.equals(this.memory, nodeProperties.memory) && Objects.equals(this.disk, nodeProperties.disk) && Objects.equals(this.operatingSystem, nodeProperties.operatingSystem) && Objects.equals(this.geoLocation, nodeProperties.geoLocation); @@ -175,7 +178,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(providerId, numberOfCores, memory, disk, operatingSystem, geoLocation); + return Objects.hash(providerId, cores, memory, disk, operatingSystem, geoLocation); } @Override @@ -183,12 +186,22 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class NodeProperties {\n"); - sb.append(" providerId: ").append(toIndentedString(providerId)).append("\n"); - sb.append(" numberOfCores: ").append(toIndentedString(numberOfCores)).append("\n"); - sb.append(" memory: ").append(toIndentedString(memory)).append("\n"); - sb.append(" disk: ").append(toIndentedString(disk)).append("\n"); - sb.append(" operatingSystem: ").append(toIndentedString(operatingSystem)).append("\n"); - sb.append(" geoLocation: ").append(toIndentedString(geoLocation)).append("\n"); + sb.append(" ").append(Hardware.JSON_PROVIDER_ID).append(": ").append(toIndentedString(providerId)).append("\n"); + sb.append(" ").append(NodeCandidate.JSON_PRICE).append(": ").append(toIndentedString(price)).append("\n"); + sb.append(" ").append(Hardware.JSON_CORES).append(": ").append(toIndentedString(cores)).append("\n"); + sb.append(" ").append(Hardware.JSON_RAM).append(": ").append(toIndentedString(memory)).append("\n"); + sb.append(" ").append(Hardware.JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); + sb.append(" ") + .append(Image.JSON_OPERATING_SYSTEM) + .append(": ") + .append(toIndentedString(operatingSystem)) + .append("\n"); + sb.append(" ") + .append(Location.JSON_GEO_LOCATION) + .append(": ") + .append(toIndentedString(geoLocation)) + .append("\n"); + sb.append("}"); return sb.toString(); } diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java index bc2e6e6..b8bf9f0 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java @@ -328,7 +328,7 @@ private Cloud createCloud(JSONObject nodeCandidateJSON, PACloud paCloud) { public NodeCandidate createNodeCandidate(JSONObject nodeCandidateJSON, JSONObject imageJSON, PACloud paCloud) { NodeCandidate nodeCandidate = new NodeCandidate(); nodeCandidate.setNodeCandidateType(NodeCandidate.NodeCandidateTypeEnum.IAAS); - nodeCandidate.setPrice(nodeCandidateJSON.optDouble("price")); + nodeCandidate.setPrice(nodeCandidateJSON.optDouble(nodeCandidate.JSON_PRICE)); nodeCandidate.setCloud(createCloud(nodeCandidateJSON, paCloud)); nodeCandidate.setLocation(createLocation(nodeCandidateJSON, paCloud)); diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java index bf9b283..3cc0a95 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java @@ -74,7 +74,7 @@ public static NodeCandidate createNodeCandidate(NodeProperties np, String jobId, image.setOperatingSystem(np.getOperatingSystem()); //Define the hardware Hardware hardware = new Hardware(); - hardware.setCores(np.getNumberOfCores()); + hardware.setCores(np.getCores()); hardware.setDisk((double) np.getDisk()); hardware.setRam(np.getMemory()); hardware.setFpga(""); From 0febd11dfaf8e648a7aaf9d6ed33b787551f0240 Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Fri, 22 Nov 2024 16:19:58 +0100 Subject: [PATCH 2/8] reusing JSON property fields for edge definition --- .../proactive/sal/model/EdgeDefinition.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java index 64708aa..1465ea8 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java @@ -13,7 +13,7 @@ /** - * Attributes defining a BYON node + * Attributes defining a EDGE node */ @AllArgsConstructor @NoArgsConstructor @@ -21,30 +21,33 @@ @Setter @ToString(callSuper = true) public class EdgeDefinition { - @JsonProperty("name") + // Default constants + public static final String DEFAULT_PORT = "22"; + + @JsonProperty(EdgeNode.JSON_NAME) private String name = null; - @JsonProperty("jobId") + @JsonProperty(EdgeNode.JSON_JOB_ID) private String jobId = null; - @JsonProperty("systemArch") + @JsonProperty(EdgeNode.JSON_SYSTEM_ARCH) private String systemArch = null; - @JsonProperty("scriptURL") + @JsonProperty(EdgeNode.JSON_SCRIPT_URL) private String scriptURL = null; - @JsonProperty("jarURL") + @JsonProperty(EdgeNode.JSON_JAR_URL) private String jarURL = null; - @JsonProperty("loginCredential") + @JsonProperty(EdgeNode.JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; - @JsonProperty("ipAddresses") + @JsonProperty(EdgeNode.JSON_IP_ADDRESSES) private List ipAddresses = null; - @JsonProperty("port") - private String port = "22"; + @JsonProperty(EdgeNode.JSON_PORT) + private String port = DEFAULT_PORT; - @JsonProperty("nodeProperties") + @JsonProperty(EdgeNode.JSON_NODE_PROPERTIES) private NodeProperties nodeProperties = null; } From e22455cb593913665ebc7d8fb9cc2814ec42304b Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Mon, 25 Nov 2024 15:28:36 +0100 Subject: [PATCH 3/8] mapping edge node properties to have same JSON values as node candidates --- endpoints/4-edge-endpoints.md | 8 ++--- .../proactive/sal/model/NodeProperties.java | 29 ++++++++++--------- .../proactive/sal/service/util/ByonUtils.java | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/endpoints/4-edge-endpoints.md b/endpoints/4-edge-endpoints.md index f80573a..28d0574 100644 --- a/endpoints/4-edge-endpoints.md +++ b/endpoints/4-edge-endpoints.md @@ -36,8 +36,8 @@ This endpoint is used to register new Edge nodes, which are passed as an [EdgeDe "nodeProperties": { "providerId": "1", "price": "{{price}}", - "numberOfCores": "{{cores}}", - "memory": "{{memory}}", + "cores": "{{cores}}", + "ram": "{{ram}}", "disk": "{{disk}}", "operatingSystem": { "operatingSystemFamily": "{{OS_name}}", @@ -71,8 +71,8 @@ The fields are defined as: - `nodeProperties`: - `providerId`: The ID of the provider. Default is `"1"`. - `price`: The price of the edge node source. - - `numberOfCores`: A string representing number of hardware cores (e.g., `"1"`). - - `memory`: The hardware memory in GB (e.g., `"1"`) + - `cores`: A string representing number of CPU cores (e.g., `"1"`). + - `ram`: The hardware ram memory in GB (e.g., `"1"`) - `disk`: The hardware storage space in GB (e.g., `"1.0"`). - `operatingSystem`: Information about the OS, including Family, Architecture, and Version. - `geoLocation`: The physical location details, such as city, country, latitude, and longitude of the edge node. diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java index a86e4d6..431fe0a 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java @@ -25,7 +25,7 @@ @Embeddable public class NodeProperties implements Serializable { - // Fields + // Fields - edge node properties fields are mapped to node candidates so field names are reused @JsonProperty(Hardware.JSON_PROVIDER_ID) private String providerId = null; @@ -36,7 +36,7 @@ public class NodeProperties implements Serializable { private Integer cores = null; @JsonProperty(Hardware.JSON_RAM) - private Long memory = null; + private Long ram = null; @JsonProperty(Hardware.JSON_DISK) private Double disk = null; @@ -92,7 +92,7 @@ public void setCores(Integer numberOfCores) { } public NodeProperties memory(Long memory) { - this.memory = memory; + this.ram = memory; return this; } @@ -100,12 +100,12 @@ public NodeProperties memory(Long memory) { * Amount of RAM this node has (in MB). * @return memory **/ - public Long getMemory() { - return memory; + public Long getRam() { + return ram; } - public void setMemory(Long memory) { - this.memory = memory; + public void setRam(Long memory) { + this.ram = memory; } public NodeProperties disk(Double disk) { @@ -169,16 +169,15 @@ public boolean equals(Object o) { } NodeProperties nodeProperties = (NodeProperties) o; return Objects.equals(this.providerId, nodeProperties.providerId) && - Objects.equals(this.price, nodeProperties.price) && - Objects.equals(this.cores, nodeProperties.cores) && - Objects.equals(this.memory, nodeProperties.memory) && Objects.equals(this.disk, nodeProperties.disk) && + Objects.equals(this.price, nodeProperties.price) && Objects.equals(this.cores, nodeProperties.cores) && + Objects.equals(this.ram, nodeProperties.ram) && Objects.equals(this.disk, nodeProperties.disk) && Objects.equals(this.operatingSystem, nodeProperties.operatingSystem) && Objects.equals(this.geoLocation, nodeProperties.geoLocation); } @Override public int hashCode() { - return Objects.hash(providerId, cores, memory, disk, operatingSystem, geoLocation); + return Objects.hash(providerId, cores, ram, disk, operatingSystem, geoLocation); } @Override @@ -186,10 +185,14 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class NodeProperties {\n"); - sb.append(" ").append(Hardware.JSON_PROVIDER_ID).append(": ").append(toIndentedString(providerId)).append("\n"); + sb.append(" ") + .append(Hardware.JSON_PROVIDER_ID) + .append(": ") + .append(toIndentedString(providerId)) + .append("\n"); sb.append(" ").append(NodeCandidate.JSON_PRICE).append(": ").append(toIndentedString(price)).append("\n"); sb.append(" ").append(Hardware.JSON_CORES).append(": ").append(toIndentedString(cores)).append("\n"); - sb.append(" ").append(Hardware.JSON_RAM).append(": ").append(toIndentedString(memory)).append("\n"); + sb.append(" ").append(Hardware.JSON_RAM).append(": ").append(toIndentedString(ram)).append("\n"); sb.append(" ").append(Hardware.JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); sb.append(" ") .append(Image.JSON_OPERATING_SYSTEM) diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java index 3cc0a95..88ccd24 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java @@ -76,7 +76,7 @@ public static NodeCandidate createNodeCandidate(NodeProperties np, String jobId, Hardware hardware = new Hardware(); hardware.setCores(np.getCores()); hardware.setDisk((double) np.getDisk()); - hardware.setRam(np.getMemory()); + hardware.setRam(np.getRam()); hardware.setFpga(""); hardware.setProviderId(np.getProviderId()); //Define the location From 534770219ad64a2075fd87405c8af8a47f8fadf8 Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Mon, 25 Nov 2024 18:17:43 +0100 Subject: [PATCH 4/8] edge to support gpu, fpga and cpu frequency --- .../org/ow2/proactive/sal/model/Hardware.java | 68 ++++++++++++- .../proactive/sal/model/NodeProperties.java | 97 ++++++++++++++++++- .../proactive/sal/service/util/ByonUtils.java | 6 +- 3 files changed, 161 insertions(+), 10 deletions(-) diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java index 3fc9b8c..5e1793e 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java @@ -33,12 +33,16 @@ public class Hardware implements Serializable { public static final String JSON_CORES = "cores"; + public static final String JSON_CPU_FREQUENCY = "cpuFrequency"; + public static final String JSON_RAM = "ram"; public static final String JSON_DISK = "disk"; public static final String JSON_FPGA = "fpga"; + public static final String JSON_GPU = "gpu"; + public static final String JSON_LOCATION = "location"; public static final String JSON_STATE = "state"; @@ -62,6 +66,10 @@ public class Hardware implements Serializable { @JsonProperty(JSON_CORES) private Integer cores = null; + @Column(name = "CPU_FREQUENCY") + @JsonProperty(JSON_CPU_FREQUENCY) + private Double cpuFrequency = null; + @Column(name = "RAM") @JsonProperty(JSON_RAM) private Long ram = null; @@ -74,6 +82,10 @@ public class Hardware implements Serializable { @JsonProperty(JSON_FPGA) private Integer fpga = null; + @Column(name = "GPU") + @JsonProperty(JSON_GPU) + private Integer gpu = null; + @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) @JsonProperty(JSON_LOCATION) private Location location = null; @@ -155,6 +167,27 @@ public void setCores(Integer cores) { this.cores = cores; } + public Hardware cpuFrequency(Double cpuFrequency) { + this.cpuFrequency = cpuFrequency; + return this; + } + + /** + * Sets the CPU frequency in GHz. + * @param cpuFrequency CPU frequency in GHz + */ + public void setCpuFrequency(Double cpuFrequency) { + this.cpuFrequency = cpuFrequency; + } + + /** + * Gets the CPU frequency in GHz. + * @return cpuFrequency + */ + public Double getCpuFrequency() { + return cpuFrequency; + } + public Hardware ram(Long ram) { this.ram = ram; return this; @@ -176,6 +209,10 @@ public Integer getFpga() { return fpga; } + public void setFpga(Integer fpga) { + this.fpga = fpga; + } + public void setFpga(String machineType) { switch (machineType) { case "f1.2xlarge": @@ -192,6 +229,27 @@ public void setFpga(String machineType) { } } + public Hardware gpu(Integer gpu) { + this.gpu = gpu; + return this; + } + + /** + * Sets the number of GPUs. + * @param gpu Number of GPUs + */ + public void setGpu(Integer gpu) { + this.gpu = gpu; + } + + /** + * Gets the number of GPUs. + * @return gpu + */ + public Integer getGpu() { + return gpu; + } + public Hardware disk(Double disk) { this.disk = disk; return this; @@ -272,13 +330,15 @@ public boolean equals(Object o) { return Objects.equals(this.id, hardware.id) && Objects.equals(this.name, hardware.name) && Objects.equals(this.providerId, hardware.providerId) && Objects.equals(this.cores, hardware.cores) && Objects.equals(this.ram, hardware.ram) && Objects.equals(this.disk, hardware.disk) && - Objects.equals(this.fpga, hardware.fpga) && Objects.equals(this.location, hardware.location) && - Objects.equals(this.state, hardware.state) && Objects.equals(this.owner, hardware.owner); + Objects.equals(this.fpga, hardware.fpga) && Objects.equals(this.gpu, hardware.gpu) && // Added GPU comparison + Objects.equals(this.cpuFrequency, hardware.cpuFrequency) && // Added CPU frequency comparison + Objects.equals(this.location, hardware.location) && Objects.equals(this.state, hardware.state) && + Objects.equals(this.owner, hardware.owner); } @Override public int hashCode() { - return Objects.hash(id, name, providerId, cores, ram, disk, fpga, location, state, owner); + return Objects.hash(id, name, providerId, cores, ram, disk, fpga, gpu, cpuFrequency, location, state, owner); } @Override @@ -292,6 +352,8 @@ public String toString() { sb.append(" ").append(JSON_RAM).append(": ").append(toIndentedString(ram)).append("\n"); sb.append(" ").append(JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); sb.append(" ").append(JSON_FPGA).append(": ").append(toIndentedString(fpga)).append("\n"); + sb.append(" ").append(JSON_GPU).append(": ").append(toIndentedString(gpu)).append("\n"); + sb.append(" ").append(JSON_CPU_FREQUENCY).append(": ").append(toIndentedString(cpuFrequency)).append("\n"); sb.append(" ").append(JSON_LOCATION).append(": ").append(toIndentedString(location)).append("\n"); sb.append(" ").append(JSON_STATE).append(": ").append(toIndentedString(state)).append("\n"); sb.append(" ").append(JSON_OWNER).append(": ").append(toIndentedString(owner)).append("\n"); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java index 431fe0a..078d25b 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java @@ -8,6 +8,7 @@ import java.io.Serializable; import java.util.Objects; +import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Embedded; @@ -35,12 +36,21 @@ public class NodeProperties implements Serializable { @JsonProperty(Hardware.JSON_CORES) private Integer cores = null; + @JsonProperty(Hardware.JSON_CPU_FREQUENCY) + private Double cpuFrequency = null; + @JsonProperty(Hardware.JSON_RAM) private Long ram = null; @JsonProperty(Hardware.JSON_DISK) private Double disk = null; + @JsonProperty(Hardware.JSON_FPGA) + private Integer fpga = null; + + @JsonProperty(Hardware.JSON_GPU) + private Integer gpu = null; + @Embedded @JsonProperty(Image.JSON_OPERATING_SYSTEM) private OperatingSystem operatingSystem = null; @@ -66,6 +76,11 @@ public void setProviderId(String providerId) { this.providerId = providerId; } + public NodeProperties price(Double price) { + this.price = price; + return this; + } + public Double getPrice() { return price; } @@ -91,11 +106,32 @@ public void setCores(Integer numberOfCores) { this.cores = numberOfCores; } - public NodeProperties memory(Long memory) { - this.ram = memory; + public NodeProperties ram(Long ram) { + this.ram = ram; + return this; + } + + public NodeProperties cpuFrequency(Double cpuFrequency) { + this.cpuFrequency = cpuFrequency; return this; } + /** + * Sets the CPU frequency in GHz. + * @param cpuFrequency CPU frequency in GHz + */ + public void setCpuFrequency(Double cpuFrequency) { + this.cpuFrequency = cpuFrequency; + } + + /** + * Gets the CPU frequency in GHz. + * @return cpuFrequency + */ + public Double getCpuFrequency() { + return cpuFrequency; + } + /** * Amount of RAM this node has (in MB). * @return memory @@ -125,6 +161,48 @@ public void setDisk(Double disk) { this.disk = disk; } + public NodeProperties fpga(Integer fpga) { + this.fpga = fpga; + return this; + } + + /** + * Sets the number of FPGAs. + * @param fpga Number of FPGAs + */ + public void setFpga(Integer fpga) { + this.fpga = fpga; + } + + /** + * Gets the number of FPGAs. + * @return fpga + */ + public Integer getFpga() { + return fpga; + } + + public NodeProperties gpu(Integer gpu) { + this.gpu = gpu; + return this; + } + + /** + * Sets the number of GPUs. + * @param gpu Number of GPUs + */ + public void setGpu(Integer gpu) { + this.gpu = gpu; + } + + /** + * Gets the number of GPUs. + * @return gpu + */ + public Integer getGpu() { + return gpu; + } + public NodeProperties operatingSystem(OperatingSystem operatingSystem) { this.operatingSystem = operatingSystem; return this; @@ -170,14 +248,18 @@ public boolean equals(Object o) { NodeProperties nodeProperties = (NodeProperties) o; return Objects.equals(this.providerId, nodeProperties.providerId) && Objects.equals(this.price, nodeProperties.price) && Objects.equals(this.cores, nodeProperties.cores) && + Objects.equals(this.cpuFrequency, nodeProperties.cpuFrequency) && Objects.equals(this.ram, nodeProperties.ram) && Objects.equals(this.disk, nodeProperties.disk) && + Objects.equals(this.fpga, nodeProperties.fpga) && Objects.equals(this.gpu, nodeProperties.gpu) && Objects.equals(this.operatingSystem, nodeProperties.operatingSystem) && Objects.equals(this.geoLocation, nodeProperties.geoLocation); + } @Override public int hashCode() { - return Objects.hash(providerId, cores, ram, disk, operatingSystem, geoLocation); + return Objects.hash(providerId, price, cores, cpuFrequency, ram, disk, fpga, gpu, operatingSystem, geoLocation); + } @Override @@ -192,8 +274,15 @@ public String toString() { .append("\n"); sb.append(" ").append(NodeCandidate.JSON_PRICE).append(": ").append(toIndentedString(price)).append("\n"); sb.append(" ").append(Hardware.JSON_CORES).append(": ").append(toIndentedString(cores)).append("\n"); + sb.append(" ") + .append(Hardware.JSON_CPU_FREQUENCY) + .append(": ") + .append(toIndentedString(cpuFrequency)) + .append("\n"); sb.append(" ").append(Hardware.JSON_RAM).append(": ").append(toIndentedString(ram)).append("\n"); sb.append(" ").append(Hardware.JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); + sb.append(" ").append(Hardware.JSON_FPGA).append(": ").append(toIndentedString(fpga)).append("\n"); + sb.append(" ").append(Hardware.JSON_GPU).append(": ").append(toIndentedString(gpu)).append("\n"); sb.append(" ") .append(Image.JSON_OPERATING_SYSTEM) .append(": ") @@ -204,8 +293,6 @@ public String toString() { .append(": ") .append(toIndentedString(geoLocation)) .append("\n"); - - sb.append("}"); return sb.toString(); } diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java index 88ccd24..4c6ddc8 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/util/ByonUtils.java @@ -75,9 +75,11 @@ public static NodeCandidate createNodeCandidate(NodeProperties np, String jobId, //Define the hardware Hardware hardware = new Hardware(); hardware.setCores(np.getCores()); - hardware.setDisk((double) np.getDisk()); + hardware.setCpuFrequency(np.getCpuFrequency()); + hardware.setDisk(np.getDisk()); hardware.setRam(np.getRam()); - hardware.setFpga(""); + hardware.setFpga(np.getFpga()); + hardware.setGpu(np.getGpu()); hardware.setProviderId(np.getProviderId()); //Define the location Location location = new Location(); From e6cc41584974422e3b771b814b4bc9e54936eaef Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Tue, 26 Nov 2024 17:52:40 +0100 Subject: [PATCH 5/8] undeploy edge node resource during cluster removal and set jobId to any --- endpoints/4-edge-endpoints.md | 32 +++++++++++-------- .../org/ow2/proactive/sal/model/EdgeNode.java | 1 + .../sal/service/service/ClusterService.java | 12 +++++++ .../sal/service/service/EdgeService.java | 25 ++++++++++----- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/endpoints/4-edge-endpoints.md b/endpoints/4-edge-endpoints.md index 28d0574..de001ce 100644 --- a/endpoints/4-edge-endpoints.md +++ b/endpoints/4-edge-endpoints.md @@ -34,11 +34,14 @@ This endpoint is used to register new Edge nodes, which are passed as an [EdgeDe } ], "nodeProperties": { - "providerId": "1", "price": "{{price}}", + "providerId": "{{providerID}}", "cores": "{{cores}}", + "cpuFrequency": "{{cpuFrequency}}", "ram": "{{ram}}", "disk": "{{disk}}", + "fpga": "{{fpga}}", + "gpu": "{{gpu}}", "operatingSystem": { "operatingSystemFamily": "{{OS_name}}", "operatingSystemArchitecture": "{{OS_architecture}}", @@ -65,22 +68,25 @@ This endpoint is used to register new Edge nodes, which are passed as an [EdgeDe - Information registered in node candidate for hardware, location, and image that represent the device. The fields are defined as: -- `name`: The name of the edge node. This is used for identification and management within the cluster. +- `name`(String): The name of the edge node, used for identification and management within the cluster. - `loginCredential`: Contains authentication details for accessing the edge node. The username and password are required for SSH access, with an option for a privateKey instead of a password. - `ipAddresses`: A list of IP addresses associated with the node, including both PUBLIC_IP and PRIVATE_IP with IP Version specified as V4. -- `nodeProperties`: - - `providerId`: The ID of the provider. Default is `"1"`. - - `price`: The price of the edge node source. - - `cores`: A string representing number of CPU cores (e.g., `"1"`). - - `ram`: The hardware ram memory in GB (e.g., `"1"`) - - `disk`: The hardware storage space in GB (e.g., `"1.0"`). +- `nodeProperties`: Represents the properties being transmitted to a node candidate, reflecting the attributes of the registered edge device. + - `price`(Double): The price of the edge node source. + - `providerId` (String): The unique identifier of the provider. + - `cores`(Integer): The number of CPU cores the node possesses. + - `cpuFrequency`(Double): The CPU frequency in GHz. + - `ram`(Long): The hardware's RAM memory in MB. + - `disk`(Double): The hardware's storage space in GB. + - `fpga`(Integer): The number of FPGAs (Field-Programmable Gate Arrays) available on the node. + - `gpu`(Integer): The number of GPUs (Graphics Processing Units) available on the node. - `operatingSystem`: Information about the OS, including Family, Architecture, and Version. - `geoLocation`: The physical location details, such as city, country, latitude, and longitude of the edge node. -- `port`: The port on which the edge node is accessible. -- `jobId`: ProActive Job ID associated with the edge node. Set to `"0"` or `"any"` if no job is linked. -- `systemArch`: The system architecture, which must be one of `"AMD"`, `"ARMv8"`, or `"ARMv7"`. -- `scriptURL`: A URL pointing to any script required during the node setup. -- `jarURL`: The URL for the node's executable `.jar` file, which corresponds to the `systemArch`. +- `port` (String): The port number on which the edge node is accessible. +- `jobId`(String): The ProActive Job ID associated with the edge node. Set to `"0"` or `"any"`, or `null`, if no job is linked. +- `systemArch`(String): The system architecture, which must be one of `"AMD"`, `"ARMv8"`, or `"ARMv7"`. +- `scriptURL`(String): A URL pointing to a script required for setting up the node. +- `jarURL`(String): The URL for the node's executable `.jar` file, which corresponds to the `systemArch`. Each system architecture requires a specific `jarURL` for node execution, available from your ProActive installation. To obtain these `.jar` files, access the ProActive Resource Manager portal and go to _Portal -> Launch a Node_. Here are examples for various architectures: diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java index 72c376e..d903d50 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java @@ -29,6 +29,7 @@ @Setter @Table(name = "EDGE_NODE") public class EdgeNode extends AbstractNode { + public static final String ANY_JOB_ID = "any"; // Constants for JSON properties public static final String JSON_NAME = "name"; diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java index 705022d..91157e8 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java @@ -470,6 +470,18 @@ private void cleanupNodeJob(String sessionId, String clusterName, ClusterNodeDef nodeTasks.forEach(task -> repositoryService.deleteTask(task)); repositoryService.flush(); + //undeploy edge node source and delete representing resource from ProActive Resource Manager + NodeCandidate nc = repositoryService.getNodeCandidate(node.getNodeCandidateId()); + if (nc.getCloud().getCloudType().equals(CloudType.EDGE)) { + EdgeNode edgeNode = ByonUtils.getEdgeNodeFromNC(nc); + edgeService.handlePACloudDeletion(edgeNode); + //remove ProActive JobId from edge device + edgeNode.setJobId(EdgeNode.ANY_JOB_ID); + repositoryService.saveEdgeNode(edgeNode); + nc.setJobIdForEDGE(EdgeNode.ANY_JOB_ID); + repositoryService.saveNodeCandidate(nc); + } + LOGGER.info("Cleanup completed for node {}", node.getName()); } catch (Exception e) { diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java index 9a19df1..a1b2211 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java @@ -58,7 +58,7 @@ public EdgeNode registerNewEdgeNode(String sessionId, EdgeDefinition edgeNodeDef EdgeNode newEdgeNode = new EdgeNode(); String jobId; if (edgeNodeDefinition.getJobId() == null || edgeNodeDefinition.getJobId().isEmpty()) { - jobId = "any"; + jobId = EdgeNode.ANY_JOB_ID; } else { jobId = edgeNodeDefinition.getJobId(); } @@ -300,25 +300,34 @@ public boolean deleteEdgeNode(String sessionId, String edgeId) throws NotConnect throw new IllegalArgumentException("The passed EDGE ID \"" + edgeId + "\" is not Found in the database"); } - LOGGER.info("Deleting the corresponding PACloud from the database ..."); + handlePACloudDeletion(edgeNode); + + return true; + } + + /** + * Handle the deletion of a PACloud related to an EdgeNode + * @param edgeNode The edge node whose related PACloud is to be deleted + */ + public void handlePACloudDeletion(EdgeNode edgeNode) { + LOGGER.info("Deleting the corresponding Edge Node PACloud from the database ..."); PACloud paCloud = repositoryService.getPACloud(edgeNode.composeNodeSourceName()); if (paCloud != null) { if (paCloud.getDeployments() != null) { - LOGGER.info("Cleaning deployments from related tasks {}", paCloud.getDeployments().toString()); + LOGGER.info("Cleaning Edge Node deployments from related tasks {}", + paCloud.getDeployments().toString()); paCloud.getDeployments().forEach(deployment -> deployment.getTask().removeDeployment(deployment)); - LOGGER.info("Cleaning deployments from paCloud {}", paCloud.getCloudId()); + LOGGER.info("Cleaning Edge Node deployments from paCloud {}", paCloud.getCloudId()); paCloud.clearDeployments(); } repositoryService.deletePACloud(paCloud); } else { - LOGGER.warn("The PACloud related to the edgeNode {} is not found.", edgeNode.getName()); + LOGGER.info("The PACloud related to the Edge Node {} is not found.", edgeNode.getName()); } if (Boolean.FALSE.equals(ByonUtils.undeployNs(edgeNode.composeNodeSourceName(), false, true))) { LOGGER.warn("The Edge node source undeploy finished with errors!"); } - repositoryService.deleteEdgeNode(edgeNode); - - return true; } + } From fe5707852fe6da3462addbd79aa19e0dfe4d98e4 Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Wed, 27 Nov 2024 09:06:05 +0100 Subject: [PATCH 6/8] documenting edge changes --- endpoints/4-edge-endpoints.md | 2 +- .../java/org/ow2/proactive/sal/service/service/EdgeService.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/endpoints/4-edge-endpoints.md b/endpoints/4-edge-endpoints.md index de001ce..2c865e9 100644 --- a/endpoints/4-edge-endpoints.md +++ b/endpoints/4-edge-endpoints.md @@ -83,7 +83,7 @@ The fields are defined as: - `operatingSystem`: Information about the OS, including Family, Architecture, and Version. - `geoLocation`: The physical location details, such as city, country, latitude, and longitude of the edge node. - `port` (String): The port number on which the edge node is accessible. -- `jobId`(String): The ProActive Job ID associated with the edge node. Set to `"0"` or `"any"`, or `null`, if no job is linked. +- `jobId`(String): The ProActive Job ID associated with the edge node. Set to `"0"` or `"any"`, or `null`, if no job is linked. Note that value `"any"` will be assigned to the jobId in this case indicating that there is no deployment on given device. When the deployment is sent to the edge device, the value will be replaced with name of ProActive deployment job. - `systemArch`(String): The system architecture, which must be one of `"AMD"`, `"ARMv8"`, or `"ARMv7"`. - `scriptURL`(String): A URL pointing to a script required for setting up the node. - `jarURL`(String): The URL for the node's executable `.jar` file, which corresponds to the `systemArch`. diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java index a1b2211..12e8a50 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java @@ -302,6 +302,8 @@ public boolean deleteEdgeNode(String sessionId, String edgeId) throws NotConnect handlePACloudDeletion(edgeNode); + repositoryService.deleteEdgeNode(edgeNode); + return true; } From 4705079d88c441b39bf768b745087786df74abd0 Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Wed, 27 Nov 2024 13:36:07 +0100 Subject: [PATCH 7/8] removing unused comments and moving constants to EdgeDefinition --- .../proactive/sal/model/EdgeDefinition.java | 51 ++++++++++++++---- .../org/ow2/proactive/sal/model/EdgeNode.java | 53 +++++-------------- .../org/ow2/proactive/sal/model/Hardware.java | 1 - .../org/ow2/proactive/sal/model/Image.java | 1 - .../proactive/sal/model/LoginCredential.java | 1 - .../proactive/sal/model/NodeCandidate.java | 1 - .../sal/service/service/ClusterService.java | 4 +- .../sal/service/service/EdgeService.java | 2 +- 8 files changed, 55 insertions(+), 59 deletions(-) diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java index 1465ea8..6808288 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java @@ -13,7 +13,7 @@ /** - * Attributes defining a EDGE node + * Attributes defining an EDGE node */ @AllArgsConstructor @NoArgsConstructor @@ -21,33 +21,62 @@ @Setter @ToString(callSuper = true) public class EdgeDefinition { - // Default constants + public static final String DEFAULT_PORT = "22"; + public static final String ANY_JOB_ID = "any"; + + // Constants for JSON properties + public static final String JSON_NAME = "name"; + + public static final String JSON_LOGIN_CREDENTIAL = "loginCredential"; + + public static final String JSON_IP_ADDRESSES = "ipAddresses"; + + public static final String JSON_NODE_PROPERTIES = "nodeProperties"; + + public static final String JSON_PORT = "port"; + + public static final String JSON_REASON = "reason"; + + public static final String JSON_DIAGNOSTIC = "diagnostic"; + + public static final String JSON_USER_ID = "userId"; + + public static final String JSON_ALLOCATED = "allocated"; + + // edge jobID corresponds to the ProActive job name + public static final String JSON_JOB_ID = "jobId"; + + public static final String JSON_SYSTEM_ARCH = "systemArch"; + + public static final String JSON_SCRIPT_URL = "scriptURL"; + + public static final String JSON_JAR_URL = "jarURL"; - @JsonProperty(EdgeNode.JSON_NAME) + @JsonProperty(JSON_NAME) private String name = null; - @JsonProperty(EdgeNode.JSON_JOB_ID) + @JsonProperty(JSON_JOB_ID) private String jobId = null; - @JsonProperty(EdgeNode.JSON_SYSTEM_ARCH) + @JsonProperty(JSON_SYSTEM_ARCH) private String systemArch = null; - @JsonProperty(EdgeNode.JSON_SCRIPT_URL) + @JsonProperty(JSON_SCRIPT_URL) private String scriptURL = null; - @JsonProperty(EdgeNode.JSON_JAR_URL) + @JsonProperty(JSON_JAR_URL) private String jarURL = null; - @JsonProperty(EdgeNode.JSON_LOGIN_CREDENTIAL) + @JsonProperty(JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; - @JsonProperty(EdgeNode.JSON_IP_ADDRESSES) + @JsonProperty(JSON_IP_ADDRESSES) private List ipAddresses = null; - @JsonProperty(EdgeNode.JSON_PORT) + @JsonProperty(JSON_PORT) private String port = DEFAULT_PORT; - @JsonProperty(EdgeNode.JSON_NODE_PROPERTIES) + @JsonProperty(JSON_NODE_PROPERTIES) private NodeProperties nodeProperties = null; } diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java index d903d50..a5c50fc 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java @@ -29,83 +29,54 @@ @Setter @Table(name = "EDGE_NODE") public class EdgeNode extends AbstractNode { - public static final String ANY_JOB_ID = "any"; - - // Constants for JSON properties - public static final String JSON_NAME = "name"; - - public static final String JSON_LOGIN_CREDENTIAL = "loginCredential"; - - public static final String JSON_IP_ADDRESSES = "ipAddresses"; - - public static final String JSON_NODE_PROPERTIES = "nodeProperties"; - - public static final String JSON_PORT = "port"; - - public static final String JSON_REASON = "reason"; - - public static final String JSON_DIAGNOSTIC = "diagnostic"; - - public static final String JSON_USER_ID = "userId"; - - public static final String JSON_ALLOCATED = "allocated"; - - // edge jobID corresponds to the ProActive job name - public static final String JSON_JOB_ID = "jobId"; - - public static final String JSON_SYSTEM_ARCH = "systemArch"; - - public static final String JSON_SCRIPT_URL = "scriptURL"; - - public static final String JSON_JAR_URL = "jarURL"; @Column(name = "NAME") - @JsonProperty(JSON_NAME) + @JsonProperty(EdgeDefinition.JSON_NAME) private String name = null; @Embedded - @JsonProperty(JSON_LOGIN_CREDENTIAL) + @JsonProperty(EdgeDefinition.JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; @ElementCollection(targetClass = IpAddress.class) private List ipAddresses = null; @Embedded - @JsonProperty(JSON_NODE_PROPERTIES) + @JsonProperty(EdgeDefinition.JSON_NODE_PROPERTIES) private NodeProperties nodeProperties = null; @Column(name = "PORT") - @JsonProperty(JSON_PORT) + @JsonProperty(EdgeDefinition.JSON_PORT) private String port = null; @Column(name = "REASON") - @JsonProperty(JSON_REASON) + @JsonProperty(EdgeDefinition.JSON_REASON) private String reason = null; @Column(name = "DIAGNOSTIC") - @JsonProperty(JSON_DIAGNOSTIC) + @JsonProperty(EdgeDefinition.JSON_DIAGNOSTIC) private String diagnostic = null; @Column(name = "USER_ID") - @JsonProperty(JSON_USER_ID) + @JsonProperty(EdgeDefinition.JSON_USER_ID) private String userId = null; @Column(name = "ALLOCATED") - @JsonProperty(JSON_ALLOCATED) + @JsonProperty(EdgeDefinition.JSON_ALLOCATED) private Boolean allocated = null; @Column(name = "JOB_ID") - @JsonProperty(JSON_JOB_ID) + @JsonProperty(EdgeDefinition.JSON_JOB_ID) private String jobId; @Column(name = "SYSTEM_ARCH") - @JsonProperty(JSON_SYSTEM_ARCH) + @JsonProperty(EdgeDefinition.JSON_SYSTEM_ARCH) private String systemArch = null; - @JsonProperty(JSON_SCRIPT_URL) + @JsonProperty(EdgeDefinition.JSON_SCRIPT_URL) private String scriptURL = null; - @JsonProperty(JSON_JAR_URL) + @JsonProperty(EdgeDefinition.JSON_JAR_URL) private String jarURL = null; public EdgeNode name(String name) { diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java index 5e1793e..5e7d28f 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java @@ -24,7 +24,6 @@ @Entity @Table(name = "HARDWARE") public class Hardware implements Serializable { - // Constants for JSON property names public static final String JSON_ID = "id"; public static final String JSON_NAME = "name"; diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java index c4af3a0..72aaaf5 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java @@ -24,7 +24,6 @@ @Entity @Table(name = "IMAGE") public class Image implements Serializable { - // Constants for JSON property names public static final String JSON_ID = "id"; public static final String JSON_NAME = "name"; diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java index 0c23ac7..4627a3a 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java @@ -23,7 +23,6 @@ @NoArgsConstructor @Embeddable public class LoginCredential implements Serializable { - // JSON property constants public static final String JSON_USERNAME = "username"; public static final String JSON_PASSWORD = "password"; diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java index 64c3475..ef9aaad 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java @@ -32,7 +32,6 @@ @Entity @Table(name = "NODE_CANDIDATE") public class NodeCandidate implements Serializable { - // JSON Property Constants public static final String JSON_ID = "id"; public static final String JSON_NODE_CANDIDATE_TYPE = "nodeCandidateType"; diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java index 91157e8..fab94fb 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java @@ -476,9 +476,9 @@ private void cleanupNodeJob(String sessionId, String clusterName, ClusterNodeDef EdgeNode edgeNode = ByonUtils.getEdgeNodeFromNC(nc); edgeService.handlePACloudDeletion(edgeNode); //remove ProActive JobId from edge device - edgeNode.setJobId(EdgeNode.ANY_JOB_ID); + edgeNode.setJobId(EdgeDefinition.ANY_JOB_ID); repositoryService.saveEdgeNode(edgeNode); - nc.setJobIdForEDGE(EdgeNode.ANY_JOB_ID); + nc.setJobIdForEDGE(EdgeDefinition.ANY_JOB_ID); repositoryService.saveNodeCandidate(nc); } diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java index 12e8a50..c24cc5c 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/EdgeService.java @@ -58,7 +58,7 @@ public EdgeNode registerNewEdgeNode(String sessionId, EdgeDefinition edgeNodeDef EdgeNode newEdgeNode = new EdgeNode(); String jobId; if (edgeNodeDefinition.getJobId() == null || edgeNodeDefinition.getJobId().isEmpty()) { - jobId = EdgeNode.ANY_JOB_ID; + jobId = EdgeDefinition.ANY_JOB_ID; } else { jobId = edgeNodeDefinition.getJobId(); } From 558f6a12f18bdca98b11040ccb3360b243dffce0 Mon Sep 17 00:00:00 2001 From: ankicabarisic Date: Wed, 27 Nov 2024 17:06:21 +0100 Subject: [PATCH 8/8] adding lombok getters, setters, and EqualsAndHashCode --- .../proactive/sal/model/EdgeDefinition.java | 5 +- .../org/ow2/proactive/sal/model/EdgeNode.java | 94 +------ .../org/ow2/proactive/sal/model/Hardware.java | 261 ++---------------- .../org/ow2/proactive/sal/model/Image.java | 151 +--------- .../org/ow2/proactive/sal/model/Location.java | 186 +------------ .../proactive/sal/model/LoginCredential.java | 79 +----- .../proactive/sal/model/NodeCandidate.java | 258 +---------------- .../proactive/sal/model/NodeProperties.java | 229 ++------------- .../sal/service/nc/NodeCandidateUtils.java | 4 +- 9 files changed, 92 insertions(+), 1175 deletions(-) diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java index 6808288..a1b6d4b 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; +import lombok.experimental.Accessors; /** @@ -17,15 +18,17 @@ */ @AllArgsConstructor @NoArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode @Getter @Setter @ToString(callSuper = true) public class EdgeDefinition { public static final String DEFAULT_PORT = "22"; + public static final String ANY_JOB_ID = "any"; - // Constants for JSON properties public static final String JSON_NAME = "name"; public static final String JSON_LOGIN_CREDENTIAL = "loginCredential"; diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java index a5c50fc..d3849a9 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeNode.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -25,9 +26,10 @@ @AllArgsConstructor @NoArgsConstructor @Entity +@Table(name = "EDGE_NODE") @Getter @Setter -@Table(name = "EDGE_NODE") +@EqualsAndHashCode public class EdgeNode extends AbstractNode { @Column(name = "NAME") @@ -79,100 +81,10 @@ public class EdgeNode extends AbstractNode { @JsonProperty(EdgeDefinition.JSON_JAR_URL) private String jarURL = null; - public EdgeNode name(String name) { - this.setName(name); - return this; - } - - public EdgeNode loginCredential(LoginCredential loginCredential) { - this.setLoginCredential(loginCredential); - return this; - } - - public EdgeNode ipAddresses(List ipAddresses) { - this.setIpAddresses(ipAddresses); - return this; - } - - public EdgeNode addIpAddressesItem(IpAddress ipAddressesItem) { - this.addIpAddressesItem(ipAddressesItem); - return this; - } - - public EdgeNode nodeProperties(NodeProperties nodeProperties) { - this.setNodeProperties(nodeProperties); - return this; - } - - public EdgeNode reason(String reason) { - this.setReason(reason); - return this; - } - - public EdgeNode diagnostic(String diagnostic) { - this.setDiagnostic(diagnostic); - return this; - } - - public EdgeNode id(String id) { - this.setId(id); - return this; - } - - public EdgeNode userId(String userId) { - this.setUserId(userId); - return this; - } - - public EdgeNode allocated(Boolean allocated) { - this.setAllocated(allocated); - return this; - } - public String composeNodeSourceName() { return "EDGE_NS_" + this.systemArch + "_" + this.id; } - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EdgeNode edgeNode = (EdgeNode) o; - return Objects.equals(this.name, edgeNode.getName()) && - Objects.equals(this.loginCredential, edgeNode.getLoginCredential()) && - Objects.equals(this.ipAddresses, edgeNode.getIpAddresses()) && - Objects.equals(this.nodeProperties, edgeNode.getNodeProperties()) && - Objects.equals(this.reason, edgeNode.getReason()) && - Objects.equals(this.diagnostic, edgeNode.getDiagnostic()) && - Objects.equals(this.nodeCandidate, edgeNode.getNodeCandidate()) && - Objects.equals(this.id, edgeNode.getId()) && Objects.equals(this.userId, edgeNode.getUserId()) && - Objects.equals(this.allocated, edgeNode.getAllocated()) && - Objects.equals(this.jobId, edgeNode.getJobId()) && - Objects.equals(this.systemArch, edgeNode.getSystemArch()) && - Objects.equals(this.scriptURL, edgeNode.getScriptURL()) && Objects.equals(jarURL, edgeNode.getJarURL()); - } - - @Override - public int hashCode() { - return Objects.hash(this.name, - this.id, - this.loginCredential, - this.ipAddresses, - this.nodeProperties, - this.reason, - this.diagnostic, - this.nodeProperties, - this.userId, - this.allocated, - this.jobId, - this.systemArch, - this.scriptURL, - this.jarURL); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java index 5e7d28f..c280c6b 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Hardware.java @@ -13,7 +13,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; /** @@ -21,9 +25,14 @@ */ @AllArgsConstructor @NoArgsConstructor +@Getter +@Setter +@Accessors(chain = true) +@EqualsAndHashCode @Entity @Table(name = "HARDWARE") public class Hardware implements Serializable { + public static final String JSON_ID = "id"; public static final String JSON_NAME = "name"; @@ -98,121 +107,11 @@ public class Hardware implements Serializable { @JsonProperty(JSON_OWNER) private String owner = null; - public Hardware id(String id) { - this.id = id; - return this; - } - - /** - * Unique identifier for the hardware - * @return id - **/ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Hardware name(String name) { - this.name = name; - return this; - } - - /** - * Human-readable name for the hardware - * @return name - **/ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Hardware providerId(String providerId) { - this.providerId = providerId; - return this; - } - - /** - * Original id issued by the provider - * @return providerId - **/ - public String getProviderId() { - return providerId; - } - - public void setProviderId(String providerId) { - this.providerId = providerId; - } - - public Hardware cores(Integer cores) { - this.cores = cores; - return this; - } - /** - * Number of cores - * @return cores - **/ - public Integer getCores() { - return cores; - } - - public void setCores(Integer cores) { - this.cores = cores; - } - - public Hardware cpuFrequency(Double cpuFrequency) { - this.cpuFrequency = cpuFrequency; - return this; - } - - /** - * Sets the CPU frequency in GHz. - * @param cpuFrequency CPU frequency in GHz - */ - public void setCpuFrequency(Double cpuFrequency) { - this.cpuFrequency = cpuFrequency; - } - - /** - * Gets the CPU frequency in GHz. - * @return cpuFrequency + * Sets the FPGA field based on machine type. + * @param machineType the machine type */ - public Double getCpuFrequency() { - return cpuFrequency; - } - - public Hardware ram(Long ram) { - this.ram = ram; - return this; - } - - /** - * Amount of RAM (in MB) - * @return ram - **/ - public Long getRam() { - return ram; - } - - public void setRam(Long ram) { - this.ram = ram; - } - - public Integer getFpga() { - return fpga; - } - - public void setFpga(Integer fpga) { - this.fpga = fpga; - } - - public void setFpga(String machineType) { + public void setCloudFpga(String machineType) { switch (machineType) { case "f1.2xlarge": this.fpga = 1; @@ -228,134 +127,26 @@ public void setFpga(String machineType) { } } - public Hardware gpu(Integer gpu) { - this.gpu = gpu; - return this; - } - - /** - * Sets the number of GPUs. - * @param gpu Number of GPUs - */ - public void setGpu(Integer gpu) { - this.gpu = gpu; - } - /** - * Gets the number of GPUs. - * @return gpu + * Custom toString() method for the Hardware class to format the output */ - public Integer getGpu() { - return gpu; - } - - public Hardware disk(Double disk) { - this.disk = disk; - return this; - } - - /** - * Amount of disk space (in GB) - * @return disk - **/ - public Double getDisk() { - return disk; - } - - public void setDisk(Double disk) { - this.disk = disk; - } - - public Hardware location(Location location) { - this.location = location; - return this; - } - - /** - * Get location - * @return location - **/ - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public Hardware state(DiscoveryItemState state) { - this.state = state; - return this; - } - - /** - * Get state - * @return state - **/ - public DiscoveryItemState getState() { - return state; - } - - public void setState(DiscoveryItemState state) { - this.state = state; - } - - public Hardware owner(String owner) { - this.owner = owner; - return this; - } - - /** - * Get owner - * @return owner - **/ - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Hardware hardware = (Hardware) o; - return Objects.equals(this.id, hardware.id) && Objects.equals(this.name, hardware.name) && - Objects.equals(this.providerId, hardware.providerId) && Objects.equals(this.cores, hardware.cores) && - Objects.equals(this.ram, hardware.ram) && Objects.equals(this.disk, hardware.disk) && - Objects.equals(this.fpga, hardware.fpga) && Objects.equals(this.gpu, hardware.gpu) && // Added GPU comparison - Objects.equals(this.cpuFrequency, hardware.cpuFrequency) && // Added CPU frequency comparison - Objects.equals(this.location, hardware.location) && Objects.equals(this.state, hardware.state) && - Objects.equals(this.owner, hardware.owner); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, providerId, cores, ram, disk, fpga, gpu, cpuFrequency, location, state, owner); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Hardware {\n"); - sb.append(" ").append(JSON_ID).append(": ").append(toIndentedString(id)).append("\n"); - sb.append(" ").append(JSON_NAME).append(": ").append(toIndentedString(name)).append("\n"); - sb.append(" ").append(JSON_PROVIDER_ID).append(": ").append(toIndentedString(providerId)).append("\n"); - sb.append(" ").append(JSON_CORES).append(": ").append(toIndentedString(cores)).append("\n"); - sb.append(" ").append(JSON_RAM).append(": ").append(toIndentedString(ram)).append("\n"); - sb.append(" ").append(JSON_DISK).append(": ").append(toIndentedString(disk)).append("\n"); - sb.append(" ").append(JSON_FPGA).append(": ").append(toIndentedString(fpga)).append("\n"); - sb.append(" ").append(JSON_GPU).append(": ").append(toIndentedString(gpu)).append("\n"); - sb.append(" ").append(JSON_CPU_FREQUENCY).append(": ").append(toIndentedString(cpuFrequency)).append("\n"); - sb.append(" ").append(JSON_LOCATION).append(": ").append(toIndentedString(location)).append("\n"); - sb.append(" ").append(JSON_STATE).append(": ").append(toIndentedString(state)).append("\n"); - sb.append(" ").append(JSON_OWNER).append(": ").append(toIndentedString(owner)).append("\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" providerId: ").append(toIndentedString(providerId)).append("\n"); + sb.append(" cores: ").append(toIndentedString(cores)).append("\n"); + sb.append(" cpuFrequency: ").append(toIndentedString(cpuFrequency)).append("\n"); + sb.append(" ram: ").append(toIndentedString(ram)).append("\n"); + sb.append(" disk: ").append(toIndentedString(disk)).append("\n"); + sb.append(" fpga: ").append(toIndentedString(fpga)).append("\n"); + sb.append(" gpu: ").append(toIndentedString(gpu)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).append("\n"); + sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java index 72aaaf5..2f30008 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Image.java @@ -13,14 +13,22 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; /** - * Represents an image offer by a cloud + * Represents an image offered by a cloud */ @AllArgsConstructor @NoArgsConstructor +@Getter +@Setter +@Accessors(chain = true) +@EqualsAndHashCode @Entity @Table(name = "IMAGE") public class Image implements Serializable { @@ -68,146 +76,9 @@ public class Image implements Serializable { @JsonProperty(JSON_OWNER) private String owner = null; - public Image id(String id) { - this.id = id; - return this; - } - /** - * Unique identifier for this image - * @return id - **/ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Image name(String name) { - this.name = name; - return this; - } - - /** - * Human-readable name - * @return name - **/ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Image providerId(String providerId) { - this.providerId = providerId; - return this; - } - - /** - * Original id issued by provider - * @return providerId - **/ - public String getProviderId() { - return providerId; - } - - public void setProviderId(String providerId) { - this.providerId = providerId; - } - - public Image operatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - return this; - } - - /** - * Get operatingSystem - * @return operatingSystem - **/ - public OperatingSystem getOperatingSystem() { - return operatingSystem; - } - - public void setOperatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - } - - public Image location(Location location) { - this.location = location; - return this; - } - - /** - * Get location - * @return location - **/ - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public Image state(DiscoveryItemState state) { - this.state = state; - return this; - } - - /** - * Get state - * @return state - **/ - public DiscoveryItemState getState() { - return state; - } - - public void setState(DiscoveryItemState state) { - this.state = state; - } - - public Image owner(String owner) { - this.owner = owner; - return this; - } - - /** - * Get owner - * @return owner - **/ - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Image image = (Image) o; - return Objects.equals(this.id, image.id) && Objects.equals(this.name, image.name) && - Objects.equals(this.providerId, image.providerId) && - Objects.equals(this.operatingSystem, image.operatingSystem) && - Objects.equals(this.location, image.location) && Objects.equals(this.state, image.state) && - Objects.equals(this.owner, image.owner); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, providerId, operatingSystem, location, state, owner); - } - + * Custom toString() method for the Image class to format the output + */ @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java index 86c1d1e..9b4a697 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/Location.java @@ -7,7 +7,6 @@ import java.io.Serializable; import java.util.Locale; -import java.util.Objects; import javax.persistence.*; @@ -16,16 +15,24 @@ import com.fasterxml.jackson.annotation.JsonValue; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; /** - * Represents a (virtual) location offers by a cloud + * Represents a (virtual) location offered by a cloud */ @AllArgsConstructor @NoArgsConstructor @Entity @Table(name = "LOCATION") +@Accessors(chain = true) +@EqualsAndHashCode +@Getter +@Setter public class Location implements Serializable { public static final String JSON_ID = "id"; @@ -116,181 +123,6 @@ public static LocationScopeEnum fromValue(String text) { @JsonProperty(JSON_OWNER) private String owner = null; - public Location id(String id) { - this.id = id; - return this; - } - - /** - * Unique identifier - * @return id - **/ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Location name(String name) { - this.name = name; - return this; - } - - /** - * Human-readable name - * @return name - **/ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Location providerId(String providerId) { - this.providerId = providerId; - return this; - } - - /** - * Original id issued by the provider - * @return providerId - **/ - public String getProviderId() { - return providerId; - } - - public void setProviderId(String providerId) { - this.providerId = providerId; - } - - public Location locationScope(LocationScopeEnum locationScope) { - this.locationScope = locationScope; - return this; - } - - /** - * Scope of the location - * @return locationScope - **/ - public LocationScopeEnum getLocationScope() { - return locationScope; - } - - public void setLocationScope(LocationScopeEnum locationScope) { - this.locationScope = locationScope; - } - - public Location isAssignable(Boolean isAssignable) { - this.isAssignable = isAssignable; - return this; - } - - /** - * True of the location can be used to start virtual machines, false if not - * @return isAssignable - **/ - public Boolean isIsAssignable() { - return isAssignable; - } - - public void setIsAssignable(Boolean isAssignable) { - this.isAssignable = isAssignable; - } - - public Location geoLocation(GeoLocation geoLocation) { - this.geoLocation = geoLocation; - return this; - } - - /** - * Get geoLocation - * @return geoLocation - **/ - public GeoLocation getGeoLocation() { - return geoLocation; - } - - public void setGeoLocation(GeoLocation geoLocation) { - this.geoLocation = geoLocation; - } - - public Location parent(Location parent) { - this.parent = parent; - return this; - } - - /** - * Get parent - * @return parent - **/ - public Location getParent() { - return parent; - } - - public void setParent(Location parent) { - this.parent = parent; - } - - public Location state(DiscoveryItemState state) { - this.state = state; - return this; - } - - /** - * Get state - * @return state - **/ - public DiscoveryItemState getState() { - return state; - } - - public void setState(DiscoveryItemState state) { - this.state = state; - } - - public Location owner(String owner) { - this.owner = owner; - return this; - } - - /** - * Get owner - * @return owner - **/ - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Location location = (Location) o; - return Objects.equals(this.id, location.id) && Objects.equals(this.name, location.name) && - Objects.equals(this.providerId, location.providerId) && - Objects.equals(this.locationScope, location.locationScope) && - Objects.equals(this.isAssignable, location.isAssignable) && - Objects.equals(this.geoLocation, location.geoLocation) && Objects.equals(this.parent, location.parent) && - Objects.equals(this.state, location.state) && Objects.equals(this.owner, location.owner); - } - - @Override - public int hashCode() { - return Objects.hash(id, name, providerId, locationScope, isAssignable, geoLocation, parent, state, owner); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java index 4627a3a..3adf101 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/LoginCredential.java @@ -6,14 +6,17 @@ package org.ow2.proactive.sal.model; import java.io.Serializable; -import java.util.Objects; import javax.persistence.Embeddable; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; /** @@ -22,6 +25,10 @@ @AllArgsConstructor @NoArgsConstructor @Embeddable +@Accessors(chain = true) +@EqualsAndHashCode +@Getter +@Setter public class LoginCredential implements Serializable { public static final String JSON_USERNAME = "username"; @@ -38,76 +45,6 @@ public class LoginCredential implements Serializable { @JsonProperty(JSON_PRIVATE_KEY) private String privateKey = null; - public LoginCredential username(String username) { - this.username = username; - return this; - } - - /** - * The username for login - * @return username - **/ - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public LoginCredential password(String password) { - this.password = password; - return this; - } - - /** - * The password for login - * @return password - **/ - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public LoginCredential privateKey(String privateKey) { - this.privateKey = privateKey; - return this; - } - - /** - * The private key for login - * @return privateKey - **/ - public String getPrivateKey() { - return privateKey; - } - - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - LoginCredential loginCredential = (LoginCredential) o; - return Objects.equals(this.username, loginCredential.username) && - Objects.equals(this.password, loginCredential.password) && - Objects.equals(this.privateKey, loginCredential.privateKey); - } - - @Override - public int hashCode() { - return Objects.hash(username, password, privateKey); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java index ef9aaad..65e2000 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeCandidate.java @@ -7,7 +7,6 @@ import java.io.Serializable; import java.util.Locale; -import java.util.Objects; import javax.persistence.*; @@ -19,7 +18,11 @@ import com.fasterxml.jackson.annotation.JsonValue; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; import lombok.extern.log4j.Log4j2; @@ -29,6 +32,10 @@ @Log4j2 @AllArgsConstructor @NoArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode +@Getter +@Setter @Entity @Table(name = "NODE_CANDIDATE") public class NodeCandidate implements Serializable { @@ -148,213 +155,6 @@ public static NodeCandidateTypeEnum fromValue(String text) { @JsonProperty(JSON_ENVIRONMENT) private Environment environment = null; - public NodeCandidate id(String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id - **/ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public NodeCandidate nodeCandidateType(NodeCandidateTypeEnum nodeCandidateType) { - this.nodeCandidateType = nodeCandidateType; - return this; - } - - /** - * Get nodeCandidateType - * @return nodeCandidateType - **/ - public NodeCandidateTypeEnum getNodeCandidateType() { - return nodeCandidateType; - } - - public void setNodeCandidateType(NodeCandidateTypeEnum nodeCandidateType) { - this.nodeCandidateType = nodeCandidateType; - } - - /** - * Get jobIdForBYON - * @return jobIdForBYON - **/ - public String getJobIdForBYON() { - return jobIdForBYON; - } - - public String getJobIdForEDGE() { - return jobIdForEDGE; - } - - public void setJobIdForBYON(String jobIdForBYON) { - this.jobIdForBYON = jobIdForBYON; - } - - public void setJobIdForEDGE(String jobIdForEDGE) { - this.jobIdForEDGE = jobIdForEDGE; - } - - public NodeCandidate price(Double price) { - this.price = price; - return this; - } - - /** - * Get price - * @return price - **/ - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price; - } - - public NodeCandidate cloud(Cloud cloud) { - this.cloud = cloud; - return this; - } - - /** - * Get cloud - * @return cloud - **/ - public Cloud getCloud() { - return cloud; - } - - public void setCloud(Cloud cloud) { - this.cloud = cloud; - } - - public NodeCandidate image(Image image) { - this.image = image; - return this; - } - - /** - * Get image - * @return image - **/ - public Image getImage() { - return image; - } - - public void setImage(Image image) { - this.image = image; - } - - public NodeCandidate hardware(Hardware hardware) { - this.hardware = hardware; - return this; - } - - /** - * Get hardware - * @return hardware - **/ - public Hardware getHardware() { - return hardware; - } - - public void setHardware(Hardware hardware) { - this.hardware = hardware; - } - - public NodeCandidate location(Location location) { - this.location = location; - return this; - } - - /** - * Get location - * @return location - **/ - public Location getLocation() { - return location; - } - - public void setLocation(Location location) { - this.location = location; - } - - public NodeCandidate pricePerInvocation(Double pricePerInvocation) { - this.pricePerInvocation = pricePerInvocation; - return this; - } - - /** - * Get pricePerInvocation - * @return pricePerInvocation - **/ - public Double getPricePerInvocation() { - return pricePerInvocation; - } - - public void setPricePerInvocation(Double pricePerInvocation) { - this.pricePerInvocation = pricePerInvocation; - } - - public NodeCandidate memoryPrice(Double memoryPrice) { - this.memoryPrice = memoryPrice; - return this; - } - - /** - * Get memoryPrice - * @return memoryPrice - **/ - public Double getMemoryPrice() { - return memoryPrice; - } - - public void setMemoryPrice(Double memoryPrice) { - this.memoryPrice = memoryPrice; - } - - public NodeCandidate nodeId(String nodeId) { - this.nodeId = nodeId; - return this; - } - - /** - * Get nodeId - * @return nodeId - **/ - public String getNodeId() { - return nodeId; - } - - public void setNodeId(String nodeId) { - this.nodeId = nodeId; - } - - public NodeCandidate environment(Environment environment) { - this.environment = environment; - return this; - } - - /** - * Get environment - * @return environment - **/ - public Environment getEnvironment() { - return environment; - } - - public void setEnvironment(Environment environment) { - this.environment = environment; - } - /** * Check if a node candidate is of BYON type * @return true if yes, false if not @@ -365,7 +165,7 @@ public boolean isByonNodeCandidate() { } /** - * Check if a node candidate is of BYON type + * Check if a node candidate is of EDGE type * @return true if yes, false if not */ @JsonIgnore @@ -373,46 +173,6 @@ public boolean isEdgeNodeCandidate() { return nodeCandidateType.equals(NodeCandidateTypeEnum.EDGE); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - 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.jobIdForEDGE, nodeCandidate.jobIdForEDGE) && - Objects.equals(this.price, nodeCandidate.price) && Objects.equals(this.cloud, nodeCandidate.cloud) && - Objects.equals(this.image, nodeCandidate.image) && - Objects.equals(this.hardware, nodeCandidate.hardware) && - Objects.equals(this.location, nodeCandidate.location) && - Objects.equals(this.pricePerInvocation, nodeCandidate.pricePerInvocation) && - Objects.equals(this.memoryPrice, nodeCandidate.memoryPrice) && - Objects.equals(this.nodeId, nodeCandidate.nodeId) && - Objects.equals(this.environment, nodeCandidate.environment); - } - - @Override - public int hashCode() { - return Objects.hash(id, - nodeCandidateType, - jobIdForBYON, - jobIdForEDGE, - price, - cloud, - image, - hardware, - location, - pricePerInvocation, - memoryPrice, - nodeId, - environment); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java index 078d25b..c902939 100644 --- a/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java +++ b/sal-common/src/main/java/org/ow2/proactive/sal/model/NodeProperties.java @@ -6,7 +6,6 @@ package org.ow2.proactive.sal.model; import java.io.Serializable; -import java.util.Objects; import javax.persistence.Column; import javax.persistence.Embeddable; @@ -15,7 +14,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.Accessors; /** @@ -23,6 +26,10 @@ */ @AllArgsConstructor @NoArgsConstructor +@Getter +@Setter +@Accessors(chain = true) +@EqualsAndHashCode @Embeddable public class NodeProperties implements Serializable { @@ -59,214 +66,16 @@ public class NodeProperties implements Serializable { @JsonProperty(Location.JSON_GEO_LOCATION) private GeoLocation geoLocation = null; - public NodeProperties providerId(String providerId) { - this.providerId = providerId; - return this; - } - - /** - * Id of the provider where this node is managed. For virtual machines this e.g. the id of the cloud. - * @return providerId - **/ - public String getProviderId() { - return providerId; - } - - public void setProviderId(String providerId) { - this.providerId = providerId; - } - - public NodeProperties price(Double price) { - this.price = price; - return this; - } - - public Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price; - } - - public NodeProperties numberOfCores(Integer numberOfCores) { - this.cores = numberOfCores; - return this; - } - - /** - * Number of cores the node has. - * @return numberOfCores - **/ - public Integer getCores() { - return cores; - } - - public void setCores(Integer numberOfCores) { - this.cores = numberOfCores; - } - - public NodeProperties ram(Long ram) { - this.ram = ram; - return this; - } - - public NodeProperties cpuFrequency(Double cpuFrequency) { - this.cpuFrequency = cpuFrequency; - return this; - } - - /** - * Sets the CPU frequency in GHz. - * @param cpuFrequency CPU frequency in GHz - */ - public void setCpuFrequency(Double cpuFrequency) { - this.cpuFrequency = cpuFrequency; - } - /** - * Gets the CPU frequency in GHz. - * @return cpuFrequency + * Custom toString method with indentation and field labels. + * It creates a more readable string output for debugging and logging. + * + * @return a string representation of the NodeProperties instance. */ - public Double getCpuFrequency() { - return cpuFrequency; - } - - /** - * Amount of RAM this node has (in MB). - * @return memory - **/ - public Long getRam() { - return ram; - } - - public void setRam(Long memory) { - this.ram = memory; - } - - public NodeProperties disk(Double disk) { - this.disk = disk; - return this; - } - - /** - * Amount of disk space this node has (in GB). - * @return disk - **/ - public Double getDisk() { - return disk; - } - - public void setDisk(Double disk) { - this.disk = disk; - } - - public NodeProperties fpga(Integer fpga) { - this.fpga = fpga; - return this; - } - - /** - * Sets the number of FPGAs. - * @param fpga Number of FPGAs - */ - public void setFpga(Integer fpga) { - this.fpga = fpga; - } - - /** - * Gets the number of FPGAs. - * @return fpga - */ - public Integer getFpga() { - return fpga; - } - - public NodeProperties gpu(Integer gpu) { - this.gpu = gpu; - return this; - } - - /** - * Sets the number of GPUs. - * @param gpu Number of GPUs - */ - public void setGpu(Integer gpu) { - this.gpu = gpu; - } - - /** - * Gets the number of GPUs. - * @return gpu - */ - public Integer getGpu() { - return gpu; - } - - public NodeProperties operatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - return this; - } - - /** - * Operating system of this node. - * @return operatingSystem - **/ - public OperatingSystem getOperatingSystem() { - return operatingSystem; - } - - public void setOperatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - } - - public NodeProperties geoLocation(GeoLocation geoLocation) { - this.geoLocation = geoLocation; - return this; - } - - /** - * Geographical location this node resides in. - * @return geoLocation - **/ - public GeoLocation getGeoLocation() { - return geoLocation; - } - - public void setGeoLocation(GeoLocation geoLocation) { - this.geoLocation = geoLocation; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NodeProperties nodeProperties = (NodeProperties) o; - return Objects.equals(this.providerId, nodeProperties.providerId) && - Objects.equals(this.price, nodeProperties.price) && Objects.equals(this.cores, nodeProperties.cores) && - Objects.equals(this.cpuFrequency, nodeProperties.cpuFrequency) && - Objects.equals(this.ram, nodeProperties.ram) && Objects.equals(this.disk, nodeProperties.disk) && - Objects.equals(this.fpga, nodeProperties.fpga) && Objects.equals(this.gpu, nodeProperties.gpu) && - Objects.equals(this.operatingSystem, nodeProperties.operatingSystem) && - Objects.equals(this.geoLocation, nodeProperties.geoLocation); - - } - - @Override - public int hashCode() { - return Objects.hash(providerId, price, cores, cpuFrequency, ram, disk, fpga, gpu, operatingSystem, geoLocation); - - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class NodeProperties {\n"); - + sb.append("NodeProperties {\n"); sb.append(" ") .append(Hardware.JSON_PROVIDER_ID) .append(": ") @@ -293,17 +102,19 @@ public String toString() { .append(": ") .append(toIndentedString(geoLocation)) .append("\n"); + sb.append("}"); return sb.toString(); } /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). + * Helper method to convert objects to indented strings. + * @param obj The object to convert. + * @return A string representation of the object or "null" if the object is null. */ - private String toIndentedString(Object o) { - if (o == null) { + private String toIndentedString(Object obj) { + if (obj == null) { return "null"; } - return o.toString().replace("\n", "\n "); + return obj.toString().replace("\n", "\n "); } } diff --git a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java index b8bf9f0..5f790f3 100644 --- a/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java +++ b/sal-service/src/main/java/org/ow2/proactive/sal/service/nc/NodeCandidateUtils.java @@ -230,7 +230,7 @@ private Hardware createHardware(JSONObject nodeCandidateJSON, PACloud paCloud) { minRam = minRam.replace(".0", ""); } hardware.setRam(Long.valueOf(minRam)); - hardware.setFpga(hardwareJSON.optString("type")); + hardware.setCloudFpga(hardwareJSON.optString("type")); if (AWS_EC2.equals(nodeCandidateJSON.optString("cloud"))) { hardware.setDisk((double) 8); @@ -251,7 +251,7 @@ private Location createLocation(JSONObject nodeCandidateJSON, PACloud paCloud) { if (location == null) { location = new Location(); location.setId(locationId); - location.name(nodeCandidateJSON.optString("region")); + location.setName(nodeCandidateJSON.optString("region")); location.setProviderId(nodeCandidateJSON.optString("region")); location.setLocationScope(Location.LocationScopeEnum.REGION); location.setIsAssignable(true);