org.apache.qpid.server.protocol
Class AMQProtocolEngine

java.lang.Object
  extended by org.apache.qpid.server.protocol.AMQProtocolEngine
All Implemented Interfaces:
org.apache.qpid.protocol.AMQProtocolWriter, org.apache.qpid.protocol.AMQVersionAwareProtocolSession, org.apache.qpid.protocol.ProtocolEngine, org.apache.qpid.protocol.ProtocolVersionAware, ConfiguredObject<ConnectionConfigType,ConnectionConfig>, ConnectionConfig, Managable, AMQConnectionModel, AMQProtocolSession, PrincipalHolder, org.apache.qpid.transport.Receiver<ByteBuffer>

public class AMQProtocolEngine
extends Object
implements org.apache.qpid.protocol.ProtocolEngine, Managable, AMQProtocolSession, ConnectionConfig


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.qpid.server.protocol.AMQProtocolSession
AMQProtocolSession.ProtocolSessionIdentifier, AMQProtocolSession.Task
 
Field Summary
protected  boolean _closed
           
 
Constructor Summary
AMQProtocolEngine(VirtualHostRegistry virtualHostRegistry, org.apache.qpid.transport.NetworkDriver driver)
           
 
Method Summary
 void addChannel(AMQChannel channel)
          Associate a channel with this session.
 void addSessionCloseTask(AMQProtocolSession.Task task)
           
 boolean channelAwaitingClosure(int channelId)
          Check to see if this chanel is closing
 void closeChannel(int channelId)
          Close a specific channel.
 void closeChannelOk(int channelId)
          Markes the specific channel as closed.
 void closeConnection(int channelId, org.apache.qpid.AMQConnectionException e, boolean closeProtocolSession)
          This must be called to close the session in order to free up any resources managed by the session.
 void closed()
           
 void closeIfLingeringClosedChannels()
           
 void closeProtocolSession()
           
 void closeSession()
          This must be called when the session is _closed in order to free up any resources managed by the session.
 void closeSession(AMQSessionModel session, org.apache.qpid.protocol.AMQConstant cause, String message)
          Close the given requested Session
 void commitTransactions(AMQChannel channel)
           
 void contentBodyReceived(int channelId, org.apache.qpid.framing.ContentBody body)
           
 void contentHeaderReceived(int channelId, org.apache.qpid.framing.ContentHeaderBody body)
           
 void dataBlockReceived(org.apache.qpid.framing.AMQDataBlock message)
          Called when a protocol data block is received
 String dump()
           
 void exception(Throwable throwable)
           
 String getAddress()
           
 AMQChannel getAndAssertChannel(int channelId)
           
 String getAuthId()
           
 Principal getAuthorizedID()
           
 AMQChannel getChannel(int channelId)
          Get the channel for this session associated with the specified id.
 List<AMQChannel> getChannels()
           
 String getClientID()
           
 Object getClientIdentifier()
           
 org.apache.qpid.framing.FieldTable getClientProperties()
           
 String getClientVersion()
           
 ConfigStore getConfigStore()
           
 ConnectionConfigType getConfigType()
           
 long getConnectionId()
           
 org.apache.qpid.framing.AMQShortString getContextKey()
          Get the context key associated with this session.
 long getCreateTime()
           
 UUID getId()
           
 Object getKey()
           
 long getLastIoTime()
           
 SocketAddress getLocalAddress()
           
 String getLocalFQDN()
          Get the fully qualified domain name of the local address to which this session is bound.
 LogActor getLogActor()
           
 ManagedObject getManagedObject()
           
 long getMaxFrameSize()
           
 Long getMaximumNumberOfChannels()
           
 org.apache.qpid.framing.MethodDispatcher getMethodDispatcher()
           
 org.apache.qpid.framing.MethodRegistry getMethodRegistry()
           
 ConfiguredObject getParent()
           
 Principal getPrincipal()
           
 byte getProtocolMajorVersion()
           
 byte getProtocolMinorVersion()
           
 ProtocolOutputConverter getProtocolOutputConverter()
           
 org.apache.qpid.framing.ProtocolVersion getProtocolVersion()
           
 long getReadBytes()
           
 org.apache.qpid.framing.MethodRegistry getRegistry()
           
 SocketAddress getRemoteAddress()
           
 Integer getRemoteParentPID()
           
 Integer getRemotePID()
           
 String getRemoteProcessName()
           
 SaslServer getSaslServer()
           
 long getSessionID()
           
 AMQProtocolSession.ProtocolSessionIdentifier getSessionIdentifier()
           
 VirtualHost getVirtualHost()
           
 long getWrittenBytes()
           
 void heartbeatBodyReceived(int channelId, org.apache.qpid.framing.HeartbeatBody body)
           
 void init()
           
 void initHeartbeats(int delay)
          Initialise heartbeats on the session.
 boolean isClosing()
           
 boolean isDurable()
           
 Boolean isFederationLink()
           
 Boolean isIncoming()
           
 boolean isProtocolVersion(byte major, byte minor)
           
 Boolean isShadow()
           
 Boolean isSystemConnection()
           
 void methodFrameReceived(int channelId, org.apache.qpid.framing.AMQMethodBody methodBody)
           
 void mgmtClose()
           
 void mgmtCloseChannel(int channelId)
           
 void readerIdle()
           
 void received(ByteBuffer msg)
           
 void removeChannel(int channelId)
          In our current implementation this is used by the clustering code.
 void removeSessionCloseTask(AMQProtocolSession.Task task)
           
 void rollbackTransactions(AMQChannel channel)
           
 void setAuthorizedID(Principal authorizedID)
           
 void setClientProperties(org.apache.qpid.framing.FieldTable clientProperties)
           
 void setContextKey(org.apache.qpid.framing.AMQShortString contextKey)
          Set the context key associated with this session.
 void setMaxFrameSize(long frameMax)
           
 void setMaximumNumberOfChannels(Long value)
           
 void setNetworkDriver(org.apache.qpid.transport.NetworkDriver driver)
           
 void setSaslServer(SaslServer saslServer)
          Set the sasl server that is to perform authentication for this session.
 void setSender(org.apache.qpid.transport.Sender<ByteBuffer> sender)
           
 void setVirtualHost(VirtualHost virtualHost)
           
 String toString()
           
 void writeFrame(org.apache.qpid.framing.AMQDataBlock frame)
          Convenience method that writes a frame to the protocol session.
 void writerIdle()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_closed

protected volatile boolean _closed
Constructor Detail

AMQProtocolEngine

public AMQProtocolEngine(VirtualHostRegistry virtualHostRegistry,
                         org.apache.qpid.transport.NetworkDriver driver)
Method Detail

getManagedObject

public ManagedObject getManagedObject()
Specified by:
getManagedObject in interface Managable

getSessionID

public long getSessionID()
Specified by:
getSessionID in interface AMQProtocolSession

getLogActor

public LogActor getLogActor()
Specified by:
getLogActor in interface AMQProtocolSession

setMaxFrameSize

public void setMaxFrameSize(long frameMax)
Specified by:
setMaxFrameSize in interface AMQProtocolSession

getMaxFrameSize

public long getMaxFrameSize()
Specified by:
getMaxFrameSize in interface AMQProtocolSession

isClosing

public boolean isClosing()
Specified by:
isClosing in interface AMQProtocolSession

received

public void received(ByteBuffer msg)
Specified by:
received in interface org.apache.qpid.transport.Receiver<ByteBuffer>

dataBlockReceived

public void dataBlockReceived(org.apache.qpid.framing.AMQDataBlock message)
                       throws Exception
Description copied from interface: AMQProtocolSession
Called when a protocol data block is received

Specified by:
dataBlockReceived in interface AMQProtocolSession
Parameters:
message - the data block that has been received
Throws:
Exception - if processing the datablock fails

methodFrameReceived

public void methodFrameReceived(int channelId,
                                org.apache.qpid.framing.AMQMethodBody methodBody)
Specified by:
methodFrameReceived in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession

contentHeaderReceived

public void contentHeaderReceived(int channelId,
                                  org.apache.qpid.framing.ContentHeaderBody body)
                           throws org.apache.qpid.AMQException
Specified by:
contentHeaderReceived in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession
Throws:
org.apache.qpid.AMQException

contentBodyReceived

public void contentBodyReceived(int channelId,
                                org.apache.qpid.framing.ContentBody body)
                         throws org.apache.qpid.AMQException
Specified by:
contentBodyReceived in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession
Throws:
org.apache.qpid.AMQException

heartbeatBodyReceived

public void heartbeatBodyReceived(int channelId,
                                  org.apache.qpid.framing.HeartbeatBody body)
Specified by:
heartbeatBodyReceived in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession

writeFrame

public void writeFrame(org.apache.qpid.framing.AMQDataBlock frame)
Convenience method that writes a frame to the protocol session. Equivalent to calling getProtocolSession().write().

Specified by:
writeFrame in interface org.apache.qpid.protocol.AMQProtocolWriter
Parameters:
frame - the frame to write

getContextKey

public org.apache.qpid.framing.AMQShortString getContextKey()
Description copied from interface: AMQProtocolSession
Get the context key associated with this session. Context key is described in the AMQ protocol specification (RFC 6).

Specified by:
getContextKey in interface AMQProtocolSession
Returns:
the context key

setContextKey

public void setContextKey(org.apache.qpid.framing.AMQShortString contextKey)
Description copied from interface: AMQProtocolSession
Set the context key associated with this session. Context key is described in the AMQ protocol specification (RFC 6).

Specified by:
setContextKey in interface AMQProtocolSession
Parameters:
contextKey - the context key

getChannels

public List<AMQChannel> getChannels()
Specified by:
getChannels in interface AMQProtocolSession

getAndAssertChannel

public AMQChannel getAndAssertChannel(int channelId)
                               throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

getChannel

public AMQChannel getChannel(int channelId)
Description copied from interface: AMQProtocolSession
Get the channel for this session associated with the specified id. A channel id is unique per connection (i.e. per session).

Specified by:
getChannel in interface AMQProtocolSession
Parameters:
channelId - the channel id which must be valid
Returns:
null if no channel exists, the channel otherwise

channelAwaitingClosure

public boolean channelAwaitingClosure(int channelId)
Description copied from interface: AMQProtocolSession
Check to see if this chanel is closing

Specified by:
channelAwaitingClosure in interface AMQProtocolSession
Parameters:
channelId - id to check
Returns:
boolean with state of channel awaiting closure

addChannel

public void addChannel(AMQChannel channel)
                throws org.apache.qpid.AMQException
Description copied from interface: AMQProtocolSession
Associate a channel with this session.

Specified by:
addChannel in interface AMQProtocolSession
Parameters:
channel - the channel to associate with this session. It is an error to associate the same channel with more than one session but this is not validated.
Throws:
org.apache.qpid.AMQException

getMaximumNumberOfChannels

public Long getMaximumNumberOfChannels()
Specified by:
getMaximumNumberOfChannels in interface AMQProtocolSession

setMaximumNumberOfChannels

public void setMaximumNumberOfChannels(Long value)
Specified by:
setMaximumNumberOfChannels in interface AMQProtocolSession

commitTransactions

public void commitTransactions(AMQChannel channel)
                        throws org.apache.qpid.AMQException
Specified by:
commitTransactions in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

rollbackTransactions

public void rollbackTransactions(AMQChannel channel)
                          throws org.apache.qpid.AMQException
Specified by:
rollbackTransactions in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

closeChannel

public void closeChannel(int channelId)
                  throws org.apache.qpid.AMQException
Close a specific channel. This will remove any resources used by the channel, including:

Specified by:
closeChannel in interface AMQProtocolSession
Parameters:
channelId - id of the channel to close
Throws:
org.apache.qpid.AMQException - if an error occurs closing the channel
IllegalArgumentException - if the channel id is not valid

closeChannelOk

public void closeChannelOk(int channelId)
Description copied from interface: AMQProtocolSession
Markes the specific channel as closed. This will release the lock for that channel id so a new channel can be created on that id.

Specified by:
closeChannelOk in interface AMQProtocolSession
Parameters:
channelId - id of the channel to close

removeChannel

public void removeChannel(int channelId)
In our current implementation this is used by the clustering code.

Specified by:
removeChannel in interface AMQProtocolSession
Parameters:
channelId - The channel to remove

initHeartbeats

public void initHeartbeats(int delay)
Initialise heartbeats on the session.

Specified by:
initHeartbeats in interface AMQProtocolSession
Parameters:
delay - delay in seconds (not ms)

closeSession

public void closeSession()
                  throws org.apache.qpid.AMQException
This must be called when the session is _closed in order to free up any resources managed by the session.

Specified by:
closeSession in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

closeConnection

public void closeConnection(int channelId,
                            org.apache.qpid.AMQConnectionException e,
                            boolean closeProtocolSession)
                     throws org.apache.qpid.AMQException
Description copied from interface: AMQProtocolSession
This must be called to close the session in order to free up any resources managed by the session.

Specified by:
closeConnection in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

closeProtocolSession

public void closeProtocolSession()

toString

public String toString()
Overrides:
toString in class Object

dump

public String dump()

getKey

public Object getKey()
Specified by:
getKey in interface AMQProtocolSession
Returns:
an object that can be used to identity

getLocalFQDN

public String getLocalFQDN()
Get the fully qualified domain name of the local address to which this session is bound. Since some servers may be bound to multiple addresses this could vary depending on the acceptor this session was created from.

Specified by:
getLocalFQDN in interface AMQProtocolSession
Returns:
a String FQDN

getSaslServer

public SaslServer getSaslServer()
Specified by:
getSaslServer in interface AMQProtocolSession
Returns:
the sasl server that can perform authentication for this session.

setSaslServer

public void setSaslServer(SaslServer saslServer)
Description copied from interface: AMQProtocolSession
Set the sasl server that is to perform authentication for this session.

Specified by:
setSaslServer in interface AMQProtocolSession

getClientProperties

public org.apache.qpid.framing.FieldTable getClientProperties()
Specified by:
getClientProperties in interface AMQProtocolSession

setClientProperties

public void setClientProperties(org.apache.qpid.framing.FieldTable clientProperties)
Specified by:
setClientProperties in interface AMQProtocolSession

getProtocolMajorVersion

public byte getProtocolMajorVersion()
Specified by:
getProtocolMajorVersion in interface org.apache.qpid.protocol.ProtocolVersionAware

getProtocolVersion

public org.apache.qpid.framing.ProtocolVersion getProtocolVersion()
Specified by:
getProtocolVersion in interface org.apache.qpid.protocol.ProtocolVersionAware

getProtocolMinorVersion

public byte getProtocolMinorVersion()
Specified by:
getProtocolMinorVersion in interface org.apache.qpid.protocol.ProtocolVersionAware

isProtocolVersion

public boolean isProtocolVersion(byte major,
                                 byte minor)

getRegistry

public org.apache.qpid.framing.MethodRegistry getRegistry()

getClientIdentifier

public Object getClientIdentifier()
Specified by:
getClientIdentifier in interface AMQProtocolSession

getVirtualHost

public VirtualHost getVirtualHost()
Specified by:
getVirtualHost in interface ConnectionConfig
Specified by:
getVirtualHost in interface AMQProtocolSession

setVirtualHost

public void setVirtualHost(VirtualHost virtualHost)
                    throws org.apache.qpid.AMQException
Specified by:
setVirtualHost in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

addSessionCloseTask

public void addSessionCloseTask(AMQProtocolSession.Task task)
Specified by:
addSessionCloseTask in interface AMQProtocolSession

removeSessionCloseTask

public void removeSessionCloseTask(AMQProtocolSession.Task task)
Specified by:
removeSessionCloseTask in interface AMQProtocolSession

getProtocolOutputConverter

public ProtocolOutputConverter getProtocolOutputConverter()
Specified by:
getProtocolOutputConverter in interface AMQProtocolSession

setAuthorizedID

public void setAuthorizedID(Principal authorizedID)
Specified by:
setAuthorizedID in interface AMQProtocolSession

getAuthorizedID

public Principal getAuthorizedID()

getPrincipal

public Principal getPrincipal()
Specified by:
getPrincipal in interface PrincipalHolder
Returns:
a Principal that was used to authorized this session

getRemoteAddress

public SocketAddress getRemoteAddress()
Specified by:
getRemoteAddress in interface org.apache.qpid.protocol.ProtocolEngine
Specified by:
getRemoteAddress in interface AMQProtocolSession

getLocalAddress

public SocketAddress getLocalAddress()
Specified by:
getLocalAddress in interface org.apache.qpid.protocol.ProtocolEngine

getMethodRegistry

public org.apache.qpid.framing.MethodRegistry getMethodRegistry()
Specified by:
getMethodRegistry in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession
Specified by:
getMethodRegistry in interface AMQProtocolSession

getMethodDispatcher

public org.apache.qpid.framing.MethodDispatcher getMethodDispatcher()
Specified by:
getMethodDispatcher in interface AMQProtocolSession

closed

public void closed()
Specified by:
closed in interface org.apache.qpid.protocol.ProtocolEngine
Specified by:
closed in interface org.apache.qpid.transport.Receiver<ByteBuffer>

readerIdle

public void readerIdle()
Specified by:
readerIdle in interface org.apache.qpid.protocol.ProtocolEngine

setNetworkDriver

public void setNetworkDriver(org.apache.qpid.transport.NetworkDriver driver)
Specified by:
setNetworkDriver in interface org.apache.qpid.protocol.ProtocolEngine

writerIdle

public void writerIdle()
Specified by:
writerIdle in interface org.apache.qpid.protocol.ProtocolEngine

exception

public void exception(Throwable throwable)
Specified by:
exception in interface org.apache.qpid.transport.Receiver<ByteBuffer>

init

public void init()
Specified by:
init in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession

setSender

public void setSender(org.apache.qpid.transport.Sender<ByteBuffer> sender)
Specified by:
setSender in interface org.apache.qpid.protocol.AMQVersionAwareProtocolSession

getReadBytes

public long getReadBytes()
Specified by:
getReadBytes in interface org.apache.qpid.protocol.ProtocolEngine

getWrittenBytes

public long getWrittenBytes()
Specified by:
getWrittenBytes in interface org.apache.qpid.protocol.ProtocolEngine
Specified by:
getWrittenBytes in interface AMQProtocolSession

getLastIoTime

public long getLastIoTime()
Specified by:
getLastIoTime in interface AMQProtocolSession

getSessionIdentifier

public AMQProtocolSession.ProtocolSessionIdentifier getSessionIdentifier()
Specified by:
getSessionIdentifier in interface AMQProtocolSession

getClientVersion

public String getClientVersion()
Specified by:
getClientVersion in interface AMQProtocolSession

closeIfLingeringClosedChannels

public void closeIfLingeringClosedChannels()
Specified by:
closeIfLingeringClosedChannels in interface AMQProtocolSession

isIncoming

public Boolean isIncoming()
Specified by:
isIncoming in interface ConnectionConfig

isSystemConnection

public Boolean isSystemConnection()
Specified by:
isSystemConnection in interface ConnectionConfig

isFederationLink

public Boolean isFederationLink()
Specified by:
isFederationLink in interface ConnectionConfig

getAuthId

public String getAuthId()
Specified by:
getAuthId in interface ConnectionConfig

getRemotePID

public Integer getRemotePID()
Specified by:
getRemotePID in interface ConnectionConfig

getRemoteProcessName

public String getRemoteProcessName()
Specified by:
getRemoteProcessName in interface ConnectionConfig

getRemoteParentPID

public Integer getRemoteParentPID()
Specified by:
getRemoteParentPID in interface ConnectionConfig

getConfigStore

public ConfigStore getConfigStore()
Specified by:
getConfigStore in interface ConnectionConfig

getConfigType

public ConnectionConfigType getConfigType()
Specified by:
getConfigType in interface ConfiguredObject<ConnectionConfigType,ConnectionConfig>

getParent

public ConfiguredObject getParent()
Specified by:
getParent in interface ConfiguredObject<ConnectionConfigType,ConnectionConfig>

isDurable

public boolean isDurable()
Specified by:
isDurable in interface ConfiguredObject<ConnectionConfigType,ConnectionConfig>

getId

public UUID getId()
Specified by:
getId in interface ConfiguredObject<ConnectionConfigType,ConnectionConfig>

getConnectionId

public long getConnectionId()
Specified by:
getConnectionId in interface AMQConnectionModel

getAddress

public String getAddress()
Specified by:
getAddress in interface ConnectionConfig

getCreateTime

public long getCreateTime()
Specified by:
getCreateTime in interface ConfiguredObject<ConnectionConfigType,ConnectionConfig>

isShadow

public Boolean isShadow()
Specified by:
isShadow in interface ConnectionConfig

mgmtClose

public void mgmtClose()
Specified by:
mgmtClose in interface ConnectionConfig

mgmtCloseChannel

public void mgmtCloseChannel(int channelId)
Specified by:
mgmtCloseChannel in interface AMQProtocolSession

getClientID

public String getClientID()

closeSession

public void closeSession(AMQSessionModel session,
                         org.apache.qpid.protocol.AMQConstant cause,
                         String message)
                  throws org.apache.qpid.AMQException
Description copied from interface: AMQConnectionModel
Close the given requested Session

Specified by:
closeSession in interface AMQConnectionModel
Throws:
org.apache.qpid.AMQException


Licensed to the Apache Software Foundation