org.apache.geode.cache.CacheFactory Java Examples

The following examples show how to use org.apache.geode.cache.CacheFactory. 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: GeodeEmbeddedPolicy.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Override public void afterAll(ExtensionContext context) {
  if (launcher.status().getStatus() == AbstractLauncher.Status.ONLINE) {
    CacheFactory.getAnyInstance().close();
  }

  final Path pidFile = Paths.get(launcher.getWorkingDirectory()).resolve("vf.gf.server.pid");
  launcher.stop();

  if (Files.exists(pidFile)) {
    // delete PID file. Otherwise ("next") geode instance complains about existing process
    try {
      Files.delete(pidFile);
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }
}
 
Example #2
Source File: GeodeExtension.java    From immutables with Apache License 2.0 6 votes vote down vote up
@Override
public void close() {
  if (launcher.status().getStatus() == AbstractLauncher.Status.ONLINE) {
    CacheFactory.getAnyInstance().close();
  }

  final Path pidFile = Paths.get(launcher.getWorkingDirectory()).resolve("vf.gf.server.pid");
  launcher.stop();

  if (Files.exists(pidFile)) {
    // delete PID file. Otherwise ("next") geode instance complains about existing process
    try {
      Files.delete(pidFile);
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }
}
 
Example #3
Source File: SimpleCacheResolver.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
/**
 * Attempts to resolve an {@link Optional} {@link Cache} instance.
 *
 * @return an {@link Optional} {@link Cache} instance.
 * @see org.springframework.geode.util.CacheUtils#isPeerCache(RegionService)
 * @see org.apache.geode.cache.CacheFactory#getAnyInstance()
 * @see org.apache.geode.cache.Cache
 * @see java.util.Optional
 */
public Optional<Cache> resolvePeerCache() {

	try {
		return Optional.ofNullable(CacheFactory.getAnyInstance())
			.filter(CacheUtils::isPeerCache);
	}
	catch (Throwable ignore) {
		return Optional.empty();
	}
}
 
Example #4
Source File: SimplePeerCacheResolverIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void createPeerCache() {
	peerCache = new CacheFactory().create();
	assertThat(peerCache).isNotNull();
}
 
Example #5
Source File: GeodeEmbeddedPolicy.java    From calcite with Apache License 2.0 4 votes vote down vote up
/**
 * Returns current cache instance which was initialized for tests.
 * @throws IllegalStateException if server process didn't start
 */
Cache cache() {
  requireStatus(AbstractLauncher.Status.ONLINE);
  return CacheFactory.getAnyInstance();
}
 
Example #6
Source File: GeodeExtension.java    From immutables with Apache License 2.0 4 votes vote down vote up
/**
 * Returns current cache instance which was initialized for tests.
 * @throws IllegalStateException if server process didn't start
 */
Cache cache() {
  requireStatus(AbstractLauncher.Status.ONLINE);
  return CacheFactory.getAnyInstance();
}