In fog computing tuples are executed in different application modules. The “checkCloudletCompletion()” abstract method in FogDevice class to check which application module to complete the execution of tuples.
protected void checkCloudletCompletion() {
boolean cloudletCompleted = false;
List <\? extends Host> list = getVmAllocationPolicy().getHostList();
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
for (Vm vm : host.getVmList()) {
while (vm.getCloudletScheduler().isFinishedCloudlets()) {
Cloudlet cl = vm.getCloudletScheduler().getNextFinishedCloudlet();
if (cl != null) {
cloudletCompleted = true;
Tuple tuple = (Tuple) cl;
TimeKeeper.getInstance().tupleEndedExecution(tuple);
Application application = getApplicationMap().get(tuple.getAppId());
System.out.println("Completed execution of tuple " + tuple.getCloudletId() + " on " + tuple.getDestModuleName());
Logger.debug(getName(), "Completed execution of tuple " + tuple.getCloudletId() + "on " + tuple.getDestModuleName());
List
for (Tuple resTuple : resultantTuples) {
resTuple.setModuleCopyMap(new HashMap
resTuple.getModuleCopyMap().put(((AppModule) vm).getName(), vm.getId());
updateTimingsOnSending(resTuple);
sendToSelf(resTuple);
}
sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_RETURN, cl);
}
}
}
}
if (cloudletCompleted) {
updateAllocatedMips(null);
}
}