Commit 4737f432 authored by Unai's avatar Unai 🇵🇲

Merged with bsc-dev

parents 20de083c e5bb5869
/.project
/stubs/
**/stubs/
**/stubs.jar
......@@ -2,7 +2,6 @@ version: '3.4'
services:
logicmodule:
image: "bscdataclay/logicmodule:2.1"
command: "${COMMAND_OPTS}"
ports:
- "11034:11034"
environment:
......@@ -21,7 +20,6 @@ services:
dsjava:
image: "bscdataclay/dsjava:2.1"
command: "${COMMAND_OPTS}"
ports:
- "2127:2127"
depends_on:
......@@ -39,4 +37,3 @@ services:
interval: 5s
retries: 10
test: ["CMD-SHELL", "/home/dataclayusr/dataclay/health/health_check.sh"]
\ No newline at end of file
......@@ -2,3 +2,6 @@ target
/bin/
/.classpath
/.project
.idea/
stubs.jar
stubs/
......@@ -16,7 +16,7 @@
<dependency>
<groupId>es.bsc.dataclay</groupId>
<artifactId>dataclay</artifactId>
<version>2.0</version>
<version>2.1</version>
</dependency>
</dependencies>
</project>
package model;
package es.bsc.compss.nfr.model;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** This class simulates an ELASTIC application using COMPSs. Objects instantiated by this class can be
* distributed and synchronized among nodes. */
public class Application {
public class COMPSsApplication {
/** Application name. */
/** COMPSsApplication name. */
private String name;
/** COMPSsApplication UUID (to be able to tell it apart of other workflows with the same name) */
private String uuid;
/** Application security attribute. */
private boolean isSecure = true;
......@@ -15,29 +20,29 @@ public class Application {
/** Application's information nature (E.x: Video stream, location data). */
private String infoNature;
/** Application master process. */
/** COMPSsApplication master process. */
private Master master;
/** Application workers. */
private ArrayList<Worker> workers = new ArrayList<>();
/** COMPSsApplication workers. */
private List<Worker> workers = new ArrayList<>();
/**
* Application constructor.
* COMPSsApplication constructor.
* @param appName Name of the application
*/
public Application(final String appName) { //TODO Add infonature in the constructor when it is fully defined
public COMPSsApplication(final String appName, final String uuid) {
this.name = appName;
this.uuid = uuid;
}
/**
* Set application master.
* @param themaster Application's master node
* @param themaster COMPSsApplication's master node
*/
public void setMaster(final Master themaster) {
this.master = themaster;
}
/**
* Add a new woker to the application.
* @param worker Worker to be added
......@@ -46,9 +51,9 @@ public class Application {
workers.add(worker);
}
/**
/**
* Get application master.
* @return Application master
* @return COMPSsApplication master
*/
public Master getMaster() {
return this.master;
......@@ -56,24 +61,18 @@ public class Application {
/**
* Get application workers.
* @return Application workers
* @return COMPSsApplication workers
*/
public ArrayList<Worker> getWorkers() {
public List<Worker> getWorkers() {
return this.workers;
}
/**
* Get active workers only.
* @return Application active workers
* @return COMPSsApplication active workers
*/
public ArrayList<Worker> getActiveWorkers() {
ArrayList<Worker> activeWorkers = new ArrayList<>();
for (Worker w : workers) {
if (w.isActive()) {
activeWorkers.add(w);
}
}
return activeWorkers;
public List<Worker> getActiveWorkers() {
return workers.stream().filter(Worker::isActive).collect(Collectors.toList());
}
/**
......@@ -102,21 +101,27 @@ public class Application {
/**
* Set application's information nature.
* @param infonature Application's information nature
* @param infoNature Application's information nature
*/
public void setInfoNature(String infoNature) {
this.infoNature = infoNature ;
}
@Override
/**
* Get application UUID
* @return uuid
*/
public String getUuid() {
return this.uuid;
}
@Override
public String toString() {
String result = "Application: " + name + " \n";
result += " - master: " + master.toString() + "\n";
result += " - workers: " + workers + "\n";
result += " - active workers: " + getActiveWorkers() + "\n";
result += " - info nature: " + getInfoNature() + "\n";
result += " - is secure: " + Boolean.toString(isSecure()) + "\n";
return result;
return "COMPSsApplication: " + name + " \n" +
" - master: " + master.toString() + "\n" +
" - workers: " + workers + "\n" +
" - active workers: " + getActiveWorkers() + "\n" +
" - info nature: " + getInfoNature() + "\n" +
" - is secure: " + Boolean.toString(isSecure()) + "\n";
}
}
package model;
package es.bsc.compss.nfr.model;
import java.util.ArrayList;
import java.util.stream.Collectors;
......@@ -6,12 +6,12 @@ import java.util.stream.Collectors;
/** This class simulates an ELASTIC system composed of many applications and nodes using COMPSs. Objects instantiated by this class can be
* distributed and synchronized among nodes. */
public class ElasticSystem {
/** List of nodes in the system. */
/** List of nodes in the system. */
private ArrayList<Node> nodes;
/** Applications in the system. */
private ArrayList<Application> apps;
private ArrayList<COMPSsApplication> apps;
/**
* System constructor empty.
......@@ -27,7 +27,7 @@ public class ElasticSystem {
* @param apps List of applications
* @param nodes List of nodes
*/
public ElasticSystem(final ArrayList<Application> apps, final ArrayList<Node> nodes) {
public ElasticSystem(final ArrayList<COMPSsApplication> apps, final ArrayList<Node> nodes) {
this.apps = new ArrayList<>(apps);
this.nodes = new ArrayList<>(nodes);
}
......@@ -43,11 +43,20 @@ public class ElasticSystem {
/**
* Add a new application to the system.
* @param app Application to be added
* @param app COMPSsApplication to be added
*/
public void addApplication(final Application app) {
public void addApplication(final COMPSsApplication app) {
apps.add(app);
}
/**
* Remove an existing application. This must be run when the app's execution finishes.
* @param app COMPSsApplication to be removed
* @return true if the list contained the specified application
*/
public boolean removeApplication(final COMPSsApplication app) {
return apps.remove(app);
}
/**
* Get system nodes.
......@@ -61,13 +70,13 @@ public class ElasticSystem {
* Get applications in the system
* @return apps
*/
public ArrayList<Application> getApplications() {
public ArrayList<COMPSsApplication> getApplications() {
return this.apps;
}
@Override
public String toString() {
String result = "Applications: " + apps.stream().map(Application::getName).collect(Collectors.toList()) + " \n";
String result = "Applications: " + apps.stream().map(COMPSsApplication::getName).collect(Collectors.toList()) + " \n";
result += " - nodes: " + nodes.stream().map(Node::getName).collect(Collectors.toList()) + "\n";
return result;
}
......
package model;
package es.bsc.compss.nfr.model;
import es.bsc.dataclay.DataClayObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
/**
* This class represents a master process.
......@@ -17,7 +14,7 @@ public class Master extends DataClayObject {
private int pid;
/** Applications executed by this master. */
private Application app;
private COMPSsApplication app;
/**
* Constructor.
......@@ -27,6 +24,7 @@ public class Master extends DataClayObject {
public Master(final Node node, final int pid) {
this.node = node;
this.pid = pid;
node.addMaster(this);
}
/**
......@@ -66,7 +64,7 @@ public class Master extends DataClayObject {
* Get application executed by this master
* @return application executed by the master
*/
public Application getApplication() {
public COMPSsApplication getApplication() {
return app;
}
......@@ -74,7 +72,7 @@ public class Master extends DataClayObject {
* Set application executed by the master
* @param application launched by the master
*/
public void setApplication(final Application app) {
public void setApplication(final COMPSsApplication app) {
this.app = app;
}
......
package model;
package es.bsc.compss.nfr.model;
import es.bsc.dataclay.DataClayObject;
import java.util.ArrayList;
import java.util.List;
/**
* This class represents a COMPSs node.
......@@ -11,10 +12,7 @@ public class Node extends DataClayObject {
/** Node name. */
private String name;
/** Node address. */
private String address;
/** Node CPU capacity. */
private int cpuCapacity;
......@@ -25,42 +23,24 @@ public class Node extends DataClayObject {
private int communicationCost;
/** List of all masters present in a given node. */
private ArrayList<Master> masters = new ArrayList<>();
private List<Master> masters = new ArrayList<>();
/** List of all workers present in a given node. */
private ArrayList<Worker> workers = new ArrayList<>();
private List<Worker> workers = new ArrayList<>();
/**
* Constructor.
* @param name Node name
* @param nodeAddress Node address.
* @param nodeCapacity Node capacity.
* @param name Node name, which can be either the IP or the hostname
* @param cpuCapacity Capacity of the CPU
* @param energyCapacity Energy capacity of the node
*/
public Node(final String name, final String nodeAddress, final int cpuCapacity, final int energyCapacity) {
public Node(final String name, final int cpuCapacity, final int energyCapacity) {
this.name = name;
this.address = nodeAddress;
this.cpuCapacity = cpuCapacity;
this.energyCapacity = energyCapacity;
this.communicationCost = 0;
}
/**
* Get the address of the node
* @return node address
*/
public String getAddress() {
return address;
}
/**
* Set node address
* @param address the address to set
*/
public void setAddress(String address) {
this.address = address;
}
/**
* Get CPU capacity of the node
* @return node cpuCapacity
......@@ -138,7 +118,7 @@ public class Node extends DataClayObject {
* Returns the list of master objects present in a specific node.
* @return List of master objects
*/
public ArrayList<Master> getMasters() {
public List<Master> getMasters() {
return masters;
}
......@@ -154,13 +134,13 @@ public class Node extends DataClayObject {
* Returns the list of worker objects present in a specific node.
* @return List of workers
*/
public ArrayList<Worker> getWorkers() {
public List<Worker> getWorkers() {
return workers;
}
@Override
public String toString() {
return " [ name = " + name + " , machine-address = " + address + " , cpuCapacity = " + cpuCapacity + " , energyCapacity = " + energyCapacity + " ]";
public String toString() {
return " [ name = " + name + " , cpuCapacity = " + cpuCapacity + " , energyCapacity = " + energyCapacity + " ]";
}
}
package model;
package es.bsc.compss.nfr.model;
import es.bsc.dataclay.DataClayObject;
import java.util.ArrayList;
import java.util.stream.Collectors;
/**
* This class represents a worker process.
......@@ -12,30 +10,26 @@ public class Worker extends DataClayObject {
/** Node containing the process. */
private Node node;
/** Worker process address. */
private String address;
/** Worker process PID. */
private int pid;
/** Boolean showing if worker is running applications. */
private boolean active;
/** Application this worker is executing. */
private Application app;
/** COMPSsApplication this worker is executing. */
private COMPSsApplication app;
/**
* Constructor.
* @param node Node containing the process.
* @param address Worker process address.
* @param node Node containing the process
* @param pid Worker process PID
*/
public Worker(final Node node, final String address, final int pid, final boolean active) {
public Worker(final Node node, final int pid, final boolean active) {
this.node = node;
this.address = address;
this.pid = pid;
this.active = active;
node.addWorker(this);
}
/**
......@@ -43,15 +37,7 @@ public class Worker extends DataClayObject {
* @return worker address
*/
public String getAddress() {
return address;
}
/**
* Set worker address
* @param address the worker address to set
*/
public void setAddress(String address) {
this.address = address;
return this.node.getName();
}
/**
......@@ -107,7 +93,7 @@ public class Worker extends DataClayObject {
* Get application that worker is executing
* @return list of all applications
*/
public Application getApplication() {
public COMPSsApplication getApplication() {
return app;
}
......@@ -115,13 +101,13 @@ public class Worker extends DataClayObject {
* Sets an application to the worker
* @param app new application that this worker is executing
*/
public void setApplication(final Application app) {
public void setApplication(final COMPSsApplication app) {
this.app = app;
}
@Override
public String toString() {
return " worker { pid = " + pid + " , address = " + address + ", node = " + node.toString() + ", application = "
return " worker { pid = " + pid + " , address = " + getAddress() + ", node = " + node.toString() + ", application = "
+ app.getName() + "}";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment