use of nl.uva.cs.lobcder.rest.wrappers.WorkerStatus in project lobcder by skoulouzis.
the class PathReservationService method getXml.
@Path("get_workers/")
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<WorkerStatus> getXml() throws MalformedURLException {
// rest/reservation/get_workers/?id=all
MyPrincipal mp = (MyPrincipal) request.getAttribute("myprincipal");
MultivaluedMap<String, String> queryParameters = info.getQueryParameters();
if (mp.getRoles().contains("planner") || mp.isAdmin() && queryParameters != null && !queryParameters.isEmpty()) {
String workerID = queryParameters.getFirst("id");
ArrayList<WorkerStatus> workersStatus = new ArrayList<>();
workers = PropertiesHelper.getWorkers();
for (String s : workers) {
WorkerStatus ws = new WorkerStatus();
ws.setHostName(new URL(s).getHost());
ws.setStatus("READY");
workersStatus.add(ws);
}
return workersStatus;
}
return null;
}
use of nl.uva.cs.lobcder.rest.wrappers.WorkerStatus in project lobcder by skoulouzis.
the class PathReservationService method getWorkersState.
@Path("workers/")
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public List<WorkerStatus> getWorkersState() {
// rest/reservation/workers/?host=kscvdfv&host=sp2&host=192.168.1.1
MyPrincipal mp = (MyPrincipal) request.getAttribute("myprincipal");
if (mp.getRoles().contains("planner") || mp.isAdmin()) {
MultivaluedMap<String, String> queryParameters = info.getQueryParameters();
List<String> queryWorkers = queryParameters.get("host");
List<WorkerStatus> workersStatus = new ArrayList<>();
workers = PropertiesHelper.getWorkers();
for (String worker : queryWorkers) {
WorkerStatus ws = new WorkerStatus();
ws.setStatus("UNKNOWN");
for (String w : workers) {
if (w.contains(worker)) {
ws.setStatus("READY");
break;
}
}
ws.setHostName(worker);
workersStatus.add(ws);
}
return workersStatus;
}
return null;
}
Aggregations