[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "bridge-replication" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Feb 15 06:25:12 CST 2011
branch "bridge-replication" has been updated
via 840b5d0a42573922616e25bc3324fb23e08066c7 (commit)
from ee7c92594e2176dffcffd1bd0a0d2cd9b60ec034 (commit)
Summary of changes:
src/BridgeImpl.cpp | 15 ++++++++++-----
src/BridgeManagerImpl.cpp | 15 ++++++++++-----
src/BridgeReplicatorStateListenerI.cpp | 2 +-
src/DebugUtil.h | 1 +
src/Service.cpp | 15 ++++++++++-----
test/BridgeManagerListenerI.cpp | 1 +
test/TestBridging.cpp | 26 +++++++++++++-------------
7 files changed, 46 insertions(+), 29 deletions(-)
- Log -----------------------------------------------------------------
commit 840b5d0a42573922616e25bc3324fb23e08066c7
Author: Brent Eagles <beagles at digium.com>
Date: Mon Feb 14 17:17:18 2011 -0330
Fix bug where replication was being attempted when a standby element was
not activated.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index faa03e9..8e0badb 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -897,13 +897,16 @@ void BridgeImpl::activate(const BridgePrx& proxy)
{
mPrx = proxy;
string listenerId = mObjAdapter->getCommunicator()->identityToString(mPrx->ice_getIdentity());
+ mLogger(Debug) << FUNLOG << " : activating with " << listenerId;
mState->key = listenerId;
mState->bridgeId = listenerId;
listenerId += ".sessionListener";
+ mActivated = true;
mSessionListenerPrx =
SessionListenerPrx::uncheckedCast(
mObjAdapter->add(mSessionListener, mObjAdapter->getCommunicator()->stringToIdentity(listenerId))
);
+ update();
}
BridgeStateItemPtr BridgeImpl::getState()
@@ -911,7 +914,6 @@ BridgeStateItemPtr BridgeImpl::getState()
mLogger(Debug) << FUNLOG;
BridgeStateItemPtr result(new BridgeStateItem);
*result = *mState;
- dumpState(cerr, result, mObjAdapter->getCommunicator());
return result;
}
@@ -924,7 +926,7 @@ void BridgeImpl::updateState(const BridgeStateItemPtr& state)
string BridgeImpl::id()
{
- return mObjAdapter->getCommunicator()->identityToString(mPrx->ice_getIdentity());
+ return mState->bridgeId;
}
void BridgeImpl::activate()
@@ -1035,9 +1037,12 @@ vector<BridgedSessionPtr> BridgeImpl::currentSessions()
void BridgeImpl::update()
{
- ReplicatedStateItemSeq seq;
- seq.push_back(getState());
- mReplicator->setState(seq);
+ if (mActivated)
+ {
+ ReplicatedStateItemSeq seq;
+ seq.push_back(getState());
+ mReplicator->setState(seq);
+ }
}
void BridgeImpl::statePreCheck()
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index e0cd0e8..008c8df 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -199,6 +199,10 @@ BridgePrx BridgeManagerImpl::createBridge(const SessionSeq& sessions,
{
mListeners->bridgeCreated(info.proxy);
}
+ else
+ {
+ mLogger(Debug) << ": bridgeCreated event not published as there are no listeners configured.";
+ }
mBridges.push_back(info);
//
@@ -379,8 +383,6 @@ void BridgeManagerImpl::createBridgeReplica(const BridgeStateItemPtr& state)
BridgeInfo info;
info.servant = bridge;
info.proxy = BridgePrx::uncheckedCast(obj);
-
- bridge->activate(info.proxy);
mBridges.push_back(info);
}
@@ -422,9 +424,12 @@ void BridgeManagerImpl::statePreCheck(const string& caller)
void BridgeManagerImpl::update()
{
- ReplicatedStateItemSeq seq;
- seq.push_back(getState());
- mReplicator->setState(seq);
+ if (mActivated)
+ {
+ ReplicatedStateItemSeq seq;
+ seq.push_back(getState());
+ mReplicator->setState(seq);
+ }
}
} // End of anonymous namespace
diff --git a/src/BridgeReplicatorStateListenerI.cpp b/src/BridgeReplicatorStateListenerI.cpp
index e1159b7..7e9f609 100644
--- a/src/BridgeReplicatorStateListenerI.cpp
+++ b/src/BridgeReplicatorStateListenerI.cpp
@@ -80,7 +80,7 @@ public:
bool found = false;
for (vector<BridgeServantPtr>::iterator b = bridges.begin(); b != bridges.end(); ++b)
{
- if ((*b)->id() == bridgeItem->bridgeId)
+ if ((*b) && (*b)->id() == bridgeItem->bridgeId)
{
(*b)->updateState(bridgeItem);
found = true;
diff --git a/src/DebugUtil.h b/src/DebugUtil.h
index 2551441..9afb360 100644
--- a/src/DebugUtil.h
+++ b/src/DebugUtil.h
@@ -84,6 +84,7 @@ std::ostream& dumpState(std::ostream& os, const AsteriskSCF::Bridge::V1::BridgeS
}
os << "BRIDGE STATE DUMP <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
os << "key : " << state->key << "\nbridge id : " << state->bridgeId << "\n";
+ os << "state : ";
switch (state->runningState)
{
case AsteriskSCF::Bridge::V1::ServiceState::Running:
diff --git a/src/Service.cpp b/src/Service.cpp
index d773280..078ae7a 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -44,9 +44,10 @@ static const string BridgeReplicaId("BridgeChannelReplica");
class ReplicaControl : virtual public Replica
{
public:
- ReplicaControl(const Ice::ObjectAdapterPtr& adapter) :
+ ReplicaControl(const Ice::ObjectAdapterPtr& adapter, const BridgeManagerServantPtr& manager) :
mActive(true),
- mAdapter(adapter)
+ mAdapter(adapter),
+ mManager(manager)
{
}
@@ -58,6 +59,7 @@ public:
bool activate(const Ice::Current&)
{
mActive = true;
+ mManager->activate();
for (vector<ReplicaListenerPrx>::const_iterator i = mListeners.begin(); i != mListeners.end(); ++i)
{
(*i)->activated(ReplicaPrx::uncheckedCast(mAdapter->createDirectProxy(mAdapter->getCommunicator()->stringToIdentity(BridgeReplicaId))));
@@ -87,8 +89,8 @@ public:
private:
bool mActive;
Ice::ObjectAdapterPtr mAdapter;
-
vector<ReplicaListenerPrx> mListeners;
+ BridgeManagerServantPtr mManager;
};
typedef IceUtil::Handle<ReplicaControl> ReplicaControlPtr;
@@ -204,7 +206,7 @@ void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& com
ReplicatorListenerPtr replicaListener = createStateListener(logger, manager);
ReplicatorListenerPrx listenerPrx = ReplicatorListenerPrx::uncheckedCast(mInfrastructureAdapter->addWithUUID(replicaListener));
- mReplicaControl = new ReplicaControl(mInfrastructureAdapter);
+ mReplicaControl = new ReplicaControl(mInfrastructureAdapter, manager);
ReplicaPrx replicaControlPrx =
ReplicaPrx::uncheckedCast(mInfrastructureAdapter->add(mReplicaControl, communicator->stringToIdentity(BridgeReplicaId)));
@@ -218,7 +220,10 @@ void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& com
replicator->addListener(listenerPrx);
replicaControlPrx->standby();
}
- manager->activate();
+ else
+ {
+ manager->activate();
+ }
bool registered = false;
try
diff --git a/test/BridgeManagerListenerI.cpp b/test/BridgeManagerListenerI.cpp
index 2abd677..f180353 100644
--- a/test/BridgeManagerListenerI.cpp
+++ b/test/BridgeManagerListenerI.cpp
@@ -27,6 +27,7 @@ BridgeManagerListenerI::BridgeManagerListenerI() :
void BridgeManagerListenerI::bridgeCreated(const AsteriskSCF::SessionCommunications::V1::BridgeManagerPrx& manager,
const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const Ice::Current&)
{
+ std::cerr << "XXX: bridgeCreated" << std::endl;
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(mMonitor);
++mCreated;
mMonitor.notify();
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 3ffb41d..3fc4510 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -36,6 +36,7 @@
//
using namespace AsteriskSCF::BridgingTest;
+using namespace AsteriskSCF::SessionCommunications::V1;
using namespace std;
/* Cache the command line arguments so that Ice can be initialized within the global fixture. */
@@ -431,6 +432,7 @@ public:
//
channel.commands()->answer(idA);
channel.commands()->answer(idB);
+ mgrPrx->listBridges();
BOOST_CHECK(bridgeListener->addedCount() == 2);
bridge->shutdown();
@@ -623,28 +625,26 @@ public:
AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
AsteriskSCF::SessionCommunications::V1::BridgePrx bridge(mgrPrx->createBridge(sessions, 0));
servant->wait(5000);
- if (servant->createCalls() != 1)
- {
- cerr << "Listener received : "+ servant->createCalls() << " create calls\n";
- }
+ //
+ // Encourage some context shifting to allow the event to propogate.
+ //
+ mgrPrx->listBridges();
+
BOOST_CHECK(servant->createCalls() == 1);
mgrPrx->removeListener(listenerPrx);
+
bridge = mgrPrx->createBridge(sessions, 0);
if (!servant->wait(5000))
{
BOOST_MESSAGE("Wait for event expired");
}
- if (servant->createCalls() != 1)
- {
- cerr << "Listener received : " << servant->createCalls() << " create calls\n";
- }
BOOST_CHECK(servant->createCalls() == 1);
- mgrPrx->removeListener(listenerPrx);
+ BridgeSeq bridges = mgrPrx2->listBridges();
+ BridgeSeq bridges2 = mgrPrx->listBridges();
+ BOOST_CHECK(bridges.size() == bridges2.size());
+ mgrPrx->addListener(listenerPrx);
+ bridge = mgrPrx->createBridge(sessions, 0);
servant->wait(5000);
- if (servant->createCalls() != 2)
- {
- cerr << "Listener received : " << servant->createCalls() << " create calls\n";
- }
BOOST_CHECK(servant->createCalls() == 2);
bridge->shutdown();
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list