private void processFailure(Sim_event ev)
    {
        if (ev == null)
        {
            System.out.println(super.get_name() + ".processFailure(): " +
                    "Error - an event is null.");
            return;
        }

        Object obj = ev.get_data();
        if (obj instanceof FailureMsg)
        {
            FailureMsg resFail = (FailureMsg) obj;

            int numFailedMachines = (int)resFail.getNumMachines();
            int numMachines = resource_.getNumMachines();

            // First, we have to set ome of the machines of the resource
            // as out of order.
            // Then, we have to set the gridlets to FAILED or
            // FAILED_RESOURCE_UNAVAILABLE
            // depending on whether there are still available machines
            // in this resource
            if (numFailedMachines >= numMachines)
            {
                // This resource will not work, as none of its machines
                // are running
                double time = resFail.getTime();

                /*****************/
                // Now, we keep the moment of the failure in a results file
                // for this res
                if (record_ == true) {
                    write("Failure", numMachines);

                    System.out.println(super.get_name() + ".processFailure(): " +
                       "receives an event GRIDRESOURCE_FAILURE. Clock: " +
                       GridSim.clock() + " which will last until clock: " +
                       (GridSim.clock() + time) +
                       ". There are NO working machines in this resource.");
                }
                /******************/

                // set all the machines as failed
                setMachineFailed(true, numMachines);
                emptyGridletLists();

                // as all the machines in this resource have failed, all
                // gridlets are lost (the ones running and the ones waiting)

            }//if (numFailedMachines >= numMachines)
            else
            {
                // This resource will still work, as some of its machines
                // are running

                /*****************/
                // Now, we keep the moment of the failure in a results file
                // for this res
                if (record_) {
                    write("Failure", numFailedMachines);

                    System.out.println(super.get_name() + ".processFailure(): " +
                       "receives an event GRIDRESOURCE_FAILURE. Clock: " +
                       GridSim.clock() +
                       ". There are STILL working machines in this resource.");
                }
                /******************/

                // set numFailedMachines machines as failed
                setMachineFailed(true, numFailedMachines);

                Machine mach;
                int machID;
                // empty only the exec list of the machines which has failed
                for(int i=0; i< numFailedMachines; i++)
                {
                    mach = resource_.getMachineList().getMachineInPos(i);
                    machID = mach.getMachineID();
                    emptyGridletLists(machID);
                }
            }
        }
    }