org.apache.geode.cache.CacheLoaderException Java Examples

The following examples show how to use org.apache.geode.cache.CacheLoaderException. 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: QuoteLoader.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
@Override
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {

  log.info("Loading quote for {}", helper.getKey());
  String quote = quotes.get(helper.getKey());

  try {
    // simulate network delay for a REST call or a database query
    Thread.sleep(100);
    return quote;

  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new CacheLoaderException(e);
  }
}
 
Example #2
Source File: QuoteLoader.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
@Override
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {

  log.info("Loading quote for {}", helper.getKey());
  String quote = quotes.get(helper.getKey());

  try {
    // simulate network delay for a REST call or a database query
    Thread.sleep(100);
    return quote;

  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
    throw new CacheLoaderException(e);
  }
}
 
Example #3
Source File: RepositoryCacheLoader.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Override
public T load(LoaderHelper<ID, T> helper) throws CacheLoaderException {

  try {
    return getRepository().findById(helper.getKey()).orElse(null);
  }
  catch (Exception cause) {
    throw newCacheRuntimeException(() -> String.format(CACHE_LOAD_EXCEPTION_MESSAGE,
        helper.getKey(), getRepository().getClass().getName()), cause);
  }
}
 
Example #4
Source File: RepositoryCacheLoaderUnitTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("all")
public void newCacheRuntimeExceptionIsCorrect() {

	RuntimeException cause = new RuntimeException("TEST");

	CacheRuntimeException cacheRuntimeException = this.cacheLoader.newCacheRuntimeException(() -> "TEST", cause);

	assertThat(cacheRuntimeException).isInstanceOf(CacheLoaderException.class);
	assertThat(cacheRuntimeException.getMessage()).isEqualTo("TEST");
	assertThat(cacheRuntimeException.getCause()).isEqualTo(cause);
}
 
Example #5
Source File: RepositoryCacheLoaderWriterSupport.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public T load(LoaderHelper<ID, T> helper) throws CacheLoaderException {
	return null;
}
 
Example #6
Source File: RepositoryCacheLoader.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
protected CacheRuntimeException newCacheRuntimeException(Supplier<String> messageSupplier, Throwable cause) {
  return new CacheLoaderException(messageSupplier.get(), cause);
}
 
Example #7
Source File: EchoCacheLoader.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Override
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {
	return helper.getKey();
}
 
Example #8
Source File: ProductCacheLoader.java    From spring-data-examples with Apache License 2.0 4 votes vote down vote up
@Override
public Product load(LoaderHelper loaderHelper) throws CacheLoaderException {
	return new Product((long) loaderHelper.getKey(), randomStringName(), randomPrice(), "");
}