Search in sources :

Example 1 with SDNControllerClient

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;
}
Also used : DefaultWeightedEdge(org.jgrapht.graph.DefaultWeightedEdge) SDNControllerClient(nl.uva.cs.lobcder.optimization.SDNControllerClient)

Example 2 with SDNControllerClient

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);
    }
}
Also used : DefaultWeightedEdge(org.jgrapht.graph.DefaultWeightedEdge) MyPrincipal(nl.uva.cs.lobcder.auth.MyPrincipal) SDNControllerClient(nl.uva.cs.lobcder.optimization.SDNControllerClient) HashSet(java.util.HashSet)

Aggregations

SDNControllerClient (nl.uva.cs.lobcder.optimization.SDNControllerClient)2 DefaultWeightedEdge (org.jgrapht.graph.DefaultWeightedEdge)2 HashSet (java.util.HashSet)1 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)1