use of nl.uva.cs.lobcder.optimization.SDNControllerClient in project lobcder by skoulouzis.
the class WebDataFileResource method getLowestCostWorker.
private String getLowestCostWorker(String reqSource) throws IOException, URISyntaxException, InterruptedException {
if (sdnClient == null) {
String uri = PropertiesHelper.getSDNControllerURL();
sdnClient = new SDNControllerClient(uri);
}
List<DefaultWeightedEdge> shortestPath = sdnClient.getShortestPath(reqSource, workersMap.keySet());
Logger.getLogger(WebDataFileResource.class.getName()).log(Level.FINEST, "getShortestPath: {0}", shortestPath);
if (PropertiesHelper.pushFlow()) {
sdnClient.pushFlow(shortestPath);
}
DefaultWeightedEdge e = shortestPath.get(0);
String[] workerSwitch = e.toString().split(" : ");
String workerIP = workerSwitch[0].substring(1);
String worker = workersMap.get(workerIP);
String w = worker + "/" + getLogicalData().getUid();
String token = UUID.randomUUID().toString();
AuthLobcderComponents.setTicket(worker, token);
// w = "http://localhost:8080/lobcder-worker/"+getLogicalData().getUid();
return w + "/" + token;
}
use of nl.uva.cs.lobcder.optimization.SDNControllerClient in project lobcder by skoulouzis.
the class SDNService method setStats.
@Path("optimizeFlow")
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public void setStats(JAXBElement<Endpoints> jbEndpoints) throws IOException, InterruptedException {
MyPrincipal mp = (MyPrincipal) request.getAttribute("myprincipal");
if (mp.getRoles().contains("worker") || mp.isAdmin()) {
Endpoints endpoints = jbEndpoints.getValue();
if (sdnClient == null) {
String uri = PropertiesHelper.getSDNControllerURL();
sdnClient = new SDNControllerClient(uri);
}
Set<String> sources = new HashSet<>();
sources.add(endpoints.source);
List<DefaultWeightedEdge> shortestPath = sdnClient.getShortestPath(endpoints.destination, sources);
sdnClient.pushFlow(shortestPath);
}
}
Aggregations