Search in sources :

Example 1 with OMFailoverProxyProvider

use of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider in project ozone by apache.

the class TestOzoneManagerHAMetadataOnly method testOMProxyProviderInitialization.

/**
 * Test that OMFailoverProxyProvider creates an OM proxy for each OM in the
 * cluster.
 */
@Test
public void testOMProxyProviderInitialization() throws Exception {
    OzoneClient rpcClient = getCluster().getRpcClient();
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(rpcClient.getObjectStore().getClientProxy());
    List<OMProxyInfo> omProxies = omFailoverProxyProvider.getOMProxyInfos();
    Assert.assertEquals(getNumOfOMs(), omProxies.size());
    for (int i = 0; i < getNumOfOMs(); i++) {
        InetSocketAddress omRpcServerAddr = getCluster().getOzoneManager(i).getOmRpcServerAddr();
        boolean omClientProxyExists = false;
        for (OMProxyInfo omProxyInfo : omProxies) {
            if (omProxyInfo.getAddress().equals(omRpcServerAddr)) {
                omClientProxyExists = true;
                break;
            }
        }
        Assert.assertTrue("There is no OM Client Proxy corresponding to OM " + "node" + getCluster().getOzoneManager(i).getOMNodeId(), omClientProxyExists);
    }
}
Also used : OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) OMProxyInfo(org.apache.hadoop.ozone.om.ha.OMProxyInfo) InetSocketAddress(java.net.InetSocketAddress) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) Test(org.junit.Test)

Example 2 with OMFailoverProxyProvider

use of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider in project ozone by apache.

the class TestOzoneManagerHAMetadataOnly method testOMProxyProviderFailoverToCurrentLeader.

/**
 * Test OMFailoverProxyProvider failover when current OM proxy is not
 * the current OM Leader.
 */
@Test
public void testOMProxyProviderFailoverToCurrentLeader() throws Exception {
    ObjectStore objectStore = getObjectStore();
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(objectStore.getClientProxy());
    // Run couple of createVolume tests to discover the current Leader OM
    createVolumeTest(true);
    createVolumeTest(true);
    // The OMFailoverProxyProvider will point to the current leader OM node.
    String leaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    // Perform a manual failover of the proxy provider to move the
    // currentProxyIndex to a node other than the leader OM.
    omFailoverProxyProvider.performFailoverToNextProxy();
    String newProxyNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    Assert.assertNotEquals(leaderOMNodeId, newProxyNodeId);
    // Once another request is sent to this new proxy node, the leader
    // information must be returned via the response and a failover must
    // happen to the leader proxy node.
    createVolumeTest(true);
    Thread.sleep(2000);
    String newLeaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    // The old and new Leader OM NodeId must match since there was no new
    // election in the Ratis ring.
    Assert.assertEquals(leaderOMNodeId, newLeaderOMNodeId);
}
Also used : ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) Test(org.junit.Test)

Example 3 with OMFailoverProxyProvider

use of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider in project ozone by apache.

the class TestOzoneManagerHAMetadataOnly method testOMRetryCache.

@Test
public void testOMRetryCache() throws Exception {
    ObjectStore objectStore = getObjectStore();
    objectStore.createVolume(UUID.randomUUID().toString());
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(objectStore.getClientProxy());
    String currentLeaderNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    OzoneManagerRatisServer ozoneManagerRatisServer = getCluster().getOzoneManager(currentLeaderNodeId).getOmRatisServer();
    RaftServer raftServer = ozoneManagerRatisServer.getServer();
    ClientId clientId = ClientId.randomId();
    long callId = 2000L;
    String userName = UserGroupInformation.getCurrentUser().getUserName();
    String volumeName = UUID.randomUUID().toString();
    GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer.captureLogs(OMVolumeCreateRequest.getLogger());
    OMRequest omRequest = OMRequest.newBuilder().setCreateVolumeRequest(CreateVolumeRequest.newBuilder().setVolumeInfo(VolumeInfo.newBuilder().setOwnerName(userName).setAdminName(userName).setVolume(volumeName).build()).build()).setClientId(UUID.randomUUID().toString()).setCmdType(OzoneManagerProtocolProtos.Type.CreateVolume).build();
    RaftClientReply raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
    Assert.assertTrue(raftClientReply.isSuccess());
    Assert.assertTrue(logCapturer.getOutput().contains("created volume:" + volumeName));
    logCapturer.clearOutput();
    raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
    Assert.assertTrue(raftClientReply.isSuccess());
    // As second time with same client id and call id, this request should
    // not be executed ratis server should return from cache.
    // If 2nd time executed, it will fail with Volume creation failed. check
    // for that.
    Assert.assertFalse(logCapturer.getOutput().contains("Volume creation failed"));
    // Sleep for little above retry cache duration to get cache clear.
    Thread.sleep(getRetryCacheDuration().toMillis() + 5000);
    raftClientReply = raftServer.submitClientRequest(RaftClientRequest.newBuilder().setClientId(clientId).setServerId(raftServer.getId()).setGroupId(ozoneManagerRatisServer.getRaftGroup().getGroupId()).setCallId(callId).setMessage(Message.valueOf(OMRatisHelper.convertRequestToByteString(omRequest))).setType(RaftClientRequest.writeRequestType()).build());
    Assert.assertTrue(raftClientReply.isSuccess());
    // As second time with same client id and call id, this request should
    // be executed by ratis server as we are sending this request after cache
    // expiry duration.
    Assert.assertTrue(logCapturer.getOutput().contains("Volume creation failed"));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) RaftClientReply(org.apache.ratis.protocol.RaftClientReply) RaftServer(org.apache.ratis.server.RaftServer) ClientId(org.apache.ratis.protocol.ClientId) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) OzoneManagerRatisServer(org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer) Test(org.junit.Test)

Example 4 with OMFailoverProxyProvider

use of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider in project ozone by apache.

the class TestOzoneManagerHAWithData method testMultipartUploadWithOneOmNodeDown.

private void testMultipartUploadWithOneOmNodeDown() throws Exception {
    OzoneBucket ozoneBucket = setupBucket();
    String keyName = UUID.randomUUID().toString();
    String uploadID = initiateMultipartUpload(ozoneBucket, keyName);
    // After initiate multipartupload, shutdown leader OM.
    // Stop leader OM, to see when the OM leader changes
    // multipart upload is happening successfully or not.
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(getObjectStore().getClientProxy());
    // The OMFailoverProxyProvider will point to the current leader OM node.
    String leaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    // Stop one of the ozone manager, to see when the OM leader changes
    // multipart upload is happening successfully or not.
    getCluster().stopOzoneManager(leaderOMNodeId);
    Thread.sleep(NODE_FAILURE_TIMEOUT * 4);
    createMultipartKeyAndReadKey(ozoneBucket, keyName, uploadID);
    String newLeaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    Assert.assertTrue(!leaderOMNodeId.equals(newLeaderOMNodeId));
}
Also used : OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider)

Example 5 with OMFailoverProxyProvider

use of org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider in project ozone by apache.

the class TestOzoneManagerHAWithFailover method testIncrementalWaitTimeWithSameNodeFailover.

/**
 * 1. Stop one of the OM
 * 2. make a call to OM, this will make failover attempts to find new node.
 * a) if LE finishes but leader not ready, it retries to same node
 * b) if LE not done, it will failover to new node and check
 * 3. Try failover to same OM explicitly.
 * Now #3 should wait additional waitBetweenRetries time.
 * LE: Leader Election.
 */
@Test
public void testIncrementalWaitTimeWithSameNodeFailover() throws Exception {
    long waitBetweenRetries = getConf().getLong(OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_KEY, OzoneConfigKeys.OZONE_CLIENT_WAIT_BETWEEN_RETRIES_MILLIS_DEFAULT);
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(getObjectStore().getClientProxy());
    // The OMFailoverProxyProvider will point to the current leader OM node.
    String leaderOMNodeId = omFailoverProxyProvider.getCurrentProxyOMNodeId();
    getCluster().stopOzoneManager(leaderOMNodeId);
    Thread.sleep(NODE_FAILURE_TIMEOUT * 4);
    // failover should happen to new node
    createKeyTest(true);
    long numTimesTriedToSameNode = omFailoverProxyProvider.getWaitTime() / waitBetweenRetries;
    omFailoverProxyProvider.performFailoverIfRequired(omFailoverProxyProvider.getCurrentProxyOMNodeId());
    Assert.assertEquals((numTimesTriedToSameNode + 1) * waitBetweenRetries, omFailoverProxyProvider.getWaitTime());
}
Also used : OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) Test(org.junit.Test)

Aggregations

OMFailoverProxyProvider (org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider)10 Test (org.junit.Test)7 ObjectStore (org.apache.hadoop.ozone.client.ObjectStore)4 OMProxyInfo (org.apache.hadoop.ozone.om.ha.OMProxyInfo)2 InetSocketAddress (java.net.InetSocketAddress)1 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)1 OzoneClient (org.apache.hadoop.ozone.client.OzoneClient)1 OzoneVolume (org.apache.hadoop.ozone.client.OzoneVolume)1 OMNodeDetails (org.apache.hadoop.ozone.om.helpers.OMNodeDetails)1 OzoneManagerRatisServer (org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1 ClientId (org.apache.ratis.protocol.ClientId)1 RaftClientReply (org.apache.ratis.protocol.RaftClientReply)1 RaftServer (org.apache.ratis.server.RaftServer)1 Ignore (org.junit.Ignore)1