code: Optional<Container> allocateContainer(final ResourceRequestEvent requestEvent) {
  
      Container container = null;
      final Optional<String> nodeName = getPreferredNode(requestEvent.getNodeNameList());
  
      if (nodeName.isPresent()) {
        container = allocateBasedOnNode(
            requestEvent.getMemorySize().orElse(this.defaultMemorySize),
            requestEvent.getVirtualCores().orElse(this.defaultNumberOfCores),
            nodeName.get());
      } else {
        final Optional<String> rackName = getPreferredRack(requestEvent.getRackNameList());
        if (rackName.isPresent()) {
          container = allocateBasedOnRack(
              requestEvent.getMemorySize().orElse(this.defaultMemorySize),
              requestEvent.getVirtualCores().orElse(this.defaultNumberOfCores),
              rackName.get());
        }
      }
  
      return Optional.ofNullable(container);
    }
docs: Allocates a container based on a request event. First it tries to match a
  given node, if it cannot, it tries to get a spot in a rack.
  @param requestEvent resource request event.
  @return an optional with the container if allocated.