org.apache.geode.cache.client.ClientCache Java Examples

The following examples show how to use org.apache.geode.cache.client.ClientCache. 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 6 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")
      .setPdxSerializer(
          new ReflectionBasedAutoSerializer("org.apache.geode_examples.serialization.Country"))
      .create();

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

  Example example = new Example(region);
  example.insertValues();
  example.printValues(example.getKeys());

  cache.close();
}
 
Example #2
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void doQueries(ClientCache cache) throws NameResolutionException,
    TypeMismatchException, QueryInvocationTargetException, FunctionDomainException {
  QueryService queryService = cache.getQueryService();

  // Query for every entry in the region, and print query results.
  System.out.println("\nExecuting query: " + QUERY1);
  SelectResults<EmployeeData> results =
      (SelectResults<EmployeeData>) queryService.newQuery(QUERY1).execute();
  printSetOfEmployees(results);

  // Query for all part time employees, and print query results.
  System.out.println("\nExecuting query: " + QUERY2);
  results = (SelectResults<EmployeeData>) queryService.newQuery(QUERY2).execute();
  printSetOfEmployees(results);

  // Query for last name of Jive, and print the full name and employee number.
  System.out.println("\nExecuting query: " + QUERY3);
  results =
      (SelectResults<EmployeeData>) queryService.newQuery(QUERY3).execute(new String[] {"Jive"});
  for (EmployeeData eachEmployee : results) {
    System.out.println(String.format("Employee %s %s has employee number %d",
        eachEmployee.getFirstName(), eachEmployee.getLastName(), eachEmployee.getEmplNumber()));
  }
}
 
Example #3
Source File: Example.java    From geode-examples with Apache License 2.0 6 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();

  Example example = new Example();

  // create a local region that matches the server region
  ClientRegionFactory<Integer, String> clientRegionFactory =
      cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
  clientRegionFactory.addCacheListener(new ExampleCacheListener());
  Region<Integer, String> region = clientRegionFactory.create("example-region");

  example.putEntries(region);
  cache.close();
}
 
Example #4
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void doQueries(ClientCache cache) throws NameResolutionException,
    TypeMismatchException, QueryInvocationTargetException, FunctionDomainException {
  QueryService queryService = cache.getQueryService();

  // Query for every entry in the region, and print query results.
  System.out.println("\nExecuting query: " + QUERY1);
  SelectResults<EmployeeData> results =
      (SelectResults<EmployeeData>) queryService.newQuery(QUERY1).execute();
  printSetOfEmployees(results);

  // Query for all part time employees, and print query results.
  System.out.println("\nExecuting query: " + QUERY2);
  results = (SelectResults<EmployeeData>) queryService.newQuery(QUERY2).execute();
  printSetOfEmployees(results);

  // Query for last name of Jive, and print the full name and employee number.
  System.out.println("\nExecuting query: " + QUERY3);
  results =
      (SelectResults<EmployeeData>) queryService.newQuery(QUERY3).execute(new String[] {"Jive"});
  for (EmployeeData eachEmployee : results) {
    System.out.println(String.format("Employee %s %s has employee number %d",
        eachEmployee.getFirstName(), eachEmployee.getLastName(), eachEmployee.getEmplNumber()));
  }
}
 
Example #5
Source File: GeodeUtils.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a proxy pointing to an existing Region on the server
 *
 * @param cache {@link GemFireCache} instance to interact with the Geode server
 * @param regionName  Name of the region to create proxy for.
 * @return Returns a Region proxy to a remote (on the Server) regions.
 */
public static synchronized Region createRegion(GemFireCache cache, String regionName) {
  Objects.requireNonNull(cache, "cache");
  Objects.requireNonNull(regionName, "regionName");
  Region region = REGION_MAP.get(regionName);
  if (region == null) {
    try {
      region = ((ClientCache) cache)
          .createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create(regionName);
    } catch (IllegalStateException | RegionExistsException e) {
      // means this is a server cache (probably part of embedded testing
      // or clientCache is passed directly)
      region = cache.getRegion(regionName);
    }

    REGION_MAP.put(regionName, region);
  }

  return region;
}
 
Example #6
Source File: Example.java    From geode-examples with Apache License 2.0 6 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<String, Integer> region =
      cache.<String, Integer>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");

  Example example = new Example(region);
  final int previous = example.getCounter();
  example.increment();
  final int current = example.getCounter();
  System.out.println(previous + " -> " + current);

  cache.close();
}
 
Example #7
Source File: Example.java    From geode-examples with Apache License 2.0 6 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.PROXY)
          .create("example-region");

  Example example = new Example(region);
  example.insertValues(10);
  example.printValues(example.getValues());

  cache.close();
}
 
Example #8
Source File: Example.java    From geode-examples with Apache License 2.0 6 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<EmployeeKey, EmployeeData> region =
      cache.<EmployeeKey, EmployeeData>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");

  Example example = new Example(region);
  example.insertValues(new String[] {"Alex Able", "Bertie Bell", "Chris Call", "Dale Driver",
      "Frankie Forth", "Jamie Jive", "Morgan Minnow", "Pat Pearson", "Ricky Reliable",
      "Taylor Tack", "Zelda Zankowski"});
  example.printValues(example.getValues());

  cache.close();
}
 
Example #9
Source File: Example.java    From geode-examples with Apache License 2.0 6 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
  ClientRegionFactory<String, Integer> clientRegionFactory =
      cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<String, Integer> region = clientRegionFactory.create(REGION_NAME);

  Example example = new Example(region);
  example.initializeEntry();
  example.executeChildProcesses(5);

  cache.close();
}
 
Example #10
Source File: Example.java    From geode-examples with Apache License 2.0 6 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();

  Example example = new Example();

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

  example.insertValues(region, example.generateIntegers(10));
  example.monitorEntries(region);

  cache.close();
}
 
Example #11
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334)
      .set("log-level", "WARN").create();

  Region<Integer, Customer> customerRegion =
      cache.<Integer, Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("customer");

  Region<OrderKey, Order> orderRegion =
      cache.<OrderKey, Order>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("order");

  Map<Integer, Customer> customers = generateCustomers();

  for (int i : customers.keySet()) {
    Customer customer = customers.get(i);
    Order order = new Order(i * 10, customer.getId());
    customerRegion.put(customer.getId(), customer);
    orderRegion.put(order.getKey(), order);
  }
  cache.close();
}
 
Example #12
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator in London cluster using port 10332
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10332)
      .set("log-level", "WARN").create();

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

  Example example = new Example(region);
  example.insertValues(10);
  example.printValues(example.getValues());

  cache.close();
}
 
Example #13
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException, LuceneQueryException {
  // 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<String, TrainStop> region =
      cache.<String, TrainStop>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");


  LuceneService luceneService = LuceneServiceProvider.get(cache);
  // Add some entries into the region
  putEntries(luceneService, region);
  findNearbyTrainStops(luceneService);
  cache.close();
}
 
Example #14
Source File: Example.java    From geode-examples with Apache License 2.0 6 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<String, Integer> region =
      cache.<String, Integer>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");

  Example example = new Example(region);
  final int previous = example.getCounter();
  example.increment();
  final int current = example.getCounter();
  System.out.println(previous + " -> " + current);

  cache.close();
}
 
Example #15
Source File: Example.java    From geode-examples with Apache License 2.0 6 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.PROXY)
          .create("example-region");

  Example example = new Example(region);
  example.insertValues(10);
  example.printValues(example.getValues());

  cache.close();
}
 
Example #16
Source File: Example.java    From geode-examples with Apache License 2.0 6 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.PROXY)
          .create("example-region");

  Example example = new Example(region);
  example.insertValues(10);
  example.printValues(example.getValues());

  cache.close();
}
 
Example #17
Source File: Example.java    From geode-examples with Apache License 2.0 6 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<EmployeeKey, EmployeeData> region =
      cache.<EmployeeKey, EmployeeData>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");

  Example example = new Example(region);
  example.insertValues(new String[] {"Alex Able", "Bertie Bell", "Chris Call", "Dale Driver",
      "Frankie Forth", "Jamie Jive", "Morgan Minnow", "Pat Pearson", "Ricky Reliable",
      "Taylor Tack", "Zelda Zankowski"});
  example.printValues(example.getValues());

  cache.close();
}
 
Example #18
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException, LuceneQueryException {
  // 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<String, TrainStop> region =
      cache.<String, TrainStop>createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create("example-region");


  LuceneService luceneService = LuceneServiceProvider.get(cache);
  // Add some entries into the region
  putEntries(luceneService, region);
  findNearbyTrainStops(luceneService);
  cache.close();
}
 
Example #19
Source File: Example.java    From geode-examples with Apache License 2.0 6 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
  ClientRegionFactory<String, Integer> clientRegionFactory =
      cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<String, Integer> region = clientRegionFactory.create(REGION_NAME);

  Example example = new Example(region);
  example.initializeEntry();
  example.executeChildProcesses(5);

  cache.close();
}
 
Example #20
Source File: Example.java    From geode-examples with Apache License 2.0 6 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();

  Example example = new Example();

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

  example.insertValues(region, example.generateIntegers(10));
  example.monitorEntries(region);

  cache.close();
}
 
Example #21
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator using default port 10334
  ClientCache cache = new ClientCacheFactory().set("log-level", "WARN").create();

  final String poolName = "subscriptionPool";
  PoolManager.createFactory().addLocator("127.0.0.1", 10334).setSubscriptionEnabled(true)
      .create(poolName);

  // create a local region that matches the server region
  final ClientRegionFactory<Integer, String> incomingRegionFactory =
      cache.<Integer, String>createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<Integer, String> incomingRegion =
      incomingRegionFactory.setPoolName(poolName).create(INCOMING_REGION_NAME);

  // create another local region that matches the server region
  final ClientRegionFactory<String, String> outgoingRegionFactory =
      cache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<String, String> outgoingRegion =
      outgoingRegionFactory.setPoolName(poolName).create(OUTGOING_REGION_NAME);

  new Example().checkWords(incomingRegion, outgoingRegion,
      Arrays.asList(new String[] {"that", "teh", "wil", "i'"}));
  cache.close();
}
 
Example #22
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334)
      .set("log-level", "WARN").create();

  Region<Integer, Customer> customerRegion =
      cache.<Integer, Customer>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("customer");

  Region<OrderKey, Order> orderRegion =
      cache.<OrderKey, Order>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("order");

  Map<Integer, Customer> customers = generateCustomers();

  for (int i : customers.keySet()) {
    Customer customer = customers.get(i);
    Order order = new Order(i * 10, customer.getId());
    customerRegion.put(customer.getId(), customer);
    orderRegion.put(order.getKey(), order);
  }
  cache.close();
}
 
Example #23
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
private static void addCacheEntries() {
  // connect to the locator using default port
  ClientCache cache = new ClientCacheFactory().addPoolLocator("localhost", 10334)
      .set("log-level", "WARN").create();

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

  // add entries to the region
  IntStream.rangeClosed(1, 10).forEach(i -> region.put(i, "value" + i));

  System.out.println(String.format("The entry count for region %s on the server is %d.",
      region.getName(), region.sizeOnServer()));

  cache.close();
}
 
Example #24
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator using default port 10334
  ClientCache cache = new ClientCacheFactory().set("log-level", "WARN").create();

  final String poolName = "subscriptionPool";
  PoolManager.createFactory().addLocator("127.0.0.1", 10334).setSubscriptionEnabled(true)
      .create(poolName);

  // create a local region that matches the server region
  final ClientRegionFactory<Integer, String> incomingRegionFactory =
      cache.<Integer, String>createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<Integer, String> incomingRegion =
      incomingRegionFactory.setPoolName(poolName).create(INCOMING_REGION_NAME);

  // create another local region that matches the server region
  final ClientRegionFactory<String, String> outgoingRegionFactory =
      cache.<String, String>createClientRegionFactory(ClientRegionShortcut.PROXY);
  Region<String, String> outgoingRegion =
      outgoingRegionFactory.setPoolName(poolName).create(OUTGOING_REGION_NAME);

  new Example().checkWords(incomingRegion, outgoingRegion,
      Arrays.asList(new String[] {"that", "teh", "wil", "i'"}));
  cache.close();
}
 
Example #25
Source File: SpringBootApacheGeodeClientCacheApplication.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
ApplicationRunner applicationAssertionRunner(ConfigurableApplicationContext applicationContext) {

	return args -> {

		Assert.notNull(applicationContext, "ApplicationContext is required");

		Environment environment = applicationContext.getEnvironment();

		Assert.notNull(environment, "Environment is required");
		Assert.isTrue(ArrayUtils.isEmpty(ArrayUtils.nullSafeArray(environment.getActiveProfiles(), String.class)),
			"Expected Active Profiles to be empty");
		Assert.isTrue(Arrays.asList(ArrayUtils.nullSafeArray(environment.getDefaultProfiles(), String.class))
				.contains("default"), "Expected Default Profiles to contain 'default'");

		ClientCache clientCache = applicationContext.getBean(ClientCache.class);

		Assert.notNull(clientCache, "ClientCache is expected");
		Assert.isTrue(SpringBootApacheGeodeClientCacheApplication.class.getSimpleName().equals(clientCache.getName()),
			"ClientCache.name is not correct");

		this.logger.info("Application assertions successful!");
	};
}
 
Example #26
Source File: BookMasterRegionTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

    ClientCache clientCache = new ClientCacheFactory()
        .addPoolLocator("localhost", 10334)
        .setPdxSerializer(new ReflectionBasedAutoSerializer("org.apache.calcite.adapter.geode.*"))
        .create();

    // Using Key/Value
    Region bookMaster = clientCache
        .createClientRegionFactory(ClientRegionShortcut.PROXY)
        .create("BookMaster");

    System.out.println("BookMaster = " + bookMaster.get(789));

    // Using OQL
    QueryService queryService = clientCache.getQueryService();
    String oql = "select itemNumber, description, retailCost from /BookMaster";
    SelectResults result = (SelectResults) queryService.newQuery(oql).execute();
    System.out.println(result.asList());
  }
 
Example #27
Source File: Example.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
  // connect to the locator in London cluster using port 10332
  ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10332)
      .set("log-level", "WARN").create();

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

  Example example = new Example(region);
  example.insertValues(10);
  example.printValues(example.getValues());

  cache.close();
}
 
Example #28
Source File: CacheUtilsUnitTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
public void collectValuesFromClientRegionWhenClientRegionKeySetOnServerReturnsNullSetIsNullSafe() {

	Region<Object, Object> mockRegion = mock(Region.class);

	RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);

	RegionService mockRegionService = mock(ClientCache.class);

	doReturn(mockRegionAttributes).when(mockRegion).getAttributes();
	doReturn(mockRegionService).when(mockRegion).getRegionService();
	doReturn(null).when(mockRegion).keySetOnServer();
	doReturn(DataPolicy.PARTITION).when(mockRegionAttributes).getDataPolicy();
	doReturn("Dead").when(mockRegionAttributes).getPoolName();

	Collection<Object> values = CacheUtils.collectValues(mockRegion);

	assertThat(values).isNotNull();
	assertThat(values).isEmpty();

	verify(mockRegion, times(3)).getAttributes();
	verify(mockRegion, times(1)).getRegionService();
	verify(mockRegion, times(1)).keySetOnServer();
	verify(mockRegion, never()).getAll(any());
	verify(mockRegion, never()).values();
	verify(mockRegionAttributes, times(1)).getDataPolicy();
	verify(mockRegionAttributes, times(1)).getPoolName();
	verifyNoInteractions(mockRegionService);
	verifyNoMoreInteractions(mockRegion);
}
 
Example #29
Source File: CacheUtilsUnitTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
public void collectValuesFromClientRegion() {

	Region<Object, Object> mockRegion = mock(Region.class);

	RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class);

	RegionService mockRegionService = mock(ClientCache.class);

	Set<?> keySetOnServer = new TreeSet<>(Arrays.asList(1, 2, 3));

	Map<Object, Object> keysValues = new HashMap<>();

	keysValues.put(1, "one");
	keysValues.put(2, "two");
	keysValues.put(3, "three");

	doReturn(mockRegionAttributes).when(mockRegion).getAttributes();
	doReturn(mockRegionService).when(mockRegion).getRegionService();
	doReturn(keySetOnServer).when(mockRegion).keySetOnServer();
	doReturn(keysValues).when(mockRegion).getAll(eq(keySetOnServer));
	doReturn(DataPolicy.EMPTY).when(mockRegionAttributes).getDataPolicy();

	assertThat(CacheUtils.collectValues(mockRegion)).containsExactlyInAnyOrder(keysValues.values().toArray());

	verify(mockRegion, times(2)).getAttributes();
	verify(mockRegion, times(1)).getRegionService();
	verify(mockRegion, times(1)).keySetOnServer();
	verify(mockRegion, times(1)).getAll(eq(keySetOnServer));
	verify(mockRegion, never()).values();
	verify(mockRegionAttributes, times(1)).getDataPolicy();
	verify(mockRegionAttributes, never()).getPoolName();
	verifyNoInteractions(mockRegionService);
	verifyNoMoreInteractions(mockRegion);
}
 
Example #30
Source File: Example.java    From geode-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws LuceneQueryException {
  // 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, EmployeeData> region =
      cache.<Integer, EmployeeData>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
          .create("example-region");

  insertValues(region);
  query(cache);
  queryNestedObject(cache);
  cache.close();
}