Open source IMDG typically provide an SPI or other interface for users to expand themselves. Taking Hazelcast as an example, we can use some playful gadgets to enhance their query,Map , and back-end persistence capabilities. Although these gadgets look small, they are also very powerful.
SQLEnquiry
Josql very simple and easy to use, in just a few steps to implement SQL query on ordinary Java objects, and the standard SQL support is also very comprehensive. The interface is also available, and we can customize the SQL functions we want.
hazelcast to create a new predicate subclass. The query uses our newly created class, hazelcast executes when we send our newly defined apply to each node. Return and summarize the eligible data and return it to us at the end. lang= >hazelcast "en-US" query using josql for where Filter enhancement is easier, but want to take advantage of josql groupby , join and various summary functions to enhance the hazelcast , the change is larger, because hazelcast is designed to make simple filter queries, and return values are objects. To expand it, you may want to take advantage of hazelcast mapreduce and Aggregator interface.
Out-of- heap storage
JDK The direct request for out-of- heap memory is provided by Bytebuffer.allocatedirect(), whose underlying call is the Sun - Private Unsafe.allocatememory(). Because the open source IMDG like hazelcast are one of the main features of the commercial version of the out-of-storage cache data, we need to expand it ourselves. But managing out-of-heap memory is cumbersome and involves managing issues such as free memory allocation, recycling, memory fragmentation, and so on, so we want to use third-party products directly. In this area, there are already some open source products:
   mapdb : Embedded database, providing file and out-of-heap storage, and acid support.
? directmemory:Apache 's Open source project, currently the 0.3 version.
? Other:hugecollections,fast-serialization and so on.
Take mapdb as an example to see how it is used. The integration method with Hazelcast is a little cumbersome and requires the implementation of three Hazelcast classes, which can refer to the project on GitHub :hugecast and Mapdb-hz-offheap.
back-end persistence
When using IMDG , we also typically provide data loading and persistence classes for each object's cache, enabling the caching of initialization loading and Read/write-through functionality. You can simply use Jdbc+dozermap to implement the loading and saving of data and the assembly of solid objects, or use Hibernate to simplify the process. Each IMDG provides a corresponding extension interface, such as the hazelcast extension point is maploader or Mapstore, the implementation of the method is very simple is not listed.
IMDG Product Feature Extensions