@Override public int getNoOfParties() { return this.conf.noOfParties(); } }
Objects.requireNonNull(conf); Objects.requireNonNull(socketMap); for (int i = 1; i < conf.noOfParties() + 1; i++) { if (i == conf.getMyId()) { continue; int externalParties = conf.noOfParties() - 1; this.receivers = new HashMap<>(externalParties); this.senders = new HashMap<>(externalParties); this.alive = true; this.selfQueue = new LinkedBlockingQueue<>(); if (conf.noOfParties() > 1) { this.sockets = Collections.unmodifiableCollection(new ArrayList<>(socketMap.values())); startCommunication(socketMap);
Map<Integer, Socket> socketMap = new HashMap<>(conf.noOfParties());
Map<Integer, Socket> socketMap = new HashMap<>(conf.noOfParties() - conf.getMyId()); for (int i = conf.getMyId() + 1; i <= conf.noOfParties(); i++) { Party p = conf.getParty(i); boolean connectionMade = false;
/** * Closes the network down and releases held resources. */ @Override public void close() { if (alive) { alive = false; if (conf.noOfParties() < 2) { logger.info("P{}: Network closed", conf.getMyId()); return; } ExceptionConverter.safe(() -> { closeCommunication(); logger.info("P{}: Network closed", conf.getMyId()); return null; }, "Unable to properly close the network."); } else { logger.info("P{}: Network already closed", conf.getMyId()); } }
protected Map<Integer, CloseableNetwork> createNetworks(List<NetworkConfiguration> confs) { int numParties = confs.get(0).noOfParties(); ExecutorService es = Executors.newFixedThreadPool(numParties); Map<Integer, CloseableNetwork> netMap = new HashMap<>(numParties); Map<Integer, Future<CloseableNetwork>> futureMap = new HashMap<>(numParties); try { for (NetworkConfiguration conf : confs) { Future<CloseableNetwork> f = es.submit(() -> newCloseableNetwork(conf)); futureMap.put(conf.getMyId(), f); } for (Entry<Integer, Future<CloseableNetwork>> entry : futureMap.entrySet()) { netMap.put(entry.getKey(), entry.getValue().get()); } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); fail("Failed to setup networks."); } finally { es.shutdownNow(); } return netMap; }
@Test public void testNoOfParties() { assertEquals(numParties, netConf.noOfParties()); }
@Test public void testToString() { String s = netConf.toString(); assertTrue(s.startsWith("NetworkConfigurationImpl")); assertTrue(s.contains("myId=" + me.getPartyId())); for (int i = 1; i < netConf.noOfParties() + 1; i++) { assertTrue(s.contains(netConf.getParty(i).toString())); } }
networkConfiguration.noOfParties(), network ); protocolSuite = (ProtocolSuite<ResourcePoolT, BuilderT>)