private int startReplicatedCacheServer(VM vm) {
    final int port = (Integer) vm.invoke(new SerializableCallable("Create Server1") {
      @Override
      public Object call() throws Exception {
        Region r1 = getCache().createRegionFactory(RegionShortcut.REPLICATE).create(regName);
        Region r2 = getCache().createRegionFactory(RegionShortcut.REPLICATE).create(regName2);
        // put domain objects
        for (int i = 0; i < 10; i++) {
          r1.put("key-" + i, new PortfolioPdx(i));
          r2.put("key-" + i, new PortfolioPdx(i));
        }

        CacheServer server = getCache().addCacheServer();
        int port = AvailablePortHelper.getRandomAvailableTCPPort();
        server.setPort(port);
        server.start();
        return port;
      }
    });
    return port;
  }
Used for saving & restoring oldObserver without serialization
geode-core/src/distributedTest/java/org/apache/geode/cache/query/dunit/SelectStarQueryDUnitTest.java