public void setGridletStatus(int newStatus) throws Exception
    {
        // if the new status is same as current one, then ignore the rest
        if (status_ == newStatus) {
            return;
        }

        // throws an exception if the new status is outside the range
        if (newStatus < Gridlet.CREATED || newStatus > Gridlet.FAILED_RESOURCE_UNAVAILABLE)
        {
            throw new Exception("Gridlet.setGridletStatus() : Error - " +
                    "Invalid integer range for Gridlet status.");
        }

        if (newStatus == Gridlet.SUCCESS) {
            finishTime_ = GridSim.clock();
        }

        if (record_)
        {
            String obj = "Sets Gridlet status from " + getGridletStatusString();
            write( obj + " to " + Gridlet.getStatusString(newStatus) );
        }

        this.status_ = newStatus;
    }