use of com.hazelcast.config.UserCodeDeploymentConfig in project hazelcast by hazelcast.
the class CacheTypesConfigTest method cacheConfigShouldBeAddedOnJoiningMember_whenKVTypesAvailableViaUserCodeDeployment.
// When the joining member is not aware of key or value class but it is later resolvable via user code deployment, then
// all Cache features should work
@Test
public void cacheConfigShouldBeAddedOnJoiningMember_whenKVTypesAvailableViaUserCodeDeployment() {
// create a HazelcastInstance with a CacheConfig referring to a Class resolvable via user code deployment
Config config = getConfig();
UserCodeDeploymentConfig codeDeploymentConfig = new UserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(OFF).setWhitelistedPrefixes("classloading");
config.setUserCodeDeploymentConfig(codeDeploymentConfig);
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
CachingProvider cachingProvider = createServerCachingProvider(hz1);
cachingProvider.getCacheManager().createCache(cacheName, createCacheConfig());
// joining member cannot resolve Person class but it is resolvable on other member via user code deployment
Config joiningMemberConfig = getClassFilteringConfig();
joiningMemberConfig.setUserCodeDeploymentConfig(codeDeploymentConfig);
HazelcastInstance hz2 = factory.newHazelcastInstance(joiningMemberConfig);
assertClusterSize(2, hz1, hz2);
ICache<String, Person> testCache = hz1.getCacheManager().getCache(cacheName);
String key = generateKeyOwnedBy(hz2);
testCache.put(key, new Person());
testCache.invoke(key, new PersonEntryProcessor());
assertNotNull(testCache.get(key));
}
use of com.hazelcast.config.UserCodeDeploymentConfig in project hazelcast by hazelcast.
the class Node method getConfigClassloader.
private static ClassLoader getConfigClassloader(Config config) {
UserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
ClassLoader classLoader;
if (userCodeDeploymentConfig.isEnabled()) {
ClassLoader parent = config.getClassLoader();
final ClassLoader theParent = parent == null ? Node.class.getClassLoader() : parent;
classLoader = doPrivileged(new PrivilegedAction<UserCodeDeploymentClassLoader>() {
@Override
public UserCodeDeploymentClassLoader run() {
return new UserCodeDeploymentClassLoader(theParent);
}
});
} else {
classLoader = config.getClassLoader();
}
return classLoader;
}
use of com.hazelcast.config.UserCodeDeploymentConfig in project hazelcast by hazelcast.
the class Node method getConfigClassloader.
private ClassLoader getConfigClassloader(Config config) {
UserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
ClassLoader classLoader;
if (userCodeDeploymentConfig.isEnabled()) {
ClassLoader parent = config.getClassLoader();
final ClassLoader theParent = parent == null ? Node.class.getClassLoader() : parent;
classLoader = doPrivileged(new PrivilegedAction<UserCodeDeploymentClassLoader>() {
@Override
public UserCodeDeploymentClassLoader run() {
return new UserCodeDeploymentClassLoader(theParent);
}
});
} else {
classLoader = config.getClassLoader();
}
return classLoader;
}
use of com.hazelcast.config.UserCodeDeploymentConfig in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method handleUserCodeDeployment.
private void handleUserCodeDeployment(Node dcRoot) {
UserCodeDeploymentConfig dcConfig = config.getUserCodeDeploymentConfig();
Node attrEnabled = getNamedItemNode(dcRoot, "enabled");
boolean enabled = getBooleanValue(getTextContent(attrEnabled));
dcConfig.setEnabled(enabled);
for (Node n : childElements(dcRoot)) {
String name = cleanNodeName(n);
if (matches("class-cache-mode", name)) {
UserCodeDeploymentConfig.ClassCacheMode classCacheMode = UserCodeDeploymentConfig.ClassCacheMode.valueOf(getTextContent(n));
dcConfig.setClassCacheMode(classCacheMode);
} else if (matches("provider-mode", name)) {
UserCodeDeploymentConfig.ProviderMode providerMode = UserCodeDeploymentConfig.ProviderMode.valueOf(getTextContent(n));
dcConfig.setProviderMode(providerMode);
} else if (matches("blacklist-prefixes", name)) {
dcConfig.setBlacklistedPrefixes(getTextContent(n));
} else if (matches("whitelist-prefixes", name)) {
dcConfig.setWhitelistedPrefixes(getTextContent(n));
} else if (matches("provider-filter", name)) {
dcConfig.setProviderFilter(getTextContent(n));
}
}
config.setUserCodeDeploymentConfig(dcConfig);
}
use of com.hazelcast.config.UserCodeDeploymentConfig in project hazelcast by hazelcast.
the class UserCodeDeploymentService method init.
@Override
public void init(NodeEngine nodeEngine, Properties properties) {
UserCodeDeploymentConfig config = nodeEngine.getConfig().getUserCodeDeploymentConfig();
if (!config.isEnabled()) {
return;
}
ClassLoader parent = nodeEngine.getConfigClassLoader().getParent();
Filter<String> classNameFilter = parseClassNameFilters(config);
Filter<Member> memberFilter = parseMemberFilter(config.getProviderFilter());
ConcurrentMap<String, ClassSource> classMap = new ConcurrentHashMap<String, ClassSource>();
ConcurrentMap<String, ClassSource> clientClassMap = new ConcurrentHashMap<String, ClassSource>();
UserCodeDeploymentConfig.ProviderMode providerMode = config.getProviderMode();
ILogger providerLogger = nodeEngine.getLogger(ClassDataProvider.class);
provider = new ClassDataProvider(providerMode, parent, classMap, clientClassMap, providerLogger);
UserCodeDeploymentConfig.ClassCacheMode classCacheMode = config.getClassCacheMode();
locator = new ClassLocator(classMap, clientClassMap, parent, classNameFilter, memberFilter, classCacheMode, nodeEngine);
enabled = config.isEnabled();
}
Aggregations