@Override public void startEntity() { Log.printConcatLine(getName(), " is starting..."); // this resource should register to regional CIS. // However, if not specified, then register to system CIS (the // default CloudInformationService) entity. int gisID = CloudSim.getEntityId(regionalCisName); if (gisID == -1) { gisID = CloudSim.getCloudInfoServiceEntityId(); } // send the registration to CIS sendNow(gisID, CloudSimTags.REGISTER_RESOURCE, getId()); // Below method is for a child class to override registerOtherEntity(); }
sendNow(srcId, ev.getTag(), getCharacteristics()); break; sendNow(srcId, ev.getTag(), 0); break; int numPE = getCharacteristics().getNumberOfPes(); sendNow(srcId, ev.getTag(), numPE); break; int freePesNumber = getCharacteristics().getNumberOfFreePes(); sendNow(srcId, ev.getTag(), freePesNumber); break; processCloudletSubmit(ev, false); break; processCloudletSubmit(ev, true); break; processCloudlet(ev, CloudSimTags.CLOUDLET_CANCEL); break; processCloudlet(ev, CloudSimTags.CLOUDLET_PAUSE); break; processCloudlet(ev, CloudSimTags.CLOUDLET_PAUSE_ACK); break;
int msg = deleteFileFromStorage(filename); if (msg == DataCloudTags.FILE_DELETE_SUCCESSFUL) { tag = DataCloudTags.CTLG_DELETE_MASTER; pack[1] = Integer.valueOf(msg); sendNow(req_source, tag, pack);
/** * Process the event for an User/Broker who wants to destroy a VM previously created in this * Datacenter. This Datacenter may send, upon request, the status back to the * User/Broker. * * @param ev information about the event just happened * @param ack indicates if the event's sender expects to receive * an acknowledge message when the event finishes to be processed * * @pre ev != null * @post $none */ protected void processVmDestroy(SimEvent ev, boolean ack) { Vm vm = (Vm) ev.getData(); getVmAllocationPolicy().deallocateHostForVm(vm); if (ack) { int[] data = new int[3]; data[0] = getId(); data[1] = vm.getId(); data[2] = CloudSimTags.TRUE; sendNow(vm.getUserId(), CloudSimTags.VM_DESTROY_ACK, data); } getVmList().remove(vm); }
updateCloudletProcessing(); Log.printConcatLine(getName(), ": Warning - Cloudlet #", cl.getCloudletId(), " owned by ", name, " is already completed/finished."); Log.printLine("Therefore, it is not being executed again"); data[0] = getId(); data[1] = cl.getCloudletId(); data[2] = CloudSimTags.FALSE; sendNow(cl.getUserId(), tag, data); sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_RETURN, cl); getId(), getCharacteristics().getCostPerSecond(), getCharacteristics().getCostPerBw()); double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles()); Host host = getVmAllocationPolicy().getHost(vmId, userId); Vm vm = host.getVm(vmId, userId); CloudletScheduler scheduler = vm.getCloudletScheduler(); send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT); data[0] = getId(); data[1] = cl.getCloudletId(); data[2] = CloudSimTags.TRUE;
super(name); setCharacteristics(characteristics); setVmAllocationPolicy(vmAllocationPolicy); setLastProcessTime(0.0); setStorageList(storageList); setVmList(new ArrayList<Vm>()); setSchedulingInterval(schedulingInterval); for (Host host : getCharacteristics().getHostList()) { host.setDatacenter(this); if (getCharacteristics().getNumberOfPes() == 0) { throw new Exception(super.getName() + " : Error - this entity has no PEs. Therefore, can't process any Cloudlets."); getCharacteristics().setId(super.getId());
updateCloudletProcessing(); Cloudlet cl = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletCancel(cloudletId); data[0] = getId(); data[1] = cloudletId; data[2] = 0; sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_SUBMIT_ACK, data); sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_RETURN, cl); if (destId == getId()) { Vm vm = getVmAllocationPolicy().getHost(vmDestId, userId).getVm(vmDestId,userId); if (vm == null) { failed = true; } else { double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles()); vm.getCloudletScheduler().cloudletSubmit(cl, fileTransferTime); int tag = ((type == CloudSimTags.CLOUDLET_MOVE_ACK) ? CloudSimTags.CLOUDLET_SUBMIT_ACK : CloudSimTags.CLOUDLET_SUBMIT); sendNow(destId, tag, cl); data[0] = getId(); data[1] = cloudletId; if (failed) { sendNow(cl.getUserId(), CloudSimTags.CLOUDLET_SUBMIT_ACK, data);
if (CloudSim.clock() < 0.111 || CloudSim.clock() > getLastProcessTime() + CloudSim.getMinTimeBetweenEvents()) { List<? extends Host> list = getVmAllocationPolicy().getHostList(); double smallerTime = Double.MAX_VALUE; schedule(getId(), (smallerTime - CloudSim.clock()), CloudSimTags.VM_DATACENTER_EVENT); setLastProcessTime(CloudSim.clock());
vmId = data[2]; status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId).getCloudletScheduler() .getCloudletStatus(cloudletId); userId = cl.getUserId(); status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().getCloudletStatus(cloudletId); } catch (Exception e) { Log.printConcatLine(getName(), ": Error in processing CloudSimTags.CLOUDLET_STATUS"); Log.printLine(e.getMessage()); return; Log.printConcatLine(getName(), ": Error in processing CloudSimTags.CLOUDLET_STATUS"); Log.printLine(e.getMessage()); return; array[0] = getId(); array[1] = cloudletId; array[2] = status; sendNow(userId, tag, array);
double eventTime = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletResume(cloudletId); status = true; if (eventTime > CloudSim.clock()) { schedule(getId(), eventTime, CloudSimTags.VM_DATACENTER_EVENT); data[0] = getId(); data[1] = cloudletId; if (status) { data[2] = CloudSimTags.FALSE; sendNow(userId, CloudSimTags.CLOUDLET_RESUME_ACK, data);
Vm vm = (Vm) ev.getData(); boolean result = getVmAllocationPolicy().allocateHostForVm(vm); data[0] = getId(); data[1] = vm.getId(); data[2] = CloudSimTags.FALSE; send(vm.getUserId(), CloudSim.getMinTimeBetweenEvents(), CloudSimTags.VM_CREATE_ACK, data); getVmList().add(vm); vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler() .getAllocatedMipsForVm(vm));
/** * Processes a Cloudlet pause request. * * @param cloudletId ID of the cloudlet to be paused * @param userId ID of the cloudlet's owner * @param ack indicates if the event's sender expects to receive * an acknowledge message when the event finishes to be processed * @param vmId the id of the VM where the cloudlet has to be paused * * @pre $none * @post $none */ protected void processCloudletPause(int cloudletId, int userId, int vmId, boolean ack) { boolean status = getVmAllocationPolicy().getHost(vmId, userId).getVm(vmId,userId) .getCloudletScheduler().cloudletPause(cloudletId); if (ack) { int[] data = new int[3]; data[0] = getId(); data[1] = cloudletId; if (status) { data[2] = CloudSimTags.TRUE; } else { data[2] = CloudSimTags.FALSE; } sendNow(userId, CloudSimTags.CLOUDLET_PAUSE_ACK, data); } }
@Override public void shutdownEntity() { Log.printConcatLine(getName(), " is shutting down..."); }
NetworkConstants.totaldatatransfer += hs.pkt.data; CloudSim.send(getDatacenter().getId(), sw.getId(), delay, CloudSimTags.Network_Event_UP, hs);
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0); } catch (Exception e) { e.printStackTrace();
if (contains(file.getName())) { return DataCloudTags.FILE_ADD_ERROR_EXIST_READ_ONLY; if (getStorageList().size() <= 0) { return DataCloudTags.FILE_ADD_ERROR_STORAGE_FULL; int msg = DataCloudTags.FILE_ADD_ERROR_STORAGE_FULL; for (int i = 0; i < getStorageList().size(); i++) { tempStorage = getStorageList().get(i); if (tempStorage.getAvailableSpace() >= file.getSize()) { tempStorage.addFile(file);
/** * Deletes the file from the storage. * Also, check whether it is possible to delete the file from the storage. * * @param fileName the name of the file to be deleted * @return the tag denoting the status of the operation, * either {@link DataCloudTags#FILE_DELETE_ERROR} or * {@link DataCloudTags#FILE_DELETE_SUCCESSFUL} */ private int deleteFileFromStorage(String fileName) { Storage tempStorage = null; File tempFile = null; int msg = DataCloudTags.FILE_DELETE_ERROR; for (int i = 0; i < getStorageList().size(); i++) { tempStorage = getStorageList().get(i); tempFile = tempStorage.getFile(fileName); tempStorage.deleteFile(fileName, tempFile); msg = DataCloudTags.FILE_DELETE_SUCCESSFUL; } // end for return msg; }
/** * Gets the host list. * * @return the host list */ @SuppressWarnings("unchecked") public <T extends Host> List<T> getHostList() { return (List<T>) getCharacteristics().getHostList(); }
/** * Checks whether the datacenter has the given file. * * @param file a file to be searched * @return <tt>true</tt> if successful, <tt>false</tt> otherwise */ protected boolean contains(File file) { if (file == null) { return false; } return contains(file.getName()); }