2

Is it normal that a client application took a longer time to insert data into GemFire Cluster for the first time? For example, my client application took around 4 seconds to insert GemFire Cluster successfully. However , the subsequent insert only took around 1 second. May i know what is the reason behind it?

Client Application Log File

@Configuration
@EnablePool(name = "sgpool", socketBufferSize = 1000000, prSingleHopEnabled = true, idleTimeout = 10000)
public class RegionConfiguration {

@Bean("People")
public ClientRegionFactoryBean<String, Person> customersRegion(GemFireCache gemfireCache) {
    ClientRegionFactoryBean<String, Person> customersRegion = new ClientRegionFactoryBean<>();
    customersRegion.setCache(gemfireCache);
    customersRegion.setClose(false);
    customersRegion.setPoolName("sgpool");
    customersRegion.setShortcut(ClientRegionShortcut.CACHING_PROXY);
    return customersRegion;
  }
}

@ClientCacheApplication
@EnablePdx
@Service
@EnableGemfireRepositories(basePackageClasses = PersonRepository.class)
@Import(RegionConfiguration.class)
public class PersonDataAccess {

@Autowired
@Qualifier("People")
private Region<String, Person> peopleRegion;

@Autowired
private PersonRepository personRepository;

@PostConstruct
public void init() {
    peopleRegion.registerInterestForAllKeys();
}

public void saveAll(Iterable<Person> iteratorList) {
    personRepository.saveAll(iteratorList);
 }
}

@Service
@EnableScheduling
@Log4j2
public class PersonService {

@Autowired
public PersonDataAccess personDataAccess;

private Person createPerson(String ic, int age) {
    return new Person(ic, "Jack - " + age, "Kay - " + age, LocalDate.of(2000, 12, 10), age, 2,
            new Address("Jack Wonderful Land 12", "Wonderful Land", "Wonderful 101221"), "11111", "22222", "33333",
            "Dream", "Space");
}

@Scheduled(fixedDelay = 1000, initialDelay = 5000)
public void testSaveRecord() {
    ArrayList<Person> personList = new ArrayList<>();
    for (int counter = 0; counter < 30000; counter++) {
        personList.add(createPerson("S2011" + counter, counter));
    }
    log.info("start saving person");
    personDataAccess.saveAll(personList);
    log.info("Complete saving all the message");
}
}

GemFire Configuration:

  1. Using PDX Serialization
  2. 1 Locator and Cache Server (GemFire 9.10.5
  3. Partition Region
  4. Client Application (Using Spring Data GemFire 2.3.4)

Thank you so much

Jack
  • 89
  • 6
  • I think the “caching PDX type” gives it away. Maybe there is a cache synchronisation check between client cache PDX types registry and server cache PDX types registry and if there’s a mismatch then there is a PDX cache registry mechanism sync.... – rupweb Dec 08 '20 at 19:25
  • I don't know is it due to synchronization check for pdx type between client and server. However, i did not use persistent region or store pdx in the GemFire Server. The GemFire Server was having "fresh start" before i run the client application – Jack Dec 10 '20 at 06:55

1 Answers1

1

Clearly the 1st time there’s a PDX cache register process going on between client and server kind of like

client server event distribution

The register process does not need to happen 2nd time because it’s now setup.

The PDX registration process is explained more here where it says: Geode maintains a central registry of the PDX domain object metadata.

There must be a way to get the region setup done before your 1st insert, so that each insert is the same.

Maybe this could help

rupweb
  • 3,052
  • 1
  • 30
  • 57
  • I am using Spring Data GemFire's MappingPdxSerializer, As a result, i don't need to implements the PDX serialization. I created a ClientRegionFactoryBean customersRegion bean. I also thinking whether it is PDX registration process. However, i don't know how to start the process earlier. – Jack Dec 10 '20 at 09:52
  • Try `@Resource private Region myRegion;` – rupweb Dec 10 '20 at 11:47
  • I tried @Resource(name = "People") private Region peopleRegion; .. still the same result. – Jack Dec 10 '20 at 14:39