summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/demo/Glacier2/callback/config.glacier222
-rw-r--r--cpp/src/Glacier2/Blobject.cpp92
-rw-r--r--cpp/src/Glacier2/Blobject.h31
-rw-r--r--cpp/src/Glacier2/ClientBlobject.cpp12
-rw-r--r--cpp/src/Glacier2/ClientBlobject.h1
-rw-r--r--cpp/src/Glacier2/Request.cpp102
-rw-r--r--cpp/src/Glacier2/Request.h16
7 files changed, 117 insertions, 159 deletions
diff --git a/cpp/demo/Glacier2/callback/config.glacier2 b/cpp/demo/Glacier2/callback/config.glacier2
index a98e4a6ea64..d61bf20319e 100644
--- a/cpp/demo/Glacier2/callback/config.glacier2
+++ b/cpp/demo/Glacier2/callback/config.glacier2
@@ -1,13 +1,23 @@
Glacier2.Client.Endpoints=ssl -p 10005
Glacier2.Server.Endpoints=tcp -h 127.0.0.1
+
+Glacier2.Client.ForwardContext=1
+Glacier2.Server.ForwardContext=1
+
+Glacier2.Client.SleepTime=500
+Glacier2.Server.SleepTime=500
+
+Glacier2.Client.Trace.Request=1
+Glacier2.Server.Trace.Request=1
+
+Glacier2.Client.Trace.Override=1
+Glacier2.Server.Trace.Override=1
+
+Glacier2.Client.Trace.Reject=1
+
Glacier2.Trace.Session=1
-Glacier2.Trace.Client=2
-Glacier2.Trace.Server=2
+
Glacier2.Trace.RoutingTable=1
-Glacier2.Server.ForwardContext=1
-Glacier2.Client.ForwardContext=1
-#Glacier2.Server.SleepTime=2000
-#Glacier2.Client.SleepTime=2000
#Ice.Trace.Network=1
#Ice.Trace.Protocol=1
diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp
index 23ef1a5bc0d..779dc292615 100644
--- a/cpp/src/Glacier2/Blobject.cpp
+++ b/cpp/src/Glacier2/Blobject.cpp
@@ -13,64 +13,15 @@ using namespace std;
using namespace Ice;
using namespace Glacier;
-#ifdef __HP_aCC
-//
-// Compiler bug!
-// The conditional in Glacier::Blobject::Blobject below result in a
-// std::exception "thread synchronization error" at runtime
-// when using string literals (looks like a RogueWave bug)
-// The work around is to use static strings:
-//
-
-static const string traceServer = "Glacier2.Trace.Server";
-static const string traceClient = "Glacier2.Trace.Client";
-
-static const string serverForwardContext = "Glacier2.Server.ForwardContext";
-static const string clientForwardContext = "Glacier2.Client.ForwardContext";
-
-static const string serverSleepTime = "Glacier2.Server.SleepTime";
-static const string clientSleepTime = "Glacier2.Client.SleepTime";
-#endif
-
Glacier::Blobject::Blobject(const CommunicatorPtr& communicator, bool reverse) :
- _communicator(communicator),
- _reverse(reverse),
- _properties(_communicator->getProperties()),
- _logger(_communicator->getLogger()),
-
-#ifdef __HP_aCC
- //
- // Compiler bug, see above
- //
- _traceLevel(_reverse ?
- _properties->getPropertyAsInt(traceServer) :
- _properties->getPropertyAsInt(traceClient)),
- _forwardContext(_reverse ?
- _properties->getPropertyAsInt(serverForwardContext) > 0 :
- _properties->getPropertyAsInt(clientForwardContext) > 0),
- _sleepTime(_reverse ?
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(serverSleepTime)) :
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(clientSleepTime)))
-
-#else
- _traceLevel(_reverse ?
- _properties->getPropertyAsInt("Glacier2.Trace.Server") :
- _properties->getPropertyAsInt("Glacier2.Trace.Client")),
- _forwardContext(_reverse ?
- _properties->getPropertyAsInt("Glacier2.Server.ForwardContext") > 0 :
- _properties->getPropertyAsInt("Glacier2.Client.ForwardContext") > 0),
- _sleepTime(_reverse ?
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt("Glacier2.Server.SleepTime")) :
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt("Glacier2.Client.SleepTime")))
-#endif
+ _logger(communicator->getLogger())
{
- _requestQueue = new RequestQueue(_communicator, _traceLevel, _reverse, _sleepTime);
+ _requestQueue = new RequestQueue(communicator, reverse);
_requestQueueControl = _requestQueue->start();
}
Glacier::Blobject::~Blobject()
{
- assert(!_communicator);
assert(!_requestQueue);
}
@@ -81,8 +32,6 @@ Glacier::Blobject::destroy()
// No mutex protection necessary, destroy is only called after all
// object adapters have shut down.
//
- _communicator = 0;
-
_requestQueue->destroy();
_requestQueueControl.join();
_requestQueue = 0;
@@ -118,38 +67,19 @@ void
Glacier::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB, const vector<Byte>& inParams,
const Current& current)
{
- try
+ modifyProxy(proxy, current);
+
+ if(proxy->ice_isTwoway())
{
- modifyProxy(proxy, current);
-
- if(proxy->ice_isTwoway())
- {
- AMI_Object_ice_invokePtr amiCB = new GlacierCB(amdCB);
- _requestQueue->addRequest(new Request(proxy, inParams, current, _forwardContext, amiCB));
- }
- else
- {
- vector<Byte> dummy;
- amdCB->ice_response(true, dummy);
- _requestQueue->addRequest(new Request(proxy, inParams, current, _forwardContext, 0));
- }
+ AMI_Object_ice_invokePtr amiCB = new GlacierCB(amdCB);
+ _requestQueue->addRequest(new Request(proxy, inParams, current, amiCB));
}
- catch(const Exception& ex)
+ else
{
- if(_traceLevel >= 1)
- {
- Trace out(_logger, "Glacier");
- if(_reverse)
- {
- out << "reverse ";
- }
- out << "routing exception:\n" << ex;
- }
-
- ex.ice_throw();
+ vector<Byte> dummy;
+ amdCB->ice_response(true, dummy);
+ _requestQueue->addRequest(new Request(proxy, inParams, current, 0));
}
-
- return;
}
void
diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h
index e4f462223dd..79eeea4c41e 100644
--- a/cpp/src/Glacier2/Blobject.h
+++ b/cpp/src/Glacier2/Blobject.h
@@ -17,29 +17,6 @@
namespace Glacier
{
-class TwowayThrottle : public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- TwowayThrottle(const Ice::CommunicatorPtr&, bool);
- ~TwowayThrottle();
-
- void twowayStarted(const Ice::ObjectPrx&, const Ice::Current&);
- void twowayFinished();
-
-private:
-
- const Ice::CommunicatorPtr _communicator;
- const bool _reverse;
-
- const Ice::PropertiesPtr _properties;
- const Ice::LoggerPtr _logger;
- const int _traceLevel;
- const int _max;
-
- int _count;
-};
-
class Blobject : public Ice::BlobjectAsync
{
public:
@@ -53,20 +30,12 @@ public:
protected:
- Ice::CommunicatorPtr _communicator;
- const bool _reverse;
-
- const Ice::PropertiesPtr _properties;
const Ice::LoggerPtr _logger;
- const int _traceLevel;
private:
void modifyProxy(Ice::ObjectPrx&, const Ice::Current&) const;
- const bool _forwardContext;
- const IceUtil::Time _sleepTime;
-
RequestQueuePtr _requestQueue;
IceUtil::ThreadControl _requestQueueControl;
};
diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp
index 377e8aa492c..3d3e312e1b7 100644
--- a/cpp/src/Glacier2/ClientBlobject.cpp
+++ b/cpp/src/Glacier2/ClientBlobject.cpp
@@ -17,11 +17,14 @@ using namespace std;
using namespace Ice;
using namespace Glacier;
+static const string clientTraceReject = "Glacier2.Client.Trace.Reject";
+
Glacier::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator,
const IceInternal::RoutingTablePtr& routingTable,
const string& allowCategories) :
Glacier::Blobject(communicator, false),
- _routingTable(routingTable)
+ _routingTable(routingTable),
+ _traceLevelReject(communicator->getProperties()->getPropertyAsInt(clientTraceReject))
{
const string ws = " \t";
string::size_type current = allowCategories.find_first_not_of(ws, 0);
@@ -52,8 +55,6 @@ void
Glacier::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCB, const vector<Byte>& inParams,
const Current& current)
{
- assert(_communicator); // Destroyed?
-
//
// If there is an _allowCategories set then enforce it.
//
@@ -61,9 +62,9 @@ Glacier::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& a
{
if(!binary_search(_allowCategories.begin(), _allowCategories.end(), current.id.category))
{
- if(_traceLevel >= 1)
+ if(_traceLevelReject >= 1)
{
- Trace out(_logger, "Glacier");
+ Trace out(current.adapter->getCommunicator()->getLogger(), "Glacier");
out << "rejecting request\n";
out << "identity: " << identityToString(current.id);
}
@@ -73,6 +74,7 @@ Glacier::ClientBlobject::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& a
}
}
+ assert(_routingTable); // Destroyed?
ObjectPrx proxy = _routingTable->get(current.id);
if(!proxy)
{
diff --git a/cpp/src/Glacier2/ClientBlobject.h b/cpp/src/Glacier2/ClientBlobject.h
index 7428357d491..b96a5235c93 100644
--- a/cpp/src/Glacier2/ClientBlobject.h
+++ b/cpp/src/Glacier2/ClientBlobject.h
@@ -33,6 +33,7 @@ private:
IceInternal::RoutingTablePtr _routingTable;
std::vector<std::string> _allowCategories;
+ const int _traceLevelReject;
};
}
diff --git a/cpp/src/Glacier2/Request.cpp b/cpp/src/Glacier2/Request.cpp
index 35bef8a9cfa..091299bdb65 100644
--- a/cpp/src/Glacier2/Request.cpp
+++ b/cpp/src/Glacier2/Request.cpp
@@ -15,11 +15,10 @@ using namespace Ice;
using namespace Glacier;
Glacier::Request::Request(const ObjectPrx& proxy, const vector<Byte>& inParams, const Current& current,
- bool forwardContext, const AMI_Object_ice_invokePtr& amiCB) :
+ const AMI_Object_ice_invokePtr& amiCB) :
_proxy(proxy),
_inParams(inParams),
_current(current),
- _forwardContext(forwardContext),
_amiCB(amiCB)
{
Context::const_iterator p = current.ctx.find("_ovrd");
@@ -30,14 +29,14 @@ Glacier::Request::Request(const ObjectPrx& proxy, const vector<Byte>& inParams,
}
void
-Glacier::Request::invoke()
+Glacier::Request::invoke(bool forwardContext)
{
if(_proxy->ice_isTwoway())
{
assert(_amiCB);
try
{
- if(_forwardContext)
+ if(forwardContext)
{
_proxy->ice_invoke_async(_amiCB, _current.operation, _current.mode, _inParams, _current.ctx);
}
@@ -54,7 +53,7 @@ Glacier::Request::invoke()
else
{
vector<Byte> dummy;
- if(_forwardContext)
+ if(forwardContext)
{
_proxy->ice_invoke(_current.operation, _current.mode, _inParams, dummy, _current.ctx);
}
@@ -66,7 +65,7 @@ Glacier::Request::invoke()
}
bool
-Glacier::Request::override(const RequestPtr& other)
+Glacier::Request::override(const RequestPtr& other) const
{
//
// Both override values have to be non-empty.
@@ -108,13 +107,30 @@ Glacier::Request::getCurrent() const
return _current;
}
-Glacier::RequestQueue::RequestQueue(const Ice::CommunicatorPtr& communicator, int traceLevel, bool reverse,
- const IceUtil::Time& sleepTime) :
- _communicator(communicator),
+static const string serverTraceRequest = "Glacier2.Server.Trace.Request";
+static const string clientTraceRequest = "Glacier2.Client.Trace.Request";
+static const string serverTraceOverride = "Glacier2.Server.Trace.Override";
+static const string clientTraceOverride = "Glacier2.Client.Trace.Override";
+static const string serverForwardContext = "Glacier2.Server.ForwardContext";
+static const string clientForwardContext = "Glacier2.Client.ForwardContext";
+static const string serverSleepTime = "Glacier2.Server.SleepTime";
+static const string clientSleepTime = "Glacier2.Client.SleepTime";
+
+Glacier::RequestQueue::RequestQueue(const Ice::CommunicatorPtr& communicator, bool reverse) :
_logger(communicator->getLogger()),
- _traceLevel(traceLevel),
_reverse(reverse),
- _sleepTime(sleepTime),
+ _traceLevelRequest(_reverse ?
+ communicator->getProperties()->getPropertyAsInt(serverTraceRequest) :
+ communicator->getProperties()->getPropertyAsInt(clientTraceRequest)),
+ _traceLevelOverride(_reverse ?
+ communicator->getProperties()->getPropertyAsInt(serverTraceOverride) :
+ communicator->getProperties()->getPropertyAsInt(clientTraceOverride)),
+ _forwardContext(_reverse ?
+ communicator->getProperties()->getPropertyAsInt(serverForwardContext) > 0 :
+ communicator->getProperties()->getPropertyAsInt(clientForwardContext) > 0),
+ _sleepTime(_reverse ?
+ IceUtil::Time::milliSeconds(communicator->getProperties()->getPropertyAsInt(serverSleepTime)) :
+ IceUtil::Time::milliSeconds(communicator->getProperties()->getPropertyAsInt(clientSleepTime))),
_destroy(false)
{
}
@@ -123,7 +139,6 @@ Glacier::RequestQueue::~RequestQueue()
{
assert(_destroy);
assert(_requests.empty());
- assert(!_communicator);
}
void
@@ -133,7 +148,6 @@ Glacier::RequestQueue::destroy()
_destroy = true;
_requests.clear();
- _communicator = 0;
notify();
}
@@ -152,6 +166,12 @@ Glacier::RequestQueue::addRequest(const RequestPtr& request)
if(request->override(*p))
{
*p = request; // Replace old request if this is an override.
+
+ if(_traceLevelOverride >= 1)
+ {
+ traceRequest(request, "override");
+ }
+
return;
}
}
@@ -166,7 +186,6 @@ Glacier::RequestQueue::run()
{
while(true)
{
- CommunicatorPtr communicator;
vector<RequestPtr> requests;
set<TransportInfoPtr> flushSet;
@@ -186,7 +205,6 @@ Glacier::RequestQueue::run()
return;
}
- communicator = _communicator;
requests.swap(_requests);
}
@@ -207,22 +225,12 @@ Glacier::RequestQueue::run()
flushSet.insert(proxy->ice_getTransportInfo());
}
- if(_traceLevel >= 2)
+ if(_traceLevelRequest >= 1)
{
- const Current& current = (*p)->getCurrent();
-
- Trace out(_logger, "Glacier");
-
- if(_reverse)
- {
- out << "reverse ";
- }
- out << "routing to:"
- << "\nproxy = " << communicator->proxyToString(proxy)
- << "\noperation = " << current.operation;
+ traceRequest(*p, "");
}
- (*p)->invoke();
+ (*p)->invoke(_forwardContext);
}
for_each(flushSet.begin(), flushSet.end(), Ice::voidMemFun(TransportInfo::flushBatchRequests));
@@ -231,7 +239,7 @@ Glacier::RequestQueue::run()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- if(_traceLevel >= 1)
+ if(_traceLevelRequest >= 1)
{
Trace out(_logger, "Glacier");
if(_reverse)
@@ -252,3 +260,39 @@ Glacier::RequestQueue::run()
}
}
}
+
+void
+Glacier::RequestQueue::traceRequest(const RequestPtr& request, const string& extra) const
+{
+ Trace out(_logger, "Glacier");
+
+ const ObjectPrx& proxy = request->getProxy();
+ const Current& current = request->getCurrent();
+
+ if(_reverse)
+ {
+ out << "reverse ";
+ }
+
+ out << "routing";
+
+ if(!extra.empty())
+ {
+ out << ' ' << extra;
+ }
+
+ out << "\nproxy = " << current.adapter->getCommunicator()->proxyToString(proxy);
+
+ out << "\noperation = " << current.operation;
+
+ out << "\ncontext = ";
+ Context::const_iterator q = current.ctx.begin();
+ while(q != current.ctx.end())
+ {
+ out << q->first << '/' << q->second;
+ if(++q != current.ctx.end())
+ {
+ out << ", ";
+ }
+ }
+}
diff --git a/cpp/src/Glacier2/Request.h b/cpp/src/Glacier2/Request.h
index 54667fdff79..90d10243636 100644
--- a/cpp/src/Glacier2/Request.h
+++ b/cpp/src/Glacier2/Request.h
@@ -24,11 +24,11 @@ class Request : virtual public IceUtil::Shared
{
public:
- Request(const Ice::ObjectPrx&, const std::vector<Ice::Byte>&, const Ice::Current&, bool,
+ Request(const Ice::ObjectPrx&, const std::vector<Ice::Byte>&, const Ice::Current&,
const Ice::AMI_Object_ice_invokePtr&);
- void invoke();
- bool override(const RequestPtr&);
+ void invoke(bool);
+ bool override(const RequestPtr&) const;
const Ice::ObjectPrx& getProxy() const;
const Ice::Current& getCurrent() const;
@@ -49,21 +49,23 @@ class RequestQueue : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mu
{
public:
- RequestQueue(const Ice::CommunicatorPtr&, int, bool, const IceUtil::Time&);
+ RequestQueue(const Ice::CommunicatorPtr&, bool);
virtual ~RequestQueue();
void destroy();
void addRequest(const RequestPtr&);
- void addBatchRequest(const RequestPtr&);
virtual void run();
private:
- Ice::CommunicatorPtr _communicator;
+ void traceRequest(const RequestPtr&, const std::string&) const;
+
const Ice::LoggerPtr _logger;
- const int _traceLevel;
const bool _reverse;
+ const int _traceLevelRequest;
+ const int _traceLevelOverride;
+ const bool _forwardContext;
const IceUtil::Time _sleepTime;
std::vector<RequestPtr> _requests;