Class ReceivingMailbox


  • public class ReceivingMailbox
    extends Object
    Mailbox that's used to receive data. Ownership of the ReceivingMailbox is with the MailboxService, which is unlike the SendingMailbox whose ownership lies with the send operator. This is because the ReceivingMailbox can be initialized even before the corresponding OpChain is registered on the receiver, whereas the SendingMailbox is initialized when the send operator is running.
    • Field Detail

      • DEFAULT_MAX_PENDING_BLOCKS

        public static final int DEFAULT_MAX_PENDING_BLOCKS
        See Also:
        Constant Field Values
    • Constructor Detail

      • ReceivingMailbox

        public ReceivingMailbox​(String id)
    • Method Detail

      • getId

        public String getId()
      • offer

        public ReceivingMailbox.ReceivingMailboxStatus offer​(TransferableBlock block,
                                                             long timeoutMs)
        Offers a non-error block into the mailbox within the timeout specified, returns whether the block is successfully added. If the block is not added, an error block is added to the mailbox.
      • setErrorBlock

        public void setErrorBlock​(TransferableBlock errorBlock)
        Sets an error block into the mailbox. No more blocks are accepted after calling this method.
      • poll

        @Nullable
        public TransferableBlock poll()
        Returns the first block from the mailbox, or null if there is no block received yet. Error block is returned if exists.
      • cancel

        public void cancel()
        Cancels the mailbox. No more blocks are accepted after calling this method. Should only be called by the receive operator to clean up the remaining blocks.
      • getNumPendingBlocks

        public int getNumPendingBlocks()