if(rlock.tryLock()) {
localExecResources.add(new Pair<String, Lock>(path, rlock));
} else {
totalLocked++;
final byte[] k = StringUtils.getBytes(path);
final GridNodeValueCollector collector = new GridNodeValueCollector(_excludeNodeList);
try {
directory.exactSearch(k, collector);
} catch (DbException e) {
String errmsg = "Exception caused while lookup: " + path;
LOG.error(errmsg, e);
throw new GridException(errmsg, e);
}
final List<GridNode> replicatedNodes = collector.getMatched();
if(replicatedNodes == null || replicatedNodes.isEmpty()) {
throw new GridException("No replicated document found for path: " + path);
}
// TODO Select a node that least recently used for write requests.
GridNode node = nodeSelector.selectNode(replicatedNodes, config);