This is Unofficial EPICS BASE Doxygen Site
epics::pvAccess::ServerChannelFindRequesterImpl Class Reference

#include "responseHandlers.h"

+ Inheritance diagram for epics::pvAccess::ServerChannelFindRequesterImpl:
+ Collaboration diagram for epics::pvAccess::ServerChannelFindRequesterImpl:

Public Member Functions

 ServerChannelFindRequesterImpl (ServerContextImpl::shared_pointer const &context, const PeerInfo::const_shared_pointer &peer, epics::pvData::int32 expectedResponseCount)
 
virtual ~ServerChannelFindRequesterImpl ()
 
void clear ()
 
ServerChannelFindRequesterImplset (std::string _name, epics::pvData::int32 searchSequenceId, epics::pvData::int32 cid, osiSockAddr const &sendTo, bool responseRequired, bool serverSearch)
 
virtual void channelFindResult (const epics::pvData::Status &status, ChannelFind::shared_pointer const &channelFind, bool wasFound) OVERRIDE FINAL
 
virtual std::tr1::shared_ptr< const PeerInfogetPeerInfo () OVERRIDE FINAL
 Return information on requesting peer if applicable. More...
 
virtual void send (epics::pvData::ByteBuffer *buffer, TransportSendControl *control) OVERRIDE FINAL
 
virtual void callback () OVERRIDE FINAL
 
virtual void timerStopped () OVERRIDE FINAL
 
- Public Member Functions inherited from epics::pvAccess::ChannelFindRequester
 POINTER_DEFINITIONS (ChannelFindRequester)
 
virtual ~ChannelFindRequester ()
 
- Public Member Functions inherited from epics::pvAccess::TransportSender
 POINTER_DEFINITIONS (TransportSender)
 
 TransportSender ()
 
virtual ~TransportSender ()
 
- Public Member Functions inherited from epics::pvAccess::Lockable
 POINTER_DEFINITIONS (Lockable)
 
virtual ~Lockable ()
 
virtual void lock ()
 
virtual void unlock ()
 
- Public Member Functions inherited from epics::pvAccess::fair_queue< T >::entry
 entry ()
 
 ~entry ()
 
- Public Member Functions inherited from epics::pvData::TimerCallback
 POINTER_DEFINITIONS (TimerCallback)
 
 TimerCallback ()
 
virtual ~TimerCallback ()
 

Additional Inherited Members

- Public Types inherited from epics::pvAccess::ChannelFindRequester
typedef ChannelFind operation_type
 
- Public Attributes inherited from epics::pvAccess::TransportSender
size_t bytesTX
 
size_t bytesRX
 

Detailed Description

Definition at line 134 of file responseHandlers.h.

Constructor & Destructor Documentation

epics::pvAccess::ServerChannelFindRequesterImpl::ServerChannelFindRequesterImpl ( ServerContextImpl::shared_pointer const &  context,
const PeerInfo::const_shared_pointer &  peer,
epics::pvData::int32  expectedResponseCount 
)

Definition at line 384 of file responseHandlers.cpp.

385  :
386  _guid(context->getGUID()),
387  _sendTo(),
388  _wasFound(false),
389  _context(context),
390  _peer(peer),
391  _expectedResponseCount(expectedResponseCount),
392  _responseCount(0),
393  _serverSearch(false)
394 {}
virtual epics::pvAccess::ServerChannelFindRequesterImpl::~ServerChannelFindRequesterImpl ( )
inlinevirtual

Definition at line 144 of file responseHandlers.h.

144 {}

Member Function Documentation

void epics::pvAccess::ServerChannelFindRequesterImpl::callback ( )
virtual

The method that is called when a timer expires.

Implements epics::pvData::TimerCallback.

Definition at line 404 of file responseHandlers.cpp.

405 {
406  channelFindResult(Status::Ok, ChannelFind::shared_pointer(), false);
407 }
static Status Ok
Definition: status.h:47
virtual void channelFindResult(const epics::pvData::Status &status, ChannelFind::shared_pointer const &channelFind, bool wasFound) OVERRIDE FINAL
void epics::pvAccess::ServerChannelFindRequesterImpl::channelFindResult ( const epics::pvData::Status status,
ChannelFind::shared_pointer const &  channelFind,
bool  wasFound 
)
virtual
Parameters
statusCompletion status.

Implements epics::pvAccess::ChannelFindRequester.

Definition at line 427 of file responseHandlers.cpp.

428 {
429  // TODO status
430  Lock guard(_mutex);
431 
432  _responseCount++;
433  if (_responseCount > _expectedResponseCount)
434  {
435  if ((_responseCount+1) == _expectedResponseCount)
436  {
437  LOG(logLevelDebug,"[ServerChannelFindRequesterImpl::channelFindResult] More responses received than expected fpr channel '%s'!", _name.c_str());
438  }
439  return;
440  }
441 
442  if (wasFound && _wasFound)
443  {
444  LOG(logLevelDebug,"[ServerChannelFindRequesterImpl::channelFindResult] Channel '%s' is hosted by different channel providers!", _name.c_str());
445  return;
446  }
447 
448  if (wasFound || (_responseRequired && (_responseCount == _expectedResponseCount)))
449  {
450  if (wasFound && _expectedResponseCount > 1)
451  {
452  Lock L(_context->_mutex);
453  _context->s_channelNameToProvider[_name] = channelFind->getChannelProvider();
454  }
455  _wasFound = wasFound;
456 
457  BlockingUDPTransport::shared_pointer bt = _context->getBroadcastTransport();
458  if (bt)
459  {
460  TransportSender::shared_pointer thisSender = shared_from_this();
461  bt->enqueueSendRequest(thisSender);
462  }
463  }
464 }
A lock for multithreading.
Definition: lock.h:36
#define LOG(level, format,...)
Definition: logger.h:48
void epics::pvAccess::ServerChannelFindRequesterImpl::clear ( )

Definition at line 396 of file responseHandlers.cpp.

397 {
398  Lock guard(_mutex);
399  _wasFound = false;
400  _responseCount = 0;
401  _serverSearch = false;
402 }
A lock for multithreading.
Definition: lock.h:36
std::tr1::shared_ptr< const PeerInfo > epics::pvAccess::ServerChannelFindRequesterImpl::getPeerInfo ( )
virtual

Return information on requesting peer if applicable.

A server-type ChannelProvider will use this method to discover if a remote client has provided credentials which may be used in access control decisions.

The returned PeerInfo is only required to have valid values for: peer, transport, and transportVersion. PeerInfo::authority may be empty if authentication has not yet occured (UDP search).

Default implementation returns NULL.

isConnected()==true and getPeerInfo()==NULL when the ChannelProvider does not provide information about the peer. This should be treated as an unauthenticated, anonymous, peer.

The returned instance must not change, and a different instance should be returned if/when peer information changes (eg. after reconnect).

May return !NULL when !isConnected(). getPeerInfo() must be called before testing isConnected() in situations where connection state is being polled.

Reimplemented from epics::pvAccess::ChannelFindRequester.

Definition at line 466 of file responseHandlers.cpp.

467 {
468  return _peer;
469 }
void epics::pvAccess::ServerChannelFindRequesterImpl::send ( epics::pvData::ByteBuffer buffer,
TransportSendControl control 
)
virtual

Called by transport. By this call transport gives callee ownership over the buffer. Calls on TransportSendControl instance must be made from calling thread. Moreover, ownership is valid only for the time of call of this method. NOTE: these limitations allow efficient implementation.

Implements epics::pvAccess::TransportSender.

Definition at line 471 of file responseHandlers.cpp.

472 {
473  control->startMessage(CMD_SEARCH_RESPONSE, 12+4+16+2);
474 
475  Lock guard(_mutex);
476  buffer->put(_guid.value, 0, sizeof(_guid.value));
477  buffer->putInt(_searchSequenceId);
478 
479  // NOTE: is it possible (very likely) that address is any local address ::ffff:0.0.0.0
480  encodeAsIPv6Address(buffer, _context->getServerInetAddress());
481  buffer->putShort((int16)_context->getServerPort());
482 
484 
485  control->ensureBuffer(1);
486  buffer->putByte(_wasFound ? (int8)1 : (int8)0);
487 
488  if (!_serverSearch)
489  {
490  // TODO for now we do not gather search responses
491  buffer->putShort((int16)1);
492  buffer->putInt(_cid);
493  }
494  else
495  {
496  buffer->putShort((int16)0);
497  }
498 
499  control->setRecipient(_sendTo);
500 }
int8_t int8
Definition: pvType.h:75
virtual void setRecipient(osiSockAddr const &sendTo)=0
EPICS_ALWAYS_INLINE void putInt(int32 value)
Definition: byteBuffer.h:537
A lock for multithreading.
Definition: lock.h:36
void encodeAsIPv6Address(ByteBuffer *buffer, const osiSockAddr *address)
EPICS_ALWAYS_INLINE void putByte(int8 value)
Definition: byteBuffer.h:525
static void serializeString(const std::string &value, ByteBuffer *buffer, SerializableControl *flusher)
static const std::string SUPPORTED_PROTOCOL
virtual void ensureBuffer(std::size_t size)=0
int16_t int16
Definition: pvType.h:79
virtual void startMessage(epics::pvData::int8 command, std::size_t ensureCapacity, epics::pvData::int32 payloadSize=0)=0
EPICS_ALWAYS_INLINE void putShort(int16 value)
Definition: byteBuffer.h:531
ServerChannelFindRequesterImpl * epics::pvAccess::ServerChannelFindRequesterImpl::set ( std::string  _name,
epics::pvData::int32  searchSequenceId,
epics::pvData::int32  cid,
osiSockAddr const &  sendTo,
bool  responseRequired,
bool  serverSearch 
)

Definition at line 414 of file responseHandlers.cpp.

416 {
417  Lock guard(_mutex);
418  _name = name;
419  _searchSequenceId = searchSequenceId;
420  _cid = cid;
421  _sendTo = sendTo;
422  _responseRequired = responseRequired;
423  _serverSearch = serverSearch;
424  return this;
425 }
A lock for multithreading.
Definition: lock.h:36
void epics::pvAccess::ServerChannelFindRequesterImpl::timerStopped ( )
virtual

The timer has stopped.

Implements epics::pvData::TimerCallback.

Definition at line 409 of file responseHandlers.cpp.

410 {
411  // noop
412 }

The documentation for this class was generated from the following files: