Search in sources :

Example 1 with MasterNetAddress

use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.

the class EmbeddedJournalIntegrationTestTransferLeadership method transferWhenAlreadyTransferring.

@Test
public void transferWhenAlreadyTransferring() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_ALREADY_TRANSFERRING).setClusterName("EmbeddedJournalTransferLeadership_transferWhenAlreadyTransferring").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();
    int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % NUM_MASTERS;
    // `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
    // we can therefore access to the new leader's address this way
    MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(newLeaderIdx);
    NetAddress netAddress = masterEBJAddr2NetAddr(newLeaderAddr);
    mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
    // this second call should throw an exception
    String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
    String exceptionMessage = mCluster.getJournalMasterClientForMaster().getTransferLeaderMessage(transferId).getTransMsg().getMsg();
    Assert.assertFalse(exceptionMessage.isEmpty());
    mCluster.notifySuccess();
}
Also used : MasterNetAddress(alluxio.multi.process.MasterNetAddress) NetAddress(alluxio.grpc.NetAddress) MasterNetAddress(alluxio.multi.process.MasterNetAddress) Test(org.junit.Test)

Example 2 with MasterNetAddress

use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.

the class EmbeddedJournalIntegrationTestTransferLeadership method resetPriorities.

@Test
public void resetPriorities() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_UNAVAILABLE_MASTER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadershipToUnavailableMaster").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();
    boolean match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == 0);
    Assert.assertTrue(match);
    for (int i = 0; i < NUM_MASTERS; i++) {
        int newLeaderIdx = (mCluster.getPrimaryMasterIndex(MASTER_INDEX_WAIT_TIME) + 1) % NUM_MASTERS;
        // `getPrimaryMasterIndex` uses the same `mMasterAddresses` variable as getMasterAddresses
        // we can therefore access to the new leader's address this way
        MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(newLeaderIdx);
        transferAndWait(newLeaderAddr);
        match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == (info.getIsLeader() ? 2 : 1));
        Assert.assertTrue(match);
        mCluster.getJournalMasterClientForMaster().resetPriorities();
        match = mCluster.getJournalMasterClientForMaster().getQuorumInfo().getServerInfoList().stream().allMatch(info -> info.getPriority() == 1);
        Assert.assertTrue(match);
    }
    mCluster.notifySuccess();
}
Also used : JournalType(alluxio.master.journal.JournalType) NetAddress(alluxio.grpc.NetAddress) QuorumServerState(alluxio.grpc.QuorumServerState) MultiProcessCluster(alluxio.multi.process.MultiProcessCluster) PortCoordination(alluxio.multi.process.PortCoordination) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test) MasterNetAddress(alluxio.multi.process.MasterNetAddress) Assert(org.junit.Assert) PropertyKey(alluxio.conf.PropertyKey) GetTransferLeaderMessagePResponse(alluxio.grpc.GetTransferLeaderMessagePResponse) MasterNetAddress(alluxio.multi.process.MasterNetAddress) Test(org.junit.Test)

Example 3 with MasterNetAddress

use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.

the class EmbeddedJournalIntegrationTestTransferLeadership method transferLeadershipOutsideCluster.

@Test
public void transferLeadershipOutsideCluster() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_OUTSIDE_CLUSTER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadership").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();
    NetAddress netAddress = NetAddress.newBuilder().setHost("hostname").setRpcPort(0).build();
    String transferId = mCluster.getJournalMasterClientForMaster().transferLeadership(netAddress);
    String exceptionMessage = mCluster.getJournalMasterClientForMaster().getTransferLeaderMessage(transferId).getTransMsg().getMsg();
    Assert.assertTrue(exceptionMessage.startsWith(String.format("<%s:%d> is not part of the quorum", netAddress.getHost(), netAddress.getRpcPort())));
    for (MasterNetAddress address : mCluster.getMasterAddresses()) {
        String host = address.getHostname();
        int port = address.getEmbeddedJournalPort();
        Assert.assertTrue(exceptionMessage.contains(String.format("%s:%d", host, port)));
    }
    mCluster.notifySuccess();
}
Also used : MasterNetAddress(alluxio.multi.process.MasterNetAddress) NetAddress(alluxio.grpc.NetAddress) MasterNetAddress(alluxio.multi.process.MasterNetAddress) Test(org.junit.Test)

Example 4 with MasterNetAddress

use of alluxio.multi.process.MasterNetAddress in project alluxio by Alluxio.

the class EmbeddedJournalIntegrationTestTransferLeadership method transferLeadershipToNewMember.

@Test
public void transferLeadershipToNewMember() throws Exception {
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.EMBEDDED_JOURNAL_NEW_MEMBER).setClusterName("EmbeddedJournalTransferLeadership_transferLeadershipToNewMember").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();
    mCluster.startNewMasters(1, false);
    waitForQuorumPropertySize(info -> info.getServerState() == QuorumServerState.AVAILABLE, NUM_MASTERS + 1);
    MasterNetAddress newLeaderAddr = mCluster.getMasterAddresses().get(NUM_MASTERS);
    transferAndWait(newLeaderAddr);
    mCluster.notifySuccess();
}
Also used : MasterNetAddress(alluxio.multi.process.MasterNetAddress) Test(org.junit.Test)

Example 5 with MasterNetAddress

use of alluxio.multi.process.MasterNetAddress 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;
}
Also used : NetAddress(alluxio.grpc.NetAddress) MasterNetAddress(alluxio.multi.process.MasterNetAddress)

Aggregations

MasterNetAddress (alluxio.multi.process.MasterNetAddress)13 Test (org.junit.Test)11 NetAddress (alluxio.grpc.NetAddress)5 FileSystemAdminShell (alluxio.cli.fsadmin.FileSystemAdminShell)2 GetTransferLeaderMessagePResponse (alluxio.grpc.GetTransferLeaderMessagePResponse)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 TimeoutException (java.util.concurrent.TimeoutException)2 AlluxioURI (alluxio.AlluxioURI)1 FileSystem (alluxio.client.file.FileSystem)1 PropertyKey (alluxio.conf.PropertyKey)1 FileSystemMasterClientServiceGrpc (alluxio.grpc.FileSystemMasterClientServiceGrpc)1 GrpcChannel (alluxio.grpc.GrpcChannel)1 QuorumServerState (alluxio.grpc.QuorumServerState)1 JournalType (alluxio.master.journal.JournalType)1 MultiProcessCluster (alluxio.multi.process.MultiProcessCluster)1 PortCoordination (alluxio.multi.process.PortCoordination)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Assert (org.junit.Assert)1