summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2010-02-23 14:12:38 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2010-02-23 14:12:38 +0000
commit477ba8279cb5d465a32f5097996244457dd3a328 (patch)
tree2ec80b8a75ac2a66a749f37334bcf9dd580d63d9
parent23d08c2fdb4f63c7959327c5e33c27aa870f6479 (diff)
downloadATCD-477ba8279cb5d465a32f5097996244457dd3a328.tar.gz
Tue Feb 23 14:08:20 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
-rw-r--r--CIAO/ChangeLog35
-rw-r--r--CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc3
-rw-r--r--CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp207
-rw-r--r--CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h7
-rw-r--r--CIAO/DAnCE/MPC/config/dance_convert_plan.mpb5
-rw-r--r--CIAO/DAnCE/MPC/config/dance_split_plan.mpb4
-rw-r--r--CIAO/DAnCE/MPC/config/dance_tools.mpb3
-rw-r--r--CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp129
-rw-r--r--CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc18
-rw-r--r--CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp168
-rw-r--r--CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h26
-rw-r--r--CIAO/DAnCE/tools/Split_Plan/DAnCE_Split_Plan_export.h58
-rw-r--r--CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp144
-rw-r--r--CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc17
-rw-r--r--CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp247
-rw-r--r--CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.h34
16 files changed, 896 insertions, 209 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog
index ca26cdb56c7..79a777b55ae 100644
--- a/CIAO/ChangeLog
+++ b/CIAO/ChangeLog
@@ -1,3 +1,38 @@
+Tue Feb 23 14:08:20 UTC 2010 William R. Otte <wotte@dre.vanderbilt.edu>
+
+ * DAnCE/DomainApplicationManager/DomainApplicationManager.mpc:
+ * DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h:
+ * DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp:
+
+ Use the split plan library instead of internal split plan impl.
+
+ * DAnCE/MPC/config/dance_convert_plan.mpb:
+ * DAnCE/MPC/config/dance_split_plan.mpb:
+ * DAnCE/MPC/config/dance_tools.mpb:
+
+ Base projects for convert_plan/split_plan.
+
+ * DAnCE/tools:
+ * DAnCE/tools/Convert_Plan:
+ * DAnCE/tools/Convert_Plan/Convert_Plan.cpp:
+ * DAnCE/tools/Convert_Plan/Convert_Plan.mpc:
+ * DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h:
+ * DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp:
+
+ Tool allowing validation/conversion of XML deployment plans to
+ CDR.
+
+ * DAnCE/tools/Split_Plan:
+ * DAnCE/tools/Split_Plan/DAnCE_Split_Plan_export.h:
+ * DAnCE/tools/Split_Plan/Split_Plan.mpc:
+ * DAnCE/tools/Split_Plan/Split_Plan.cpp:
+ * DAnCE/tools/Split_Plan/Split_Plan_impl.h:
+ * DAnCE/tools/Split_Plan/Split_Plan_impl.cpp:
+
+ Tool allowing users to split plans into locality constrained
+ partitions. Also contains important bugfixes for process
+ colocation.
+
Tue Feb 23 13:40:49 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
* bin/ciao_tests.lst:
diff --git a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc
index 6135df1f966..a01b3ad421b 100644
--- a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc
+++ b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager.mpc
@@ -1,7 +1,8 @@
// -*- MPC -*-
// $Id$
-project : dance_lib, dance_output, dance_domainapplicationmanager_skel, dance_domainapplication, dance_nodemanager_stub, naming {
+project : dance_lib, dance_output, dance_domainapplicationmanager_skel, \
+ dance_domainapplication, dance_nodemanager_stub, naming, dance_split_plan {
sharedname = DAnCE_DomainApplicationManager
dynamicflags = DOMAINAPPLICATIONMANAGER_BUILD_DLL
diff --git a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp
index 9c8ee8a5f98..a70568b07da 100644
--- a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp
+++ b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.cpp
@@ -186,204 +186,6 @@ DomainApplicationManager_Impl::getPlan ()
}
void
-DomainApplicationManager_Impl::split_plan (const Deployment::DeploymentPlan & plan,
- TNodePlans & sub_plans)
-{
- DANCE_TRACE ( "DomainApplicationManager_Impl::split_plan");
-
- DANCE_DEBUG (9, (LM_TRACE, ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Creating sub-plans\n")));
- // Create empty sub-plans
- for (CORBA::ULong i = 0; i < plan.instance.length(); ++i)
- {
- ACE_CString node = plan.instance[i].node.in();
- if (0 == sub_plans.find (node)) continue;
-
- ::Deployment::DeploymentPlan tmp_plan;
-
- // Construct the UUID for the child plan.
- // Currently, this UUID consists of:
- // The global UUID for the parent plan + the name of the node the
- // child plan is to be installed on.
- ACE_CString child_uuid (plan.UUID.in ());
- // child_uuid += "@"; CCM#61
- // child_uuid += node;
-
- tmp_plan.UUID = CORBA::string_dup (child_uuid.c_str());
- tmp_plan.implementation.length (0);
- tmp_plan.instance.length (0);
- tmp_plan.connection.length (0);
- tmp_plan.externalProperty.length (0);
- tmp_plan.dependsOn.length (0);
- tmp_plan.artifact.length (0);
-
- // @@ There is an optimization point here, since we really don't have to
- // pass the entire CIAOServerResources into each individual child plan.
- tmp_plan.infoProperty = plan.infoProperty;
-
- sub_plans.bind (node, tmp_plan);
-
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Created sub-plan for node %C with UUID %C\n"),
- node.c_str (), child_uuid.c_str ()));
- }
-
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("First phase produced %u child plans, proceeding to second\n"),
- sub_plans.current_size ()));
-
- // (1) Iterate over the <instance> field of the global DeploymentPlan
- // structure.
- // (2) Retrieve the necessary information to contruct the node-level
- // plans one by one.
- for (CORBA::ULong i = 0; i < plan.instance.length (); ++i)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Processing instance: %C\n"), plan.instance[i].name.in()));
- // @@TODO Fill in the child deployment plan in the map.
- // If the component instance already exists in the child plan,
- // then we overwrite the existing instance, since the new instance
- // might have different resource usage requirements.
-
- // Get the instance deployment description
- const ::Deployment::InstanceDeploymentDescription & my_instance = plan.instance[i];
-
- // Get the child plan.
- ::Deployment::DeploymentPlan child_plan;
-
- if (0 != sub_plans.find (my_instance.node.in(), child_plan))
- {
- DANCE_ERROR (1, (LM_ERROR, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("ERROR: Unable to find sub-plan for instance %C\n"),
- my_instance.node.in ()));
- }
-
- // Fill in the contents of the child plan entry.
-
- // Append the "MonolithicDeploymentDescriptions implementation"
- // field with a new "implementation", which is specified by the
- // <implementationRef> field of <my_instance> entry. NOTE: The
- // <artifactRef> field needs to be changed accordingly.
- ::Deployment::MonolithicDeploymentDescription const & my_implementation
- = plan.implementation[my_instance.implementationRef];
-
- CORBA::ULong index_imp = child_plan.implementation.length ();
- child_plan.implementation.length (++index_imp);
- child_plan.implementation[index_imp-1] = my_implementation;
-
- // Initialize with the correct sequence length.
- CORBA::ULongSeq ulong_seq;
- ulong_seq.length (my_implementation.artifactRef.length ());
-
- // Append the "ArtifactDeploymentDescriptions artifact" field
- // with some new "artifacts", which is specified by the
- // <artifactRef> sequence of <my_implementation> entry.
- CORBA::ULong const impl_length = my_implementation.artifactRef.length ();
- for (CORBA::ULong iter = 0;
- iter < impl_length;
- iter ++)
- {
- CORBA::ULong artifact_ref = my_implementation.artifactRef[iter];
-
- // Fill in the <artifact> field of the child plan
- CORBA::ULong index_art = child_plan.artifact.length ();
- child_plan.artifact.length (++index_art);
- child_plan.artifact[index_art-1] = plan.artifact[artifact_ref];
-
- // Fill in the artifactRef field of the MonolithicDeploymentDescription
- ulong_seq[iter] = index_art - 1;
- }
-
- // Change the <artifactRef> field of the "implementation".
- child_plan.implementation[index_imp-1].artifactRef = ulong_seq;
-
- // Append the "InstanceDeploymentDescription instance" field with
- // a new "instance", which is almost the same as the "instance" in
- // the global plan except the <implementationRef> field.
- // NOTE: The <implementationRef> field needs to be changed accordingly.
- CORBA::ULong index_ins = child_plan.instance.length ();
- child_plan.instance.length (++index_ins);
- child_plan.instance[index_ins-1] = my_instance;
-
- // Change the <implementationRef> field of the "instance".
- // @@ The implementationRef starts from 0.
- // @@TODO: Below logic needs to be changed once we want to avoid
- // duplicate <implementation> for the optimization.
- child_plan.instance[index_ins-1].implementationRef = index_imp - 1;
-
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Processing connections.\n")));
- // Copy connections
- for (CORBA::ULong j = 0; j < plan.connection.length(); ++j)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("For connection: %C\n"), plan.connection[j].name.in()));
- for (CORBA::ULong k = 0; k < plan.connection[j].internalEndpoint.length(); ++k)
- {
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("For endpoint: %C(%C)\n"),
- plan.connection[j].internalEndpoint[k].portName.in(),
- plan.connection[j].internalEndpoint[k].provider ? "provider" : "client"));
- if (i == plan.connection[j].internalEndpoint[k].instanceRef) // the instance (i) is referenced by the connection
- {
- Deployment::PlanConnectionDescription * connection_copied = 0;
- for (CORBA::ULong m = 0; m < child_plan.connection.length(); ++m)
- {
- if (ACE_OS::strcmp (plan.connection[j].name.in (), child_plan.connection[m].name.in ()) == 0)
- {
- connection_copied = &child_plan.connection[m];
- break;
- }
- }
-
- if (!connection_copied)
- {
- // Copy the connection
- CORBA::ULong const index_con = child_plan.connection.length();
- child_plan.connection.length (index_con + 1);
- child_plan.connection[index_con] = plan.connection[j];
- connection_copied = &child_plan.connection[index_con];
- connection_copied->internalEndpoint.length (0);
- }
-
- // Copy the endpoint
- CORBA::ULong const index_ep = connection_copied->internalEndpoint.length();
-
- DANCE_DEBUG (9, (LM_TRACE, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT ("Copying endpoint %u from connection into endpoint %u\n"),
- k, index_ep));
-
- connection_copied->internalEndpoint.length (index_ep + 1);
- connection_copied->internalEndpoint[index_ep] = plan.connection[j].internalEndpoint[k];
- connection_copied->internalEndpoint[index_ep].instanceRef = index_ins - 1;
- }
- }
- }
- sub_plans.rebind (my_instance.node.in(), child_plan);
- }
-
- //Debug
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO
- ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Original plan connection count: %u\n"), plan.connection.length()));
- CORBA::ULong cnt = 0;
- for (TNodePlans::iterator it = sub_plans.begin(); it != sub_plans.end(); ++it)
- {
- cnt += (*it).int_id_.connection.length();
- }
- DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("DomainApplicationManager_Impl::split_plan - ")
- ACE_TEXT("Child plans connection count: %u\n"), cnt));
-}
-
-void
DomainApplicationManager_Impl::preparePlan()
{
DANCE_TRACE ("DomainApplicationManager_Impl::preparePlan()");
@@ -391,12 +193,13 @@ DomainApplicationManager_Impl::preparePlan()
try
{
// Map of sub plans for each node
- TNodePlans sub_plans;
- // Splitting deployment plan on sub plans for each node
- DomainApplicationManager_Impl::split_plan (this->plan_, sub_plans);
+ Split_Plan::TNodePlans sub_plans;
+ Split_Plan split_plan (this->plan_, sub_plans);
+ split_plan.split_plan ();
+
DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("DomainApplicationManager_Impl::preparePlan - Plan successfully split\n")));
// Executing preparePlan on each NodeManager described in DeploymentPlan
- for (TNodePlans::iterator iter_plans = sub_plans.begin();
+ for (Split_Plan::TNodePlans::iterator iter_plans = sub_plans.begin();
iter_plans != sub_plans.end();
++iter_plans)
{
diff --git a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h
index 5b5b5b7306b..a0515544f9e 100644
--- a/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h
+++ b/CIAO/DAnCE/DomainApplicationManager/DomainApplicationManager_Impl.h
@@ -23,15 +23,13 @@
#include "Deployment/Deployment_NodeManagerC.h"
#include "DomainApplication/Domain_Application_Impl.h"
#include "Deployment/Deployment_DomainApplicationManagerS.h"
+#include "Split_Plan/Split_Plan_impl.h"
namespace DAnCE
{
class DomainApplicationManager_Export DomainApplicationManager_Impl
: public virtual POA_Deployment::DomainApplicationManager
{
- private:
- typedef ACE_Map_Manager<ACE_CString, Deployment::DeploymentPlan, ACE_Null_Mutex> TNodePlans;
-
public:
DomainApplicationManager_Impl (CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
@@ -59,9 +57,6 @@ namespace DAnCE
typedef ACE_Vector<DomainApplication_Impl*> TApplications;
TApplications running_app_;
- void split_plan (const Deployment::DeploymentPlan & plan,
- TNodePlans & sub_plans);
-
void preparePlan();
};
diff --git a/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb b/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb
new file mode 100644
index 00000000000..584c266e6b9
--- /dev/null
+++ b/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb
@@ -0,0 +1,5 @@
+project : dance_config_handlers, dance_deployment_stub, dance_tools {
+ after += DAnCE_Convert_Plan
+ libs += DAnCE_Convert_Plan
+
+}
diff --git a/CIAO/DAnCE/MPC/config/dance_split_plan.mpb b/CIAO/DAnCE/MPC/config/dance_split_plan.mpb
new file mode 100644
index 00000000000..6d85a9b4412
--- /dev/null
+++ b/CIAO/DAnCE/MPC/config/dance_split_plan.mpb
@@ -0,0 +1,4 @@
+project : dance, dance_deployment_stub, dance_tools {
+ after += DAnCE_Split_Plan_Impl
+ libs += DAnCE_Split_Plan_Impl
+}
diff --git a/CIAO/DAnCE/MPC/config/dance_tools.mpb b/CIAO/DAnCE/MPC/config/dance_tools.mpb
new file mode 100644
index 00000000000..2457ef84368
--- /dev/null
+++ b/CIAO/DAnCE/MPC/config/dance_tools.mpb
@@ -0,0 +1,3 @@
+project : dance {
+ includes += $(DANCE_ROOT)/tools
+}
diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp
new file mode 100644
index 00000000000..f8dd0481266
--- /dev/null
+++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp
@@ -0,0 +1,129 @@
+// $Id$
+
+#include "ace/Dynamic_Service.h"
+#include "ace/Get_Opt.h"
+#include "ace/Auto_Ptr.h"
+#include "tao/ORB.h"
+#include "DAnCE/Deployment/Deployment_DeploymentPlanC.h"
+#include "DAnCE/Logger/Log_Macros.h"
+#include "DAnCE/Logger/Logger_Service.h"
+#include "Convert_Plan_Impl.h"
+
+
+const char *input_filename = 0;
+const char *output_filename = 0;
+void
+usage (void)
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("usage: dance_split_plan [options]\n")
+ ACE_TEXT ("Converts a provided plan to CDR. If no output file is nominated, ")
+ ACE_TEXT ("the input XML plan will be validated against schema and the program will exit\n")
+ ACE_TEXT ("\t-x <plan>\t\tXML Encoded input plan\n")
+ ACE_TEXT ("\t-o <file>\t\tOutput destination for converted plan\n")
+ ));
+}
+
+bool
+parse_args (int argc, ACE_TCHAR *argv [])
+{
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT ("dance_split_plan options: ")));
+
+ for (int i = 0; i < argc; ++i)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, ACE_TEXT("\t%s\n"), argv[i]));
+ }
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("x:o:h"), 0);
+
+ int c;
+ ACE_CString s;
+ while ((c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 'x':
+ input_filename = get_opt.opt_arg ();
+ break;
+
+ case 'o':
+ output_filename = get_opt.opt_arg ();
+ break;
+
+ case 'h':
+ usage ();
+ return false;
+ default:
+ usage ();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv [])
+{
+ DANCE_DISABLE_TRACE ();
+
+ int retval = 0;
+
+ try
+ {
+ DAnCE::Logger_Service
+ * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger");
+
+ if (dlf)
+ {
+ dlf->init (argc, argv);
+ }
+
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO
+ ACE_TEXT("Convert_Plan - initializing ORB\n")));
+
+ // Need an ORB for the Config handlers
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ if (!parse_args (argc, argv))
+ {
+ return -1;
+ }
+
+ if (!input_filename)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan - "
+ "No input filename provided\n"));
+ return -1;
+ }
+
+ auto_ptr <Deployment::DeploymentPlan> plan (DAnCE::Convert_Plan::read_xml_plan (input_filename));
+
+ if (!plan.get ())
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan - "
+ "Unable to load an XML based plan\n"));
+ return -1;
+ }
+
+ if (!output_filename)
+ {
+ DANCE_DEBUG (2, (LM_DEBUG, DLINFO "Convert_Plan - "
+ "XML Input file validated correctly with no output file specifed, exiting\n"));
+ return 0;
+ }
+
+ DAnCE::Convert_Plan::write_cdr_plan (output_filename, *plan);
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Convert_Plan");
+ retval = -1;
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, "Convert_Plan - error: unknown c++ exception\n"));
+ retval = -1;
+ }
+
+ return retval;
+}
diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc
new file mode 100644
index 00000000000..63707347fa9
--- /dev/null
+++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc
@@ -0,0 +1,18 @@
+project (DAnCE_Convert_Plan) : dance_lib, dance_output, dance_deployment_stub {
+
+ dynamicflags = DANCE_CONVERT_PLAN_BUILD_DLL
+ includes += $(DANCE_ROOT)/tools
+
+ Source_Files {
+ Convert_Plan_Impl.cpp
+ }
+}
+
+
+project (DAnCE_Convert_Plan_Exec) : dance_exe, dance_output, dance_convert_plan {
+ exename = dance_convert_plan
+
+ Source_Files {
+ Convert_Plan.cpp
+ }
+}
diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp
new file mode 100644
index 00000000000..5932b427714
--- /dev/null
+++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp
@@ -0,0 +1,168 @@
+// $Id$
+
+#include "Convert_Plan_Impl.h"
+#include "ace/FILE_Connector.h"
+#include "tao/CDR.h"
+#include "Config_Handlers/XML_File_Intf.h"
+#include "Logger/Log_Macros.h"
+
+namespace DAnCE
+{
+ Deployment::DeploymentPlan *
+ Convert_Plan::read_xml_plan (const char *filename)
+ {
+ CIAO::Config_Handlers::XML_File_Intf xml_intf (filename);
+ xml_intf.add_search_path ("ACE_ROOT", "/docs/schema/");
+ xml_intf.add_search_path ("TAO_ROOT", "/docs/schema/");
+ xml_intf.add_search_path ("CIAO_ROOT", "/docs/schema/");
+ xml_intf.add_search_path ("DANCE_ROOT", "/docs/schema/");
+
+ return xml_intf.release_plan ();
+ }
+
+ Deployment::DeploymentPlan *
+ Convert_Plan::read_cdr_plan (const char *filename)
+ {
+ ACE_FILE_Addr file_addr (ACE_sap_any_cast (ACE_FILE_Addr &));
+
+ if (filename)
+ file_addr.set (filename);
+ else
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - passed nil file name\n"));
+ return 0;
+ }
+
+ ACE_FILE_Connector conn;
+ ACE_FILE_IO file;
+
+ if (conn.connect (file,
+ file_addr,
+ 0,
+ ACE_Addr::sap_any,
+ 0,
+ O_RDONLY,
+ ACE_DEFAULT_FILE_PERMS == -1))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - unable to read file %p\n",
+ filename));
+ return 0;
+ }
+
+ ACE_FILE_Info info;
+ if (file.get_info (info) == -1)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - unable to determine file size %p\n",
+ filename));
+ return 0;
+ }
+
+ ACE_OFF_T bufsize = info.size_ - 1;
+
+ char *buffer = 0;
+ ACE_NEW_RETURN (buffer,
+ char[bufsize],
+ 0);
+
+#if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE)
+ ACE_OS::memset(buffer, 0, sizeof (buffer));
+#endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */
+
+ // Make sure <buffer> is released automagically.
+ ACE_Auto_Basic_Array_Ptr<char> b (buffer);
+
+ if (file.seek (0, SEEK_SET) == -1)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - seek failed %p\n",
+ filename));
+ return 0;
+ }
+
+ char byte_order;
+ ssize_t size = file.recv (&byte_order, 1);
+ size = file.recv (buffer, bufsize);
+
+ if (size != bufsize)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - read %u bytes "
+ "instead of %u bytes\n", size, bufsize));
+ return 0;
+ }
+
+ ACE_Message_Block mb (ACE_CDR::MAX_ALIGNMENT + bufsize);
+ ACE_CDR::mb_align (&mb);
+ mb.copy (buffer, bufsize);
+
+ TAO_InputCDR input_cdr (&mb);
+ input_cdr.reset_byte_order ((int) byte_order);
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO "Convert_Plan_Impl::read_cdr_plan - "
+ "Reading file %C in %s endian format\n",
+ filename, ACE_CDR_BYTE_ORDER ? ACE_TEXT("little") : ACE_TEXT("big")));
+
+
+ Deployment::DeploymentPlan *retval;
+
+ ACE_NEW_RETURN (retval, Deployment::DeploymentPlan (), 0);
+
+ input_cdr >> *retval;
+
+ file.close ();
+
+ return retval;
+ }
+
+ bool
+ Convert_Plan::write_cdr_plan (const char *output_filename, Deployment::DeploymentPlan &plan)
+ {
+ ACE_FILE_Addr file_addr (ACE_sap_any_cast (ACE_FILE_Addr &));
+
+ if (output_filename)
+ file_addr.set (output_filename);
+ else
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::write_cdr_plan - passed nil file name\n"));
+ return 0;
+ }
+
+ ACE_FILE_Connector conn;
+ ACE_FILE_IO file;
+
+ if (conn.connect (file,
+ file_addr,
+ 0,
+ ACE_Addr::sap_any,
+ 0,
+ O_RDWR | O_CREAT,
+ ACE_DEFAULT_FILE_PERMS == -1))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::write_cdr_plan - unable to write file %p\n",
+ output_filename));
+ return 0;
+ }
+
+ char byte_order = ACE_CDR_BYTE_ORDER;
+ size_t n = file.send (&byte_order, 1);
+
+ TAO_OutputCDR output_cdr (0, ACE_CDR_BYTE_ORDER, 0, 0, 0,
+ ACE_DEFAULT_CDR_MEMCPY_TRADEOFF,
+ ACE_CDR_GIOP_MAJOR_VERSION,
+ ACE_CDR_GIOP_MINOR_VERSION);
+
+ output_cdr << plan;
+
+ const ACE_Message_Block *output_mb = output_cdr.begin ();
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO "Convert_Plan_Impl::write_cdr_plan - "
+ ACE_TEXT ("Writing plan to file %s in %s endian format\n"),
+ output_filename,
+ ACE_CDR_BYTE_ORDER ? ACE_TEXT("little") : ACE_TEXT("big")));
+
+ n = file.send (output_mb->rd_ptr (),
+ output_mb->length ());
+
+ file.close ();
+
+ return true;
+ }
+}
diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h
new file mode 100644
index 00000000000..6be9fa23bd8
--- /dev/null
+++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h
@@ -0,0 +1,26 @@
+// $Id$
+
+/**
+ * @file Convert_Plan_impl.h
+ *
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ */
+
+#ifndef DANCE_CONVERT_PLAN_H
+#define DANCE_CONVERT_PLAN_H
+
+#include "Convert_Plan/DAnCE_Convert_Plan_export.h"
+#include "Deployment/Deployment_DeploymentPlanC.h"
+
+namespace DAnCE
+{
+ class DAnCE_Convert_Plan_Export Convert_Plan
+ {
+ public:
+ static Deployment::DeploymentPlan * read_xml_plan (const char *filename);
+ static Deployment::DeploymentPlan * read_cdr_plan (const char *filename);
+ static bool write_cdr_plan (const char *filename, Deployment::DeploymentPlan &plan);
+ };
+};
+
+#endif
diff --git a/CIAO/DAnCE/tools/Split_Plan/DAnCE_Split_Plan_export.h b/CIAO/DAnCE/tools/Split_Plan/DAnCE_Split_Plan_export.h
new file mode 100644
index 00000000000..fd07498538a
--- /dev/null
+++ b/CIAO/DAnCE/tools/Split_Plan/DAnCE_Split_Plan_export.h
@@ -0,0 +1,58 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl DAnCE_Split_Plan
+// ------------------------------
+#ifndef DANCE_SPLIT_PLAN_EXPORT_H
+#define DANCE_SPLIT_PLAN_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (ACE_AS_STATIC_LIBS) && !defined (DANCE_SPLIT_PLAN_HAS_DLL)
+# define DANCE_SPLIT_PLAN_HAS_DLL 0
+#endif /* ACE_AS_STATIC_LIBS && DANCE_SPLIT_PLAN_HAS_DLL */
+
+#if !defined (DANCE_SPLIT_PLAN_HAS_DLL)
+# define DANCE_SPLIT_PLAN_HAS_DLL 1
+#endif /* ! DANCE_SPLIT_PLAN_HAS_DLL */
+
+#if defined (DANCE_SPLIT_PLAN_HAS_DLL) && (DANCE_SPLIT_PLAN_HAS_DLL == 1)
+# if defined (DANCE_SPLIT_PLAN_BUILD_DLL)
+# define DAnCE_Split_Plan_Export ACE_Proper_Export_Flag
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* DANCE_SPLIT_PLAN_BUILD_DLL */
+# define DAnCE_Split_Plan_Export ACE_Proper_Import_Flag
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* DANCE_SPLIT_PLAN_BUILD_DLL */
+#else /* DANCE_SPLIT_PLAN_HAS_DLL == 1 */
+# define DAnCE_Split_Plan_Export
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARATION(T)
+# define DANCE_SPLIT_PLAN_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* DANCE_SPLIT_PLAN_HAS_DLL == 1 */
+
+// Set DANCE_SPLIT_PLAN_NTRACE = 0 to turn on library specific tracing even if
+// tracing is turned off for ACE.
+#if !defined (DANCE_SPLIT_PLAN_NTRACE)
+# if (ACE_NTRACE == 1)
+# define DANCE_SPLIT_PLAN_NTRACE 1
+# else /* (ACE_NTRACE == 1) */
+# define DANCE_SPLIT_PLAN_NTRACE 0
+# endif /* (ACE_NTRACE == 1) */
+#endif /* !DANCE_SPLIT_PLAN_NTRACE */
+
+#if (DANCE_SPLIT_PLAN_NTRACE == 1)
+# define DANCE_SPLIT_PLAN_TRACE(X)
+#else /* (DANCE_SPLIT_PLAN_NTRACE == 1) */
+# if !defined (ACE_HAS_TRACE)
+# define ACE_HAS_TRACE
+# endif /* ACE_HAS_TRACE */
+# define DANCE_SPLIT_PLAN_TRACE(X) ACE_TRACE_IMPL(X)
+# include "ace/Trace.h"
+#endif /* (DANCE_SPLIT_PLAN_NTRACE == 1) */
+
+#endif /* DANCE_SPLIT_PLAN_EXPORT_H */
+
+// End of auto generated file.
diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp
new file mode 100644
index 00000000000..4b8d0d10721
--- /dev/null
+++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp
@@ -0,0 +1,144 @@
+// $Id$
+
+#include "ace/Dynamic_Service.h"
+#include "ace/Get_Opt.h"
+#include "ace/Auto_Ptr.h"
+#include "tao/ORB.h"
+#include "DAnCE/Deployment/Deployment_DeploymentPlanC.h"
+#include "DAnCE/Logger/Log_Macros.h"
+#include "DAnCE/Logger/Logger_Service.h"
+#include "DAnCE/Config_Handlers/XML_File_Intf.h"
+#include "DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h"
+#include "Split_Plan_impl.h"
+
+
+bool cdr_encoded_ = false;
+const char *input_filename = 0;
+
+void
+usage (void)
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("usage: dance_split_plan [options]\n")
+ ACE_TEXT ("Applies the split plan algorithm and saves the result to")
+ ACE_TEXT ("CDR encoded plans\n")
+ ACE_TEXT ("\t-c <plan>\t\tCDR Encoded input plan\n")
+ ACE_TEXT ("\t-x <plan>\t\tXML Encoded input plan\n")
+ ));
+}
+
+bool
+parse_args (int argc, ACE_TCHAR *argv [])
+{
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT ("dance_split_plan options: ")));
+
+ for (int i = 0; i < argc; ++i)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, ACE_TEXT("\t%s\n"), argv[i]));
+ }
+
+ ACE_Get_Opt get_opt (argc, argv, ACE_TEXT ("c:x:h"), 0);
+
+ int c;
+ ACE_CString s;
+ while ((c = get_opt ()) != EOF)
+ {
+ switch (c)
+ {
+ case 'c':
+ cdr_encoded_ = true;
+ input_filename = get_opt.opt_arg ();
+ break;
+
+ case 'x':
+ cdr_encoded_ = false;
+ input_filename = get_opt.opt_arg ();
+ break;
+
+ case 'h':
+ usage ();
+ return false;
+ default:
+ usage ();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv [])
+{
+ DANCE_DISABLE_TRACE ();
+
+ int retval = 0;
+
+ try
+ {
+ DAnCE::Logger_Service
+ * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger");
+
+ if (dlf)
+ {
+ dlf->init (argc, argv);
+ }
+
+ DANCE_DEBUG (6, (LM_TRACE, DLINFO
+ ACE_TEXT("PlanLauncher - initializing ORB\n")));
+
+ // Need an ORB for the Config handlers
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ if (!parse_args (argc, argv))
+ {
+ return -1;
+ }
+
+ auto_ptr<Deployment::DeploymentPlan> plan;
+
+ if (!cdr_encoded_)
+ {
+ plan.reset (DAnCE::Convert_Plan::read_xml_plan (input_filename));
+ }
+ else
+ {
+ plan.reset (DAnCE::Convert_Plan::read_cdr_plan (input_filename));
+ }
+
+ if (plan.get () == 0)
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO "Split_Plan - "
+ "Unable to convert provided plan into IDL representation\n"));
+ return 0;
+ }
+
+ DAnCE::Split_Plan::TNodePlans plans;
+ DAnCE::Split_Plan split (*plan, plans);
+ split.split_plan ();
+
+ for (DAnCE::Split_Plan::TNodePlans::iterator iter_plans = plans.begin();
+ iter_plans != plans.end();
+ ++iter_plans)
+ {
+ ACE_CString name ((*iter_plans).ext_id_);
+ DANCE_DEBUG (3, (LM_DEBUG, DLINFO "Split_Plan - "
+ "Writing sub plan for node %C\n",
+ name.c_str ()));
+
+ name += input_filename;
+ DAnCE::Convert_Plan::write_cdr_plan (name.c_str (), (*iter_plans).int_id_);
+ }
+ }
+ catch (const CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("PlanLauncher");
+ retval = -1;
+ }
+ catch (...)
+ {
+ DANCE_ERROR (1, (LM_ERROR, "Split_Plan - error: unknown c++ exception\n"));
+ retval = -1;
+ }
+
+ return retval;
+}
diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc
new file mode 100644
index 00000000000..39a6150135c
--- /dev/null
+++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc
@@ -0,0 +1,17 @@
+project (DAnCE_Split_Plan_Impl) : dance_lib, dance_deployment_stub, dance_output {
+
+ dynamicflags = DANCE_SPLIT_PLAN_BUILD_DLL
+ includes += $(DANCE_ROOT)/tools
+
+ Source_Files {
+ Split_Plan_impl.cpp
+ }
+}
+
+project (DAnCE_Split_Plan_Exec) : dance_exe, dance_output, dance_split_plan, dance_convert_plan {
+ exename = dance_split_plan
+
+ Source_Files {
+ Split_Plan.cpp
+ }
+}
diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp
new file mode 100644
index 00000000000..55a9f4f755f
--- /dev/null
+++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp
@@ -0,0 +1,247 @@
+// $Id$
+
+#include "Split_Plan_impl.h"
+#include "DAnCE/Logger/Log_Macros.h"
+
+namespace DAnCE
+{
+ Split_Plan::Split_Plan (const Deployment::DeploymentPlan &plan,
+ TNodePlans &sub_plans)
+ : plan_ (plan),
+ sub_plans_ (sub_plans)
+ {
+ }
+ void
+ Split_Plan::split_plan ()
+ {
+ DANCE_TRACE ( "Split_Plan::split_plan");
+
+ const Deployment::DeploymentPlan &plan = this->plan_;
+ TNodePlans &sub_plans = this->sub_plans_;
+
+ DANCE_DEBUG (9, (LM_TRACE, ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Creating sub-plans\n")));
+ // Create empty sub-plans
+ for (CORBA::ULong i = 0; i < plan.instance.length(); ++i)
+ {
+ ACE_CString node = plan.instance[i].node.in();
+ if (0 == sub_plans.find (node)) continue;
+
+ ::Deployment::DeploymentPlan tmp_plan;
+
+ // Construct the UUID for the child plan.
+ // Currently, this UUID consists of:
+ // The global UUID for the parent plan + the name of the node the
+ // child plan is to be installed on.
+ ACE_CString child_uuid (plan.UUID.in ());
+ // child_uuid += "@"; CCM#61
+ // child_uuid += node;
+
+ tmp_plan.UUID = CORBA::string_dup (child_uuid.c_str());
+ tmp_plan.implementation.length (0);
+ tmp_plan.instance.length (0);
+ tmp_plan.connection.length (0);
+ tmp_plan.externalProperty.length (0);
+ tmp_plan.dependsOn.length (0);
+ tmp_plan.artifact.length (0);
+
+ // @@ There is an optimization point here, since we really don't have to
+ // pass the entire CIAOServerResources into each individual child plan.
+ tmp_plan.infoProperty = plan.infoProperty;
+
+ CORBA::ULong num_localities (plan.localityConstraint.length ());
+ Deployment::PlanLocalities default_loc (num_localities);
+ default_loc.length (num_localities);
+
+ for (CORBA::ULong i = 0; i < num_localities; ++i)
+ {
+ default_loc[i].constraint = Deployment::PlanNoConstraint;
+ }
+
+ tmp_plan.localityConstraint = default_loc;
+
+ sub_plans.bind (node, tmp_plan);
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Created sub-plan for node %C with UUID %C\n"),
+ node.c_str (), child_uuid.c_str ()));
+ }
+
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("First phase produced %u child plans, proceeding to second\n"),
+ sub_plans.current_size ()));
+
+ // (1) Iterate over the <instance> field of the global DeploymentPlan
+ // structure.
+ // (2) Retrieve the necessary information to contruct the node-level
+ // plans one by one.
+ for (CORBA::ULong i = 0; i < plan.instance.length (); ++i)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Processing instance: %C\n"), plan.instance[i].name.in()));
+ // @@TODO Fill in the child deployment plan in the map.
+ // If the component instance already exists in the child plan,
+ // then we overwrite the existing instance, since the new instance
+ // might have different resource usage requirements.
+
+ // Get the instance deployment description
+ const ::Deployment::InstanceDeploymentDescription & my_instance = plan.instance[i];
+
+ // Get the child plan.
+ ::Deployment::DeploymentPlan child_plan;
+
+ if (0 != sub_plans.find (my_instance.node.in(), child_plan))
+ {
+ DANCE_ERROR (1, (LM_ERROR, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("ERROR: Unable to find sub-plan for instance %C\n"),
+ my_instance.node.in ()));
+ }
+
+ // Fill in the contents of the child plan entry.
+
+ // Append the "MonolithicDeploymentDescriptions implementation"
+ // field with a new "implementation", which is specified by the
+ // <implementationRef> field of <my_instance> entry. NOTE: The
+ // <artifactRef> field needs to be changed accordingly.
+ ::Deployment::MonolithicDeploymentDescription const & my_implementation
+ = plan.implementation[my_instance.implementationRef];
+
+ CORBA::ULong index_imp = child_plan.implementation.length ();
+ child_plan.implementation.length (++index_imp);
+ child_plan.implementation[index_imp-1] = my_implementation;
+
+ // Initialize with the correct sequence length.
+ CORBA::ULongSeq ulong_seq;
+ ulong_seq.length (my_implementation.artifactRef.length ());
+
+ // Append the "ArtifactDeploymentDescriptions artifact" field
+ // with some new "artifacts", which is specified by the
+ // <artifactRef> sequence of <my_implementation> entry.
+ CORBA::ULong const impl_length = my_implementation.artifactRef.length ();
+ for (CORBA::ULong iter = 0;
+ iter < impl_length;
+ iter ++)
+ {
+ CORBA::ULong artifact_ref = my_implementation.artifactRef[iter];
+
+ // Fill in the <artifact> field of the child plan
+ CORBA::ULong index_art = child_plan.artifact.length ();
+ child_plan.artifact.length (++index_art);
+ child_plan.artifact[index_art-1] = plan.artifact[artifact_ref];
+
+ // Fill in the artifactRef field of the MonolithicDeploymentDescription
+ ulong_seq[iter] = index_art - 1;
+ }
+
+ // Change the <artifactRef> field of the "implementation".
+ child_plan.implementation[index_imp-1].artifactRef = ulong_seq;
+
+ // Append the "InstanceDeploymentDescription instance" field with
+ // a new "instance", which is almost the same as the "instance" in
+ // the global plan except the <implementationRef> field.
+ // NOTE: The <implementationRef> field needs to be changed accordingly.
+ CORBA::ULong index_ins = child_plan.instance.length ();
+ child_plan.instance.length (++index_ins);
+ child_plan.instance[index_ins-1] = my_instance;
+
+ // Change the <implementationRef> field of the "instance".
+ // @@ The implementationRef starts from 0.
+ // @@TODO: Below logic needs to be changed once we want to avoid
+ // duplicate <implementation> for the optimization.
+ child_plan.instance[index_ins-1].implementationRef = index_imp - 1;
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Processing connections.\n")));
+ // Copy connections
+ for (CORBA::ULong j = 0; j < plan.connection.length(); ++j)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("For connection: %C\n"), plan.connection[j].name.in()));
+ for (CORBA::ULong k = 0; k < plan.connection[j].internalEndpoint.length(); ++k)
+ {
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("For endpoint: %C(%C)\n"),
+ plan.connection[j].internalEndpoint[k].portName.in(),
+ plan.connection[j].internalEndpoint[k].provider ? "provider" : "client"));
+ if (i == plan.connection[j].internalEndpoint[k].instanceRef) // the instance (i) is referenced by the connection
+ {
+ Deployment::PlanConnectionDescription * connection_copied = 0;
+ for (CORBA::ULong m = 0; m < child_plan.connection.length(); ++m)
+ {
+ if (ACE_OS::strcmp (plan.connection[j].name.in (), child_plan.connection[m].name.in ()) == 0)
+ {
+ connection_copied = &child_plan.connection[m];
+ break;
+ }
+ }
+
+ if (!connection_copied)
+ {
+ // Copy the connection
+ CORBA::ULong const index_con = child_plan.connection.length();
+ child_plan.connection.length (index_con + 1);
+ child_plan.connection[index_con] = plan.connection[j];
+ connection_copied = &child_plan.connection[index_con];
+ connection_copied->internalEndpoint.length (0);
+ }
+
+ // Copy the endpoint
+ CORBA::ULong const index_ep = connection_copied->internalEndpoint.length();
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT ("Copying endpoint %u from connection into endpoint %u\n"),
+ k, index_ep));
+
+ connection_copied->internalEndpoint.length (index_ep + 1);
+ connection_copied->internalEndpoint[index_ep] = plan.connection[j].internalEndpoint[k];
+ connection_copied->internalEndpoint[index_ep].instanceRef = index_ins - 1;
+ }
+ }
+ }
+
+ for (CORBA::ULong j = 0; j < plan.localityConstraint.length (); ++j)
+ {
+ ::Deployment::PlanLocality loc = plan.localityConstraint[j];
+ for (CORBA::ULong k = 0; k < loc.constrainedInstanceRef.length (); ++k)
+ {
+ if (loc.constrainedInstanceRef[k] == i) // we are the same instance...
+ {
+ // add our new instance ref to the child plan's corresponding contraint.
+ CORBA::ULong child_loc_len (child_plan.localityConstraint[j].constrainedInstanceRef.length ());
+
+ DANCE_DEBUG (9, (LM_TRACE, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT ("Found matching locality constraint %u:%u, adding to %u:%u as %u\n"),
+ j, k, j, child_loc_len, index_ins - 1));
+ child_plan.localityConstraint[j].constraint = loc.constraint;
+ child_plan.localityConstraint[j].constrainedInstanceRef.length (child_loc_len + 1);
+ child_plan.localityConstraint[j].constrainedInstanceRef[child_loc_len] = index_ins - 1;
+ }
+ }
+ }
+
+
+ sub_plans.rebind (my_instance.node.in(), child_plan);
+ }
+
+ //Debug
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO
+ ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Original plan connection count: %u\n"), plan.connection.length()));
+ CORBA::ULong cnt = 0;
+ for (TNodePlans::iterator it = sub_plans.begin(); it != sub_plans.end(); ++it)
+ {
+ cnt += (*it).int_id_.connection.length();
+ }
+ DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("Split_Plan::split_plan - ")
+ ACE_TEXT("Child plans connection count: %u\n"), cnt));
+ }
+}
diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.h b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.h
new file mode 100644
index 00000000000..0ed4a92b724
--- /dev/null
+++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.h
@@ -0,0 +1,34 @@
+// $Id$
+
+/**
+ * @file Split_Plan_impl.h
+ *
+ * @author William R. Otte <wotte@dre.vanderbilt.edu>
+ */
+
+#ifndef DANCE_SPLIT_PLAN_H
+#define DANCE_SPLIT_PLAN_H
+
+#include "ace/Map_Manager.h"
+#include "ace/SStringfwd.h"
+#include "Deployment/Deployment_DeploymentPlanC.h"
+#include "Split_Plan/DAnCE_Split_Plan_export.h"
+
+namespace DAnCE
+{
+ class DAnCE_Split_Plan_Export Split_Plan
+ {
+ public:
+ typedef ACE_Map_Manager<ACE_CString, Deployment::DeploymentPlan, ACE_Null_Mutex> TNodePlans;
+
+ Split_Plan (const Deployment::DeploymentPlan &plan,
+ TNodePlans &sub_plans);
+
+ void split_plan ();
+
+ private:
+ const Deployment::DeploymentPlan &plan_;
+ TNodePlans &sub_plans_;
+ };
+}
+#endif