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);
}
}
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);
}
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"));
}
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));
}
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());
}
Aggregations