[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "retry_deux" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Jan 17 17:28:29 CST 2012


branch "retry_deux" has been created
        at  7c49b6b4767c55addec761e35de7693615ea9475 (commit)

- Log -----------------------------------------------------------------
commit 7c49b6b4767c55addec761e35de7693615ea9475
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Tue Jan 17 17:28:21 2012 -0600

    Minor tweaks to the RetryPolicy helper.

diff --git a/include/AsteriskSCF/Helpers/Retry.h b/include/AsteriskSCF/Helpers/Retry.h
index 3d89bfb..2bb2622 100644
--- a/include/AsteriskSCF/Helpers/Retry.h
+++ b/include/AsteriskSCF/Helpers/Retry.h
@@ -55,7 +55,7 @@ public:
      *
      * @returns true if there are attempts left.
      **/
-    bool canRetry()
+    bool canRetry() const
     {
         return mCounter < mMaxRetries;
     }
@@ -72,9 +72,14 @@ public:
         return canRetry();
     }
 
+    size_t getMaxRetries() const
+    {
+        return mMaxRetries;
+    }
+
 private:
-    size_t mMaxRetries;
-    IceUtil::Time mRetryInterval;
+    const size_t mMaxRetries;
+    const IceUtil::Time mRetryInterval;
     size_t mCounter;
 };
 

commit 2caccb8646c9ffac4ce4851e8842c8f45582d1e5
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Jan 5 11:13:14 2012 -0400

    Add helper class for marking an item as destroyed and retrieving the destruction status. (issue ASTSCF-290)

diff --git a/include/AsteriskSCF/WorkQueue/Dispatched.h b/include/AsteriskSCF/WorkQueue/Dispatched.h
new file mode 100644
index 0000000..b69bcf8
--- /dev/null
+++ b/include/AsteriskSCF/WorkQueue/Dispatched.h
@@ -0,0 +1,49 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+#pragma once
+
+#include <boost/interprocess/detail/atomic.hpp>
+
+namespace AsteriskSCF
+{
+namespace WorkQueue
+{
+
+class ASTSCF_DLL_EXPORT Dispatched
+{
+public:
+    Dispatched() : mDestroyed(0) { }
+
+    void setDestroyed() { boost::interprocess::detail::atomic_inc32(&mDestroyed); }
+
+    bool isDestroyed()
+    {
+        if (boost::interprocess::detail::atomic_read32(&mDestroyed) > 0)
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+private:
+    unsigned int mDestroyed;
+};
+
+}; //end namespace WorkQueue
+}; //end namespace AsteriskSCF
diff --git a/test/WorkQueue/TestWorkQueue.cpp b/test/WorkQueue/TestWorkQueue.cpp
index 099445f..b7d77ef 100644
--- a/test/WorkQueue/TestWorkQueue.cpp
+++ b/test/WorkQueue/TestWorkQueue.cpp
@@ -19,6 +19,7 @@
 
 #include <AsteriskSCF/WorkQueue/WorkQueue.h>
 #include <AsteriskSCF/WorkQueue/DefaultQueueListener.h>
+#include <AsteriskSCF/WorkQueue/Dispatched.h>
 
 using namespace AsteriskSCF::System::WorkQueue::V1;
 using namespace AsteriskSCF::WorkQueue;
@@ -75,6 +76,34 @@ public:
 
 typedef IceUtil::Handle<Task> TaskPtr;
 
+class RandomObject : public IceUtil::Shared, public Dispatched
+{
+};
+
+typedef IceUtil::Handle<RandomObject> RandomObjectPtr;
+
+class DispatchedTask : public Work
+{
+public:
+    DispatchedTask(const RandomObjectPtr& object) : mObject(object), taskExecuted(false), taskAborted(false) { }
+    void execute()
+    {
+        if (mObject->isDestroyed())
+        {
+            taskAborted = true;
+        }
+        else
+        {
+            taskExecuted = true;
+        }
+    }
+    RandomObjectPtr mObject;
+    bool taskExecuted;
+    bool taskAborted;
+};
+
+typedef IceUtil::Handle<DispatchedTask> DispatchedTaskPtr;
+
 class ThreadHook : public Ice::ThreadNotification
 {
 public:
@@ -353,6 +382,51 @@ BOOST_AUTO_TEST_CASE(executeNonExistent)
     BOOST_CHECK(listener->shutdownNotice == true);
 }
 
+BOOST_AUTO_TEST_CASE(dispatchedWorkExecution)
+{
+    TestListenerPtr listener(new TestListener);
+    QueuePtr queue(new WorkQueue(listener));
+    RandomObjectPtr randomObject(new RandomObject());
+    DispatchedTaskPtr work(new DispatchedTask(randomObject));
+
+    queue->enqueueWork(work);
+    bool moreWork = queue->executeWork();
+
+    BOOST_CHECK(moreWork == false);
+    BOOST_CHECK(work->taskExecuted == true);
+    BOOST_CHECK(work->taskAborted == false);
+    BOOST_CHECK(listener->emptyNotice == true);
+    BOOST_CHECK(queue->getSize() == 0);
+
+    queue->shutdown();
+
+    BOOST_CHECK(listener->shutdownNotice == true);
+}
+
+BOOST_AUTO_TEST_CASE(dispatchedWorkAbortion)
+{
+    TestListenerPtr listener(new TestListener);
+    QueuePtr queue(new WorkQueue(listener));
+    RandomObjectPtr randomObject(new RandomObject());
+    DispatchedTaskPtr work(new DispatchedTask(randomObject));
+
+    queue->enqueueWork(work);
+
+    randomObject->setDestroyed();
+
+    bool moreWork = queue->executeWork();
+
+    BOOST_CHECK(moreWork == false);
+    BOOST_CHECK(work->taskExecuted == false);
+    BOOST_CHECK(work->taskAborted == true);
+    BOOST_CHECK(listener->emptyNotice == true);
+    BOOST_CHECK(queue->getSize() == 0);
+
+    queue->shutdown();
+
+    BOOST_CHECK(listener->shutdownNotice == true);
+}
+
 BOOST_AUTO_TEST_CASE(executionOrder1)
 {
     TestListenerPtr listener(new TestListener);

commit cd330e8a7fd8520dba57d6b6f6707c5283de0c6e
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jan 3 14:37:37 2012 -0600

    Adjust component library names and update test config files

diff --git a/config/IceUtilCppTests.conf b/config/IceUtilCppTests.conf
index e2671c4..e98a9e9 100644
--- a/config/IceUtilCppTests.conf
+++ b/config/IceUtilCppTests.conf
@@ -17,4 +17,4 @@ IceBox.ServiceManager.Endpoints=default -h 127.0.0.1 -p 56000
 IceBox.ServiceManager.ThreadPool.Size=4
 IceBoxManager.Proxy=IceBox/ServiceManager:default -h 127.0.0.1 -p 56000
 
-IceBox.Service.ProxyHelper=astscf-ice-util-cpp-test:create
+IceBox.Service.ProxyHelper=ASTSCFIceUtilCppTest:create
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3031d1e..1e0cd0a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,18 +1,18 @@
-astscf_component_init(ASTSCFIceUtilCpp-test)
+astscf_component_init(ASTSCFIceUtilCppTest)
 astscf_slice_collection(LOCAL PATH "${CMAKE_CURRENT_SOURCE_DIR}")
-astscf_component_add_slices(ASTSCFIceUtilCpp-test LOCAL ProxyHelper/SimpleIf.ice)
-astscf_component_add_files(ASTSCFIceUtilCpp-test LocatorRegistration/LocatorRegistrationTest.cpp)
-astscf_component_add_files(ASTSCFIceUtilCpp-test LocatorRegistration/LocatorRegistrationTest.h)
-astscf_component_add_files(ASTSCFIceUtilCpp-test PropertyHelper/PropertyHelperTest.cpp)
-astscf_component_add_files(ASTSCFIceUtilCpp-test PropertyHelper/PropertyHelperTest.h)
-astscf_component_add_files(ASTSCFIceUtilCpp-test ProxyHelper/ProxyHelperTests.cpp)
-astscf_component_add_files(ASTSCFIceUtilCpp-test ProxyHelper/ProxyHelperTests.h)
-astscf_component_add_files(ASTSCFIceUtilCpp-test UtilityTests.cpp)
-astscf_component_add_ice_libraries(ASTSCFIceUtilCpp-test IceBox)
-astscf_component_add_boost_libraries(ASTSCFIceUtilCpp-test unit_test_framework date_time thread)
-astscf_component_add_slice_collection_libraries(ASTSCFIceUtilCpp-test ASTSCF)
-astscf_component_build_icebox(ASTSCFIceUtilCpp-test)
-astscf_test_icebox(ASTSCFIceUtilCpp-test config/IceUtilCppTests.conf)
+astscf_component_add_slices(ASTSCFIceUtilCppTest LOCAL ProxyHelper/SimpleIf.ice)
+astscf_component_add_files(ASTSCFIceUtilCppTest LocatorRegistration/LocatorRegistrationTest.cpp)
+astscf_component_add_files(ASTSCFIceUtilCppTest LocatorRegistration/LocatorRegistrationTest.h)
+astscf_component_add_files(ASTSCFIceUtilCppTest PropertyHelper/PropertyHelperTest.cpp)
+astscf_component_add_files(ASTSCFIceUtilCppTest PropertyHelper/PropertyHelperTest.h)
+astscf_component_add_files(ASTSCFIceUtilCppTest ProxyHelper/ProxyHelperTests.cpp)
+astscf_component_add_files(ASTSCFIceUtilCppTest ProxyHelper/ProxyHelperTests.h)
+astscf_component_add_files(ASTSCFIceUtilCppTest UtilityTests.cpp)
+astscf_component_add_ice_libraries(ASTSCFIceUtilCppTest IceBox)
+astscf_component_add_boost_libraries(ASTSCFIceUtilCppTest unit_test_framework date_time thread)
+astscf_component_add_slice_collection_libraries(ASTSCFIceUtilCppTest ASTSCF)
+astscf_component_build_icebox(ASTSCFIceUtilCppTest)
+astscf_test_icebox(ASTSCFIceUtilCppTest config/IceUtilCppTests.conf)
 
 add_subdirectory(Async)
 add_subdirectory(Component)

commit 60d6e20934eba3fa76c3fed6bac751ef4bf61ec5
Merge: 6226bac e61c485
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Dec 30 14:53:25 2011 -0600

    Merge branch 'master' of git.asterisk.org:asterisk-scf/release/ice-util-cpp


commit e61c48510445e079475a77e1a374225bc53cf768
Author: Brent Eagles <beagles at digium.com>
Date:   Tue Dec 6 16:46:23 2011 -0330

    All proxies and object adapters use the loopback adapter for endpoints
    instead of all available interfaces.

diff --git a/config/IceUtilCppTests.conf b/config/IceUtilCppTests.conf
index 029ae1a..e2671c4 100644
--- a/config/IceUtilCppTests.conf
+++ b/config/IceUtilCppTests.conf
@@ -13,8 +13,8 @@ Ice.Default.CollocationOptimized=0
 # We use a single file for configuration.
 #
 IceBox.InheritProperties=1
-IceBox.ServiceManager.Endpoints=default -p 56000
+IceBox.ServiceManager.Endpoints=default -h 127.0.0.1 -p 56000
 IceBox.ServiceManager.ThreadPool.Size=4
-IceBoxManager.Proxy=IceBox/ServiceManager:default -p 56000
+IceBoxManager.Proxy=IceBox/ServiceManager:default -h 127.0.0.1 -p 56000
 
 IceBox.Service.ProxyHelper=astscf-ice-util-cpp-test:create
diff --git a/test/Component/ComponentTest.cpp b/test/Component/ComponentTest.cpp
index 680143c..cc56c5a 100644
--- a/test/Component/ComponentTest.cpp
+++ b/test/Component/ComponentTest.cpp
@@ -101,7 +101,7 @@ struct GlobalIceFixture
         int status = 0;
         try
         {
-            IceBoxTestEnv.adapter  = IceBoxTestEnv.communicator->createObjectAdapterWithEndpoints("ComponentTest", "default -p 10300");
+            IceBoxTestEnv.adapter  = IceBoxTestEnv.communicator->createObjectAdapterWithEndpoints("ComponentTest", "default -h 127.0.0.1 -p 10300");
             sharedTestData.mListener = new MockServiceListenerImpl();
             sharedTestData.mListenerPrx = MockServiceListenerPrx::uncheckedCast(
                 IceBoxTestEnv.adapter->addWithUUID(sharedTestData.mListener));
diff --git a/test/Component/component-base-test.conf b/test/Component/component-base-test.conf
index 17e30f3..f958bad 100644
--- a/test/Component/component-base-test.conf
+++ b/test/Component/component-base-test.conf
@@ -14,8 +14,8 @@ IceBox.Service.ComponentTest=component-base-test:create
 
 IceBox.LoadOrder=ServiceDiscovery,MockComponent,ComponentTest
 
-MockComponent.ServiceAdapter.Endpoints=tcp -p 10090
-MockComponent.BackplaneAdapter.Endpoints=tcp -p 10091
+MockComponent.ServiceAdapter.Endpoints=tcp -h 127.0.0.1 -p 10090
+MockComponent.BackplaneAdapter.Endpoints=tcp -h 127.0.0.1 -p 10091
 MockComponent.ThreadPool.Size=4
 MockComponent.ThreadPool.SizeMax=10
 MockComponent.ThreadPool.SizeWarn=9
@@ -27,26 +27,26 @@ MockComponent.Standby=no
 
 # For testing
 ComponentTest.Endpoints=tcp -p 10300
-ComponentService.Proxy=ComponentService:tcp -p 10091
-LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -p 4412
-LocatorService.Proxy=LocatorService:tcp -p 4411
+ComponentService.Proxy=ComponentService:tcp -h 127.0.0.1 -p 10091
+LocatorServiceManagement.Proxy=LocatorServiceManagement:tcp -h 127.0.0.1 -p 4412
+LocatorService.Proxy=LocatorService:tcp -h 127.0.0.1 -p 4411
 
 # Endpoints for Icestorm events
-TopicManager.Proxy=ServiceDiscovery/TopicManager:default -p 4421
+TopicManager.Proxy=ServiceDiscovery/TopicManager:default -h 127.0.0.1 -p 4421
 
 ##########################################
 # Service Locator properties
 
 ServiceDiscovery.IceStorm.InstanceName=ServiceDiscovery
-ServiceDiscovery.IceStorm.TopicManager.Endpoints=default -p 4421
-ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -p 4422:udp -p 4422
+ServiceDiscovery.IceStorm.TopicManager.Endpoints=default -h 127.0.0.1 -p 4421
+ServiceDiscovery.IceStorm.Publish.Endpoints=tcp -h 127.0.0.1 -p 4422:udp -h 127.0.0.1 -p 4422
 ServiceDiscovery.IceStorm.Trace.TopicManager=2
 ServiceDiscovery.IceStorm.Transient=1
 ServiceDiscovery.IceStorm.Flush.Timeout=2000
 
-ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -p 4412
-ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -p 4411
-ServiceDiscovery.BackplaneAdapter.Endpoints=tcp -p 4410
+ServiceDiscovery.Management.ServiceAdapter.Endpoints=tcp -h 127.0.0.1 -p 4412
+ServiceDiscovery.Locator.ServiceAdapter.Endpoints=tcp -h 127.0.0.1 -p 4411
+ServiceDiscovery.BackplaneAdapter.Endpoints=tcp -h 127.0.0.1 -p 4410
 ServiceDiscovery.Standalone=true
 
 

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list