-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[STORM-3054] Add Topology level configuration socket timeout for DRPC Invocation Client #2651
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a96581f
Add Topology level configuration socket timeout for DRPC Invocation C…
kishorvpatil da1cb49
Fix ReturnResults reconnection logic
kishorvpatil 0ce231e
Add debug statements to ReturnResults
kishorvpatil 6812f0f
Reverting Client Map key to List
kishorvpatil 0221cc4
Merge branch 'master' of github.com:apache/storm into storm3054
kishorvpatil e678a44
Fix stylecheck issue
kishorvpatil 883987e
Invalidate the DRPC Thrift Client in ReturnResults Bolt
kishorvpatil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ public class ReturnResults extends BaseRichBolt { | |
OutputCollector _collector; | ||
boolean local; | ||
Map<String, Object> _conf; | ||
Map<List, DRPCInvocationsClient> _clients = new HashMap<List, DRPCInvocationsClient>(); | ||
Map<List<String>, DRPCInvocationsClient> _clients = new HashMap<>(); | ||
|
||
@Override | ||
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { | ||
|
@@ -54,6 +54,7 @@ public void prepare(Map<String, Object> topoConf, TopologyContext context, Outpu | |
public void execute(Tuple input) { | ||
String result = (String) input.getValue(0); | ||
String returnInfo = (String) input.getValue(1); | ||
LOG.debug("Request Info: {}, Result: {}", returnInfo, result); | ||
if (returnInfo != null) { | ||
Map<String, Object> retMap; | ||
try { | ||
|
@@ -66,34 +67,22 @@ public void execute(Tuple input) { | |
final String host = (String) retMap.get("host"); | ||
final int port = ObjectReader.getInt(retMap.get("port")); | ||
String id = (String) retMap.get("id"); | ||
DistributedRPCInvocations.Iface client; | ||
if (local) { | ||
client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host); | ||
} else { | ||
List server = new ArrayList() {{ | ||
add(host); | ||
add(port); | ||
}}; | ||
|
||
if (!_clients.containsKey(server)) { | ||
try { | ||
_clients.put(server, new DRPCInvocationsClient(_conf, host, port)); | ||
} catch (TTransportException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
client = _clients.get(server); | ||
} | ||
|
||
LOG.debug("Request Id: {}, Result: {}", id, result); | ||
DistributedRPCInvocations.Iface client = getDRPCClient(host, port); | ||
|
||
int retryCnt = 0; | ||
int maxRetries = 3; | ||
while (retryCnt < maxRetries) { | ||
retryCnt++; | ||
try { | ||
client.result(id, result); | ||
_collector.ack(input); | ||
break; | ||
if (client != null) { | ||
LOG.debug("Trying to publish Request Id: {}, Result: {}, to DRPC {}", id, result, host); | ||
client.result(id, result); | ||
_collector.ack(input); | ||
break; | ||
} else { | ||
client = getDRPCClient(host, port); | ||
} | ||
} catch (AuthorizationException aze) { | ||
LOG.error("Not authorized to return results to DRPC server", aze); | ||
_collector.fail(input); | ||
|
@@ -103,21 +92,34 @@ public void execute(Tuple input) { | |
LOG.error("Failed to return results to DRPC server", tex); | ||
_collector.fail(input); | ||
} | ||
reconnectClient((DRPCInvocationsClient) client); | ||
client = getDRPCClient(host, port); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void reconnectClient(DRPCInvocationsClient client) { | ||
if (client instanceof DRPCInvocationsClient) { | ||
try { | ||
LOG.info("reconnecting... "); | ||
client.reconnectClient(); //Blocking call | ||
} catch (TException e2) { | ||
LOG.error("Failed to connect to DRPC server", e2); | ||
private DistributedRPCInvocations.Iface getDRPCClient(String host, int port) { | ||
DistributedRPCInvocations.Iface client; | ||
if (local) { | ||
client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host); | ||
} else { | ||
List server = new ArrayList() { | ||
{ | ||
add(host); | ||
add(port); | ||
} | ||
}; | ||
if (!_clients.containsKey(server)) { | ||
try { | ||
DRPCInvocationsClient oldClient = _clients.put(server, new DRPCInvocationsClient(_conf, host, port)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it loses the cache functionality. Instead of this approach, can we invalidate cache when we find that the client is broken? |
||
oldClient.close(); | ||
} catch (TTransportException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
client = _clients.get(server); | ||
} | ||
return client; | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it always reuse the existing client even TException is being raised from the client. I guess we need to handle the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is same as before, if we could not make connection. or reconnect failed in previous case. The whole reason to create new client from scratch in
getDCPClient
is to avoid usingreconnect
with security enabled. The stale connection fails to respond to security challenge.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kishorvpatil
I meant we don't invalidate broken
client
from_clients
so it will always pick sameclient
, instead of rebuilding newclient
.