code: public static void getFreeSlots(Map<String, SupervisorInfo> supervisorInfos,
                                      StormClusterState stormClusterState) throws Exception {
          Map<String, Assignment> assignments = Cluster.get_all_assignment(stormClusterState, null);
          for (Entry<String, Assignment> entry : assignments.entrySet()) {
              Assignment assignment = entry.getValue();
              Set<ResourceWorkerSlot> workers = assignment.getWorkers();
              for (ResourceWorkerSlot worker : workers) {
                  SupervisorInfo supervisorInfo = supervisorInfos.get(worker.getNodeId());
                  if (supervisorInfo == null) {
                      // the supervisor is dead
                      continue;
                  }
                  supervisorInfo.getAvailableWorkerPorts().remove(worker.getPort());
              }
          }
      }
docs: Get free resources