Example usage for org.springframework.data.gemfire.function.execution GemfireOnRegionFunctionTemplate execute

List of usage examples for org.springframework.data.gemfire.function.execution GemfireOnRegionFunctionTemplate execute

Introduction

In this page you can find the example usage for org.springframework.data.gemfire.function.execution GemfireOnRegionFunctionTemplate execute.

Prototype

<T> T execute(GemfireFunctionCallback<T> callback);

Source Link

Document

Execute a Pivotal GemFire Function using a native Pivotal GemFire org.apache.geode.cache.execute.Execution instance.

Usage

From source file:org.spring.data.gemfire.cache.PeerCacheFunctionServiceIntegrationTest.java

@Test
public void factorialFunctionComputation() {
    for (int index = 0; index < 10; index++) {
        assertEquals(0, factorials.get(index).intValue());
    }//from ww w.  j a va2s.co  m

    GemfireOnRegionFunctionTemplate functionTemplate = new GemfireOnRegionFunctionTemplate(factorials);

    functionTemplate.execute(FactorialFunction.ID);

    assertEquals(1, factorials.get(0).intValue());
    assertEquals(1, factorials.get(1).intValue());
    assertEquals(2, factorials.get(2).intValue());
    assertEquals(6, factorials.get(3).intValue());
    assertEquals(24, factorials.get(4).intValue());
    assertEquals(120, factorials.get(5).intValue());
    assertEquals(720, factorials.get(6).intValue());
    assertEquals(5040, factorials.get(7).intValue());
    assertEquals(40320, factorials.get(8).intValue());
    assertEquals(362880, factorials.get(9).intValue());
}