if (log.isDebugEnabled()) {
if (log.isInfoEnabled()) {
  protected final boolean allocate(      final Task task,       final int startingRuleIndex,       final long currTime,      final Object parent) {        DeadlineTimerEvent deadlineI = null;    Allocation allocI = null;        if (parent instanceof DeadlineTimerEvent) {      // called from handleDeadline - prev. allocation timed out      // we'll want to re-allocate if possible, rescinding the previous      // allocation and deadline      // if not possible, publish a failure Disposition whose reason is DeadlineExceeded      deadlineI = (DeadlineTimerEvent)parent;      allocI = (Allocation)deadlineI.getRegarding();    } else if (parent instanceof Allocation) {      // called from handleAllocation - Allocation failed before the deadline went off      // We'll want to re-allocate if possible, rescinding the previous      // allocation      // if we're out of time, publish a Disposition that says so and rescind prev.      // if there are more rules, pub new alloc, deadline and rescind prev.      // Else rescind prev, pub a failure Disposition whose reason      // is same as that on the old Allocation      allocI = (Allocation)parent;      deadlineI = null;    } else {      // Initial allocation of this Task      // We'll want to create an allocation and deadline if possible      // If no time available, publish a Disposition that says so      // if no matching rules, publish a Disposition that says so    }    long taskDeadline = getTaskDeadline(task);    // Do an extra little check to see if the Task is already late    // make sure the deadline has not been exceeded    if (taskDeadline <= currTime) {      // Task deadline is already past the current time!      if (log.isDebugEnabled()) {        log.info(		" unable to allocate task: "+task.getUID()+		 "\ndue to deadline ("+taskDeadline+" <= "+		 currTime+")");      }      int[] aspect_types = {AspectType.END_TIME};      double[] results = {(double)getTaskDeadline(task)};            if (allocI != null) {	rescindAllocation(allocI);      }      if (deadlineI != null) {	rescindDeadlineTimerEvent(deadlineI);      }      // Should this reason instead be the failure reason on the previous      // allocation, if there was one?      // FIXME!!!      //      publishFailureDisposition(Constants.Rating.FAIL_DEADLINE, aspect_types, results, task);      String reason = Constants.Rating.FAIL_DEADLINE;      if (deadlineI == null) {	if (allocI != null) {	  AllocationResult repAR = allocI.getReportedResult();	  if (repAR != null) {	    reason = repAR.auxiliaryQuery(AuxiliaryQueryType.FAILURE_REASON);	  }	  if (reason.equals(Constants.Rating.SUCCESS)) 	    reason = Constants.Rating.FAIL_DEADLINE;	  if (reason == null)	    reason = "(no reason given)";	}      }      publishFailureDisposition(reason, aspect_types, results, task);      return false;    } // end of check if Task already late    // find a matching rule    int matchingRuleIndex = startingRuleIndex;    String text = task.getVerb().toString();    String failureReason = null;  // Reason to put in failure area    int[] aspect_types = new int[1];; // Aspects to specify    double[] results = new double[1]; // and the values    // Loop over available rules    while (true) {      if (++matchingRuleIndex >= expandedRules.length) {	haveAllocatedPastLocals = true;        // no more rules apply        if (log.isDebugEnabled()) {	  if (expandedRules.length == 0) {	    log.info("allocate: " + myId + " couldn't allocate cause have no expanded rules at all!");	  } else if (startingRuleIndex < 0) {	    log.info(		  " unable to allocate task: "+task.getUID()+		   "\ndue to no rule at all in " +		   expandedRules.length+" matching \""+		   text+"\"");	  } else {	    log.info(		  " unable to allocate task: "+task.getUID()+		   "\ndue to no rule remaining from index "+(startingRuleIndex + 1)+" to "+		   expandedRules.length+" matching \""+		   text+"\"");	  }        }//  	if (log.isDebugEnabled()) {//  	  String par;//  	  if (parent == null) {//  	    par = "(none)";//  	  } else {//  	    par = parent.toString();//  	  }//  	  log.info("allocate:" + this + ":parent = " + par);//  	}         if (parent instanceof DeadlineTimerEvent) {	  // We ran out of time	  aspect_types[0] = AspectType.END_TIME;	  results[0] = (double)getTaskDeadline(task);	  failureReason = Constants.Rating.FAIL_DEADLINE;        } else if (parent instanceof Allocation) {	  // give same reasone as in allocation	  AllocationResult ar = allocI.getReportedResult();	  // get out the aspect_types, values, and failureReason	  aspect_types = ar.getAspectTypes();	  results = ar.getResult();	  failureReason = ar.auxiliaryQuery(AuxiliaryQueryType.FAILURE_REASON);	} else {	  // Never was a matching rule	  // FIXME!!! Is this the right aspect_type and results?	  aspect_types[0] = AspectType.UNDEFINED;	  results[0] = (double)0;	  failureReason = Constants.Rating.FAIL_ALLOCATION;	}	if (allocI != null) {	  rescindAllocation(allocI);	}	if (deadlineI != null) {	  rescindDeadlineTimerEvent(deadlineI);	}	publishFailureDisposition(failureReason, aspect_types, results, task);	        return false;      } // end of block to handle no more matching rules      // OK, got a rule to look at      // examine this rule[i]      // We must see if this rule matches      String ruleTask = expandedRules[matchingRuleIndex].getTask();      if (ruleTask.equals(text)) {        // found matching rule -- use it below        break;      }    } // end of while(true) loop over available rules    // found a matching rule, expandedRules[matchingRuleIndex]    //     // check if asset is available?  currently we (blindly)    //   attempt the allocation.    Asset allocAsset =       expandedRules[matchingRuleIndex].getAsset();    // Now calculate the deadlines.  If they've passed, we'll    // handle that specially        // There are 2 deadlines:     //   1) "deadlineTime" by which, if the allocator has not heard     //      anything else, it will assume that this allocation failed.      //      That is the time for the DeadlineTimerEvent.    //   2) "taskDeadlineTime" is the deadline included in the new     //      Task, to instruct the other Agent to finish by that time,     //      giving the answer enough time to get back to this allocator,     //      and perhaps allow this allocator time to re-allocate this     //      Task.        // FIXME!!! Since we're not reducing the deadline for future    // re-allocations, should I just    // always use the taskDeadline retrieved above?    // Accomplish roughly the same thing by saying we'll always    // use the simple deadline method    this.useSimpleDeadline = true;    // FIXME!!! Change this later!!!!        long deadlineTime =      calculateDeadlineTime(			    currTime,			    task,			    allocAsset,			    matchingRuleIndex);    // Also reduce the deadline for completing the new task    //   to account for time for a remote allocation to transfer    //   over the wire.  Local allocations do not incur this cost.    long taskDeadlineTime; // deadline for new task    long fastResponseTime; // quickest we could possibly respond by    if (allocAsset instanceof LocalAsset) {      // this is an allocation to a local asset      taskDeadlineTime = deadlineTime;      // The "fastest" response for an allocation to a local asset:      //    (local-ALLOC + executor-response)      // which we'll estimate down to just (local-Alloc) = allocPubDelay      fastResponseTime = 	currTime + 	this.allocPubDelay;    } else {      haveAllocatedPastLocals = true;      // this is an allocation to an Organization      taskDeadlineTime = deadlineTime - this.transDelay;      // Calculation the expected "fastest" response for an       //   allocation to the organization:        //     (org-ALLOC + TRANS-out + remote-local-ALLOC + TRANS-back)      //     = (allocPubDelay + transDelay + taskRespPubDelay + transDelay)      //     = (allocPubDelay + 2*transDelay + taskRespPubDelay)      fastResponseTime = 	currTime + 	(this.allocPubDelay + 	 (2 * this.transDelay) + 	 this.taskRespPubDelay);    }          // make sure deadline is reasonable    // HACK!!! Lets not fail tasks with deadline exceeded    // on this account just now.    // FIXME!!!!    if (false && taskDeadlineTime <= fastResponseTime) {      // The deadlines are too soon!  There's no way they can       //   be satisfied, so don't try.      //      // Note that we used the guess-timated travel times, so this       //   may fail tasks that might have succeeded.      if (log.isDebugEnabled()) {        log.info( 		"Unable to allocate task cause calculated "+		"deadline too soon");      }      aspect_types[0] = AspectType.END_TIME;      results[0] = (double)taskDeadlineTime;      failureReason = Constants.Rating.FAIL_DEADLINE;      if (allocI != null) {	rescindAllocation(allocI);      }      if (deadlineI != null) {	rescindDeadlineTimerEvent(deadlineI);      }      publishFailureDisposition(failureReason, aspect_types, results, task);      return false;    }    // If get here the calculated deadlines are OK on this new matching rule    // Rescind any old objects    if (allocI != null) {      rescindAllocation(allocI);    }    if (deadlineI != null) {      rescindDeadlineTimerEvent(deadlineI);    }        // generate an allocation    publishAllocation(task, matchingRuleIndex, deadlineTime, taskDeadlineTime);    return true;  } // end of allocate()