Search in sources :

Example 11 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentTest method createClientConfig.

private ClientConfig createClientConfig() {
    ClientConfig config = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addClass("usercodedeployment.IncrementingEntryProcessor");
    config.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
    config.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
    return config;
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig)

Example 12 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientUserCodeDeploymentTest method testWithParentAndChildClassesWorksIndependentOfOrder_parentFirst.

@Test
public void testWithParentAndChildClassesWorksIndependentOfOrder_parentFirst() {
    ClientConfig clientConfig = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addClass(SampleBaseClass.class);
    clientUserCodeDeploymentConfig.addClass(SampleSubClass.class);
    clientConfig.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
    factory.newHazelcastInstance(createNodeConfig());
    factory.newHazelcastClient(clientConfig);
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ClientDomConfigProcessor method handleUserCodeDeployment.

private void handleUserCodeDeployment(Node node) {
    Node enabledNode = getNamedItemNode(node, "enabled");
    boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim());
    ClientUserCodeDeploymentConfig userCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    userCodeDeploymentConfig.setEnabled(enabled);
    for (Node child : childElements(node)) {
        handleUserCodeDeploymentNode(userCodeDeploymentConfig, child);
    }
    clientConfig.setUserCodeDeploymentConfig(userCodeDeploymentConfig);
}
Also used : Node(org.w3c.dom.Node) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig)

Example 14 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class ThreadLeakClientTest method testThreadLeakWhenClientCanNotStartDueToIncorrectUserCodeDeploymentClass.

@Test(expected = HazelcastException.class)
public void testThreadLeakWhenClientCanNotStartDueToIncorrectUserCodeDeploymentClass() {
    Hazelcast.newHazelcastInstance();
    ClientConfig config = new ClientConfig();
    ClientUserCodeDeploymentConfig clientUserCodeDeploymentConfig = new ClientUserCodeDeploymentConfig();
    clientUserCodeDeploymentConfig.addClass("invalid.class.test");
    config.setUserCodeDeploymentConfig(clientUserCodeDeploymentConfig.setEnabled(true));
    Set<Thread> testStartThreads = getThreads();
    try {
        HazelcastClient.newHazelcastClient(config);
    } finally {
        Hazelcast.shutdownAll();
        assertHazelcastThreadShutdown(testStartThreads);
    }
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest) ClientDiscoverySpiTest(com.hazelcast.client.impl.spi.impl.discovery.ClientDiscoverySpiTest)

Example 15 with ClientUserCodeDeploymentConfig

use of com.hazelcast.client.config.ClientUserCodeDeploymentConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method testUserCodeDeploymentConfig.

@Test
public void testUserCodeDeploymentConfig() {
    ClientConfig config = userCodeDeploymentTestClient.getClientConfig();
    ClientUserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
    List<String> classNames = userCodeDeploymentConfig.getClassNames();
    assertFalse(userCodeDeploymentConfig.isEnabled());
    assertEquals(2, classNames.size());
    assertTrue(classNames.contains("SampleClassName1"));
    assertTrue(classNames.contains("SampleClassName2"));
    List<String> jarPaths = userCodeDeploymentConfig.getJarPaths();
    assertEquals(1, jarPaths.size());
    assertTrue(jarPaths.contains("/User/jar/path/test.jar"));
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) ClientUserCodeDeploymentConfig(com.hazelcast.client.config.ClientUserCodeDeploymentConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientUserCodeDeploymentConfig (com.hazelcast.client.config.ClientUserCodeDeploymentConfig)27 Test (org.junit.Test)24 QuickTest (com.hazelcast.test.annotation.QuickTest)23 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)22 ClientConfig (com.hazelcast.client.config.ClientConfig)14 ClientUserCodeDeploymentService (com.hazelcast.client.impl.spi.impl.ClientUserCodeDeploymentService)12 Config (com.hazelcast.config.Config)5 File (java.io.File)3 URL (java.net.URL)3 IncrementingEntryProcessor (usercodedeployment.IncrementingEntryProcessor)3 AttributeConfig (com.hazelcast.config.AttributeConfig)2 UserCodeDeploymentConfig (com.hazelcast.config.UserCodeDeploymentConfig)2 HazelcastException (com.hazelcast.core.HazelcastException)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 DomainClassWithInnerClass (usercodedeployment.DomainClassWithInnerClass)2 ClientDiscoverySpiTest (com.hazelcast.client.impl.spi.impl.discovery.ClientDiscoverySpiTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Node (org.w3c.dom.Node)1 EntryProcessorWithAnonymousAndInner (usercodedeployment.EntryProcessorWithAnonymousAndInner)1 Person (usercodedeployment.Person)1