@Test
  public void testP2PDistributedRegionFunctionExecutionStats() {
    final String rName = getUniqueName();
    Host host = Host.getHost(0);
    final VM datastore0 = host.getVM(0);
    final VM datastore1 = host.getVM(1);
    final VM datastore2 = host.getVM(2);
    final VM datastore3 = host.getVM(3);

    datastore0.invoke(initializeStats);
    datastore1.invoke(initializeStats);
    datastore2.invoke(initializeStats);
    datastore3.invoke(initializeStats);

    datastore0.invoke(() -> {
      AttributesFactory factory = new AttributesFactory();
      factory.setScope(Scope.DISTRIBUTED_ACK);
      factory.setDataPolicy(DataPolicy.EMPTY);
      Region<String, Integer> region = getCache().createRegion(rName, factory.create());
      logger.info("Region Created :" + region);
      assertNotNull(region);
      FunctionService.registerFunction(new TestFunction(true, TestFunction.TEST_FUNCTION2));
      for (int i = 1; i <= 200; i++) {
        region.put("execKey-" + i, i);
      }
    });

    SerializableRunnableIF createAndPopulateRegionWithReplicate = () -> {
      AttributesFactory factory = new AttributesFactory();
      factory.setScope(Scope.DISTRIBUTED_ACK);
      factory.setDataPolicy(DataPolicy.REPLICATE);
      Region<String, Integer> region = getCache().createRegion(rName, factory.create());
      logger.info("Region Created :" + region);
      assertNotNull(region);
      FunctionService.registerFunction(new TestFunction(true, TestFunction.TEST_FUNCTION2));
      for (int i = 1; i <= 200; i++) {
        region.put("execKey-" + i, i);
      }
    };

    datastore1.invoke(createAndPopulateRegionWithReplicate);
    datastore2.invoke(createAndPopulateRegionWithReplicate);
    datastore3.invoke(createAndPopulateRegionWithReplicate);

    datastore0.invoke(() -> {
      Region region = getCache().getRegion(rName);
      try {
        List list = (List) FunctionService.onRegion(region).setArguments(Boolean.TRUE)
            .execute(TestFunction.TEST_FUNCTION2).getResult();
        // this is the Distributed Region with Empty Data policy.
        // therefore no function execution takes place here. it only receives the results.
        resultReceived_Aggregate += list.size();
        assertEquals(resultReceived_Aggregate,
            ((InternalDistributedSystem) getCache().getDistributedSystem())
                .getFunctionStatsManager().getFunctionServiceStats().getResultsReceived());

        resultReceived_TESTFUNCTION2 += list.size();
        assertEquals(resultReceived_TESTFUNCTION2,
            ((InternalDistributedSystem) getCache().getDistributedSystem())
                .getFunctionStatsManager().getFunctionServiceStats().getResultsReceived());

      } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("test failed due to", e);
      }
    });

    // there is a replicated region on 3 nodes so we cannot predict on which
    // node the function execution will take place
    // so i have avoided that check.

    datastore0.invoke(closeDistributedSystem);
    datastore1.invoke(closeDistributedSystem);
    datastore2.invoke(closeDistributedSystem);
    datastore3.invoke(closeDistributedSystem);
  }
Test the function execution statistics in case of the distributed Region P2P DataStore0 is with
Empty datapolicy
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/execute/FunctionServiceStatsDUnitTest.java