public synchronized Optional<ServerName> acquire() {
    List<ServerName> serverList = master.getServerManager().getOnlineServersList();
    Collections.shuffle(serverList);
    Optional<ServerName> worker = serverList.stream()
      .filter(
        serverName -> !currentWorkers.containsKey(serverName) || currentWorkers.get(serverName) > 0)
      .findAny();
    worker.ifPresent(name -> currentWorkers.compute(name, (serverName,
      availableWorker) -> availableWorker == null ? maxTasks - 1 : availableWorker - 1));
    return worker;
  }
help assign and release a worker for each remote task. For each worker, concurrent running task
should be no more than maxTasks. If a task failed to acquire a worker, it will suspend and wait
for workers available.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/WorkerAssigner.java