@Test(expectedExceptions = {SchedulerException.class}) public void testSplitWithUnsplittableConstraint() throws SchedulerException { Instance orig = makeInstance(); orig.getSatConstraints().add(new MaxOnline(orig.getModel().getMapping().getAllNodes(), 5)); List<Collection<Node>> parts = splitIn(orig.getModel().getMapping().getAllNodes(), 3); FixedNodeSetsPartitioning f = new FixedNodeSetsPartitioning(parts); f.split(new DefaultParameters(), orig); }
@Override public List<Instance> split(Parameters ps, Instance i) throws SchedulerException { Model mo = i.getModel(); SynchronizedElementBuilder eb = new SynchronizedElementBuilder(mo); List<Instance> parts = new ArrayList<>(partitions.size()); int nbVMs = i.getModel().getMapping().getNbVMs(); int nbNodes = i.getModel().getMapping().getNbNodes(); TIntIntHashMap vmPosition = new TIntIntHashMap(nbVMs); TIntIntHashMap nodePosition = new TIntIntHashMap(nbNodes); int partNumber = 0; Set<VM> toLaunch = getVMsToLaunch(i); for (Collection<Node> s : partitions) { SubModel partModel = new SubModel(mo, eb, s, new HashSet<>(toLaunch.size() / partitions.size())); parts.add(new Instance(partModel, new THashSet<>(), i.getOptConstraint())); partModel.getMapping().fillVMIndex(vmPosition, partNumber); for (Node n : s) { nodePosition.put(n.id(), partNumber); } partNumber++; } int p = 0; for (VM v : toLaunch) { if (!parts.get(p).getModel().getMapping().addReadyVM(v)) { throw new SplitException(parts.get(p).getModel(), "Unable to dispatch the VM to launch '" + v + "'"); } vmPosition.put(v.id(), p); p = (p + 1) % parts.size(); } for (SatConstraint cstr : i.getSatConstraints()) { if (!cstrMapper.split(cstr, i, parts, vmPosition, nodePosition)) { throw new SplitException(i.getModel(), "Unable to split " + cstr); } } return parts; }
FixedNodeSetsPartitioning extends StaticPartitioning { @Override public List<Instance> split(Parameters ps, Instance i) throws SchedulerException { Model mo = i.getModel(); SynchronizedElementBuilder eb = new SynchronizedElementBuilder(mo); List<Instance> parts = new ArrayList<>(partitions.size()); int nbVMs = i.getModel().getMapping().getNbVMs(); int nbNodes = i.getModel().getMapping().getNbNodes(); TIntIntHashMap vmPosition = new TIntIntHashMap(nbVMs); TIntIntHashMap nodePosition = new TIntIntHashMap(nbNodes); int partNumber = 0; Set<VM> toLaunch = getVMsToLaunch(i); for (Collection<Node> s : partitions) { SubModel partModel = new SubModel(mo, eb, s, new HashSet<>(toLaunch.size() / partitions.size())); parts.add(new Instance(partModel, new THashSet<>(), i.getOptConstraint())); partModel.getMapping().fillVMIndex(vmPosition, partNumber); for (Node n : s) { nodePosition.put(n.id(), partNumber); } partNumber++; } int p = 0; for (VM v : toLaunch) { if (!parts.get(p).getModel().getMapping().addReadyVM(v)) { throw new SplitException(parts.get(p).getModel(), "Unable to dispatch the VM to launch '" + v + "'"); } vmPosition.put(v.id(), p); p = (p + 1) % parts.size(); } for (SatConstraint cstr : i.getSatConstraints()) { if (!cstrMapper.split(cstr, i, parts, vmPosition, nodePosition)) { throw new SplitException(i.getModel(), "Unable to split " + cstr); } } return parts; } }
FixedNodeSetsPartitioning extends StaticPartitioning { @Override public List<Instance> split(Parameters ps, Instance i) throws SchedulerException { Model mo = i.getModel(); SynchronizedElementBuilder eb = new SynchronizedElementBuilder(mo); List<Instance> parts = new ArrayList<>(partitions.size()); int nbVMs = i.getModel().getMapping().getNbVMs(); int nbNodes = i.getModel().getMapping().getNbNodes(); TIntIntHashMap vmPosition = new TIntIntHashMap(nbVMs); TIntIntHashMap nodePosition = new TIntIntHashMap(nbNodes); int partNumber = 0; Set<VM> toLaunch = getVMsToLaunch(i); for (Collection<Node> s : partitions) { SubModel partModel = new SubModel(mo, eb, s, new HashSet<>(toLaunch.size() / partitions.size())); parts.add(new Instance(partModel, new THashSet<>(), i.getOptConstraint())); partModel.getMapping().fillVMIndex(vmPosition, partNumber); for (Node n : s) { nodePosition.put(n.id(), partNumber); } partNumber++; } int p = 0; for (VM v : toLaunch) { if (!parts.get(p).getModel().getMapping().addReadyVM(v)) { throw new SplitException(parts.get(p).getModel(), "Unable to dispatch the VM to launch '" + v + "'"); } vmPosition.put(v.id(), p); p = (p + 1) % parts.size(); } for (SatConstraint cstr : i.getSatConstraints()) { if (!cstrMapper.split(cstr, i, parts, vmPosition, nodePosition)) { throw new SplitException(i.getModel(), "Unable to split " + cstr); } } return parts; } FixedNodeSetsPartitioning(Collection<Collection<Node>> parts); }
FixedNodeSetsPartitioning extends StaticPartitioning { @Override public List<Instance> split(Parameters ps, Instance i) throws SchedulerException { Model mo = i.getModel(); SynchronizedElementBuilder eb = new SynchronizedElementBuilder(mo); List<Instance> parts = new ArrayList<>(partitions.size()); int nbVMs = i.getModel().getMapping().getNbVMs(); int nbNodes = i.getModel().getMapping().getNbNodes(); TIntIntHashMap vmPosition = new TIntIntHashMap(nbVMs); TIntIntHashMap nodePosition = new TIntIntHashMap(nbNodes); int partNumber = 0; Set<VM> toLaunch = getVMsToLaunch(i); for (Collection<Node> s : partitions) { SubModel partModel = new SubModel(mo, eb, s, new HashSet<>(toLaunch.size() / partitions.size())); parts.add(new Instance(partModel, new THashSet<>(), i.getOptConstraint())); partModel.getMapping().fillVMIndex(vmPosition, partNumber); for (Node n : s) { nodePosition.put(n.id(), partNumber); } partNumber++; } int p = 0; for (VM v : toLaunch) { if (!parts.get(p).getModel().getMapping().addReadyVM(v)) { throw new SplitException(parts.get(p).getModel(), "Unable to dispatch the VM to launch '" + v + "'"); } vmPosition.put(v.id(), p); p = (p + 1) % parts.size(); } for (SatConstraint cstr : i.getSatConstraints()) { if (!cstrMapper.split(cstr, i, parts, vmPosition, nodePosition)) { throw new SplitException(i.getModel(), "Unable to split " + cstr); } } return parts; } FixedNodeSetsPartitioning(Collection<Collection<Node>> parts); ConstraintSplitterMapper getSplitterMapper(); void setSplitterMapper(ConstraintSplitterMapper m); Collection<Collection<Node>> getPartitions(); boolean setPartitions(Collection<Collection<Node>> parts); @Override List<Instance> split(Parameters ps, Instance i); }
FixedNodeSetsPartitioning extends StaticPartitioning { @Override public List<Instance> split(Parameters ps, Instance i) throws SchedulerException { Model mo = i.getModel(); SynchronizedElementBuilder eb = new SynchronizedElementBuilder(mo); List<Instance> parts = new ArrayList<>(partitions.size()); int nbVMs = i.getModel().getMapping().getNbVMs(); int nbNodes = i.getModel().getMapping().getNbNodes(); TIntIntHashMap vmPosition = new TIntIntHashMap(nbVMs); TIntIntHashMap nodePosition = new TIntIntHashMap(nbNodes); int partNumber = 0; Set<VM> toLaunch = getVMsToLaunch(i); for (Collection<Node> s : partitions) { SubModel partModel = new SubModel(mo, eb, s, new HashSet<>(toLaunch.size() / partitions.size())); parts.add(new Instance(partModel, new THashSet<>(), i.getOptConstraint())); partModel.getMapping().fillVMIndex(vmPosition, partNumber); for (Node n : s) { nodePosition.put(n.id(), partNumber); } partNumber++; } int p = 0; for (VM v : toLaunch) { if (!parts.get(p).getModel().getMapping().addReadyVM(v)) { throw new SplitException(parts.get(p).getModel(), "Unable to dispatch the VM to launch '" + v + "'"); } vmPosition.put(v.id(), p); p = (p + 1) % parts.size(); } for (SatConstraint cstr : i.getSatConstraints()) { if (!cstrMapper.split(cstr, i, parts, vmPosition, nodePosition)) { throw new SplitException(i.getModel(), "Unable to split " + cstr); } } return parts; } FixedNodeSetsPartitioning(Collection<Collection<Node>> parts); ConstraintSplitterMapper getSplitterMapper(); void setSplitterMapper(ConstraintSplitterMapper m); Collection<Collection<Node>> getPartitions(); boolean setPartitions(Collection<Collection<Node>> parts); @Override List<Instance> split(Parameters ps, Instance i);  }