diff --git a/endpoints/4-edge-endpoints.md b/endpoints/4-edge-endpoints.md index f80573a..2c865e9 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}}", - "numberOfCores": "{{cores}}", - "memory": "{{memory}}", + "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. - - `numberOfCores`: A string representing number of hardware cores (e.g., `"1"`). - - `memory`: The hardware 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. 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`. 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/EdgeDefinition.java b/sal-common/src/main/java/org/ow2/proactive/sal/model/EdgeDefinition.java index 64708aa..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,41 +10,76 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; +import lombok.experimental.Accessors; /** - * Attributes defining a BYON node + * Attributes defining an EDGE node */ @AllArgsConstructor @NoArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode @Getter @Setter @ToString(callSuper = true) public class EdgeDefinition { - @JsonProperty("name") + + public static final String DEFAULT_PORT = "22"; + + public static final String ANY_JOB_ID = "any"; + + 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(JSON_NAME) private String name = null; - @JsonProperty("jobId") + @JsonProperty(JSON_JOB_ID) private String jobId = null; - @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; - @JsonProperty("loginCredential") + @JsonProperty(JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; - @JsonProperty("ipAddresses") + @JsonProperty(JSON_IP_ADDRESSES) private List ipAddresses = null; - @JsonProperty("port") - private String port = "22"; + @JsonProperty(JSON_PORT) + private String port = DEFAULT_PORT; - @JsonProperty("nodeProperties") + @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 de1c187..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,154 +26,65 @@ @AllArgsConstructor @NoArgsConstructor @Entity +@Table(name = "EDGE_NODE") @Getter @Setter -@Table(name = "EDGE_NODE") +@EqualsAndHashCode public class EdgeNode extends AbstractNode { @Column(name = "NAME") - @JsonProperty("name") + @JsonProperty(EdgeDefinition.JSON_NAME) private String name = null; @Embedded - @JsonProperty("loginCredential") + @JsonProperty(EdgeDefinition.JSON_LOGIN_CREDENTIAL) private LoginCredential loginCredential = null; @ElementCollection(targetClass = IpAddress.class) private List ipAddresses = null; @Embedded - @JsonProperty("nodeProperties") + @JsonProperty(EdgeDefinition.JSON_NODE_PROPERTIES) private NodeProperties nodeProperties = null; @Column(name = "PORT") - @JsonProperty("port") + @JsonProperty(EdgeDefinition.JSON_PORT) private String port = null; @Column(name = "REASON") - @JsonProperty("reason") + @JsonProperty(EdgeDefinition.JSON_REASON) private String reason = null; @Column(name = "DIAGNOSTIC") - @JsonProperty("diagnostic") + @JsonProperty(EdgeDefinition.JSON_DIAGNOSTIC) private String diagnostic = null; @Column(name = "USER_ID") - @JsonProperty("userId") + @JsonProperty(EdgeDefinition.JSON_USER_ID) private String userId = null; @Column(name = "ALLOCATED") - @JsonProperty("allocated") + @JsonProperty(EdgeDefinition.JSON_ALLOCATED) private Boolean allocated = null; @Column(name = "JOB_ID") - @JsonProperty("jobId") + @JsonProperty(EdgeDefinition.JSON_JOB_ID) private String jobId; @Column(name = "SYSTEM_ARCH") - @JsonProperty("systemArch") + @JsonProperty(EdgeDefinition.JSON_SYSTEM_ARCH) private String systemArch = null; - @JsonProperty("scriptURL") + @JsonProperty(EdgeDefinition.JSON_SCRIPT_URL) private String scriptURL = null; - @JsonProperty("jarURL") + @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 4fd5666..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,141 +25,93 @@ */ @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"; + + public static final String JSON_PROVIDER_ID = "providerId"; + + 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"; + + 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 = "CPU_FREQUENCY") + @JsonProperty(JSON_CPU_FREQUENCY) + private Double cpuFrequency = 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; + @Column(name = "GPU") + @JsonProperty(JSON_GPU) + private Integer gpu = 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) { - 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 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(String machineType) { + * Sets the FPGA field based on machine type. + * @param machineType the machine type + */ + public void setCloudFpga(String machineType) { switch (machineType) { case "f1.2xlarge": this.fpga = 1; @@ -171,95 +127,9 @@ public void setFpga(String machineType) { } } - 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.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); - } - + * Custom toString() method for the Hardware class to format the output + */ @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -269,9 +139,11 @@ public String toString() { 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"); 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..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,187 +13,72 @@ 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 { + 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) { - 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 4d75848..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,28 +15,54 @@ 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"; + + 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 +70,8 @@ public class Location implements Serializable { */ public enum LocationScopeEnum { PROVIDER("PROVIDER"), - REGION("REGION"), - ZONE("ZONE"), - HOST("HOST"); private String value; @@ -77,205 +99,30 @@ 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) { - 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 21a7588..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,94 +25,46 @@ @AllArgsConstructor @NoArgsConstructor @Embeddable +@Accessors(chain = true) +@EqualsAndHashCode +@Getter +@Setter public class LoginCredential implements Serializable { - @JsonProperty("username") - private String username = null; - - @JsonProperty("password") - private String password = null; - - @JsonProperty("privateKey") - 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 static final String JSON_USERNAME = "username"; - public LoginCredential privateKey(String privateKey) { - this.privateKey = privateKey; - return this; - } + public static final String JSON_PASSWORD = "password"; - /** - * The private key for login - * @return privateKey - **/ - public String getPrivateKey() { - return privateKey; - } + public static final String JSON_PRIVATE_KEY = "privateKey"; - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } + @JsonProperty(JSON_USERNAME) + private String username = null; - @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); - } + @JsonProperty(JSON_PASSWORD) + private String password = null; - @Override - public int hashCode() { - return Objects.hash(username, password, privateKey); - } + @JsonProperty(JSON_PRIVATE_KEY) + private String privateKey = null; @Override 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..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,14 +32,44 @@ @Log4j2 @AllArgsConstructor @NoArgsConstructor +@Accessors(chain = true) +@EqualsAndHashCode +@Getter +@Setter @Entity @Table(name = "NODE_CANDIDATE") public class NodeCandidate implements Serializable { + 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 +77,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,260 +108,53 @@ 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) { - 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 @@ -344,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 @@ -352,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 f5c3e34..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,15 +6,19 @@ package org.ow2.proactive.sal.model; import java.io.Serializable; -import java.util.Objects; +import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.Embedded; 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,185 +26,95 @@ */ @AllArgsConstructor @NoArgsConstructor +@Getter +@Setter +@Accessors(chain = true) +@EqualsAndHashCode @Embeddable public class NodeProperties implements Serializable { - @JsonProperty("price") - private Double price = null; - @JsonProperty("providerId") + // Fields - edge node properties fields are mapped to node candidates so field names are reused + @JsonProperty(Hardware.JSON_PROVIDER_ID) private String providerId = null; - @JsonProperty("numberOfCores") - private Integer numberOfCores = null; - - @JsonProperty("memory") - private Long memory = null; - - @JsonProperty("disk") - private Float disk = null; - - @Embedded - @JsonProperty("operatingSystem") - private OperatingSystem operatingSystem = null; - - @Embedded - @JsonProperty("geoLocation") - 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 Double getPrice() { - return price; - } - - public void setPrice(Double price) { - this.price = price; - } - - public NodeProperties numberOfCores(Integer numberOfCores) { - this.numberOfCores = numberOfCores; - return this; - } - - /** - * Number of cores the node has. - * @return numberOfCores - **/ - public Integer getNumberOfCores() { - return numberOfCores; - } - - public void setNumberOfCores(Integer numberOfCores) { - this.numberOfCores = numberOfCores; - } - - public NodeProperties memory(Long memory) { - this.memory = memory; - return this; - } - - /** - * Amount of RAM this node has (in MB). - * @return memory - **/ - public Long getMemory() { - return memory; - } + @JsonProperty(NodeCandidate.JSON_PRICE) + private Double price = null; - public void setMemory(Long memory) { - this.memory = memory; - } + @JsonProperty(Hardware.JSON_CORES) + private Integer cores = null; - public NodeProperties disk(Float disk) { - this.disk = disk; - return this; - } + @JsonProperty(Hardware.JSON_CPU_FREQUENCY) + private Double cpuFrequency = null; - /** - * Amount of disk space this node has (in GB). - * @return disk - **/ - public Float getDisk() { - return disk; - } + @JsonProperty(Hardware.JSON_RAM) + private Long ram = null; - public void setDisk(Float disk) { - this.disk = disk; - } + @JsonProperty(Hardware.JSON_DISK) + private Double disk = null; - public NodeProperties operatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - return this; - } + @JsonProperty(Hardware.JSON_FPGA) + private Integer fpga = null; - /** - * Operating system of this node. - * @return operatingSystem - **/ - public OperatingSystem getOperatingSystem() { - return operatingSystem; - } + @JsonProperty(Hardware.JSON_GPU) + private Integer gpu = null; - public void setOperatingSystem(OperatingSystem operatingSystem) { - this.operatingSystem = operatingSystem; - } + @Embedded + @JsonProperty(Image.JSON_OPERATING_SYSTEM) + private OperatingSystem operatingSystem = null; - public NodeProperties geoLocation(GeoLocation geoLocation) { - this.geoLocation = geoLocation; - return this; - } + @Embedded + @JsonProperty(Location.JSON_GEO_LOCATION) + private GeoLocation geoLocation = null; /** - * 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.numberOfCores, nodeProperties.numberOfCores) && - Objects.equals(this.memory, nodeProperties.memory) && 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, numberOfCores, memory, disk, operatingSystem, geoLocation); - } - + * 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. + */ @Override 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("NodeProperties {\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_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(": ") + .append(toIndentedString(operatingSystem)) + .append("\n"); + sb.append(" ") + .append(Location.JSON_GEO_LOCATION) + .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 bc2e6e6..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); @@ -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/service/ClusterService.java b/sal-service/src/main/java/org/ow2/proactive/sal/service/service/ClusterService.java index 705022d..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 @@ -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(EdgeDefinition.ANY_JOB_ID); + repositoryService.saveEdgeNode(edgeNode); + nc.setJobIdForEDGE(EdgeDefinition.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..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 = "any"; + jobId = EdgeDefinition.ANY_JOB_ID; } else { jobId = edgeNodeDefinition.getJobId(); } @@ -300,25 +300,36 @@ 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); + + repositoryService.deleteEdgeNode(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; } + } 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..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 @@ -74,10 +74,12 @@ public static NodeCandidate createNodeCandidate(NodeProperties np, String jobId, image.setOperatingSystem(np.getOperatingSystem()); //Define the hardware Hardware hardware = new Hardware(); - hardware.setCores(np.getNumberOfCores()); - hardware.setDisk((double) np.getDisk()); - hardware.setRam(np.getMemory()); - hardware.setFpga(""); + hardware.setCores(np.getCores()); + hardware.setCpuFrequency(np.getCpuFrequency()); + hardware.setDisk(np.getDisk()); + hardware.setRam(np.getRam()); + hardware.setFpga(np.getFpga()); + hardware.setGpu(np.getGpu()); hardware.setProviderId(np.getProviderId()); //Define the location Location location = new Location();