Example: Reloading a map with the ClientLoader interface
Reloading a map is the same as preloading a map, except that the isPreload argument is set to false in the ClientLoader.load method.
Client-based reload example
The following sample shows how to reload maps. Compared to the preload sample, the main difference is that a loadSql and parameters are provided. This sample only reloads the Customer data with an ID between 1000 and 2000. The isPreload parameter on the load method is set to false.// Get the StateManager
StateManager stateMgr = StateManagerFactory.getStateManager();
// Set ObjectGrid state to PRELOAD before calling ClientLoader.loader
stateMgr.setObjectGridState(AvailabilityState.PRELOAD, objectGrid);
ClientLoader c = ClientLoaderFactory.getClientLoader();
// Load the data
String loadSql = "select c from CUSTOMER c
where c.custId >= :startCustId and c.custId < :endCustId ";
Map<String, Long> params = new HashMap<String, Long>();
params.put("startCustId", 1000L);
params.put("endCustId", 2000L);
c.load(objectGrid, "CUSTOMER", "customerPU", null, null,
loadSql, params, false, null);
// Set ObjectGrid state back to ONLINE
stateMgr.setObjectGridState(AvailabilityState.ONLINE, objectGrid);
Remember: This query string observes both JPA query syntax and eXtreme Scale entity query syntax.
This query string is important because it runs twice: to invalidate
the matched ObjectGrid entities and to load the matched JPA entities.