Tuple execution process can be done by “FogDevice” class in “processTupleArrival()” method, a tuple is chosen with its id, type and source, destination module.
protected void processTupleArrival(SimEvent ev){
Tuple tuple = (Tuple)ev.getData();
if(getName().equals("cloud")){
updateCloudTraffic();
}
System.out.println(" Received tuple " + tuple.getCloudletId() + " with tupleType = " +tuple.getTupleType() + "\t| Source : " +
CloudSim.getEntityName(ev.getSource())+"|Dest : " + CloudSim.getEntityName(ev.getDestination()));
if(FogUtils.appIdToGeoCoverageMap.containsKey(tuple.getAppId())){
}
if(tuple.getDirection() == Tuple.ACTUATOR){
sendTupleToActuator(tuple);
return;
}
if(getHost().getVmList().size() > 0){
final AppModule operator = (AppModule)getHost().getVmList().get(0);
if(CloudSim.clock() > 0){
getHost().getVmScheduler().deallocatePesForVm(operator);
getHost().getVmScheduler().allocatePesForVm(operator, new ArrayList
protected static final long serialVersionUID = 1L;
{add((double) getHost().getTotalMips());}});
}
}
if(getName().equals("cloud") && tuple.getDestModuleName()==null){
sendNow(getControllerId(), FogEvents.TUPLE_FINISHED, null);
}
if(appToModulesMap.containsKey(tuple.getAppId())){
if(appToModulesMap.get(tuple.getAppId()).contains(tuple.getDestModuleName())){
int vmId = -1;
for(Vm vm : getHost().getVmList()){
if(((AppModule)vm).getName().equals(tuple.getDestModuleName()))
vmId = vm.getId();
}
if(vmId < 0
|| (tuple.getModuleCopyMap().containsKey(tuple.getDestModuleName()) &&
tuple.getModuleCopyMap().get(tuple.getDestModuleName())!=vmId )){
return;
}
tuple.setVmId(vmId);
updateTimingsOnReceipt(tuple);
executeTuple(ev, tuple.getDestModuleName());
}else if(tuple.getDestModuleName()!=null){
if(tuple.getDirection() == Tuple.UP)
sendUp(tuple);
else if(tuple.getDirection() == Tuple.DOWN){
for(int childId : getChildrenIds())
sendDown(tuple, childId);
}
}else{
sendUp(tuple);
}
}else{
if(tuple.getDirection() == Tuple.UP)
sendUp(tuple);
else if(tuple.getDirection() == Tuple.DOWN){
for(int childId : getChildrenIds())
sendDown(tuple, childId);
}
}
}