org.apache.geode.cache.execute.Execution Java Examples

The following examples show how to use org.apache.geode.cache.execute.Execution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Example.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator using default port 10334
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334)
      .set("log-level", "WARN").create();

  // create a local region that matches the server region
  Region<Integer, String> region =
      cache.<Integer, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("example-region");

  Execution execution = FunctionService.onRegion(region);
  new Example().getPrimes(region, execution);
  cache.close();
}
 
Example #2
Source File: Example.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
public Set<Integer> getPrimes(Region<Integer, String> region, Execution execution) {
  Set<Integer> primes = new HashSet<>();

  for (Integer key : (Iterable<Integer>) () -> IntStream.rangeClosed(1, maximum).iterator()) {
    region.put(key, key.toString());
  }

  ResultCollector<Integer, List> results = execution.execute(PrimeNumber.ID);
  primes.addAll(results.getResult());
  System.out.println("The primes in the range from 1 to " + maximum + " are:\n" + primes);
  return primes;
}
 
Example #3
Source File: ExampleTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testExample() throws Exception {
  Example example = new Example(10);

  Region<Integer, String> region = mock(Region.class);
  List<Integer> primes = Arrays.asList(1, 2, 3, 5, 7);
  ResultCollector resultCollector = mock(ResultCollector.class);
  when(resultCollector.getResult()).thenReturn(primes);
  Execution execution = mock(Execution.class);
  when(execution.execute(PrimeNumber.ID)).thenReturn(resultCollector);

  assertEquals(new HashSet(primes), example.getPrimes(region, execution));
}
 
Example #4
Source File: Example.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator using default port 10334
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334)
      .set("log-level", "WARN").create();

  // create a local region that matches the server region
  Region<Integer, String> region =
      cache.<Integer, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("example-region");

  Execution execution = FunctionService.onRegion(region);
  new Example().getPrimes(region, execution);
  cache.close();
}
 
Example #5
Source File: Example.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
public Set<Integer> getPrimes(Region<Integer, String> region, Execution execution) {
  Set<Integer> primes = new HashSet<>();

  for (Integer key : (Iterable<Integer>) () -> IntStream.rangeClosed(1, maximum).iterator()) {
    region.put(key, key.toString());
  }

  ResultCollector<Integer, List> results = execution.execute(PrimeNumber.ID);
  primes.addAll(results.getResult());
  System.out.println("The primes in the range from 1 to " + maximum + " are:\n" + primes);
  return primes;
}
 
Example #6
Source File: ExampleTest.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
@Test
public void testExample() throws Exception {
  Example example = new Example(10);

  Region<Integer, String> region = mock(Region.class);
  List<Integer> primes = Arrays.asList(1, 2, 3, 5, 7);
  ResultCollector resultCollector = mock(ResultCollector.class);
  when(resultCollector.getResult()).thenReturn(primes);
  Execution execution = mock(Execution.class);
  when(execution.execute(PrimeNumber.ID)).thenReturn(resultCollector);

  assertEquals(new HashSet(primes), example.getPrimes(region, execution));
}
 
Example #7
Source File: GeodeSamplesLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenExecuteUppercaseNames_thenCustomerNamesAreUppercased() {
    Execution execution = FunctionService.onRegion(this.customerRegion);
    execution.execute(UpperCaseNames.class.getName());
    Customer customer = this.customerRegion.get(new CustomerKey(1));
    assertEquals("GHEORGE", customer.getFirstName());
}