/** * Constructor. */ ReliableChannel( Function<ClientChannelConfiguration, Result<ClientChannel>> chFactory, ClientConfiguration clientCfg ) throws ClientException { if (chFactory == null) throw new NullPointerException("chFactory"); if (clientCfg == null) throw new NullPointerException("clientCfg"); this.chFactory = chFactory; this.clientCfg = clientCfg; List<InetSocketAddress> addrs = parseAddresses(clientCfg.getAddresses()); primary = addrs.get(new Random().nextInt(addrs.size())); // we already verified there is at least one address ch = chFactory.apply(new ClientChannelConfiguration(clientCfg).setAddress(primary)).get(); for (InetSocketAddress a : addrs) if (a != primary) this.backups.add(a); }
/** */ public static boolean equal(ClientConfiguration a, Object o) { if (!(o instanceof ClientConfiguration)) return false; ClientConfiguration b = (ClientConfiguration)o; return Arrays.equals(a.getAddresses(), b.getAddresses()) && a.isTcpNoDelay() == b.isTcpNoDelay() && a.getTimeout() == b.getTimeout() && a.getSendBufferSize() == b.getSendBufferSize() && a.getReceiveBufferSize() == b.getReceiveBufferSize(); }
/** * Constructor. */ ReliableChannel( Function<ClientChannelConfiguration, Result<ClientChannel>> chFactory, ClientConfiguration clientCfg ) throws ClientException { if (chFactory == null) throw new NullPointerException("chFactory"); if (clientCfg == null) throw new NullPointerException("clientCfg"); this.chFactory = chFactory; this.clientCfg = clientCfg; List<InetSocketAddress> addrs = parseAddresses(clientCfg.getAddresses()); primary = addrs.get(new Random().nextInt(addrs.size())); // we already verified there is at least one address ch = chFactory.apply(new ClientChannelConfiguration(clientCfg).setAddress(primary)).get(); for (InetSocketAddress a : addrs) if (a != primary) this.backups.add(a); }