From f11da3f924c7db3c50fb119392a536de5bc5883c Mon Sep 17 00:00:00 2001 From: nilabjar Date: Sat, 10 Feb 2007 20:14:28 +0000 Subject: ChangeLogTag: Sat Feb 10 20:13:35 UTC 2007 Nilabja R --- ChangeLog | 8 ++- DAnCE/TargetManager/ResourceCommitmentManager.cpp | 58 +++++++++++++++++++++ DAnCE/TargetManager/ResourceCommitmentManager.h | 61 +++++++++++++++++++++++ 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 DAnCE/TargetManager/ResourceCommitmentManager.cpp create mode 100644 DAnCE/TargetManager/ResourceCommitmentManager.h diff --git a/ChangeLog b/ChangeLog index 5d98a3e2a2e..079ae5183f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +Sat Feb 10 20:13:35 UTC 2007 Nilabja R + + * DAnCE/TargetManager/ResourceCommitmentManager.h: + * DAnCE/TargetManager/ResourceCommitmentManager.cpp: + Added the above files. + Sat Feb 10 20:09:29 UTC 2007 Nilabja R * ciao/Deployment_ResourceCommitmentManager.idl: - Added id tag + Added id tag Fri Feb 9 20:39:25 UTC 2007 Nilabja R diff --git a/DAnCE/TargetManager/ResourceCommitmentManager.cpp b/DAnCE/TargetManager/ResourceCommitmentManager.cpp new file mode 100644 index 00000000000..321f739899d --- /dev/null +++ b/DAnCE/TargetManager/ResourceCommitmentManager.cpp @@ -0,0 +1,58 @@ +//$Id$ +// +#include "DomainDataManager.h" +#include "ResourceCommitmentManager.h" + +// Implementation skeleton constructor +CIAO::ResourceCommitmentManager_i::ResourceCommitmentManager_i (void) +{ +} + +// Implementation skeleton destructor +CIAO::ResourceCommitmentManager_i::~ResourceCommitmentManager_i (void) +{ +} + +void CIAO::ResourceCommitmentManager_i::commitResources ( + const ::Deployment::ResourceAllocations& resources + ) + ACE_THROW_SPEC ((::CORBA::SystemException, + ::Deployment::ResourceCommitmentFailure)) +{ + CIAO::DomainDataManager::get_data_manager ()->commitResourceAllocation (resources); + + // commit succesful .. add to commited resource + this->add_to_commited_resource (resources); + return; +} + +void CIAO::ResourceCommitmentManager_i::releaseResources ( + const ::Deployment::ResourceAllocations & resources + ) + ACE_THROW_SPEC ((::CORBA::SystemException, + ::Deployment::ResourceCommitmentFailure)) +{ + ::Deployment::ResourceAllocations res; + + // if the resources set is null , use the already allocated resources .. + if (resources.length () == 0) + res = this->resources_; + else + res = resources; + + CIAO::DomainDataManager::get_data_manager ()->releaseResourceAllocation (res); + return; +} + +int CIAO::ResourceCommitmentManager_i::add_to_commited_resource ( + ::Deployment::ResourceAllocations res) +{ + CORBA::ULong current_length = this->resources_.length (); + + this->resources_.length (current_length + res.length ()); + + for (CORBA::ULong i =0;i < res.length ();i++) + this->resources_[current_length + i] = res[i]; + + return 0; +} diff --git a/DAnCE/TargetManager/ResourceCommitmentManager.h b/DAnCE/TargetManager/ResourceCommitmentManager.h new file mode 100644 index 00000000000..c29dea0c59f --- /dev/null +++ b/DAnCE/TargetManager/ResourceCommitmentManager.h @@ -0,0 +1,61 @@ +//$Id$ +// +#ifndef DEPLOYMENT_RESOURCECOMMITMENTMANAGERI_H_ +#define DEPLOYMENT_RESOURCECOMMITMENTMANAGERI_H_ + +#include "Deployment_ResourceCommitmentManagerS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +namespace CIAO { + + class ResourceCommitmentManager_i + : public virtual POA_Deployment::ResourceCommitmentManager + { + public: + // Constructor + ResourceCommitmentManager_i (void); + + // Destructor + virtual ~ResourceCommitmentManager_i (void); + + /** + * @function commitResources + * @brief Commits the resources + * + * @description This function makes a call to the DomainDataManager in order + * to commit the resources mentioned in the ResourceAllocation + * sequence. If the resource cannot be allocated throws a + * ResourceCommitmentFailed exception + */ + virtual + void commitResources ( + const ::Deployment::ResourceAllocations& resources + ) + ACE_THROW_SPEC ((::CORBA::SystemException, + ::Deployment::ResourceCommitmentFailure)); + + virtual + void releaseResources ( + const ::Deployment::ResourceAllocations & resources + ) + ACE_THROW_SPEC ((::CORBA::SystemException, + ::Deployment::ResourceCommitmentFailure)); + + private: + /** + * @function add_to_commited_resource + * @brief This function adds the res to already commited resources. + * This is to be called from within commitResources + */ + int add_to_commited_resource (::Deployment::ResourceAllocations res); + + /// The commited resource + ::Deployment::ResourceAllocations resources_; + }; + +}; + +#endif /* DEPLOYMENT_RESOURCECOMMITMENTMANAGERI_H_ */ -- cgit v1.2.1