Class GridNioSessionImpl

    • Constructor Detail

      • GridNioSessionImpl

        public GridNioSessionImpl​(GridNioFilterChain filterChain,
                                  @Nullable
                                  @Nullable InetSocketAddress locAddr,
                                  @Nullable
                                  @Nullable InetSocketAddress rmtAddr,
                                  boolean accepted)
        Parameters:
        filterChain - Chain.
        locAddr - Local address.
        rmtAddr - Remote address.
        accepted - True if this session was initiated from remote host.
    • Method Detail

      • send

        public GridNioFuture<?> send​(Object msg)
        Performs a request for asynchronous data send.
        Specified by:
        send in interface GridNioSession
        Parameters:
        msg - Message to be sent. This message will be eventually passed in to a parser plugged to the nio server.
        Returns:
        Future representing result.
      • localAddress

        @Nullable
        public @Nullable InetSocketAddress localAddress()
        Gets local address of this session.
        Specified by:
        localAddress in interface GridNioSession
        Returns:
        Local network address or null if non-socket communication is used.
      • remoteAddress

        @Nullable
        public @Nullable InetSocketAddress remoteAddress()
        Gets address of remote peer on this session.
        Specified by:
        remoteAddress in interface GridNioSession
        Returns:
        Address of remote peer or null if non-socket communication is used.
      • bytesSent

        public long bytesSent()
        Gets the total count of bytes sent since the session was created.
        Specified by:
        bytesSent in interface GridNioSession
        Returns:
        Total count of bytes sent.
      • bytesReceived

        public long bytesReceived()
        Gets the total count of bytes received since the session was created.
        Specified by:
        bytesReceived in interface GridNioSession
        Returns:
        Total count of bytes received.
      • bytesSent0

        public long bytesSent0()
        Returns:
        Sent bytes since last NIO sessions balancing.
      • bytesReceived0

        public long bytesReceived0()
        Returns:
        Received bytes since last NIO sessions balancing.
      • reset0

        public void reset0()
      • closeTime

        public long closeTime()
        If session is closed, this method will return session close time returned by System.currentTimeMillis(). If session is not closed, this method will return 0.
        Specified by:
        closeTime in interface GridNioSession
        Returns:
        Session close time.
      • lastReceiveTime

        public long lastReceiveTime()
        Returns the time when last read activity was performed on this session.
        Specified by:
        lastReceiveTime in interface GridNioSession
        Returns:
        Lats receive time.
      • lastSendTime

        public long lastSendTime()
        Returns time when last send activity was performed on this session.
        Specified by:
        lastSendTime in interface GridNioSession
        Returns:
        Last send time.
      • lastSendScheduleTime

        public long lastSendScheduleTime()
        Returns time when last send was scheduled on this session.
        Specified by:
        lastSendScheduleTime in interface GridNioSession
        Returns:
        Last send schedule time.
      • meta

        public <T> T meta​(int key)
        Gets metadata associated with specified key.
        Specified by:
        meta in interface GridNioSession
        Parameters:
        key - Key to look up.
        Returns:
        Associated meta object or null if meta was not found.
      • addMeta

        public <T> T addMeta​(int key,
                             @Nullable
                             T val)
        Adds metadata associated with specified key.
        Specified by:
        addMeta in interface GridNioSession
        Parameters:
        key - Metadata Key.
        val - Metadata value.
        Returns:
        Previously associated object or null if no objects were associated.
      • removeMeta

        public <T> T removeMeta​(int key)
        Removes metadata with the specified key.
        Specified by:
        removeMeta in interface GridNioSession
        Parameters:
        key - Metadata key.
        Returns:
        Object that was associated with the key or null.
      • accepted

        public boolean accepted()
        Specified by:
        accepted in interface GridNioSession
        Returns:
        True if this connection was initiated from remote node.
      • chain

        protected <T> GridNioFilterChain<T> chain()
        Type Parameters:
        T - Chain type.
        Returns:
        Filter chain.
      • bytesSent

        public void bytesSent​(int cnt)
        Adds given amount of bytes to the sent bytes counter.

        Note that this method is designed to be called in one thread only.

        Parameters:
        cnt - Number of bytes sent.
      • bytesReceived

        public void bytesReceived​(int cnt)
        Adds given amount ob bytes to the received bytes counter.

        Note that this method is designed to be called in one thread only.

        Parameters:
        cnt - Number of bytes received.
      • resetSendScheduleTime

        public void resetSendScheduleTime()
        Resets send schedule time to avoid multiple idle notifications.
      • setClosed

        public boolean setClosed()
        Atomically moves this session into a closed state.
        Returns:
        True if session was moved to a closed state, false if session was already closed.
      • closed

        public boolean closed()
        Returns:
        True if this session was closed.
      • readsPaused

        public void readsPaused​(boolean readsPaused)
        Parameters:
        readsPaused - New reads paused flag.
      • readsPaused

        public boolean readsPaused()
        Description copied from interface: GridNioSession
        Checks whether reads are paused.
        Specified by:
        readsPaused in interface GridNioSession
        Returns:
        Reads paused flag.