Class MirrorNetwork


Utility class.
  • Method Details

    • forNetwork

      static MirrorNetwork forNetwork(ExecutorService executor, List<String> addresses)
      Create an arbitrary mirror network.
      Parameters:
      executor - the executor service
      addresses - the arbitrary address for the network
      Returns:
      the new mirror network object
    • forMainnet

      static MirrorNetwork forMainnet(ExecutorService executor)
      Create a mirror network for mainnet.
      Parameters:
      executor - the executor service
      Returns:
      the new mirror network for mainnet
    • forTestnet

      static MirrorNetwork forTestnet(ExecutorService executor)
      Create a mirror network for testnet.
      Parameters:
      executor - the executor service
      Returns:
      the new mirror network for testnet
    • forPreviewnet

      static MirrorNetwork forPreviewnet(ExecutorService executor)
      Create a mirror network for previewnet.
      Parameters:
      executor - the executor service
      Returns:
      the new mirror network for previewnet
    • getNetwork

      List<String> getNetwork()
      Extract the network names.
      Returns:
      the network names
    • setNetwork

      Assign the desired network.
      Parameters:
      network - the desired network
      Returns:
      the mirror network
      Throws:
      TimeoutException - when the transaction times out
      InterruptedException - when a thread is interrupted while it's waiting, sleeping, or otherwise occupied
    • createNodeFromNetworkEntry

      protected MirrorNode createNodeFromNetworkEntry(Map.Entry<String,BaseNodeAddress> entry)
      Specified by:
      createNodeFromNetworkEntry in class BaseNetwork<MirrorNetwork,BaseNodeAddress,MirrorNode>
    • getNextMirrorNode

      MirrorNode getNextMirrorNode() throws InterruptedException
      Extract the next healthy mirror node on the list.
      Returns:
      the next healthy mirror node on the list
      Throws:
      InterruptedException - when a thread is interrupted while it's waiting, sleeping, or otherwise occupied
    • getRestBaseUrl

      String getRestBaseUrl() throws InterruptedException
      Convenience to get the REST base URL from the next healthy mirror node.
      Throws:
      InterruptedException
    • getNextRestBaseUrlRoundRobin

      String getNextRestBaseUrlRoundRobin()
      The REST base URL for one mirror node REST call, chosen by round-robin.

      Distinct from getRestBaseUrl(), which picks by health order and is what the consensus-era mirror REST call sites still use. Round-robin is what the HTTP transport proposal specifies: drawing at random from a list nothing ever demotes makes a two-node network with one node down a coin flip that retrying cannot escape, re-flipped on the next call.

      A transport failure does not mark a mirror node unhealthy. Demotion on failure is the right end state and a different design; it is excluded deliberately rather than forgotten.

      Returns:
      the base URL to pin for the whole call