From 33aa522dd55af2fbc817f920b720e499127757d6 Mon Sep 17 00:00:00 2001 From: "William R. Otte" Date: Tue, 23 Feb 2010 16:23:13 +0000 Subject: Tue Feb 23 16:22:42 UTC 2010 William R. Otte --- CIAO/ChangeLog | 16 + CIAO/DAnCE/MPC/config/dance_convert_plan.mpb | 1 + CIAO/DAnCE/MPC/config/dance_split_plan.mpb | 1 + CIAO/DAnCE/MPC/config/dance_tools.mpb | 1 + .../DAnCE/NodeApplication/NodeApplication_Impl.cpp | 110 +++--- CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp | 78 ++-- CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc | 1 + .../DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp | 84 ++--- CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h | 2 +- CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp | 94 ++--- CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc | 1 + CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp | 406 ++++++++++----------- 12 files changed, 408 insertions(+), 387 deletions(-) diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 013234949fa..8ec8ad07a04 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,19 @@ +Tue Feb 23 16:22:42 UTC 2010 William R. Otte + + * DAnCE/MPC/config/dance_convert_plan.mpb: + * DAnCE/MPC/config/dance_split_plan.mpb: + * DAnCE/MPC/config/dance_tools.mpb: + * DAnCE/NodeApplication/NodeApplication_Impl.cpp: + * 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: + * DAnCE/tools/Split_Plan/Split_Plan.mpc: + * DAnCE/tools/Split_Plan/Split_Plan.cpp: + * DAnCE/tools/Split_Plan/Split_Plan_impl.cpp: + + Fuzz fixes. + Tue Feb 23 16:13:24 UTC 2010 William R. Otte * DAnCE/NodeApplication/NodeApplication_Impl.cpp: diff --git a/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb b/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb index 584c266e6b9..9a6306ee3e4 100644 --- a/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb +++ b/CIAO/DAnCE/MPC/config/dance_convert_plan.mpb @@ -1,3 +1,4 @@ +// $Id$ 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 index 6d85a9b4412..5ef5536636a 100644 --- a/CIAO/DAnCE/MPC/config/dance_split_plan.mpb +++ b/CIAO/DAnCE/MPC/config/dance_split_plan.mpb @@ -1,3 +1,4 @@ +// $Id$ 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 index 2457ef84368..411d44a2223 100644 --- a/CIAO/DAnCE/MPC/config/dance_tools.mpb +++ b/CIAO/DAnCE/MPC/config/dance_tools.mpb @@ -1,3 +1,4 @@ +// $Id$ project : dance { includes += $(DANCE_ROOT)/tools } diff --git a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp index b0f51acd845..ac38eb04cd7 100644 --- a/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp +++ b/CIAO/DAnCE/NodeApplication/NodeApplication_Impl.cpp @@ -1089,10 +1089,10 @@ NodeApplication_Impl::create_container (size_t server, size_t cont_idx) } DANCE_DEBUG (9, (LM_TRACE, DLINFO ACE_TEXT("NodeApplication_Impl::create_container - ") - ACE_TEXT("Configuring %u components on container %u on server %u\n"), - container.components.size (), - server, - cont_idx)); + ACE_TEXT("Configuring %u components on container %u on server %u\n"), + container.components.size (), + server, + cont_idx)); // Configure components for (size_t i = 0; i < container.components.size (); ++i) @@ -1128,12 +1128,12 @@ NodeApplication_Impl::create_colocation_groups (void) for (CORBA::ULong i = 0; i < this->plan_.localityConstraint.length (); ++i) { if (this->plan_.localityConstraint[i].constraint == ::Deployment::PlanNoConstraint) - { - DANCE_DEBUG (10, (LM_INFO, DLINFO - ACE_TEXT ("NodeApplication_Impl::create_colocation_groups - ") - ACE_TEXT ("Skipping NoConstraint Colocation group\n"))); - continue; - } + { + DANCE_DEBUG (10, (LM_INFO, DLINFO + ACE_TEXT ("NodeApplication_Impl::create_colocation_groups - ") + ACE_TEXT ("Skipping NoConstraint Colocation group\n"))); + continue; + } else if (this->plan_.localityConstraint[i].constraint != ::Deployment::PlanSameProcess) { DANCE_ERROR (1, (LM_ERROR, DLINFO @@ -1800,37 +1800,37 @@ NodeApplication_Impl::finishLaunch (const ::Deployment::Connections & providedRe (conn.internalEndpoint[1].kind == ::Deployment::MultiplexReceptacle || conn.internalEndpoint[1].kind == ::Deployment::SimplexReceptacle)) { - obj = Components::CCMObject:: - _narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->ref.in ()); - - if (this->is_local_facet (conn)) - { - ::Components::CCMObject_var facet = - ::Components::CCMObject::_narrow (providedReference[i].endpoint[0].in ()); - - ::Components::CCMObject_var recep = - ::Components::CCMObject::_narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->ref.in ()); - - ::CIAO::Deployment::Container_var cont = - ::CIAO::Deployment::Container::_narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->container->ref.in ()); - - this->connect_receptacle (conn, - facet.in (), - conn.internalEndpoint[0].portName.in (), - obj.in (), - conn.internalEndpoint[1].portName.in(), - cont.in ()); - } - else - { - this->connect_receptacle (conn, - obj.in (), - "", - providedReference[i].endpoint[0].in(), - conn.internalEndpoint[1].portName.in(), - ::CIAO::Deployment::Container::_nil()); - } - } + obj = Components::CCMObject:: + _narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->ref.in ()); + + if (this->is_local_facet (conn)) + { + ::Components::CCMObject_var facet = + ::Components::CCMObject::_narrow (providedReference[i].endpoint[0].in ()); + + ::Components::CCMObject_var recep = + ::Components::CCMObject::_narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->ref.in ()); + + ::CIAO::Deployment::Container_var cont = + ::CIAO::Deployment::Container::_narrow (this->instances_[conn.internalEndpoint[1].instanceRef]->container->ref.in ()); + + this->connect_receptacle (conn, + facet.in (), + conn.internalEndpoint[0].portName.in (), + obj.in (), + conn.internalEndpoint[1].portName.in(), + cont.in ()); + } + else + { + this->connect_receptacle (conn, + obj.in (), + "", + providedReference[i].endpoint[0].in(), + conn.internalEndpoint[1].portName.in(), + ::CIAO::Deployment::Container::_nil()); + } + } break; } CORBA::Object_var tmp = @@ -1911,12 +1911,12 @@ NodeApplication_Impl::finishLaunch (const ::Deployment::Connections & providedRe { // What we should do with Cookie, returned from connect call??? DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("NodeApplication_Impl::finishLaunch - Set for receptacle\n"))); - if (CORBA::is_nil (providedReference[i].endpoint[0].in ())) - { - DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("NodeApplication_Impl::finishLaunch - ") - ACE_TEXT ("Reference provided from DomainApplication was nil.\n"))); - throw 1; - } + if (CORBA::is_nil (providedReference[i].endpoint[0].in ())) + { + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("NodeApplication_Impl::finishLaunch - ") + ACE_TEXT ("Reference provided from DomainApplication was nil.\n"))); + throw 1; + } ::Components::CCMObject_var facet = ::Components::CCMObject::_narrow (providedReference[i].endpoint[0].in ()); @@ -2070,14 +2070,14 @@ NodeApplication_Impl::connect_receptacle (const ::Deployment::PlanConnectionDesc { DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("NodeApplication_Impl::connect_receptacle - ") ACE_TEXT("connect SimplexReceptacle for [%C] started\n"), recep_name.c_str())); - if (CORBA::is_nil (facet)) - { - DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("NodeApplication_Impl::connect_receptacle - ") - "Object reference for facet to connect to [%C] was nil\n", - recep_name.c_str ())); - throw ::Deployment::InvalidConnection ("", - "Provided facet reference was nil\n"); - } + if (CORBA::is_nil (facet)) + { + DANCE_ERROR (1, (LM_ERROR, DLINFO ACE_TEXT ("NodeApplication_Impl::connect_receptacle - ") + "Object reference for facet to connect to [%C] was nil\n", + recep_name.c_str ())); + throw ::Deployment::InvalidConnection ("", + "Provided facet reference was nil\n"); + } res = facet->connect (recep_name.c_str(), receptacle); DANCE_DEBUG (6, (LM_DEBUG, DLINFO ACE_TEXT("NodeApplication_Impl::connect_receptacle - connect finished\n"))); diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp index f8dd0481266..7715a4b7657 100644 --- a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp +++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.cpp @@ -16,11 +16,11 @@ 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 \t\tXML Encoded input plan\n") - ACE_TEXT ("\t-o \t\tOutput destination for converted plan\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 \t\tXML Encoded input plan\n") + ACE_TEXT ("\t-o \t\tOutput destination for converted plan\n") + )); } bool @@ -40,22 +40,22 @@ parse_args (int argc, ACE_TCHAR *argv []) 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 '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; - } + case 'h': + usage (); + return false; + default: + usage (); + return false; + } } return true; @@ -79,38 +79,38 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv []) } DANCE_DEBUG (6, (LM_TRACE, DLINFO - ACE_TEXT("Convert_Plan - initializing ORB\n"))); + 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; - } + { + return -1; + } if (!input_filename) - { - DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan - " - "No input filename provided\n")); - return -1; - } + { + DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan - " + "No input filename provided\n")); + return -1; + } auto_ptr 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; - } + { + 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_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); } diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc index 169a29b61f7..5628fafdcaf 100644 --- a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc +++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan.mpc @@ -1,3 +1,4 @@ +// $Id$ project (DAnCE_Convert_Plan) : dance_lib, dance_output, dance_deployment_stub, dance_config_handlers { dynamicflags = DANCE_CONVERT_PLAN_BUILD_DLL diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp index 5932b427714..0acfc785dca 100644 --- a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp +++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.cpp @@ -29,40 +29,40 @@ namespace DAnCE file_addr.set (filename); else { - DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - passed nil file name\n")); - return 0; + 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)) + 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; + 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; + 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); + char[bufsize], + 0); #if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE) ACE_OS::memset(buffer, 0, sizeof (buffer)); @@ -73,9 +73,9 @@ namespace DAnCE 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; + DANCE_ERROR (1, (LM_ERROR, DLINFO "Convert_Plan_Impl::read_cdr_plan - seek failed %p\n", + filename)); + return 0; } char byte_order; @@ -84,9 +84,9 @@ namespace DAnCE 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; + 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); @@ -97,8 +97,8 @@ namespace DAnCE 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"))); + "Reading file %C in %s endian format\n", + filename, ACE_CDR_BYTE_ORDER ? ACE_TEXT("little") : ACE_TEXT("big"))); Deployment::DeploymentPlan *retval; @@ -121,45 +121,45 @@ namespace DAnCE 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; + 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)) + 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; + 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); + 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"))); + 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 ()); + output_mb->length ()); file.close (); diff --git a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h index 6be9fa23bd8..4065fc0eb2a 100644 --- a/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h +++ b/CIAO/DAnCE/tools/Convert_Plan/Convert_Plan_Impl.h @@ -1,7 +1,7 @@ // $Id$ /** - * @file Convert_Plan_impl.h + * @file Convert_Plan_Impl.h * * @author William R. Otte */ diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp index 4b8d0d10721..5dcb053abdb 100644 --- a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp +++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.cpp @@ -19,11 +19,11 @@ 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 \t\tCDR Encoded input plan\n") - ACE_TEXT ("\t-x \t\tXML Encoded input plan\n") - )); + ACE_TEXT ("Applies the split plan algorithm and saves the result to") + ACE_TEXT ("CDR encoded plans\n") + ACE_TEXT ("\t-c \t\tCDR Encoded input plan\n") + ACE_TEXT ("\t-x \t\tXML Encoded input plan\n") + )); } bool @@ -43,24 +43,24 @@ parse_args (int argc, ACE_TCHAR *argv []) 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 '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; - } + case 'h': + usage (); + return false; + default: + usage (); + return false; + } } return true; @@ -84,50 +84,50 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv []) } DANCE_DEBUG (6, (LM_TRACE, DLINFO - ACE_TEXT("PlanLauncher - initializing ORB\n"))); + 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; - } + { + return -1; + } auto_ptr plan; if (!cdr_encoded_) - { - plan.reset (DAnCE::Convert_Plan::read_xml_plan (input_filename)); - } + { + plan.reset (DAnCE::Convert_Plan::read_xml_plan (input_filename)); + } else - { - plan.reset (DAnCE::Convert_Plan::read_cdr_plan (input_filename)); - } + { + 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_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 ())); + 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_); - } + name += input_filename; + DAnCE::Convert_Plan::write_cdr_plan (name.c_str (), (*iter_plans).int_id_); + } } catch (const CORBA::Exception &ex) { diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc index 39a6150135c..de005ed5697 100644 --- a/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc +++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan.mpc @@ -1,3 +1,4 @@ +// $Id$ project (DAnCE_Split_Plan_Impl) : dance_lib, dance_deployment_stub, dance_output { dynamicflags = DANCE_SPLIT_PLAN_BUILD_DLL diff --git a/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp index 55a9f4f755f..a46380f653e 100644 --- a/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp +++ b/CIAO/DAnCE/tools/Split_Plan/Split_Plan_impl.cpp @@ -1,4 +1,4 @@ -// $Id$ +g// $Id$ #include "Split_Plan_impl.h" #include "DAnCE/Logger/Log_Macros.h" @@ -6,7 +6,7 @@ namespace DAnCE { Split_Plan::Split_Plan (const Deployment::DeploymentPlan &plan, - TNodePlans &sub_plans) + TNodePlans &sub_plans) : plan_ (plan), sub_plans_ (sub_plans) { @@ -20,58 +20,58 @@ namespace DAnCE TNodePlans &sub_plans = this->sub_plans_; DANCE_DEBUG (9, (LM_TRACE, ACE_TEXT("Split_Plan::split_plan - ") - ACE_TEXT("Creating sub-plans\n"))); + 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 ())); + 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 ())); + 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 field of the global DeploymentPlan // structure. @@ -79,169 +79,169 @@ namespace DAnCE // 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 - // field of entry. NOTE: The - // 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 - // sequence of 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 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 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 field. - // NOTE: The 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 field of the "instance". - // @@ The implementationRef starts from 0. - // @@TODO: Below logic needs to be changed once we want to avoid - // duplicate 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); + 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 + // field of entry. NOTE: The + // 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 + // sequence of 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 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 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 field. + // NOTE: The 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 field of the "instance". + // @@ The implementationRef starts from 0. + // @@TODO: Below logic needs to be changed once we want to avoid + // duplicate 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())); + 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(); + 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)); + ACE_TEXT("Child plans connection count: %u\n"), cnt)); } } -- cgit v1.2.1