public void start() { channel = gondola.getNetwork().createChannel(cmember.memberId, peerId); reset(); // Start local threads assert threads.size() == 0 : String.format("The threads have not been properly shutdown. %d threads remaining", threads.size()); threads.add(new Sender()); threads.add(new Receiver()); threads.add(new Backfiller()); threads.forEach(t -> t.start()); }
public void start() throws GondolaException { if (threads.size() > 0) { throw new IllegalStateException("start() can only be called once"); } if (channel == null) { // Peer is not a slave so create a channel to remote member channel = gondola.getNetwork().createChannel(cmember.memberId, peerId); } channel.start(); reset(); // Start local threads threads.add(new Receiver()); threads.add(new Backfiller()); threads.add(new Sender()); threads.forEach(t -> t.start()); }
/** * See Stoppable.stop(). */ @Override public boolean stop() { // Stop new retry threads from starting stopped = true; // Stop any existing retry threads and then close the current socket, if any for (Thread t : threads) { ((SocketCreator) t).close(); } boolean status = Utils.stopThreads(threads); close(socket, in, out); ((SocketNetwork) gondola.getNetwork()).removeChannel(this); return status; }
SaveQueue(Gondola gondola, CoreMember cmember) throws GondolaException { this.gondola = gondola; this.cmember = cmember; gondola.getConfig().registerForUpdates(configListener); storage = gondola.getStorage(); stats = gondola.getStats(); numWorkers = gondola.getConfig().getInt("storage.save_queue_workers"); String address = storage.getAddress(cmember.memberId); if (address != null && !address.equals(gondola.getNetwork().getAddress()) && gondola.getNetwork().isActive(address)) { throw new IllegalStateException(String.format("[%s-%s] Process %s at address %s is currently using storage", gondola.getHostId(), cmember.memberId, gondola.getProcessId(), address)); } storage.setAddress(cmember.memberId, gondola.getNetwork().getAddress()); storage.setPid(cmember.memberId, gondola.getProcessId()); initSavedIndex(); }
SaveQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; gondola.getConfig().registerForUpdates(this); storage = gondola.getStorage(); stats = gondola.getStats(); numWorkers = gondola.getConfig().getInt("storage.save_queue_workers"); String address = storage.getAddress(cmember.memberId); if (address != null && gondola.getNetwork().isActive(address)) { throw new IllegalStateException(String.format("[%s-%s] Process %s at address %s is currently using storage", gondola.getHostId(), cmember.memberId, gondola.getProcessId(), address)); } storage.setAddress(cmember.memberId, gondola.getNetwork().getAddress()); storage.setPid(cmember.memberId, gondola.getProcessId()); initSavedIndex(); }
public CoreMember(Gondola gondola, Shard shard, int memberId, List<Integer> peerIds, boolean isPrimary) throws GondolaException { this.gondola = gondola; this.shard = shard; this.memberId = memberId; this.peerIds = peerIds; this.isPrimary = isPrimary; gondola.getConfig().registerForUpdates(configListener); // Acquire file lock to prevent another process running with the same member id try { fileLock(true); } catch (IOException e) { throw new GondolaException(e); } clock = gondola.getClock(); pool = gondola.getMessagePool(); storage = gondola.getStorage(); incomingQueue = new ArrayBlockingQueue<>(incomingQueueSize); saveQueue = new SaveQueue(gondola, this); commitQueue = new CommitQueue(gondola, this); gondola.getNetwork().register(memberId, channel -> acceptSlaveConnection(channel)); peerIds.forEach(id -> peers.put(id, new Peer(gondola, this, id))); // Initialize some convenience variables for use when calculating the commit index majority = (peers.size() + 1) / 2 + 1; matchIndices = new int[peers.size()]; reset(); }
logger.info("Nasty storage " + ns.isEnabled()); if (gondola.getNetwork() instanceof NastyNetwork) { NastyNetwork nn = (NastyNetwork) gondola.getNetwork(); nn.enable(args[1].equals("on")); logger.info("Nasty network " + nn.isEnabled());