private Member.SlaveStatus getSlaveStatus(Shard shard) { try { return shard.getLocalMember().getSlaveStatus(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
InterruptedException { trace("[{}] shardId={} un-followed shardId={}", gondola.getHostId(), shardId, masterShardId); Member.SlaveStatus status = gondola.getShard(shardId).getLocalMember().getSlaveStatus(); if (status == null) { return; if (gondola.getShard(shardId).getLocalMember().getSlaveStatus() == null) { return true;
private boolean setSlave(String shardId, int memberId, long timeoutMs) throws InterruptedException, ShardManagerException { try { Member localMember = gondola.getShard(shardId).getLocalMember(); Member.SlaveStatus slaveStatus = localMember.getSlaveStatus(); if (slaveStatus != null && slaveStatus.masterId == memberId && slaveStatus.running) { return true; } localMember.setSlave(memberId); return Utils.pollingWithTimeout(() -> { Member.SlaveStatus status = gondola.getShard(shardId).getLocalMember().getSlaveStatus(); if (slaveOperational(status)) { trace("[{}] Successfully connect to leader node={}", gondola.getHostId(), memberId); return true; } trace("[{}] Slave status={} role={}", gondola.getHostId(), status, gondola.getShard(shardId).getLocalRole()); return false; }, timeoutMs / POLLING_TIMES, timeoutMs); } catch (Exception e) { throw new ShardManagerException(e); } }
private boolean waitLogApproach(String shardId, long timeoutMs, int logPosDiff) throws ShardManagerException, InterruptedException { Shard shard = gondola.getShard(shardId); try { return Utils.pollingWithTimeout(() -> { if (shard.getCommitIndex() != 0 && shard.getCommitIndex() - filter.getChangeLogProcessor().getAppliedIndex(shardId) <= logPosDiff) { return true; } Member.SlaveStatus slaveStatus = shard.getLocalMember().getSlaveStatus(); if (!slaveOperational(slaveStatus)) { throw new ShardManagerException(MASTER_IS_GONE); } trace("[{}] {} Log status={}, ci={}, si={}, ai={} targetDiff={}", gondola.getHostId(), shardId, slaveOperational(slaveStatus) ? "RUNNING" : "DOWN", shard.getCommitIndex(), getSavedIndex(shard), filter.getChangeLogProcessor().getAppliedIndex(shardId), logPosDiff); return false; }, timeoutMs / POLLING_TIMES, timeoutMs); } catch (ExecutionException e) { throw new ShardManagerException(e); } }