Search in sources :

Example 1 with FilteringClassLoader

use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentExceptionTest method createNodeConfig.

private Config createNodeConfig() {
    Config i2Config = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
    i2Config.setClassLoader(filteringCL);
    return i2Config;
}
Also used : ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader)

Example 2 with FilteringClassLoader

use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.

the class SqlClientCompactQueryTest method setup.

@Before
public void setup() {
    MapConfig mapConfig = new MapConfig("default").setInMemoryFormat(inMemoryFormat);
    Config config = smallInstanceConfig().addMapConfig(mapConfig);
    config.getSerializationConfig().getCompactSerializationConfig().setEnabled(true);
    if (!clusterHaveUserClasses) {
        List<String> excludes = singletonList("example.serialization");
        FilteringClassLoader classLoader = new FilteringClassLoader(excludes, null);
        config.setClassLoader(classLoader);
    }
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
}
Also used : MapConfig(com.hazelcast.config.MapConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader) MapConfig(com.hazelcast.config.MapConfig) Before(org.junit.Before)

Example 3 with FilteringClassLoader

use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.

the class AbstractSplitBrainProtectionFunctionTest method initClockOffsetTest.

/**
 * Sets up the test to use Hazelcast classes off a separate classloader so that the clock offset can be set to any arbitrary
 * value. This is necessary for clock offset tests as {@link Clock} 's offset is initialized
 * in a static context.
 */
protected void initClockOffsetTest(long offsetMillis) {
    System.setProperty(ClockProperties.HAZELCAST_CLOCK_OFFSET, String.valueOf(offsetMillis));
    Thread thread = currentThread();
    tccl = thread.getContextClassLoader();
    filteringClassloader = new FilteringClassLoader(Collections.<String>emptyList(), "com.hazelcast");
    thread.setContextClassLoader(filteringClassloader);
}
Also used : FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader) Thread.currentThread(java.lang.Thread.currentThread)

Example 4 with FilteringClassLoader

use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.

the class CompactFormatIntegrationTest method getConfig.

@Override
protected Config getConfig() {
    Config config = super.smallInstanceConfig();
    config.getMapConfig("test").setInMemoryFormat(inMemoryFormat);
    if (serverDoesNotHaveClasses) {
        List<String> excludes = singletonList("example.serialization");
        FilteringClassLoader classLoader = new FilteringClassLoader(excludes, null);
        config.setClassLoader(classLoader);
    }
    config.getSerializationConfig().getCompactSerializationConfig().setEnabled(true);
    return config;
}
Also used : Config(com.hazelcast.config.Config) FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader)

Example 5 with FilteringClassLoader

use of com.hazelcast.internal.util.FilteringClassLoader in project hazelcast by hazelcast.

the class UserCodeDeploymentBasicTest method testInnerClassFetchedFirst_thenMainClassFetchedFromRemote.

@Test
public void testInnerClassFetchedFirst_thenMainClassFetchedFromRemote() {
    Config i1Config = new Config();
    i1Config.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    Config filteredConfig = new Config();
    FilteringClassLoader filteringCL = new FilteringClassLoader(singletonList("usercodedeployment"), null);
    filteredConfig.setClassLoader(filteringCL);
    filteredConfig.getUserCodeDeploymentConfig().setEnabled(true).setClassCacheMode(classCacheMode);
    HazelcastInstance instanceWithClasses = factory.newHazelcastInstance(i1Config);
    HazelcastInstance instanceWithoutTheClasses = factory.newHazelcastInstance(filteredConfig);
    IMap<Object, Object> map = instanceWithClasses.getMap("test");
    DomainClassWithInnerClass mainDomainObject = new DomainClassWithInnerClass(new DomainClassWithInnerClass.InnerClass(2));
    map.put("main", mainDomainObject);
    DomainClassWithInnerClass.InnerClass innerObject = new DomainClassWithInnerClass.InnerClass(1);
    map.put("inner", innerObject);
    IMap<Object, Object> map2 = instanceWithoutTheClasses.getMap("test");
    map2.get("inner");
    map2.get("main");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) DomainClassWithInnerClass(usercodedeployment.DomainClassWithInnerClass) UserCodeDeploymentConfig(com.hazelcast.config.UserCodeDeploymentConfig) Config(com.hazelcast.config.Config) FilteringClassLoader(com.hazelcast.internal.util.FilteringClassLoader) DomainClassWithInnerClass(usercodedeployment.DomainClassWithInnerClass) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

FilteringClassLoader (com.hazelcast.internal.util.FilteringClassLoader)21 Config (com.hazelcast.config.Config)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 QuickTest (com.hazelcast.test.annotation.QuickTest)13 Test (org.junit.Test)13 UserCodeDeploymentConfig (com.hazelcast.config.UserCodeDeploymentConfig)12 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 ClientUserCodeDeploymentConfig (com.hazelcast.client.config.ClientUserCodeDeploymentConfig)2 MapConfig (com.hazelcast.config.MapConfig)2 BeforeClass (org.junit.BeforeClass)2 DomainClassWithInnerClass (usercodedeployment.DomainClassWithInnerClass)2 AttributeConfig (com.hazelcast.config.AttributeConfig)1 CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)1 SerializationConfig (com.hazelcast.config.SerializationConfig)1 Data (com.hazelcast.internal.serialization.Data)1 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1