Adding New Nodes Dynamically

It is possible to add new nodes dynamically after a defined deployment is started. New nodes can only be created out of pre-defined services and they can’t include any internal events. In the following code, service1 service is first created similar to the one in Quick Start. Then, at line 19, a new node named n2 is being created out of service1 service. Node.limitedBuilder method returns an instance of Node.LimitedBuilder which then can be further customized by chaining the proper method calls. This builder wouldn’t allow the definition of internal events for the node. However, all the other node configurations are available.

 1public class SampleTest {
 2    protected static ReditRunner runner;
 3    @Test
 4    public void simpleDefinition() throws DeploymentVerificationException, RuntimeEngineException, TimeoutException, WorkspaceException {
 5        Deployment deployment = Deployment.builder("sample-multithread")
 6                // Service Definitions
 7                .withServiceFromJvmClasspath("s1", "target/classes", "**commons-io*.jar")
 8                    .startCommand("java -cp ${REDIT_JVM_CLASSPATH} io.redit.samples.multithread.Main")
 9                    .dockerImageName("redit/sample-multithread")
10                    .dockerFileAddress("../sample-multithread/docker/Dockerfile", true)
11                    .logFile("/var/log/sample1")
12                    .logDirectory("/var/log/samples")
13                    .serviceType(ServiceType.JAVA).and()
14                // Node Definitions
15                .withNode("n1", "s1")
16                .build();
17        ReditRunner runner = ReditRunner.run(deployment);
18        // Adding new nodes to the deployed environment
19        runner.addNode(Node.limitedBuilder("n52", "s1"));
20    }
21}

The current limitation of this capability is that if there is a network partition applied to the current deployment, the new node wouldn’t be included in that network partition. Introduction of new network partitions will include the new node in generating blocking rules for iptables. This limitation will be removed in future releases.