use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class LiteMemberMapNearCacheBasicTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(createConfig(nearCacheConfig, false));
HazelcastInstance liteMember = hazelcastFactory.newHazelcastInstance(createConfig(nearCacheConfig, true));
IMap<K, V> memberMap = member.getMap(DEFAULT_NEAR_CACHE_NAME);
IMap<K, V> liteMemberMap = liteMember.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = getMapNearCacheManager(liteMember);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), liteMember, member, new IMapDataStructureAdapter<K, V>(liteMemberMap), new IMapDataStructureAdapter<K, V>(memberMap), true, nearCache, nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class MapNearCacheBasicTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
Config config = getConfig();
config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setNearCacheConfig(nearCacheConfig);
HazelcastInstance[] instances = hazelcastFactory.newInstances(config);
HazelcastInstance member = instances[0];
IMap<K, V> map = member.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = getMapNearCacheManager(member);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), member, new IMapDataStructureAdapter<K, V>(map), true, nearCache, nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class TxnMapNearCacheBasicTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
Config config = getConfig();
config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setNearCacheConfig(nearCacheConfig);
HazelcastInstance[] instances = hazelcastFactory.newInstances(config);
HazelcastInstance member = instances[0];
// this creates the Near Cache instance
member.getMap(DEFAULT_NEAR_CACHE_NAME);
NearCacheManager nearCacheManager = getMapNearCacheManager(member);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
return new NearCacheTestContext<K, V, Data, String>(getSerializationService(member), member, new TransactionalMapDataStructureAdapter<K, V>(member, DEFAULT_NEAR_CACHE_NAME), false, nearCache, nearCacheManager);
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
ClientContext context = getContext();
logger = context.getLoggingService().getLogger(getClass());
NearCacheConfig nearCacheConfig = context.getClientConfig().getNearCacheConfig(name);
NearCacheManager nearCacheManager = context.getNearCacheManager();
IMapDataStructureAdapter<K, V> adapter = new IMapDataStructureAdapter<K, V>(this);
nearCache = nearCacheManager.getOrCreateNearCache(name, nearCacheConfig, adapter);
invalidateOnChange = nearCache.isInvalidatedOnChange();
if (invalidateOnChange) {
addNearCacheInvalidationListener(new ConnectedServerVersionAwareNearCacheEventHandler());
}
}
use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.
the class ClientNearCacheInvalidationTest method setup.
@Before
public void setup() {
hazelcastFactory = new TestHazelcastFactory();
member = hazelcastFactory.newHazelcastInstance(getConfig());
if (MEMBER_COUNT > 1) {
HazelcastInstance[] allMembers = new HazelcastInstance[MEMBER_COUNT];
allMembers[0] = member;
for (int i = 1; i < MEMBER_COUNT; i++) {
allMembers[i] = hazelcastFactory.newHazelcastInstance(getConfig());
}
waitAllForSafeState(allMembers);
}
ClientConfig clientConfig = createClientConfig();
clientConfig.addNearCacheConfig(createNearCacheConfig(inMemoryFormat));
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) HazelcastServerCachingProvider.createCachingProvider(member).getCacheManager();
ICache<Object, String> cache = cacheManager.createCache(DEFAULT_CACHE_NAME, createCacheConfig(inMemoryFormat));
ICache<Object, String> memberCache = member.getCacheManager().getCache(CacheUtil.getPrefixedCacheName(DEFAULT_CACHE_NAME, null, null));
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(DEFAULT_CACHE_NAME));
testContext = new NearCacheTestContext(client, member, cacheManager, memberCacheManager, nearCacheManager, cache, memberCache, nearCache);
// make sure several partitions are populated with data
for (int i = 0; i < 1000; i++) {
testContext.memberCache.put(Integer.toString(i), Integer.toString(i));
}
}
Aggregations