BigMemory 4.3.10 | Product Documentation | BigMemory Max Developer Guide | Bulk Loading | Using the Bulk Load API
 
Using the Bulk Load API
With bulk loading, the API for putting data into BigMemory Max stays the same. Just use cache.put(...), cache.load(...), or cache.loadAll(...). What changes is that there is a special mode that suspends the normal distributed-cache consistency guarantees and provides optimized flushing to the Terracotta Server Array (the L2 cache).
Note:
The initial consistency mode of a cache is set by configuration and cannot be changed programmatically. The bulk-load API should be used for temporarily suspending the configured consistency mode to allow for bulk-load operations. For more information about setting the consistency mode, see "Terracotta Clustering Configuration Elements" in the Configuration Guide for BigMemory Max.
The following are the bulk-load API methods that are available in org.terracotta.modules.ehcache.Cache.
*public boolean isClusterBulkLoadEnabled()
Returns true if a cache is in bulk-load mode (is not consistent) throughout the cluster. Returns false if the cache is not in bulk-load mode (is consistent) anywhere in the cluster.
*public boolean isNodeBulkLoadEnabled()
Returns true if a cache is in bulk-load mode (is not consistent) on the current node. Returns false if the cache is not in bulk-load mode (is consistent) on the current node.
*public void setNodeBulkLoadEnabled(boolean)
Sets a cache's consistency mode to the configured consistency mode (false) or to bulk load (true) on the local node. There is no operation if the cache is already in the mode specified by setNodeBulkLoadEnabled(). When using this method on a nonstop cache, a multiple of the nonstop cache's timeout value applies. The bulk-load operation must complete within that timeout multiple to prevent the configured nonstop behavior from taking effect. For more information on tuning nonstop timeouts, see "Tuning Nonstop Timeouts and Behaviors" in the Configuration Guide for BigMemory Max.
*public void waitUntilBulkLoadComplete()
Waits until a cache is consistent before returning. Changes are automatically batched and the cache is updated throughout the cluster. Returns immediately if a cache is consistent throughout the cluster.
Notes on Bulk-Load Mode
*Consistency cannot be guaranteed because isClusterBulkLoadEnabled() can return false in one node just before another node calls setNodeBulkLoadEnabled(true) on the same cache. Understanding exactly how your application uses the bulk-load API is crucial to effectively managing the integrity of cached data.
*If a cache is not consistent, any ObjectNotFound exceptions that may occur are logged.
*get() methods that fail with ObjectNotFound return null.
*Eviction is independent of consistency mode. Any configured or manually executed eviction proceeds unaffected by a cache's consistency mode.