/** * Constructs and initializes an {@link RuntimeException} with the given {@link String message} * and {@link Object arguments} used to format the message. * * @param message {@link String} describing the {@link RuntimeException exception}. * @param args array of {@link Object arguments} used to replace format placeholders in the {@link String message}. * @return a new {@link RuntimeException} with the given {@link String message}. * @see #newRuntimeException(Throwable, String, Object...) * @see java.lang.RuntimeException */ public static RuntimeException newRuntimeException(String message, Object... args) { return newRuntimeException(null, message, args); }
/** * Constructs and initializes an {@link RuntimeException} with the given {@link String message} * and {@link Object arguments} used to format the message. * * @param message {@link String} describing the {@link RuntimeException exception}. * @param args {@link Object arguments} used to replace format placeholders in the {@link String message}. * @return a new {@link RuntimeException} with the given {@link String message}. * @see #newRuntimeException(Throwable, String, Object...) * @see java.lang.RuntimeException */ public static RuntimeException newRuntimeException(String message, Object... args) { return newRuntimeException(null, message, args); }
/** * Loads the configured data {@link Resource snapshot} into the given {@link Region}. * * @param region {@link Region} to load. * @return the given {@link Region}. * @throws RuntimeException if the snapshot load fails. * @see org.apache.geode.cache.Region#loadSnapshot(InputStream) */ protected Region<K, V> loadSnapshot(Region<K, V> region) { Optional.ofNullable(this.snapshot).ifPresent(snapshot -> { try { region.loadSnapshot(snapshot.getInputStream()); } catch (Exception cause) { throw newRuntimeException(cause, "Failed to load snapshot [%s]", snapshot); } }); return region; }
/** * Loads the configured data {@link Resource snapshot} into the given {@link Region}. * * @param region {@link Region} to load. * @return the given {@link Region}. * @throws RuntimeException if the snapshot load fails. * @see org.apache.geode.cache.Region#loadSnapshot(InputStream) */ protected Region<K, V> loadSnapshot(Region<K, V> region) { Optional.ofNullable(this.snapshot).ifPresent(snapshot -> { try { region.loadSnapshot(snapshot.getInputStream()); } catch (Exception cause) { throw newRuntimeException(cause, "Failed to load snapshot [%s]", snapshot); } }); return region; }
private <T extends GemFireCache> T loadCacheXml(T cache) { // Load cache.xml Resource and initialize the cache Optional.ofNullable(getCacheXml()).ifPresent(cacheXml -> { try { logDebug("Initializing cache with [%s]", cacheXml); cache.loadCacheXml(cacheXml.getInputStream()); } catch (IOException cause) { throw newRuntimeException(cause, "Failed to load cache.xml [%s]", cacheXml); } }); return cache; }
private <T extends GemFireCache> T loadCacheXml(T cache) { // Load cache.xml Resource and initialize the cache Optional.ofNullable(getCacheXml()).ifPresent(cacheXml -> { try { logDebug("Initializing cache with [%s]", cacheXml); cache.loadCacheXml(cacheXml.getInputStream()); } catch (IOException cause) { throw newRuntimeException(cause, "Failed to load cache.xml [%s]", cacheXml); } }); return cache; }
public static void close(boolean throwOnError, Consumer<String> logger) { get().ifPresent(connection -> { try { connection.close(); } catch (ResourceException cause) { String message = String.format("Failed to close Pivotal GemFire Connection: %s", cause.getMessage()); if (throwOnError) { throw newRuntimeException(cause, message); } else { logger.accept(message); } } }); } }
public static void close(boolean throwOnError, Consumer<String> logger) { get().ifPresent(connection -> { try { connection.close(); } catch (ResourceException cause) { String message = String.format("Failed to close GemFire Connection: %s", cause.getMessage()); if (throwOnError) { throw newRuntimeException(cause, message); } else { logger.accept(message); } } }); } }
synchronized GFConnectionFactory resolveGemFireConnectionFactory() { GFConnectionFactory connectionFactory = getGemFireConnectionFactory(); if (connectionFactory == null) { String resolvedGemFireJcaResourceAdapterJndiName = resolveGemFireJcaResourceAdapterJndiName(); try { connectionFactory = this.gemfireConnectionFactory = (GFConnectionFactory) resolveContext().lookup(resolvedGemFireJcaResourceAdapterJndiName); } catch (NamingException cause) { throw newRuntimeException(cause, "Failed to resolve a GFConnectionFactory from the configured JNDI context name [%s]", resolvedGemFireJcaResourceAdapterJndiName); } } return connectionFactory; }
public static GFConnection acquire(GFConnectionFactory connectionFactory, boolean throwOnError, Consumer<String> logger) { try { return of(connectionFactory.getConnection()); } catch (ResourceException cause) { String message = String.format("Failed to acquire GemFire Connection from GemFire's JCA ResourceAdapter: %s", cause.getMessage()); if (throwOnError) { throw newRuntimeException(cause, message); } else { logger.accept(message); return null; } } }
synchronized GFConnectionFactory resolveGemFireConnectionFactory() { GFConnectionFactory connectionFactory = getGemFireConnectionFactory(); if (connectionFactory == null) { String resolvedGemFireJcaResourceAdapterJndiName = resolveGemFireJcaResourceAdapterJndiName(); try { connectionFactory = this.gemfireConnectionFactory = (GFConnectionFactory) resolveContext().lookup(resolvedGemFireJcaResourceAdapterJndiName); } catch (NamingException cause) { throw newRuntimeException(cause, "Failed to resolve a GFConnectionFactory from the configured JNDI context name [%s]", resolvedGemFireJcaResourceAdapterJndiName); } } return connectionFactory; }
public static GFConnection acquire(GFConnectionFactory connectionFactory, boolean throwOnError, Consumer<String> logger) { try { return of(connectionFactory.getConnection()); } catch (ResourceException cause) { String message = String.format("Failed to acquire Pivotal GemFire Connection from GemFire's JCA ResourceAdapter: %s", cause.getMessage()); if (throwOnError) { throw newRuntimeException(cause, message); } else { logger.accept(message); return null; } } }
throw newRuntimeException(cause, "Error occurred when initializing peer cache");
throw newRuntimeException(cause, "Error occurred when initializing peer cache");