public int getMemberId() { if (peer == null) { return cmember.getMemberId(); } else { return peer.getPeerId(); } }
/** * Forces this member to become the leader. */ public void forceLeader() throws Exception { if (!isLeader()) { sendRequestVoteRequest(false); } }
/** * Returns the last saved index for this cluster. */ public int getLastSavedIndex() throws Exception { return cmember.getSavedIndex(); }
/** * Returns true if this message can accomodate another command of cmdSize. */ public boolean canBatch(int cmdSize) { assert getType() == TYPE_APPEND_ENTRY_REQ; return batching && size + cmdSize + 2 <= buffer.length && !isHeartbeat(); }
/** * If success is true, matchIndex should be set to mnIndex. * If success is false, nextIndex should be set to mnIndex. */ public void appendEntryReply(Message message, int fromMemberId, int term, int mnIndex, boolean success) throws Exception { notImplemented(message, fromMemberId); }
@Override public boolean appendEntryRequest(Message message, int fromMemberId, int term, int prevLogTerm, int prevLogIndex, int commitIndex, boolean isHeartbeat, int entryTerm, byte[] buffer, int bufferOffset, int bufferLen, boolean lastCommand) throws Exception { cmember.addIncoming(message); return false; }
/** * Blocks until the command in buffer has been committed or the timeout has expired. * After this call, this command object can be used again. * * @param timeout If -1, timeout is disabled. * @throws NotLeaderException if the member is not currently the leader. */ public void commit(byte[] buf, int bufOffset, int bufLen, int timeout) throws InterruptedException, GondolaException, TimeoutException { ccmd.commit(buf, bufOffset, bufLen, timeout); }
/** * Reinitializes the members after changing the contents of storage. */ public void reset() throws GondolaException { reset(Role.FOLLOWER, 0); }
/** * Returns commitIndex. */ public int getCommitIndex() { return cmember.getCommitIndex(); } }
PhantomRef(T message, ReferenceQueue<Message> queue) { super(message, queue); id = message.id; size = message.size; type = message.getType(); refCount = message.refCount; } }
/** * Returns the current known operational state for this member. */ public boolean isOperational() { if (peer == null) { return true; } else { return peer.isOperational(); } }
public int getMemberId() { if (peer == null) { return cmember.getMemberId(); } else { return peer.getPeerId(); } }
/** * Forces this member to become the leader. */ public void forceLeader() throws GondolaException { if (!isLeader()) { sendRequestVoteRequest(false); } }
/** * Returns true if this message can accomodate another command of cmdSize. */ public boolean canBatch(int cmdSize) { assert getType() == TYPE_APPEND_ENTRY_REQ; return batching && size + cmdSize + 2 <= buffer.length && !isHeartbeat(); }
/** * The results are valid only if the local member is the leader. */ public boolean isLogUpToDate() throws Exception { if (peer == null) { return cmember.sentRid.index == cmember.getSavedIndex(); } else { return cmember.sentRid.index == peer.matchIndex; } }
public void requestVoteReply(Message message, int fromMemberId, int term, boolean isPrevote, boolean voteGranted) throws InterruptedException, GondolaException { notImplemented(message, fromMemberId); } }
@Override public void requestVoteRequest(Message message, int fromMemberId, int term, boolean isPrevote, Rid lastRid) throws Exception { cmember.addIncoming(message); }
/** * Blocks until the command in buffer has been committed or the timeout has expired. * After this call, this command object can be used again. * * @param timeout If -1, timeout is disabled. * @return 0 if successful. * @throws NotLeaderException if the member is not currently the leader. */ public void commit(byte[] buf, int bufOffset, int bufLen, int timeout) throws InterruptedException, NotLeaderException, TimeoutException { ccmd.commit(buf, bufOffset, bufLen, timeout); }
/** * Returns the last saved index for this shard. Waits until the storage is settled if necessary. */ public int getLastSavedIndex() throws InterruptedException { return cmember.getSavedIndex(); }
/** * If success is true, matchIndex should be set to mnIndex. If success is false, nextIndex should be set to * mnIndex. */ public void appendEntryReply(Message message, int fromMemberId, int term, int mnIndex, boolean success) throws InterruptedException, GondolaException { notImplemented(message, fromMemberId); }