From 3b0588532354adf7bf3b86e611a8ae4996bfe6ad Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Wed, 3 Sep 2014 11:01:11 -0230 Subject: - C#, Java: Removed Outgoing, fixed generated code to make synchronous requests using AMI. - Java: AsyncResult is now an interface. - Added --arg to allTests.py. - Fixed operations, adapterDeactivation and metrics test to work with background IO. - Added Collocated interrupt test. - Added support for batch oneway requests using AMI. - Added test in operations for batch oneway requests using AMI. --- cpp/src/Ice/OutgoingAsync.cpp | 77 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 11 deletions(-) (limited to 'cpp/src/Ice/OutgoingAsync.cpp') diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 749384821f4..c9d0ac28234 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -456,15 +456,42 @@ IceInternal::OutgoingAsync::__prepare(const std::string& operation, OperationMod _observer.attach(_proxy.get(), operation, context); - // - // Can't call async via a batch proxy. - // - if(_proxy->ice_isBatchOneway() || _proxy->ice_isBatchDatagram()) + switch(_proxy->__reference()->getMode()) { - throw Ice::FeatureNotSupportedException(__FILE__, __LINE__, "can't send batch requests with AMI"); - } + case Reference::ModeTwoway: + case Reference::ModeOneway: + case Reference::ModeDatagram: + { + _os.writeBlob(requestHdr, sizeof(requestHdr)); + break; + } - _os.writeBlob(requestHdr, sizeof(requestHdr)); + case Reference::ModeBatchOneway: + case Reference::ModeBatchDatagram: + { + while(true) + { + try + { + _handler = _proxy->__getRequestHandler(); + _handler->prepareBatchRequest(&_os); + break; + } + catch(const RetryException&) + { + _proxy->__setRequestHandler(_handler, 0); // Clear request handler and retry. + } + catch(const Ice::LocalException& ex) + { + _observer.failed(ex.ice_name()); + _proxy->__setRequestHandler(_handler, 0); // Clear request handler + _handler = 0; + throw; + } + } + break; + } + } Reference* ref = _proxy->__reference().get(); @@ -535,7 +562,7 @@ IceInternal::OutgoingAsync::__sent() _sent = true; assert(!(_state & Done)); - if(_proxy->__reference()->getMode() != Reference::ModeTwoway) + if(!_proxy->ice_isTwoway()) { _childObserver.detach(); if(!_callback || !_callback->hasSentCallback()) @@ -594,6 +621,25 @@ IceInternal::OutgoingAsync::__finished(const Ice::Exception& exc) } } +void +IceInternal::OutgoingAsync::__invokeExceptionAsync(const Ice::Exception& ex) +{ + if((_state & Done) == 0 && _handler) + { + // + // If we didn't finish a batch oneway or datagram request, we + // must notify the connection about that we give up ownership + // of the batch stream. + // + int mode = _proxy->__reference()->getMode(); + if(mode == Reference::ModeBatchOneway || mode == Reference::ModeBatchDatagram) + { + _handler->abortBatchRequest(); + } + } + AsyncResult::__invokeExceptionAsync(ex); +} + void IceInternal::OutgoingAsync::__finished() { @@ -757,12 +803,21 @@ IceInternal::OutgoingAsync::__finished() bool IceInternal::OutgoingAsync::__invoke(bool synchronous) { + const Reference::Mode mode = _proxy->__reference()->getMode(); + if(mode == Reference::ModeBatchOneway || mode == Reference::ModeBatchDatagram) + { + _state |= Done | OK; + _handler->finishBatchRequest(&_os); + _observer.detach(); + return true; + } + while(true) { try { _sent = false; - _handler = _proxy->__getRequestHandler(true); + _handler = _proxy->__getRequestHandler(); AsyncStatus status = _handler->sendAsyncRequest(this); if(status & AsyncStatusSent) { @@ -783,7 +838,7 @@ IceInternal::OutgoingAsync::__invoke(bool synchronous) } } - if(_proxy->ice_isTwoway() || !(status & AsyncStatusSent)) + if(mode == Reference::ModeTwoway || !(status & AsyncStatusSent)) { IceUtil::Monitor::Lock sync(_monitor); if(!(_state & Done)) @@ -921,7 +976,7 @@ IceInternal::ProxyBatchOutgoingAsync::__invoke() RequestHandlerPtr handler; try { - handler = _proxy->__getRequestHandler(true); + handler = _proxy->__getRequestHandler(); AsyncStatus status = handler->sendAsyncRequest(this); if(status & AsyncStatusSent) { -- cgit v1.2.3