Class MultiClient<T>

java.lang.Object
com.qwazr.server.client.MultiClient<T>
Type Parameters:
T - The type of the class which handle the connection to one server
All Implemented Interfaces:
java.lang.Iterable<T>

public class MultiClient<T>
extends java.lang.Object
implements java.lang.Iterable<T>
This class represents a connection to a set of servers
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected MultiClient​(T[] clients, java.util.concurrent.ExecutorService executorService)
    Create a new multi client with given clients
  • Method Summary

    Modifier and Type Method Description
    protected <R> R firstRandomSuccess​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.function.Consumer<javax.ws.rs.WebApplicationException> exceptions)  
    protected <R> R firstRandomSuccess​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.logging.Logger logger)  
    protected <R> java.util.List<R> forEachParallel​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.function.Consumer<javax.ws.rs.WebApplicationException> exceptions)  
    protected <R> java.util.List<R> forEachParallel​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.logging.Logger logger)  
    java.util.Iterator<T> iterator()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • MultiClient

      protected MultiClient​(T[] clients, java.util.concurrent.ExecutorService executorService)
      Create a new multi client with given clients
      Parameters:
      clients - an array of client
      executorService - an externally maintained executor service
  • Method Details

    • iterator

      public final java.util.Iterator<T> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<T>
    • firstRandomSuccess

      protected <R> R firstRandomSuccess​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.function.Consumer<javax.ws.rs.WebApplicationException> exceptions)
    • firstRandomSuccess

      protected <R> R firstRandomSuccess​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.logging.Logger logger)
    • forEachParallel

      protected <R> java.util.List<R> forEachParallel​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.function.Consumer<javax.ws.rs.WebApplicationException> exceptions)
    • forEachParallel

      protected <R> java.util.List<R> forEachParallel​(com.qwazr.utils.concurrent.FunctionEx<T,​R,​java.lang.Exception> action, java.util.logging.Logger logger)