use of alluxio.grpc.NetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestTransferLeadership method transferAndWait.
private String transferAndWait(MasterNetAddress newLeaderAddr) throws Exception {
NetAddress netAddress = NetAddress.newBuilder().setHost(newLeaderAddr.getHostname()).setRpcPort(newLeaderAddr.getEmbeddedJournalPort()).build();
String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
waitForQuorumPropertySize(info -> info.getIsLeader() && info.getServerAddress().equals(netAddress), 1);
return transferId;
}
use of alluxio.grpc.NetAddress in project alluxio by Alluxio.
the class RaftJournalSystem method getQuorumServerInfoList.
/**
* Used to get information of internal RAFT quorum.
*
* @return list of information for participating servers in RAFT quorum
*/
public synchronized List<QuorumServerInfo> getQuorumServerInfoList() throws IOException {
List<QuorumServerInfo> quorumMemberStateList = new LinkedList<>();
GroupInfoReply groupInfo = getGroupInfo();
if (groupInfo == null) {
throw new UnavailableException("Cannot get raft group info");
}
if (groupInfo.getException() != null) {
throw groupInfo.getException();
}
RaftProtos.RoleInfoProto roleInfo = groupInfo.getRoleInfoProto();
if (roleInfo == null) {
throw new UnavailableException("Cannot get server role info");
}
RaftProtos.LeaderInfoProto leaderInfo = roleInfo.getLeaderInfo();
if (leaderInfo == null) {
throw new UnavailableException("Cannot get server leader info");
}
for (RaftProtos.ServerRpcProto member : leaderInfo.getFollowerInfoList()) {
HostAndPort hp = HostAndPort.fromString(member.getId().getAddress());
NetAddress memberAddress = NetAddress.newBuilder().setHost(hp.getHost()).setRpcPort(hp.getPort()).build();
quorumMemberStateList.add(QuorumServerInfo.newBuilder().setIsLeader(false).setPriority(member.getId().getPriority()).setServerAddress(memberAddress).setServerState(member.getLastRpcElapsedTimeMs() > mConf.getMaxElectionTimeoutMs() ? QuorumServerState.UNAVAILABLE : QuorumServerState.AVAILABLE).build());
}
InetSocketAddress localAddress = mConf.getLocalAddress();
NetAddress self = NetAddress.newBuilder().setHost(localAddress.getHostString()).setRpcPort(localAddress.getPort()).build();
quorumMemberStateList.add(QuorumServerInfo.newBuilder().setIsLeader(true).setPriority(roleInfo.getSelf().getPriority()).setServerAddress(self).setServerState(QuorumServerState.AVAILABLE).build());
quorumMemberStateList.sort(Comparator.comparing(info -> info.getServerAddress().toString()));
return quorumMemberStateList;
}
use of alluxio.grpc.NetAddress in project alluxio by Alluxio.
the class EmbeddedJournalIntegrationTestResizing method replaceAll.
@Ignore
@Test
public void replaceAll() throws Exception {
final int NUM_MASTERS = 5;
final int NUM_WORKERS = 0;
mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_REPLACE_ALL).setClusterName("EmbeddedJournalResizing_replaceAll").setNumMasters(NUM_MASTERS).setNumWorkers(NUM_WORKERS).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).addProperty(PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS, "5min").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MIN_ELECTION_TIMEOUT, "750ms").addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_MAX_ELECTION_TIMEOUT, "1500ms").build();
mCluster.start();
AlluxioURI testDir = new AlluxioURI("/" + CommonUtils.randomAlphaNumString(10));
FileSystem fs = mCluster.getFileSystemClient();
fs.createDirectory(testDir);
assertTrue(fs.exists(testDir));
List<MasterNetAddress> originalMasters = new ArrayList<>(mCluster.getMasterAddresses());
for (MasterNetAddress masterNetAddress : originalMasters) {
// remove a master from the Alluxio cluster (could be the leader)
int masterIdx = mCluster.getMasterAddresses().indexOf(masterNetAddress);
mCluster.stopAndRemoveMaster(masterIdx);
waitForQuorumPropertySize(info -> info.getServerState() == QuorumServerState.UNAVAILABLE, 1);
// remove said master from the Ratis quorum
NetAddress toRemove = masterEBJAddr2NetAddr(masterNetAddress);
mCluster.getJournalMasterClientForMaster().removeQuorumServer(toRemove);
waitForQuorumPropertySize(info -> true, NUM_MASTERS - 1);
waitForQuorumPropertySize(info -> info.getServerAddress() == toRemove, 0);
// start a new master to replace the lost master
mCluster.startNewMasters(1, false);
waitForQuorumPropertySize(info -> true, NUM_MASTERS);
// verify that the cluster is still operational
fs = mCluster.getFileSystemClient();
assertTrue(fs.exists(testDir));
}
Set<NetAddress> og = originalMasters.stream().map(this::masterEBJAddr2NetAddr).collect(Collectors.toSet());
Set<NetAddress> curr = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().map(QuorumServerInfo::getServerAddress).collect(Collectors.toSet());
Set<NetAddress> intersection = new HashSet<>(og);
intersection.retainAll(curr);
// assert that none of the current masters are part of the original
assertTrue(intersection.isEmpty());
// assert the quorum remained the same size as the start
assertEquals(NUM_MASTERS, curr.size());
mCluster.notifySuccess();
}
Aggregations