How to Create a new event and make it to execute in order

  • Create a class and define a tag for the event want to create. Here, the event is to stop the VM running and the tag for the evnet is VM_FAIL.
  • public class NewTag {
    private static final int BASE = 0;
    public static final int VM_FAIL=1;
    }

  • To execute this event as of the normal events in cloudsim, this should be added in the “Datacenter” class. The Datacenter class is extended and the tag for the event is added in the switch case of the “processEvent(SimEvent ev)” method. The implementation method name is given under this tag. This tag is also used as a normal Cloudsim tags during the execution.
  • public class NewCenter extends Datacenter {
    ………….;
    ……….;
    public void processEvent(SimEvent ev) {
    int srcId = -1;
    switch (ev.getTag()) {
    ……;
    …….
    case NewTag.VM_FAIL: // New event
    processVmFail(ev); //Implemented event method
    default:
    processOtherEvent(ev);
    break;
    }
    }
    protected void processVmFail(SimEvent ev)
    {
    /// implement the event action
    }
    }