code: @VisibleForTesting
  	boolean tryAssignResource(final LogicalSlot logicalSlot) {
  
  		assertRunningInJobMasterMainThread();
  
  		checkNotNull(logicalSlot);
  
  		// only allow to set the assigned resource in state SCHEDULED or CREATED
  		// note: we also accept resource assignment when being in state CREATED for testing purposes
  		if (state == SCHEDULED || state == CREATED) {
  			if (ASSIGNED_SLOT_UPDATER.compareAndSet(this, null, logicalSlot)) {
  				if (logicalSlot.tryAssignPayload(this)) {
  					// check for concurrent modification (e.g. cancelling call)
  					if ((state == SCHEDULED || state == CREATED) && !taskManagerLocationFuture.isDone()) {
  						taskManagerLocationFuture.complete(logicalSlot.getTaskManagerLocation());
  						assignedAllocationID = logicalSlot.getAllocationId();
  						return true;
  					} else {
  						// free assigned resource and return false
  						ASSIGNED_SLOT_UPDATER.set(this, null);
  						return false;
  					}
  				} else {
  					ASSIGNED_SLOT_UPDATER.set(this, null);
  					return false;
  				}
  			} else {
  				// the slot already has another slot assigned
  				return false;
  			}
  		} else {
  			// do not allow resource assignment if we are not in state SCHEDULED
  			return false;
  		}
  	}
docs: Tries to assign the given slot to the execution. The assignment works only if the
  Execution is in state SCHEDULED. Returns true, if the resource could be assigned.
  
  @param logicalSlot to assign to this execution
  @return true if the slot could be assigned to the execution, otherwise false