public Peer(Gondola gondola, CoreMember cmember, int peerId) { this.gondola = gondola; this.clock = gondola.getClock(); this.storage = gondola.getStorage(); this.cmember = cmember; this.peerId = peerId; entry0 = new LogEntry(storage, 1) { @Override public void release() { // Don't release back into pool } }; entry0.term = 0; entry0.index = 0; entry0.size = 0; }
public Peer(Gondola gondola, CoreMember cmember, int peerId) { this.gondola = gondola; this.clock = gondola.getClock(); this.storage = gondola.getStorage(); this.cmember = cmember; this.peerId = peerId; entry0 = new LogEntry(storage, 1) { @Override public void release() { // Don't release back into pool } }; entry0.term = 0; entry0.index = 0; entry0.size = 0; }
CommitQueue(Gondola gondola, CoreMember cmember) throws GondolaException { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null; //savedIndex; this.matchIndices = null; //matchIndices; gondola.getConfig().registerForUpdates(configListener); stats = gondola.getStats(); }
CommitQueue(Gondola gondola, CoreMember cmember) throws Exception { this.gondola = gondola; this.cmember = cmember; this.storage = gondola.getStorage(); this.pool = gondola.getMessagePool(); this.savedIndex = null;//savedIndex; this.matchIndices = null;//matchIndices; gondola.getConfig().registerForUpdates(this); stats = gondola.getStats(); }
public CoreMember(Gondola gondola, Cluster cluster, int memberId, List<Integer> peerIds, boolean isPrimary) throws Exception { this.gondola = gondola; this.cluster = cluster; this.memberId = memberId; this.isPrimary = isPrimary; gondola.getConfig().registerForUpdates(this); acquireFileLock(); clock = gondola.getClock(); pool = gondola.getMessagePool(); storage = gondola.getStorage(); incomingQueue = new ArrayBlockingQueue<>(incomingQueueSize); saveQueue = new SaveQueue(gondola, this); commitQueue = new CommitQueue(gondola, this); for (int id : peerIds) { Peer peer = new Peer(gondola, this, id); peers.add(peer); peerMap.put(peer.peerId, peer); } // Initialize some convenience variables for use when calculating the commit index majority = (peers.size() + 1) / 2 + 1; matchIndices = new int[peers.size()]; reset(); }
LogEntry le = gondola.getStorage().getLastLogEntry(cluster.getLocalMember().getMemberId()); int savedIndex = 0; if (le != null) { if (gondola.getStorage() instanceof NastyStorage) { NastyStorage ns = (NastyStorage) gondola.getStorage(); ns.enable(args[1].equals("on")); logger.info("Nasty storage " + ns.isEnabled()); case "q": le = gondola.getStorage().getLastLogEntry(cluster.getLocalMember().getMemberId()); if (le != null) { logger.info("lastTerm={}, lastIndex={}", le.term, le.index);
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(); }
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(); }