use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodB.
@Test
public void testMethodB() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
}
}
}
use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodASetNull.
@Test
public void testMethodASetNull() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
if (impl.getImplementationId() == 1) {
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
} else {
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
}
}
use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodAUpdatedNull.
@Test
public void testMethodAUpdatedNull() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
if (impl.getImplementationId() == 1) {
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
}
} else {
try {
this.checkSetAndIncreasedProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
}
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
}
}
}
use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.
the class OptimizationTest method globalOptimization.
// @Test
public void globalOptimization() {
ScheduleOptimizer<FakeProfile, FakeResourceDescription, FakeImplementation> so = new ScheduleOptimizer<>(ds);
long updateId = System.currentTimeMillis();
Collection<ResourceScheduler<FakeProfile, FakeResourceDescription, FakeImplementation>> workers = new ArrayList<>();
drs1.clear();
drs2.clear();
workers.add(drs1);
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(4));
action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
drs1.scheduleAction(action1);
try {
action1.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(4));
action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
drs1.scheduleAction(action2);
try {
action2.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 1, CoreManager.getCoreImplementations(4));
action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
drs1.scheduleAction(action3);
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(5));
action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
drs1.scheduleAction(action4);
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 1, CoreManager.getCoreImplementations(4));
action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
drs1.scheduleAction(action5);
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 1, CoreManager.getCoreImplementations(6));
action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
drs1.scheduleAction(action6);
workers.add(drs2);
so.globalOptimization(updateId, workers);
}
use of es.bsc.compss.components.impl.ResourceScheduler in project compss by bsc-wdc.
the class ExecutionAction method tryToSchedule.
@SuppressWarnings("unchecked")
@Override
public final void tryToSchedule(Score actionScore) throws BlockedActionException, UnassignedActionException {
// COMPUTE RESOURCE CANDIDATES
List<ResourceScheduler<? extends WorkerResourceDescription>> candidates = new LinkedList<>();
if (this.isTargetResourceEnforced()) {
// The scheduling is forced to a given resource
candidates.add((ResourceScheduler<WorkerResourceDescription>) this.getEnforcedTargetResource());
} else if (isSchedulingConstrained()) {
// The scheduling is constrained by dependencies
for (AllocatableAction a : this.getConstrainingPredecessors()) {
candidates.add((ResourceScheduler<WorkerResourceDescription>) a.getAssignedResource());
}
} else {
// Free scheduling
List<ResourceScheduler<? extends WorkerResourceDescription>> compatibleCandidates = getCompatibleWorkers();
if (compatibleCandidates.size() == 0) {
throw new BlockedActionException();
}
for (ResourceScheduler<? extends WorkerResourceDescription> currentWorker : compatibleCandidates) {
if (currentWorker.getResource().hasAvailableSlots()) {
candidates.add(currentWorker);
}
}
if (candidates.size() == 0) {
throw new UnassignedActionException();
}
}
this.schedule(actionScore, candidates);
}
Aggregations