com.hazelcast.nio

## Interface EndpointManager<T extends Connection>

- All Superinterfaces:
    ConnectionListenable, Consumer<Packet>
  All Known Implementing Classes:
    TcpIpEndpointManager

      @PrivateApi
      public interface EndpointManager<T extends Connection>
      extends ConnectionListenable, Consumer<Packet>

  Responsible for managing `Connection` objects.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<T>` | `getActiveConnections()` Returns all connections bind or not that are currently holding resources on this member.
    `T` | `getConnection(Address address)` Gets the connection for a given address.
    `Collection<T>` | `getConnections()` Returns connections that have been successfully established (ie.
    `T` | `getOrConnect(Address address)` Gets the existing connection for a given address or connects.
    `T` | `getOrConnect(Address address, boolean silent)` Gets the existing connection for a given address.
    `boolean` | `registerConnection(Address address, T connection)` Registers (ie.
    `boolean` | `transmit(Packet packet, Address target)` Transmits a packet to a certain address.
    `boolean` | `transmit(Packet packet, T connection)` Transmits a packet to a certain connection.

    - ### Methods inherited from interface com.hazelcast.nio.ConnectionListenable

      `addConnectionListener`

    - ### Methods inherited from interface com.hazelcast.util.function.Consumer

      `accept`

- - ### Method Detail

    - #### getConnections

          Collection<T> getConnections()

      Returns connections that have been successfully established (ie. Bind was completed)

    - #### getActiveConnections

          Collection<T> getActiveConnections()

      Returns all connections bind or not that are currently holding resources on this member. If the connection never successfully finishes with the handshake then it will only be visible through this sub-set.
      Returns:
        Collection of all connections hold on this member

    - #### registerConnection

          boolean registerConnection(Address address,
                                     T connection)

      Registers (ie. stores) the connection for the given remote address. Once this call finishes every subsequent call to `getConnection(Address)` will return the relevant `Connection` resource.
      Parameters:
        `address` - - The remote endpoint to register the connection under
        `connection` - - The connection to be registered
      Returns:
        True if the call was successful

    - #### getConnection

          T getConnection(Address address)

      Gets the connection for a given address. If the connection does not exist, it returns null.
      Parameters:
        `address` - the remote side of the connection
      Returns:
        the found Connection, or none if one doesn't exist

    - #### getOrConnect

          T getOrConnect(Address address)

      Gets the existing connection for a given address or connects. This call is silent.
      Parameters:
        `address` - the address to connect to
      Returns:
        the found connection, or `null` if no connection exists
      See Also:
        `getOrConnect(Address, boolean)`

    - #### getOrConnect

          T getOrConnect(Address address,
                         boolean silent)

      Gets the existing connection for a given address. If it does not exist, the system will try to connect asynchronously. In this case, it returns `null`.

      When the connection is established at some point in time, it can be retrieved using the `getConnection(Address)`.

      Parameters:
        `address` - the address to connect to
        `silent` - if logging should be done on debug level (`silent=true`) or on info level (`silent=false`)
      Returns:
        the existing connection

    - #### transmit

          boolean transmit(Packet packet,
                           T connection)

      Transmits a packet to a certain connection.

      If this method is called with a `null` connection, the call returns `false`.

      Parameters:
        `packet` - the packet to transmit
        `connection` - he connection to where the Packet should be transmitted
      Returns:
        `true` if the transmit was a success, `false` if a failure (there is no guarantee that the packet is actually going to be received since the packet perhaps is stuck in some buffer; it just means that it's buffered somewhere)
      Throws:
        `NullPointerException` - if the packet is `null`

    - #### transmit

          boolean transmit(Packet packet,
                           Address target)

      Transmits a packet to a certain address.

      If the connection to the target doesn't exist yet, the system will try to make the connection. In this case true can be returned, even though the connection eventually can't be established.

      Parameters:
        `packet` - The Packet to transmit.
        `target` - The address of the target machine where the Packet should be transmitted.
      Returns:
        true if the transmit was a success, false if a failure.
      Throws:
        `NullPointerException` - if packet or target is null.
      See Also:
        `transmit(com.hazelcast.nio.Packet, com.hazelcast.nio.Connection)`

Copyright © 2020. All rights reserved.