Search code examples
gemfirespring-data-gemfire

It takes a long time to connect to a GemFire server in my application


I am setting up the spring-data-gemfire in my project at my workplace. However, it takes a long time to connect to a GemFire server and retrieve the data from my application.

2020-Mar-13 09:00:10 | TRACE | annotation.ScheduledAnnotationPostProcessor | No @Scheduled annotations found on bean class: class org.springframework.gemfire.client.CLientCacheFactoryBean
2020-Mar-13 09:00:10 | TRACE | support.DefaultListableBeanFactory |Finished creating instance of bean 'gemfireCache'
2020-Mar-13 09:00:42 | TRACE | internal.ClassPathLoader | getResource(gemfire.properties)
2020-Mar-13 09:00:42 | TRACE | internal.ClassPathLoader | getResource trying: sun.misc.Launcher$AppClassLoader@73d16e93
2020-Mar-13 09:00:42 | TRACE | internal.ClassPathLoader | getResource trying: java.net.Launcher$AppClassLoader@73d16e93
.....

May I know why it takes more than 40 secs from "Finished creating instance of bean.." to "getResource.." ?

Current Versions

  1. Spring Data GemFire 2.2.1.RELEASE
  2. Spring Boot 2.2.1.RELEASE
  3. 3 Server and 2 Locator (Installed at virtual Machine)
  4. Private Local Network
  5. Using Java Serialization
  6. Using Caching Proxy for my client

When i try a simple gemfire application at my home, it took around 5 seconds.

[TRACE] 2020-03-14 16:54:58.623 [main] CachedIntrospectionResults - Found bean property 'propertiesPersister' of type [org.springframework.util.PropertiesPersister]
[TRACE] 2020-03-14 16:54:58.623 [main] CachedIntrospectionResults - Found bean property 'singleton' of type [boolean]
[TRACE] 2020-03-14 16:54:58.626 [main] TypeConverterDelegate - Converting String to [class [Lorg.springframework.core.io.Resource;] using property editor [org.springframework.core.io.support.ResourceArrayPropertyEditor@669253b7
[TRACE] 2020-03-14 16:54:58.627 [main] PathMatchingResourcePatternResolver - Resolved classpath location [META-INF/gemfire-named-queries.properties] to resources []
[TRACE] 2020-03-14 16:54:58.627 [main] DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name '(inner bean)#6cc0bcf6'
[TRACE] 2020-03-14 16:54:58.628 [main] DefaultListableBeanFactory - Finished creating instance of bean '(inner bean)#6cc0bcf6'
[TRACE] 2020-03-14 16:54:58.630 [main] DefaultListableBeanFactory - Finished creating instance of bean '(inner bean)#1a6f5124'
[TRACE] 2020-03-14 16:54:58.631 [main] DefaultListableBeanFactory - Creating instance of bean '(inner bean)#49a64d82'
[TRACE] 2020-03-14 16:54:58.635 [main] DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name '(inner bean)#49a64d82'
[TRACE] 2020-03-14 16:54:58.635 [main] DefaultListableBeanFactory - Finished creating instance of bean '(inner bean)#49a64d82'
[TRACE] 2020-03-14 16:54:58.636 [main] DefaultListableBeanFactory - Returning cached instance of singleton bean 'gemfireCache'
[TRACE] 2020-03-14 16:55:03.415 [main] ClassPathLoader - getResource(gemfire.properties)
[TRACE] 2020-03-14 16:55:03.418 [main] ClassPathLoader - getResource trying: sun.misc.Launcher$AppClassLoader@73d16e93
[TRACE] 2020-03-14 16:55:03.418 [main] ClassPathLoader - getResource trying: java.net.URLClassLoader@1500e009
[TRACE] 2020-03-14 16:55:03.418 [main] ClassPathLoader - getResource(gfsecurity.properties)
[TRACE] 2020-03-14 16:55:03.419 [main] ClassPathLoader - getResource trying: sun.misc.Launcher$AppClassLoader@73d16e93
[TRACE] 2020-03-14 16:55:03.419 [main] ClassPathLoader - getResource trying: java.net.URLClassLoader@1500e009
[TRACE] 2020-03-14 16:55:03.429 [main] ClassPathLoader - forName(org.apache.logging.log4j.core.impl.Log4jContextFactory)
[TRACE] 2020-03-14 16:55:03.429 [main] ClassPathLoader - forName trying: sun.misc.Launcher$AppClassLoader@73d16e93
[TRACE] 2020-03-14 16:55:03.429 [main] ClassPathLoader - forName found by: sun.misc.Launcher$AppClassLoader@73d16e93 2020-03-14 16:55:03,432 main INFO Log4j Core is available and using Log4jProvider
[TRACE] 2020-03-14 16:55:03.434 [main] ClassPathLoader - forName(org.apache.geode.internal.logging.log4j.Log4jAgent)
[TRACE] 2020-03-14 16:55:03.434 [main] ClassPathLoader - forName trying: sun.misc.Launcher$AppClassLoader@73d16e93
[TRACE] 2020-03-14 16:55:03.435 [main] ClassPathLoader - forName found by: sun.misc.Launcher$AppClassLoader@73d16e93 020-03-14 16:55:03,436 main INFO Using org.apache.geode.internal.logging.log4j.Log4jAgent by default for service org.apache.geode.internal.logging.ProviderAgent
[TRACE] 2020-03-14 16:55:03.848 [main] ThreadContext - get() - in thread [main]
[DEBUG] 2020-03-14 16:55:03.854 [main] geode - LogWriter is created.
[DEBUG] 2020-03-14 16:55:03.854 [main] security - SecurityLogWriter is created.
[TRACE] 2020-03-14 16:55:03.858 [main] ClassPathLoader - getResource(org/apache/geode/internal/GemFireVersion.properties)
[TRACE] 2020-03-14 16:55:03.858 [main] ClassPathLoader - getResource trying: sun.misc.Launcher$AppClassLoader@73d16e93
[TRACE] 2020-03-14 16:55:03.858 [main] ClassPathLoader - getResource found by: sun.misc.Launcher$AppClassLoader@73d16e93

My Simple gemfire application

@SpringBootApplication
@ClientCacheApplication(locators = {@ClientCacheApplication.Locator(host = "192.167.0.5", port = 10311) }, socketBufferSize = 90000, subscriptionEnabled = true)
@EnableEntityDefinedRegions(basePackageClasses = Person.class, clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY)
@EnableGemfireRepositories(basePackageClasses = PersonRepository.class)
public class Application {

Solution

  • In some cases it may simply be that you're having DNS lookup issues - especially since performance seems to be different between your home and other location(s).

    You can try this:

    Get your hostname using the hostname command. Add this as an alias to your /etc/hosts file for 127.0.0.1. For example if your hostname looks something like foobar.local then your /etc/hosts should be adjusted to include this:

    127.0.0.1   localhost  foobar foobar.local
    

    Notice that I added both the FQDN (including .local as returned by hostname) as well as the shorter version.