private int startLocator(final VM locatorVM, final int port) {
    return locatorVM.invoke("Start Locator In VM", () -> {
      assertThat(InternalLocator.hasLocator()).isFalse();

      Properties config = new Properties();
      config.setProperty(LOCATORS, "");

      InetAddress bindAddress = InetAddress.getByName(hostName);

      File logFile = new File(getTestMethodName() + "-locator" + port + ".log");
      Locator locator = Locator.startLocatorAndDS(port, logFile, bindAddress, config);

      assertThat(InternalLocator.hasLocator()).isTrue();
      return locator.getPort();
    });
  }
Starts a locator with given configuration. If DS is already started it will use the same DS
geode-core/src/distributedTest/java/org/apache/geode/management/LocatorManagementDUnitTest.java