All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jsync.app.core.Data Maven / Gradle / Ivy

There is a newer version: 1.10.13
Show newest version
package io.jsync.app.core;

import com.hazelcast.core.*;
import io.jsync.shareddata.impl.SharedSet;

/**
 * Data is the central API for interacting with data in the cluster.
 * 

* To add persistent data you must add the appropriate DataType's to the cluster. */ public class Data { private SharedSet persistentMaps = new SharedSet<>(); private io.jsync.app.core.Cluster cluster; protected Data(Cluster parent) { if (parent == null) { throw new NullPointerException(); } this.cluster = parent; } private HazelcastInstance hazelcast() { return cluster.hazelcast(); } /** * This method returns a Hazelcast IMap from the parameters specified * * @param name the name of the map * @param persistent true for persistent data * @return the IMap associated with the name */ public IMap getMap(String name, boolean persistent) { String identifier = name; if (persistent) { identifier = "persistent." + name; if (!persistentMaps.contains(identifier)) { persistentMaps.add(identifier); // First time it was requested so we shall load it. //loadAll = true; // Temporary } } return hazelcast().getMap(identifier); } /** * This method returns a Hazelcast IMap from the parameters specified * * @param name the name of the IMap * @return the IMap associated with the name */ public IMap getMap(String name) { return getMap(name, false); } /** * This method returns a Hazelcast MultiMap from the parameters specified * * @param name the name of the MultiMap * @return the MultiMap associated with the name */ public MultiMap getMultiMap(String name) { return hazelcast().getMultiMap(name); } /** * This method returns a Hazelcast ISet from the parameters specified * * @param name the name of the ISet * @return the ISet associated with the name */ public ISet getSet(String name) { return hazelcast().getSet(name); } /** * This method returns a Hazelcast IList from the parameters specified * * @param name the name of the IList * @return the IList associated with the name */ public IList getList(String name) { return hazelcast().getList(name); } /** * This method returns a persistent Hazelcast IMap from the parameters specified * * @param name the name of the IMap * @return the IMap associated with the name */ public IMap persistentMap(String name) { return getMap(name, true); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy