Class ProtonLink<L extends Link<L>>
- Direct Known Subclasses:
ProtonReceiver,ProtonSender
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ProtonConnectionprotected final Attachprotected Attachprotected final ProtonSessionFields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtonLink(ProtonSession session, String name, ProtonLinkCreditState creditState) Create a new link instance with the given parent session. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected voidcheckLinkOperable(String failurePrefix) protected voidcheckNotClosed(String errorMessage) protected voidcheckNotOpened(String errorMessage) close()Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.protected abstract LdecorateOutgoingFlow(Flow flow) detach()Detach this end of the link.detachHandler(EventHandler<L> remoteDetachHandler) Sets aEventHandlerfor when an AMQP Detach frame is received from the remote peer for thisLinkwhich would have been locally opened previously, the Detach from would have been marked as not having been closed.Symbol[]Gets the local link max message size.getName()Symbol[]Gets the parent of thisEndpointwhich can be itself forConnectioninstance.Gets the local link receiver settlement mode.Symbol[]Gets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.Symbol[]Gets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.Gets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.<T extends Terminus>
TReturns the remote targetTerminuscast to the given type.Gets the local link sender settlement mode.getState()<T extends Terminus>
TReturns the currently set Target for thisLink.protected abstract LhandleRemoteAttach(Attach attach) protected abstract LhandleRemoteDetach(Detach detach) protected abstract LhandleRemoteDisposition(Disposition disposition, ProtonIncomingDelivery delivery) protected abstract LhandleRemoteDisposition(Disposition disposition, ProtonOutgoingDelivery delivery) protected abstract LhandleRemoteFlow(Flow flow) protected abstract ProtonIncomingDeliveryhandleRemoteTransfer(Transfer transfer, ProtonBuffer payload) booleanReturns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred.booleanReturns true if thisLinkis currently locally detached or locally closed meaning the state returned fromLink.getState()is equal toLinkState.DETACHEDorLinkState.CLOSED.booleanReturns true if thisLinkis currently locally detached meaning the state returned fromLink.getState()is equal toLinkState.DETACHED.booleanReturns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not.booleanbooleanReturns true if thisLinkis currently remotely closed meaning the state returned fromLink.getRemoteState()is equal toLinkState.CLOSED.booleanReturns true if thisLinkis currently remotely detached or closed meaning the state returned fromLink.getRemoteState()is equal toLinkState.DETACHEDorLinkState.CLOSED.booleanReturns true if thisLinkis currently remotely detached meaning the state returned fromLink.getRemoteState()is equal toLinkState.DETACHED.booleanReturns true if thisLinkis currently remotely open meaning the state returned fromLink.getRemoteState()is equal toLinkState.ACTIVE.booleanisSender()localDetachHandler(EventHandler<L> localDetachHandler) Sets aEventHandlerfor when an this link is detached locally via a call toLink.detach()This is a convenience event that supplements the normalEndpoint.localCloseHandler(EventHandler)event point if set.open()Open the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed.parentEndpointClosedHandler(EventHandler<L> handler) protected abstract Lself()setDesiredCapabilities(Symbol... capabilities) Sets the capabilities that are desired from the remote when thisEndpointis opened.setMaxMessageSize(UnsignedLong maxMessageSize) Sets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session.setOfferedCapabilities(Symbol... capabilities) Sets the capabilities to be offered on to the remote when thisEndpointis opened.setProperties(Map<Symbol, Object> properties) Sets the properties to be sent to the remote when thisEndpointis Opened.setReceiverSettleMode(ReceiverSettleMode receiverSettleMode) Sets the receiver settle mode.setSenderSettleMode(SenderSettleMode senderSettleMode) Sets the sender settle mode.setTarget(Coordinator coordinator) Sets theCoordinatortarget to assign to the local end of thisLink.protected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidMethods inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResourceMethods inherited from interface org.apache.qpid.protonj2.engine.Link
creditStateUpdateHandler, getCredit, getRole, isDraining
-
Field Details
-
connection
-
session
-
localAttach
-
remoteAttach
-
-
Constructor Details
-
Method Details
-
getConnection
- Specified by:
getConnectionin interfaceLink<L extends Link<L>>- Returns:
- the parent
Connectionfor theLink
-
getSession
-
getParent
Description copied from interface:EndpointGets the parent of thisEndpointwhich can be itself forConnectioninstance. -
getName
-
isSender
public boolean isSender() -
isReceiver
public boolean isReceiver() -
self
-
getState
-
getRemoteState
- Specified by:
getRemoteStatein interfaceLink<L extends Link<L>>- Returns:
- the remote link state (as last communicated)
-
open
Description copied from interface:EndpointOpen the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives. -
detach
Description copied from interface:LinkDetach this end of the link. -
close
Description copied from interface:EndpointClose the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it. If the engine encounters an error writing the performative or the engine is in a failed state from a previous error then this method will throw an exception. If the engine has been shutdown then this method will close out the local end of theEndpointand clean up any local resources before returning normally. -
setSenderSettleMode
Description copied from interface:LinkSets the sender settle mode.Should only be called during link set-up, i.e. before calling
Endpoint.open(). If this endpoint is the initiator of the link, this method can be used to set a value other than the default.If this endpoint is not the initiator, this method should be used to set a local value. According to the AMQP spec, the application may choose to accept the sender's suggestion (accessed by calling
Link.getRemoteSenderSettleMode()) or choose another value. The value has no effect on Proton, but may be useful to the application at a later point.In order to be AMQP compliant the application is responsible for honoring the settlement mode. See
Link.- Specified by:
setSenderSettleModein interfaceLink<L extends Link<L>>- Parameters:
senderSettleMode- TheSenderSettleModethat will be set on the local end of this link.- Returns:
- this Link.
-
getSenderSettleMode
Description copied from interface:LinkGets the local link sender settlement mode.- Specified by:
getSenderSettleModein interfaceLink<L extends Link<L>>- Returns:
- the local sender settlement mode, or null if none was set.
- See Also:
-
setReceiverSettleMode
Description copied from interface:LinkSets the receiver settle mode.Should only be called during link set-up, i.e. before calling
Endpoint.open(). If this endpoint is the initiator of the link, this method can be used to set a value other than the default. Used in analogous way toLink.setSenderSettleMode(SenderSettleMode)- Specified by:
setReceiverSettleModein interfaceLink<L extends Link<L>>- Parameters:
receiverSettleMode- TheReceiverSettleModethat will be set on the local end of this link.- Returns:
- this Link.
-
getReceiverSettleMode
Description copied from interface:LinkGets the local link receiver settlement mode.- Specified by:
getReceiverSettleModein interfaceLink<L extends Link<L>>- Returns:
- the local receiver settlement mode, or null if none was set.
- See Also:
-
setSource
Description copied from interface:LinkSets theSourceto assign to the local end of thisLink.Must be called during link setup, i.e. before calling the
Endpoint.open()method. -
getSource
-
setTarget
Description copied from interface:LinkSets theTargetto assign to the local end of thisLink. Must be called during link setup, i.e. before calling theEndpoint.open()method. -
setTarget
Description copied from interface:LinkSets theCoordinatortarget to assign to the local end of thisLink.Must be called during link setup, i.e. before calling the
Endpoint.open()method.- Specified by:
setTargetin interfaceLink<L extends Link<L>>- Parameters:
coordinator- TheCoordinatortarget that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException- if theLinkhas already been opened.
-
getTarget
Description copied from interface:LinkReturns the currently set Target for thisLink. A link target can be either aTargettype for aSenderorReceiverlink or if the link is to be transaction resource then the target type will be aCoordinatorinstance. -
setProperties
Description copied from interface:EndpointSets the properties to be sent to the remote when thisEndpointis Opened. TheEndpointproperties value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called. -
getProperties
- Specified by:
getPropertiesin interfaceEndpoint<L extends Link<L>>- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setOfferedCapabilities
Description copied from interface:EndpointSets the capabilities to be offered on to the remote when thisEndpointis opened. The offered capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called. -
getOfferedCapabilities
-
setDesiredCapabilities
Description copied from interface:EndpointSets the capabilities that are desired from the remote when thisEndpointis opened. The desired capabilities value can only be modified prior to a call toEndpoint.open(), once theEndpointhas been opened locally an error will be thrown if this method is called. -
getDesiredCapabilities
- Specified by:
getDesiredCapabilitiesin interfaceEndpoint<L extends Link<L>>- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
-
setMaxMessageSize
Description copied from interface:LinkSets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session. Null or 0 means no limit.Must be called during link setup, i.e. before calling the
Endpoint.open()method.- Specified by:
setMaxMessageSizein interfaceLink<L extends Link<L>>- Parameters:
maxMessageSize- the local max message size value, or null to clear. 0 also means no limit.- Returns:
- this Link.
-
getMaxMessageSize
Description copied from interface:LinkGets the local link max message size.- Specified by:
getMaxMessageSizein interfaceLink<L extends Link<L>>- Returns:
- the local max message size, or null if none was set. 0 also means no limit.
- See Also:
-
isLocallyOpen
public boolean isLocallyOpen()Description copied from interface:EndpointReturns true if thisEndpointis currently locally open meaning that theEndpoint.open()has been called but theEndpoint.close()has not. -
isLocallyClosed
public boolean isLocallyClosed()Description copied from interface:EndpointReturns true if thisEndpointis currently locally closed meaning that a call to theEndpoint.close()method has occurred. -
isLocallyDetached
public boolean isLocallyDetached()Description copied from interface:LinkReturns true if thisLinkis currently locally detached meaning the state returned fromLink.getState()is equal toLinkState.DETACHED. A link is locally detached after a call toLink.detach().- Specified by:
isLocallyDetachedin interfaceLink<L extends Link<L>>- Returns:
- true if the link is locally closed.
- See Also:
-
isLocallyClosedOrDetached
public boolean isLocallyClosedOrDetached()Description copied from interface:LinkReturns true if thisLinkis currently locally detached or locally closed meaning the state returned fromLink.getState()is equal toLinkState.DETACHEDorLinkState.CLOSED. A link is locally detached after a call toLink.detach()and is locally closed after a call toEndpoint.close().- Specified by:
isLocallyClosedOrDetachedin interfaceLink<L extends Link<L>>- Returns:
- true if the link is locally closed or detached.
- See Also:
-
isRemotelyOpen
public boolean isRemotelyOpen()Description copied from interface:LinkReturns true if thisLinkis currently remotely open meaning the state returned fromLink.getRemoteState()is equal toLinkState.ACTIVE. A link is remotely opened after anAttachhas been received from the remote and before aDetachhas been received from the remote.- Specified by:
isRemotelyOpenin interfaceEndpoint<L extends Link<L>>- Specified by:
isRemotelyOpenin interfaceLink<L extends Link<L>>- Returns:
- true if the link is remotely open.
- See Also:
-
isRemotelyClosed
public boolean isRemotelyClosed()Description copied from interface:LinkReturns true if thisLinkis currently remotely closed meaning the state returned fromLink.getRemoteState()is equal toLinkState.CLOSED. A link is remotely closed after anDetachhas been received from the remote with the close flag equal to true.- Specified by:
isRemotelyClosedin interfaceEndpoint<L extends Link<L>>- Specified by:
isRemotelyClosedin interfaceLink<L extends Link<L>>- Returns:
- true if the link is remotely closed.
- See Also:
-
isRemotelyDetached
public boolean isRemotelyDetached()Description copied from interface:LinkReturns true if thisLinkis currently remotely detached meaning the state returned fromLink.getRemoteState()is equal toLinkState.DETACHED. A link is remotely detached after anDetachhas been received from the remote with the close flag equal to false.- Specified by:
isRemotelyDetachedin interfaceLink<L extends Link<L>>- Returns:
- true if the link is remotely detached.
- See Also:
-
isRemotelyClosedOrDetached
public boolean isRemotelyClosedOrDetached()Description copied from interface:LinkReturns true if thisLinkis currently remotely detached or closed meaning the state returned fromLink.getRemoteState()is equal toLinkState.DETACHEDorLinkState.CLOSED. A link is remotely detached or closed after aDetachhas been received from the remote.- Specified by:
isRemotelyClosedOrDetachedin interfaceLink<L extends Link<L>>- Returns:
- true if the link is remotely detached or closed.
- See Also:
-
getRemoteSenderSettleMode
Description copied from interface:LinkGets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Specified by:
getRemoteSenderSettleModein interfaceLink<L extends Link<L>>- Returns:
- the sender settlement mode conveyed by the peer, or null if there was none.
- See Also:
-
getRemoteReceiverSettleMode
Description copied from interface:LinkGets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Specified by:
getRemoteReceiverSettleModein interfaceLink<L extends Link<L>>- Returns:
- the sender receiver mode conveyed by the peer, or null if there was none.
- See Also:
-
getRemoteSource
-
getRemoteTarget
Description copied from interface:LinkReturns the remote targetTerminuscast to the given type. This can be used when the underlying type is known by the caller or as a control to validate the assumption of the underlying type.the currently set Target for this
Link. A link target can be either aTargettype for aSenderorReceiverlink or if the link is to be transaction resource then the target type will be aCoordinatorinstance. -
getRemoteOfferedCapabilities
-
getRemoteDesiredCapabilities
-
getRemoteProperties
-
getRemoteMaxMessageSize
Description copied from interface:LinkGets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.- Specified by:
getRemoteMaxMessageSizein interfaceLink<L extends Link<L>>- Returns:
- the remote max message size conveyed by the peer, or null if none was set. 0 also means no limit.
-
localDetachHandler
Description copied from interface:LinkSets aEventHandlerfor when an this link is detached locally via a call toLink.detach()This is a convenience event that supplements the normalEndpoint.localCloseHandler(EventHandler)event point if set. If no local detached event handler is set the endpoint will route the detached event to the local closed event handler if set and allow it to process the event in one location.Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.
- Specified by:
localDetachHandlerin interfaceLink<L extends Link<L>>- Parameters:
localDetachHandler- TheEventHandlerto notify when this link is locally detached.- Returns:
- the link for chaining.
-
detachHandler
Description copied from interface:LinkSets aEventHandlerfor when an AMQP Detach frame is received from the remote peer for thisLinkwhich would have been locally opened previously, the Detach from would have been marked as not having been closed.This is a convenience event that supplements the normal
Endpoint.closeHandler(EventHandler)event point if set. If no detached event handler is set the endpoint will route the detached event to the closed event handler if set and allow it to process the event in one location.- Specified by:
detachHandlerin interfaceLink<L extends Link<L>>- Parameters:
remoteDetachHandler- TheEventHandlerto notify when this link is remotely closed.- Returns:
- the
Linkfor chaining.
-
parentEndpointClosedHandler
Description copied from interface:LinkSets aEventHandlerfor when the parentSessionorConnectionof this link is locally closed.Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.
- Specified by:
parentEndpointClosedHandlerin interfaceLink<L extends Link<L>>- Parameters:
handler- TheEventHandlerto notify when this link's parent Session is locally closed.- Returns:
- the link for chaining.
-
transitionedToLocallyOpened
protected void transitionedToLocallyOpened() -
transitionedToLocallyDetached
protected void transitionedToLocallyDetached() -
transitionedToLocallyClosed
protected void transitionedToLocallyClosed() -
transitionToRemotelyOpenedState
protected void transitionToRemotelyOpenedState() -
transitionToRemotelyDetached
protected void transitionToRemotelyDetached() -
transitionToRemotelyClosed
protected void transitionToRemotelyClosed() -
transitionToParentLocallyClosed
protected void transitionToParentLocallyClosed() -
transitionToParentRemotelyClosed
protected void transitionToParentRemotelyClosed() -
handleRemoteAttach
-
handleRemoteDetach
-
handleRemoteFlow
-
handleRemoteDisposition
protected abstract L handleRemoteDisposition(Disposition disposition, ProtonOutgoingDelivery delivery) -
handleRemoteDisposition
protected abstract L handleRemoteDisposition(Disposition disposition, ProtonIncomingDelivery delivery) -
handleRemoteTransfer
protected abstract ProtonIncomingDelivery handleRemoteTransfer(Transfer transfer, ProtonBuffer payload) -
decorateOutgoingFlow
-
checkLinkOperable
-
areDeliveriesStillActive
protected boolean areDeliveriesStillActive() -
checkNotOpened
-
checkNotClosed
-