use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class NetworkConverter method toJSON.
@Override
public JSONObject toJSON(Network net) throws JSONConverterException {
JSONObject container = new JSONObject();
container.put(ModelViewConverter.IDENTIFIER, getJSONId());
container.put("switches", switchesToJSON(net.getSwitches()));
container.put("links", linksToJSON(net.getLinks()));
container.put("routing", routingToJSON(net.getRouting()));
return container;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class StaticRoutingConverter method nodesMapToJSON.
/**
* Convert a nodes map (a pair of two distinguishable nodes to source and destination) into a JSON object
*
* @param nm the nodes map to convert
* @return the nodes map JSON object
*/
public JSONObject nodesMapToJSON(StaticRouting.NodesMap nm) {
JSONObject o = new JSONObject();
o.put("src", nm.getSrc().id());
o.put("dst", nm.getDst().id());
return o;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class DeadlineConverter method toJSON.
@Override
public JSONObject toJSON(Deadline deadline) {
JSONObject c = new JSONObject();
c.put("id", getJSONId());
c.put("vm", JSONs.elementToJSON(deadline.getInvolvedVMs().iterator().next()));
c.put("timestamp", deadline.getTimestamp());
c.put("continuous", deadline.isContinuous());
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class PrecedenceConverter method toJSON.
@Override
public JSONObject toJSON(Precedence precedence) {
JSONObject c = new JSONObject();
Iterator<VM> it = precedence.getInvolvedVMs().iterator();
c.put("id", getJSONId());
c.put("vm1", JSONs.elementToJSON(it.next()));
c.put("vm2", JSONs.elementToJSON(it.next()));
c.put("continuous", precedence.isContinuous());
return c;
}
use of net.minidev.json.JSONObject in project scheduler by btrplace.
the class NamingServiceConverterTest method test.
@Test
public void test() throws JSONConverterException {
NamingService<VM> ns = NamingService.newVMNS();
Model mo = new DefaultModel();
for (int i = 0; i < 10; i++) {
VM v = mo.newVM();
ns.register(v, "VM " + i);
}
NamingServiceConverter nsc = new NamingServiceConverter();
JSONObject o = nsc.toJSON(ns);
System.out.println(o);
@SuppressWarnings("unchecked") NamingService<VM> ns2 = (NamingService<VM>) nsc.fromJSON(mo, o);
Assert.assertEquals(ns, ns2);
}
Aggregations