Class RelayTransportAgent

    • Field Detail

      • FORWARD_SENDER

        public static final java.lang.String FORWARD_SENDER
        ID of sender of forwarding messages.
        See Also:
        Constant Field Values
      • FORWARD_DEST

        public static final java.lang.String FORWARD_DEST
        ID of forwarding messages.
        See Also:
        Constant Field Values
      • intmsgfeat

        protected jadex.bridge.component.impl.IInternalMessageFeature intmsgfeat
        Relay transport agent's internal message feature.
      • forwarding

        protected boolean forwarding
        Flag if the transport allows forwarding.
      • keepalivecount

        protected int keepalivecount
        Maintain a connection to at least this number of relays.
      • keepaliveinterval

        protected long keepaliveinterval
        Delay of keepalive messages.
      • routingdelay

        protected int routingdelay
        Maximum time spent on finding routing services.
      • debug

        protected boolean debug
        Set to true for more verbose output.
      • cachesize

        protected int cachesize
        Size of the routing cache.
      • nextclean

        protected long nextclean
        Timestamp of the next clean for direct routes.
      • keepaliveconnections

        protected java.util.Set<IComponentIdentifier> keepaliveconnections
        List of working connections to relays.
      • connectstep

        protected IComponentStep<java.lang.Void> connectstep
        Component step used to connect to relays.
      • keepaliveupdatefuture

        protected Future<java.lang.Void> keepaliveupdatefuture
        Update future to shorten timeout when keepalive update happens.
      • relayupdatefuture

        protected Future<java.lang.Void> relayupdatefuture
        Update future to shorten timeout when query update happens.
    • Constructor Detail

      • RelayTransportAgent

        public RelayTransportAgent()
        Creates the agent.
    • Method Detail

      • start

        public IFuture<java.lang.Void> start()
        Agent initialization.
      • sendMessage

        public ITerminableFuture<java.lang.Integer> sendMessage​(IMsgHeader header,
                                                                byte[] encheader,
                                                                byte[] body)
        Send a message.
        Specified by:
        sendMessage in interface ITransportService
        Parameters:
        header - Message header.
        body - Message body.
        encheader - Message header already encoded and encrypted for sending.
        Returns:
        Done, when sent, failure otherwise.
      • setupForwarding

        protected void setupForwarding()
        Sets the transport up to allow forwarding / relay mode.
      • setupClient

        protected void setupClient()
        Sets the transport up to be a relay client.
      • getRoutingService

        protected IRoutingService getRoutingService​(IComponentIdentifier relayplatform)
        Gets a proxy of the routing service of a known relay.
        Parameters:
        relay - The relay ID.
        Returns:
        Service proxy.
      • getRouteFromCache

        protected Tuple2<IComponentIdentifier,​java.lang.Integer> getRouteFromCache​(IComponentIdentifier target)
        Gets a route from cache.
        Parameters:
        target - The target.
        Returns:
        The route, or null if not found.
      • hasDirectConnection

        protected boolean hasDirectConnection​(IComponentIdentifier target)
        Checks if a direct connection to target exists.
        Parameters:
        target - The target.
        Returns:
        True, if connection exists.
      • getRtComponent

        protected IComponentIdentifier getRtComponent​(IComponentIdentifier platformid)
        Gets the relay transport component for a platform.
        Parameters:
        platformid - The platform ID.
        Returns:
        ID of the relay transport component.
      • encryptHeader

        protected IFuture<byte[]> encryptHeader​(IMsgHeader header)
        Encrypts the header.
        Parameters:
        header - Header.
        Returns:
        Encrypted header.