code: public static void createMasters(MasterRegistry registry, MasterContext context) {
      List<Callable<Void>> callables = new ArrayList<>();
      for (final MasterFactory factory : alluxio.master.ServiceUtils.getMasterServiceLoader()) {
        callables.add(() -> {
          if (factory.isEnabled()) {
            factory.create(registry, context);
          }
          return null;
        });
      }
      try {
        CommonUtils.invokeAll(callables, 10 * Constants.MINUTE_MS);
      } catch (Exception e) {
        throw new RuntimeException("Failed to start masters", e);
      }
    }
docs: Creates all the masters and registers them to the master registry.
  
  @param registry the master registry
  @param context master context