Grid Context
-
Grid Context exposes platform's internal APIs to create and access distributed data structures.
-
A very simple interface to access some of the most commonly used powerful distributed collections frameworks
-
Context Variable: grid
A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction.
Interfaces
public Set<Integer> intSet(String name);
public Set<Long> longSet(String name);
public Set<Float> floatSet(String name);
public Set<Double> doubleSet(String name);
public Set<String> stringSet(String name);
public Set<org.json.JSONObject> jsonSet(String name);
public Set<Map<String, Object>> mapSet(String name);
public Set<Object> objSet(String name);
Example
def myset = grid.stringSet("MY_SET_NAME");
myset.add("SOME_VALUE");
Set Builder
More fine grained Set collection can be configured using the builder pattern
Set<Long> myset = grid.setBuilder("MY_LONG_VALUES")
.withCacheMode("REPLICATED")
.withAtomicityMode("TRANSACTIONAL")
.withBackups(2)
.withCollocated(true)
.build();
BlockingQueue , represents a queue which is thread safe to put elements into, and take elements out of from. ... For instance, if a thread tries to take an element and there are none left in the queue, the thread can be blocked until there is an element to take.
Interfaces
public BlockingQueue<Integer> intQueue(String name);
public BlockingQueue<Long> longQueue(String name);
public BlockingQueue<Float> floatQueue(String name);
public BlockingQueue<Double> doubleQueue(String name);
public BlockingQueue<String> stringQueue(String name);
public BlockingQueue<org.json.JSONObject> jsonQueue(String name);
public BlockingQueue<Map<String, Object>> mapQueue(String name);
public BlockingQueue<Object> objQueue(String name);
By default, the above interfaces creates a queue if does not exist with a maximum capacity of 100000 elements. If you want to change the capacity restriction, you can use the below interfaces.
public BlockingQueue<Integer> intQueue(String name, int capacity);
public BlockingQueue<Long> longQueue(String name, int capacity);
public BlockingQueue<Float> floatQueue(String name, int capacity);
public BlockingQueue<Double> doubleQueue(String name, int capacity);
public BlockingQueue<String> stringQueue(String name, int capacity);
public BlockingQueue<org.json.JSONObject> jsonQueue(String name, int capacity);
public BlockingQueue<Map<String, Object>> mapQueue(String name, int capacity);
public BlockingQueue<Object> objQueue(String name, int capacity);
Queue Builder
More fine grained BlockingQueue collection can be configured using the builder pattern
BlockingQueue<org.json.JSONObject> myqueue = grid.queueBuilder("MY_TASKS")
.withCacheMode("REPLICATED")
.withAtomicityMode("TRANSACTIONAL")
.withBackups(2)
.withCollocated(true)
.withCapacity(500)
.build();
Distributed Cache is a memory-only, disk or a hybrid based caching and processing engine which can be used to cache, persist and process big data. It offers various features for Fast Data paradigm like In-memory distributed caching, high performance distributes computations, fault tolerant services, node auto discovery, map-reduce processing, etc.
Interfaces
public Cache<String, Integer> intCache(String name);
public Cache<String, Long> longCache(String name);
public Cache<String, Float> floatCache(String name);
public Cache<String, Double> doubleCache(String name);
public Cache<String, String> stringCache(String name);
public Cache<String, org.json.JSONObject> jsonCache(String name);
public Cache<String, Map<String, Object>> mapCache(String name);
public Cache<String, Object> objCache(String name);
By default, the above interfaces creates the cache if it does not exist with a default atomicity mode ATOMIC
- Atomicity Modes
- ATOMIC
- Specifies atomic-only cache behavior. In this mode distributed transactions and distributed locking are not supported. Disabling transactions and locking allows to achieve much higher performance and throughput ratios.
- TRANSACTIONAL
- Enables fully ACID-compliant transactional cache behavior for the key-value API.
Below interfaces can be used to create caches with a specific atomicity
public Cache<String, Integer> intCache(String name, String atomicity);
public Cache<String, Long> longCache(String name, String atomicity);
public Cache<String, Float> floatCache(String name, String atomicity);
public Cache<String, Double> doubleCache(String name, String atomicity);
public Cache<String, String> stringCache(String name, String atomicity);
public Cache<String, org.json.JSONObject> jsonCache(String name, String atomicity);
public Cache<String, Map<String, Object>> mapCache(String name, String atomicity);
public Cache<String, Object> objCache(String name, String atomicity);
Cache Builder
More fine grained Cache collection can be configured using the builder pattern
Cache<String, org.json.JSONObject> mycache = grid.cacheBuilder("MY_CONFIGS")
.withCacheMode("REPLICATED")
.withAtomicityMode("TRANSACTIONAL")
.withBackups(2)
.withCollocated(true)
.withKeyClass(String.class)
.withValueClass(org.json.JSONObject.class)
.build();
Distributed atomic sequence provided by IgniteCacheAtomicSequence interface is similar to distributed atomic long, but its value can only go up. It also supports reserving a range of values to avoid costly network trips or cache updates every time a sequence must provide a next value. That is, when you perform incrementAndGet() (or any other atomic operation) on an atomic sequence, the data structure reserves ahead a range of values, which are guaranteed to be unique across the cluster for this sequence instance.
Interfaces
public IgniteAtomicSequence sequence(String name);
public IgniteAtomicSequence sequence(String name, long initVal);
public IgniteAtomicSequence sequence(String name, long initVal, boolean create);
Sequence Builder
More fine grained sequence can be configured using the builder pattern
IgniteAtomicSequence idegen = grid.sequenceBuilder("UNIQUEUE_ID_SEQUENCE")
.withReserveSize(100)
.withBackups(2)
.withInitVal(100000)
.withCacheMode("REPLICATED")
.build();
Interfaces
//Get or create AtomicLong with initial value as 0
public IgniteAtomicLong atomicLong(String name);
//Get or create AtomicLong with initial value specified
public IgniteAtomicLong atomicLong(String name, long initVal);
Interfaces
//Gets or create IgniteCountDownLatch with initial value 0 and auto delete option true
public IgniteCountDownLatch countDownLatch(String name);
//Gets or create IgniteCountDownLatch with initial value specified and auto delete option true
public IgniteCountDownLatch countDownLatch(String name, int cnt);
//Gets or create IgniteCountDownLatch with initial and auto delete options specified
public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel);
Interfaces
//Gets or create Lock with failover, fairness and create if not exists as true
public IgniteLock lock(String name) ;
//Gets or create Lock with failover arg and fairness and create if not exists as true
public IgniteLock lock(String name, boolean failoverSafe) ;
//Gets or create Lock with failover & fairness args and create if not exists as true
public IgniteLock lock(String name, boolean failoverSafe, boolean fair);
//Gets or create Lock with failover, fairness and create if not exists arguments
public IgniteLock lock(String name, boolean failoverSafe, boolean fair, boolean create);
Interfaces
// Gets or create IgniteSemaphore with count as 1 and failover and create flags true
public IgniteSemaphore semaphore(String name);
// Gets or create IgniteSemaphore with count specified and failover and create flags true
public IgniteSemaphore semaphore(String name, int cnt) ;
// Gets or create IgniteSemaphore with count, failover specified and create flag true
public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe);
// Gets or create IgniteSemaphore with count, failover and create arguments specified
public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create);
Updated about 3 years ago