Beispiel #1
0
  private void make(Configuration cfg) {

    VJob v = new BasicPlasmaVJob("vappHA");

    ManagedElementSet<VirtualMachine> t1 = new SimpleManagedElementSet<VirtualMachine>();
    t1.add(cfg.getAllVirtualMachines().get("vappHA.VM1"));
    t1.add(cfg.getAllVirtualMachines().get("vappHA.VM2"));
    t1.add(cfg.getAllVirtualMachines().get("vappHA.VM3"));
    v.addConstraint(new ContinuousSpread(t1));
    v.addVirtualMachine(cfg.getAllVirtualMachines().get("vappHA.VM10"));
    v.addVirtualMachine(cfg.getAllVirtualMachines().get("vappHA.top"));
    v.addVirtualMachine(cfg.getAllVirtualMachines().get("vappHA.middle"));
    ManagedElementSet<Node> ns = new SimpleManagedElementSet<Node>();
    ns.add(cfg.getOnlines().get("node-1"));
    ns.add(cfg.getOnlines().get("node-2"));
    v.addConstraint(new Capacity(ns, 15));

    ManagedElementSet<Node> ns2 = new SimpleManagedElementSet<Node>();
    ns2.add(cfg.getOnlines().get("node-3"));
    ns2.add(cfg.getOnlines().get("node-4"));
    Set<ManagedElementSet<Node>> x = new HashSet<ManagedElementSet<Node>>();
    x.add(ns);
    x.add(ns2);
    v.addConstraint(new Among(t1, x));
    v.addConstraint(new Ban(t1, ns2));
    try {
      ProtobufVJobSerializer.getInstance().write(v, RESOURCE);
    } catch (Exception e) {
      Assert.fail(e.getMessage(), e);
    }
  }
Beispiel #2
0
  private Configuration makeConfiguration() {
    Configuration cfg = new SimpleConfiguration();
    for (int i = 1; i <= 20; i++) {
      VirtualMachine vm = new SimpleVirtualMachine("vappHA.VM" + i);
      cfg.addWaiting(vm);
      if (i % 2 == 0) {
        vm.setTemplate("foo");
      } else {
        vm.setTemplate("bar");
      }
    }
    VirtualMachine vmX = new SimpleVirtualMachine("vappHA.top");
    vmX.setTemplate("foo");
    cfg.addWaiting(vmX);
    VirtualMachine vmY = new SimpleVirtualMachine("vappHA.middle");
    vmX.setTemplate("ttt");
    cfg.addWaiting(vmY);

    for (int i = 1; i <= 20; i++) {
      Node n = new SimpleNode("node-" + i);
      cfg.addOnline(n);
    }
    cfg.addOnline(new SimpleNode("node-frontend"));
    return cfg;
  }
Beispiel #3
0
  /**
   * The node is not known
   *
   * @throws VJobBuilderException
   */
  @Test(expectedExceptions = {VJobBuilderException.class})
  public void testUnknownNode() throws VJobBuilderException {
    Configuration cfg = makeConfiguration();
    // make(cfg);
    cfg.remove(cfg.getAllNodes().get("node-4"));
    VJobElementBuilder eB = new DefaultVJobElementBuilder(null);
    eB.useConfiguration(cfg);
    ProtobufVJobBuilder builder = new ProtobufVJobBuilder(eB);
    DefaultPBConstraintsCatalog c = new DefaultPBConstraintsCatalog();
    c.add(new AmongBuilder());
    c.add(new LonelyBuilder());
    c.add(new BanBuilder());
    c.add(new CapacityBuilder());
    c.add(new ContinuousSpreadBuilder());
    builder.setConstraintCatalog(c);

    try {
      VJob v = builder.build(new File(RESOURCE));
      System.out.println(v);
    } catch (IOException e) {
      Assert.fail(e.getMessage(), e);
    }
  }