## Simple Tutorial for using ReDaC (Redeployment and Reconfiguration)

Prerequisite:
Before you proceed further, please read the step-by-step tutorial page first.
Note:

- ReDaC is a middleware service provided by the DAnCE framework.
- ReDaC service is used for redeployment and/or reconfiguration of your running component-based application on the fly without shutting down your application.
- ReDaC currently works for CIAO QoS-enabled component middleware only.

## Example Description

We will use the Hello example to illustrate how one could use ReDaC service to perform redeployment and reconfiguration.

### Initial Deployment

Below steps are required for the initial deployment of your application, which is performed by DAnCE. The below steps are different from those presented in the step-by-step tutorial page in the sense that we pass different command line options to the Plan_Launcher client:

- Go into the descriptors directory Start NodeManagers (NodeDameons) by running `run_NodeDaemons.pl`

- This step is the same as the one presented in the step-by-step tutorial page.

- Start the execution manager: `$CIAO_ROOT/DAnCE/ExecutionManager/Execution_Manager -o EM.ior -i NodeManagerMap.dat`

- As one can see, we use the "NodeManagerMap.dat" file to instruct the Execution_Manager how to find the endpoint of each individual NodeManager (i.e., Node Daemon) where component(s) will be deployed.

- This step is the same as the one presented in the step-by-step tutorial page.

- Start the plan launcher: `$CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -p flattened_deploymentplan_without_ns.cdp -k file://EM.ior -o DAM.ior`

- After this, components should be deployed successfully.
- This step is different from the one presented in the step-by-step tutorial page in the way that we added an additional "`-o`" option when running `Plan_Launcher`, which dumps an IOR file of DAnCE's DomainApplicationManager. With this option added, the `plan_launcher` will exit immediately after the application is deployed, instead of staying in the interactive mode. (As a normal user, you don't need to worry about the details of what exactly a DomainApplicationManager is.)

### Redeployment and Reconfiguration

Basically, you could use ReDaC service in two ways.

1. Use ReDaC service directly through DAnCE's Plan_Launcher client
2. Use ReDaC service programmatically by writing your own client

This tutorial illustrates how exactly you could use ReDaC.
Use ReDaC service through Plan_Launcher of DAnCE:

- As we've already mentioned, you should first deploy your Hello application with DAnCE, which is described in the above "Initial Deployment" section of this tutorial.``

- Use ReDaC service through `Plan_Launcher`'s "-r" command line option to perform redeployment and reconfiguration.
  Run the command `$CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -r flattened_deploymentplan_without_ns_add.cdp` will add additional components to the existing running assembly.

- Run the command `$CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -r flattened_deploymentplan_without_ns_remove.cdp` will remove components from the existing running assembly.

- Run the command ```$CIAO_ROOT/DAnCE/Plan_Launcher/plan_launcher -i file://DAM.ior` will tear down your entire application completely.

NOTE: By using ReDaC through Plan_Launcher, as a user you must provide a new DeploymentPlan (.cdp) XML file, which captures the new deployment and configuration settings of your application, and the Plan_UUID of the new DeploymentPlan should be the same as the one of the old (running) DeploymentPlan. Otherwise, DAnCE will think you want to deploy a totally different deployment plan, instead of applying some changes to the existing plan. One could use CoSMIC MDD tool to create such a deployment plan XML file.
Use ReDaC service programmatically:

You could also use ReDaC service programmatically by writing your own client to invoke ReDaC service. Basically, to accomplish this, your client program needs to:

1. Obtain the `ExecutionManager` object reference, either through naming service or through IOR file.
2. Invoke the operation `perform_redeployment` on this interface by passing a single argument type called `DeploymentPlan`.

The IDL signature of this operation is as follows:
`
void perform_redeployment (in DeploymentPlan new_plan)
raises (PlanError,
InstallationFailure,
UnknownImplId,
ImplEntryPointNotFound,
InvalidConnection,
InvalidProperty,
::Components::RemoveFailure);`
In order to simplify the creation of a the `"new_plan",` we are implementing a utility class which allows a developer to easily manipulate a deployment plan data structure.

Email: