@Override
    public synchronized void gridletSubmit(Gridlet gridlet, boolean ack) {
    	// Create a server side Gridlet
    	SSGridlet sgl = new SSGridlet(gridlet);
    	if(!validateGridlet(sgl)) {
        	try {
        		// reject the Gridlet 
	    		gridlet.setGridletStatus(Gridlet.FAILED);
	    		super.sendFinishGridlet(gridlet);
	    		return;
	    	}
        	catch(Exception ex) {
        		logger.log(Level.WARNING, "Error on job submission", ex);
        		return;
        	}
    	}
    	
    	if(prioritySelector != null) {
    		sgl.setPriority(prioritySelector.getSchedulePriority(sgl));
    	}
    	
    	//-------------- FOR DEBUGGING PURPOSES ONLY  --------------
    	visualizer.notifyListeners(this.get_id(), ActionType.ITEM_ARRIVED, true, sgl);
    	//----------------------------------------------------------
    	
    	sgl.setStatus(Gridlet.QUEUED);
    	waitingJobs.add(sgl);
    	
        if (ack) {
            // sends back an ack
        	super.sendAck(GridSimTags.GRIDLET_SUBMIT_ACK, true,
        			gridlet.getGridletID(), gridlet.getUserID());
        }
    	
    	backfillGridlets();
        
    	//------------------ FOR DEBUGGING PURPOSES ONLY ----------------
        
        // Notifies the listeners that a Gridlet has been either scheduled
        // to run immediately or put in the waiting queue
    	visualizer.notifyListeners(this.get_id(), ActionType.ITEM_SCHEDULED, true, sgl);

    }