Gemfire Pdx Serialization Put All

389 Views Asked by At

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

1

There are 1 best solutions below

3
On

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