Пример #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);
    }
  }
Пример #2
0
  /**
   * The VM is not known and can not be instantiated.
   *
   * @throws VJobBuilderException
   */
  @Test(expectedExceptions = {VJobBuilderException.class})
  public void testUnknownVM() throws VJobBuilderException {
    Configuration cfg = makeConfiguration();
    // make(cfg);
    cfg.remove(cfg.getAllVirtualMachines().get("vappHA.VM10"));
    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);
    }
  }