Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-10874. Freon tool DNRPCLoadGenerator should not cache client objects. #6705

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ XceiverClientSpi acquireClient(Pipeline pipeline, boolean topologyAware)
void releaseClient(XceiverClientSpi xceiverClient, boolean invalidateClient,
boolean topologyAware);

XceiverClientSpi acquireClientUncached(Pipeline pipeline, boolean topologyAware)
throws Exception;
Comment on lines +45 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new method to the XceiverClientFactory interface, how about creating a new, non-caching implementation as parent class of XceiverClientManager?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see ad95eb8

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.hadoop.hdds.scm;

import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

import org.apache.hadoop.hdds.conf.Config;
Expand Down Expand Up @@ -187,6 +186,39 @@ public XceiverClientSpi acquireClient(Pipeline pipeline,
}
}

/**
* Similar to acquireClient() but does not use the cache.
* User must close the client explicitly after use.
* @param pipeline pipeline
* @param topologyAware topology aware
* @return XceiverClientSpi object
* @throws IOException
*/
@Override
public XceiverClientSpi acquireClientUncached(Pipeline pipeline,
boolean topologyAware) throws
Exception {
HddsProtos.ReplicationType type = pipeline.getType();
XceiverClientSpi client = null;
switch (type) {
case RATIS:
client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf,
trustManager);
break;
case STAND_ALONE:
client = new XceiverClientGrpc(pipeline, conf, trustManager);
break;
case EC:
client = new ECXceiverClientGrpc(pipeline, conf, trustManager);
break;
case CHAINED:
default:
throw new IOException("not implemented " + pipeline.getType());
}
client.connect();
return client;
}

/**
* Releases a XceiverClientSpi after use.
*
Expand Down Expand Up @@ -229,34 +261,12 @@ public void releaseClient(XceiverClientSpi client, boolean invalidateClient,

private XceiverClientSpi getClient(Pipeline pipeline, boolean topologyAware)
throws IOException {
HddsProtos.ReplicationType type = pipeline.getType();
try {
// create different client different pipeline node based on
// network topology
String key = getPipelineCacheKey(pipeline, topologyAware);
return clientCache.get(key, new Callable<XceiverClientSpi>() {
@Override
public XceiverClientSpi call() throws Exception {
XceiverClientSpi client = null;
switch (type) {
case RATIS:
client = XceiverClientRatis.newXceiverClientRatis(pipeline, conf,
trustManager);
break;
case STAND_ALONE:
client = new XceiverClientGrpc(pipeline, conf, trustManager);
break;
case EC:
client = new ECXceiverClientGrpc(pipeline, conf, trustManager);
break;
case CHAINED:
default:
throw new IOException("not implemented " + pipeline.getType());
}
client.connect();
return client;
}
});
return clientCache.get(key,
() -> acquireClientUncached(pipeline, topologyAware));
} catch (Exception e) {
throw new IOException(
"Exception getting XceiverClient: " + e.toString(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ public XceiverClientSpi acquireClient(Pipeline pipeline,
return mockXceiverClientSpi;
}

@Override
public XceiverClientSpi acquireClientUncached(Pipeline pipeline,
boolean topologyAware) throws IOException {
return acquireClient(pipeline, topologyAware);
}

@Override
public void releaseClient(XceiverClientSpi xceiverClient,
boolean invalidateClient, boolean topologyAware) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public Void call() throws Exception {
}
clients = new ArrayList<>(numClients);
for (int i = 0; i < numClients; i++) {
clients.add(xceiverClientManager.acquireClient(pipeline));
clients.add(xceiverClientManager.acquireClientUncached(pipeline, true));
}

init();
Expand All @@ -171,7 +171,7 @@ public Void call() throws Exception {
runTests(this::sendRPCReq);
} finally {
for (XceiverClientSpi client : clients) {
xceiverClientManager.releaseClient(client, false);
client.close();
}
xceiverClientManager.close();
scmClient.close();
Expand Down