[asterisk-scf-commits] asterisk-scf/release/mediaformatgeneric.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue May 8 17:28:34 CDT 2012
branch "master" has been updated
via 683577ed1b6a05d0745dab5a3a751f84644b4a15 (commit)
from e4bf44a30769d12c6c1304d6218ec112be2a6d1e (commit)
Summary of changes:
src/Component.cpp | 7 ++-
src/Configuration.cpp | 167 ++++++++++++++++++++++++++++++++--------------
src/Configuration.h | 9 ++-
src/MediaFormatGeneric.h | 3 +-
4 files changed, 131 insertions(+), 55 deletions(-)
- Log -----------------------------------------------------------------
commit 683577ed1b6a05d0745dab5a3a751f84644b4a15
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue May 8 12:04:37 2012 -0500
Changes for new retry logic.
diff --git a/src/Component.cpp b/src/Component.cpp
index 94d8ffb..1cc0904 100644
--- a/src/Component.cpp
+++ b/src/Component.cpp
@@ -30,6 +30,8 @@
#include <AsteriskSCF/Logger.h>
#include <AsteriskSCF/Discovery/LocatorRegistrationWrapper.h>
#include <AsteriskSCF/Component/Component.h>
+#include <AsteriskSCF/Operations/OperationContext.h>
+
#include "MediaFormatGeneric.h"
#include "Configuration.h"
@@ -95,7 +97,8 @@ void SDPDescriptorCompareServiceImpl::removeAllFormats()
mSupportedFormats.clear();
}
-FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int, int, const Ice::StringSeq& params, const Ice::Current&)
+FormatPtr SDPDescriptorServiceImpl::getNamedFormat(
+ const std::string& name, int, int, const Ice::StringSeq& params, const Ice::Current&)
{
boost::shared_lock<boost::shared_mutex> lock(mLock);
std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
@@ -516,7 +519,7 @@ void Component::createPrimaryServices()
ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(
getServiceAdapter()->addWithUUID(mSdpComparator));
mCompareGuid = getName() + ".Media/SDP_Descriptor";
- getServiceLocatorManagement()->addCompare(mCompareGuid, comparatorServicePrx);
+ getServiceLocatorManagement()->addCompare(AsteriskSCF::Operations::createContext(), mCompareGuid, comparatorServicePrx);
}
catch(const Ice::Exception& e)
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 2f29437..524201b 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -1,7 +1,7 @@
/*
* Asterisk SCF -- An open-source communications framework.
*
- * Copyright (C) 2011, Digium, Inc.
+ * Copyright (C) 2011-2012, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk SCF project. Please do not directly contact
@@ -18,9 +18,9 @@
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/thread/shared_mutex.hpp>
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+#include <AsteriskSCF/Operations/OperationMonitor.h>
#include "MediaFormatGenericConfigurationIf.h"
#include "Configuration.h"
@@ -28,14 +28,18 @@
using namespace AsteriskSCF::System::Configuration::V1;
using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
+using namespace AsteriskSCF::Operations;
class ConfigurationServiceImplPriv
{
public:
ConfigurationServiceImplPriv(const SDPDescriptorServiceImplPtr& descriptorService,
const SDPDescriptorCompareServiceImplPtr& comparatorService) :
+ mOperationContextCache(OperationContextCache::create(DEFAULT_TTL_SECONDS)),
mDescriptorService(descriptorService), mComparatorService(comparatorService) { };
+ OperationContextCachePtr mOperationContextCache;
+
/**
* Formats configuration group
*/
@@ -111,15 +115,15 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskS
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
ConfigurationGroupSeq& mGroups;
};
-
+
ConfigurationGroupSeq newGroups;
FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
-
+
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
(*group)->visit(v);
}
-
+
return newGroups;
}
@@ -130,7 +134,7 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
public:
GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) :
mImplPriv(implPriv), mGroups(visitorGroups) { };
-
+
private:
void visitFormatsGroup(const FormatsGroupPtr&)
{
@@ -138,49 +142,50 @@ ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const Asteri
{
return;
}
-
+
mGroups.push_back(mImplPriv->mFormatsGroup);
};
-
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
ConfigurationGroupSeq& mGroups;
};
-
+
ConfigurationGroupSeq newGroups;
FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
-
+
for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
{
(*group)->visit(v);
}
-
+
return newGroups;
}
ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice::Current&)
{
ConfigurationGroupSeq groups;
-
+
boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
-
+
if (mImplPriv->mFormatsGroup)
{
FormatsGroupPtr general = new FormatsGroup();
groups.push_back(general);
}
-
+
return groups;
}
-void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
{
class GroupVisitor : public FormatsConfigurationGroupVisitor
{
public:
GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-
+
private:
/**
* Helper function which performs serial number checking of items
@@ -197,22 +202,22 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
{
continue;
}
-
+
ConfigurationItemDict::const_iterator localItem = localItems.find(item->first);
-
+
if (localItem == localItems.end())
{
// This is a new item so serial checking does not apply
continue;
}
-
+
if (item->second->serialNumber < localItem->second->serialNumber)
{
throw SerialConflict(group, item->second);
}
}
}
-
+
void visitFormatsGroup(const FormatsGroupPtr& group)
{
if (!mImplPriv->mFormatsGroup)
@@ -223,7 +228,7 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
{
performSerialCheck(group->configurationItems, mImplPriv->mFormatsGroup->configurationItems, group);
}
-
+
for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
item != group->configurationItems.end();
++item)
@@ -240,27 +245,49 @@ void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Confi
mImplPriv->mFormatsGroup->configurationItems.insert((*item));
}
}
-
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
};
-
- FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
- boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
-
- for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ ContextDataPtr data = checkAndThrow(mImplPriv->mOperationContextCache, context);
+
+ if (!data)
{
- (*group)->visit(v);
+ // retry detected
+ return;
+ }
+
+ try
+ {
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+ data->setCompleted();
+ }
+ catch (const std::exception& e)
+ {
+ data->setException(e);
+ }
+ catch (...)
+ {
+ data->setException();
}
}
-void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+void ConfigurationServiceImpl::removeConfigurationItems(
+ const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
{
class GroupVisitor : public FormatsConfigurationGroupVisitor
{
public:
GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-
+
void removeItems(FormatsConfigurationItemVisitor* visitor, ConfigurationItemDict& itemsToRemove,
ConfigurationItemDict& localItems)
{
@@ -289,38 +316,60 @@ void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::Syste
localItems.erase(localItem);
}
}
-
+
void visitFormatsGroup(const FormatsGroupPtr& group)
{
if (!mImplPriv->mFormatsGroup)
{
return;
}
-
+
removeItems(0, group->configurationItems, mImplPriv->mFormatsGroup->configurationItems);
};
-
+
private:
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
};
-
- FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
- boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
-
- for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ ContextDataPtr data = checkAndThrow(mImplPriv->mOperationContextCache, context);
+
+ if (!data)
{
- (*group)->visit(v);
+ // retry detected
+ return;
+ }
+
+ try
+ {
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+ data->setCompleted();
+ }
+ catch (const std::exception& e)
+ {
+ data->setException(e);
+ }
+ catch (...)
+ {
+ data->setException();
}
}
-void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+void ConfigurationServiceImpl::removeConfigurationGroups(
+ const AsteriskSCF::System::V1::OperationContextPtr& context,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
{
class GroupVisitor : public FormatsConfigurationGroupVisitor
{
public:
GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
-
+
private:
void visitFormatsGroup(const FormatsGroupPtr&)
{
@@ -331,19 +380,39 @@ void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::Syst
mImplPriv->mDescriptorService->removeAllFormats();
mImplPriv->mComparatorService->removeAllFormats();
-
+
mImplPriv->mFormatsGroup = 0;
};
-
+
boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
};
-
- FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
- boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
-
- for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ ContextDataPtr data = checkAndThrow(mImplPriv->mOperationContextCache, context);
+
+ if (!data)
{
- (*group)->visit(v);
+ // retry detected
+ return;
+ }
+
+ try
+ {
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+ data->setCompleted();
+ }
+ catch (const std::exception& e)
+ {
+ data->setException(e);
+ }
+ catch (...)
+ {
+ data->setException();
}
}
diff --git a/src/Configuration.h b/src/Configuration.h
index 5982fc7..16b0be9 100644
--- a/src/Configuration.h
+++ b/src/Configuration.h
@@ -38,9 +38,12 @@ public:
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
- void setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
- void removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
- void removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void setConfiguration(const AsteriskSCF::System::V1::OperationContextPtr&,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationItems(const AsteriskSCF::System::V1::OperationContextPtr&,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationGroups(const AsteriskSCF::System::V1::OperationContextPtr&,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
private:
/**
diff --git a/src/MediaFormatGeneric.h b/src/MediaFormatGeneric.h
index f5f52c0..643c595 100644
--- a/src/MediaFormatGeneric.h
+++ b/src/MediaFormatGeneric.h
@@ -56,7 +56,8 @@ typedef IceUtil::Handle<SDPDescriptorCompareServiceImpl> SDPDescriptorCompareSer
class SDPDescriptorServiceImpl : public AsteriskSCF::Media::SDP::V1::SDPDescriptorService
{
public:
- AsteriskSCF::Media::V1::FormatPtr getNamedFormat(const std::string&, int, int, const Ice::StringSeq&, const Ice::Current&);
+ AsteriskSCF::Media::V1::FormatPtr getNamedFormat(
+ const std::string&, int, int, const Ice::StringSeq&, const Ice::Current&);
AsteriskSCF::Media::V1::FormatPtr getDescribedFormat(const AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr&,
const Ice::Current&);
AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr getDescriptor(const AsteriskSCF::Media::V1::FormatPtr&,
-----------------------------------------------------------------------
--
asterisk-scf/release/mediaformatgeneric.git
More information about the asterisk-scf-commits
mailing list